« Back to History
mesr_stock_entry.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php /* ========================================================== FILE: mesr_stock_entry.php PURPOSE: MESR MASTER ENTRY (UI CONTROLLER ONLY) ========================================================== */ require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('mesr_stock_entry'); $pdo = $ctx['pdo']; $company_id = 3; // 🔒 LOCKED function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } /* ---------- LOAD LOCATION ---------- */ $locStmt = $pdo->prepare(" SELECT id, location_name FROM mesr_data_location WHERE company_id = :cid AND is_active = 1 ORDER BY location_name "); $locStmt->execute([':cid'=>$company_id]); $locations = $locStmt->fetchAll(PDO::FETCH_ASSOC); /* ---------- LOAD MACHINE ---------- */ $macStmt = $pdo->prepare(" SELECT id, machine_name FROM mesr_machine WHERE company_id = :cid AND is_active = 1 ORDER BY machine_name "); $macStmt->execute([':cid'=>$company_id]); $machines = $macStmt->fetchAll(PDO::FETCH_ASSOC); require_once __DIR__ . '/partials/header.php'; ?> <form id="mesrForm"> <!-- ================= MASTER CARD ================= --> <div class="card"> <h2>MESR Stock Entry</h2> <div class="form-cols-4"> <div class="form-group"> <label>Month</label> <input type="month" id="mesr_month" name="month" required> </div> <div class="form-group"> <label>Location</label> <select id="mesr_location" name="location_id" required> <option value="">Select</option> <?php foreach($locations as $l): ?> <option value="<?=h($l['id'])?>"> <?=h($l['location_name'])?> </option> <?php endforeach; ?> </select> </div> <div class="form-group"> <label>Machine</label> <select id="mesr_machine" name="machine_id" required> <option value="">Select</option> <?php foreach($machines as $m): ?> <option value="<?=h($m['id'])?>"> <?=h($m['machine_name'])?> </option> <?php endforeach; ?> </select> </div> </div> </div> <!-- ================= ADD SECTION ================= --> <div class="card"> <h3>Add Section</h3> <button type="button" class="btn" onclick="loadSection('kasab')"> + Kasab Stock </button> <button type="button" class="btn" onclick="loadSection('bobin')"> + Yarn in Bobin </button> <button type="button" class="btn" onclick="loadSection('machine')"> + Yarn in Machine </button> </div> <!-- ================= SECTION CONTAINER ================= --> <div id="mesr_sections"></div> <!-- ================= SAVE ================= --> <div class="card"> <button type="button" class="btn btn-success" onclick="saveCurrentSection()"> SAVE </button> </div> </form> <script> /* ====================================================== MASTER JS CONTROLLER ====================================================== */ let activeSection = null; /* ---------- LOAD SECTION UI ---------- */ function loadSection(type){ activeSection = type; fetch('/erp/mesr/sections/' + type + '_section.php') .then(res => res.text()) .then(html => { document.getElementById('mesr_sections').innerHTML = html; }) .catch(() => alert('Failed to load section')); } /* ---------- SAVE DISPATCHER ---------- */ function saveCurrentSection(){ if (!activeSection) { alert('Please add a section first'); return; } if (typeof window['save_' + activeSection] !== 'function') { alert('Save function missing for ' + activeSection); return; } window['save_' + activeSection](); } </script> <?php require_once __DIR__ . '/partials/footer.php'; ?>