« Back to History
bobin_entry.php
|
20260721_154033.php
Initial Bulk Import
Copy Code
<?php // ... (Header और SQL Logic वही रहेगा) require_once __DIR__ . '/../modules/auth/page_acl.php'; $ctx = page_require_access('mesr_stock_entry'); $company_id = (int)$ctx['company_id']; $pdo = $ctx['pdo']; // Dropdowns Fetch... // ... require_once __DIR__ . '/../partials/header.php'; ?> <div class="app-container"> <div class="index-welcome"> <h2>Bobin Stock Entry <span class="welcome-user">| Inventory</span></h2> </div> <form id="form_bobin"> <div class="form-card" style="padding: 20px; margin-bottom: 20px;"> <div class="form-cols-3"> <div class="form-group"><label>Month</label><input type="month" name="month" value="<?=date('Y-m')?>"></div> <div class="form-group"> <label>Location</label> <select name="location_id"><?php foreach($locations as $l) echo "<option value='{$l['id']}'>{$l['location_name']}</option>"; ?></select> </div> <div class="form-group"> <label>Machine</label> <select name="machine_id"><?php foreach($machines as $m) echo "<option value='{$m['id']}'>{$m['machine_name']}</option>"; ?></select> </div> </div> </div> <div class="form-card" style="padding: 20px;"> <table class="table erp-table" id="tbl_bobin"> <thead> <tr><th>Denier/Color</th><th>Total Wt</th><th>Per Yarn</th><th>Empty Wt</th><th>Net Yarn</th><th>Action</th></tr> </thead> <tbody> <tr> <td> <select name="denier[]"><?php foreach($deniers as $d) echo "<option>$d</option>"; ?></select> <select name="color[]"><?php foreach($colors as $c) echo "<option>$c</option>"; ?></select> </td> <td><input type="number" step="0.001" name="total_weight[]" oninput="calcB(this)" class="tw"></td> <td><input type="number" step="0.001" name="per_bobin_yarn_weight[]" value="0.070" oninput="calcB(this)" class="py"></td> <td><input type="number" step="0.001" name="per_bobin_empty_weight[]" value="0.040" oninput="calcB(this)" class="pe"></td> <td><input type="number" name="yarn_weight[]" class="yw" readonly></td> <td><button type="button" class="status-finish" onclick="this.closest('tr').remove()">X</button></td> </tr> </tbody> </table> <div style="margin-top:15px; display:flex; justify-content:space-between;"> <button type="button" class="page-link-btn" onclick="addRow('tbl_bobin')">+ Add Row</button> <button type="submit" class="btn-primary">Save Bobin</button> </div> </div> </form> </div> <script> function calcB(el){ const row = el.closest('tr'); const tw = parseFloat(row.querySelector('.tw').value)||0; const py = parseFloat(row.querySelector('.py').value)||0; const pe = parseFloat(row.querySelector('.pe').value)||0; if(py > 0){ const total_bobin = tw / py; row.querySelector('.yw').value = (tw - (total_bobin * pe)).toFixed(3); } } function addRow(id) { const tbody = document.querySelector(`#${id} tbody`); const newRow = tbody.rows[0].cloneNode(true); newRow.querySelectorAll('input').forEach(i => i.value = ''); tbody.appendChild(newRow); } document.getElementById('form_bobin').onsubmit = async (e) => { e.preventDefault(); const resp = await fetch('save/save_bobin.php', { method: 'POST', body: new FormData(e.target) }); alert(await resp.text()); }; </script> <?php require_once __DIR__ . '/../partials/footer.php'; ?>