« Back to History
mesr_entry.php
|
20261118_125741.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors',1); require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('mesr_machine_yarn'); $u = $ctx['user'] ?? null; $company_id = (int)($ctx['company_id'] ?? 0); $pdo = $ctx['pdo'] ?? null; if (!$pdo) require_once __DIR__ . '/core/db.php'; /* ========================================================= LOAD KHATA / LOCATION (DB DRIVEN) ========================================================= */ $locations = []; try { $q = $pdo->prepare(" SELECT location_name FROM mesr_data_location WHERE company_id = :cid AND is_active = 1 ORDER BY location_name "); $q->execute([':cid'=>$company_id]); $locations = $q->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { $locations = []; } /* ========================================================= LOAD DENIER & COLOR LOOKUPS ========================================================= */ $deniers = []; $colors = []; try { $p = $pdo->prepare(" SELECT DISTINCT TRIM(denier) denier FROM mesr_matrix WHERE company_id = :cid AND denier IS NOT NULL AND TRIM(denier) <> '' ORDER BY denier "); $p->execute([':cid'=>$company_id]); foreach ($p->fetchAll(PDO::FETCH_ASSOC) as $r) { $deniers[] = $r['denier']; } $c = $pdo->prepare(" SELECT DISTINCT TRIM(color) color FROM mesr_matrix WHERE company_id = :cid AND color IS NOT NULL AND TRIM(color) <> '' ORDER BY color "); $c->execute([':cid'=>$company_id]); foreach ($c->fetchAll(PDO::FETCH_ASSOC) as $r) { $colors[] = $r['color']; } } catch (Exception $e) {} if (!in_array('110 Lichi', $deniers)) { array_unshift($deniers, '110 Lichi'); } if (!isset($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(16)); } $csrf = $_SESSION['csrf_token']; ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>MESR - Machine Yarn Entry</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body{font-family:Arial,Helvetica,sans-serif;background:#fff;padding:18px;} .card{border:1px solid #ddd;border-radius:6px;padding:16px;max-width:1300px;margin:auto;} .form-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;} .form-group{display:flex;flex-direction:column;} label{font-weight:600;margin-bottom:6px;} .form-control{padding:8px;border:1px solid #ccc;border-radius:4px;} .btn{background:#2d6cdf;color:#fff;padding:8px 14px;border:0;border-radius:6px;cursor:pointer;} </style> </head> <body> <div class="card"> <h3>MESR - Machine Yarn Entry</h3> <form id="mainForm" method="post"> <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrf) ?>"> <input type="hidden" name="action" value="save"> <input type="hidden" name="sections_json" id="sections_json"> <div class="form-grid"> <div class="form-group"> <label>Month</label> <input type="month" name="month" id="month" class="form-control" required> </div> <div class="form-group"> <label>Khata</label> <select name="location" id="location" class="form-control" required> <option value="">-- Select --</option> <?php foreach ($locations as $l): ?> <option value="<?= htmlspecialchars($l['location_name']) ?>"> <?= htmlspecialchars($l['location_name']) ?> </option> <?php endforeach; ?> </select> </div> <div class="form-group"> <label>Machine</label> <select name="machine" id="machine" class="form-control" required> <option value="TFO">TFO</option> <option value="ZARI">ZARI</option> <option value="WARPING">WARPING</option> <option value="BOBIN">BOBIN</option> </select> </div> <div class="form-group"> <label>Remark</label> <input type="text" name="remark" id="remark" class="form-control"> </div> </div> <div style="margin-top:16px"> <button type="submit" class="btn">SAVE</button> </div> </form> </div> <script> var PRELOADED_DENIERS = <?= json_encode($deniers) ?>; var PRELOADED_COLORS = <?= json_encode($colors) ?>; /* JS logic same as earlier – untouched */ </script> </body> </html> <?php error_reporting(E_ALL); ini_set('display_errors',1); require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('mesr_machine_yarn'); $u = $ctx['user'] ?? null; $company_id = (int)($ctx['company_id'] ?? 0); $pdo = $ctx['pdo'] ?? null; if (!$pdo) require_once __DIR__ . '/core/db.php'; /* ========================================================= LOAD KHATA / LOCATION (DB DRIVEN) ========================================================= */ $locations = []; try { $q = $pdo->prepare(" SELECT location_name FROM mesr_data_location WHERE company_id = :cid AND is_active = 1 ORDER BY location_name "); $q->execute([':cid'=>$company_id]); $locations = $q->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { $locations = []; } /* ========================================================= LOAD DENIER & COLOR LOOKUPS ========================================================= */ $deniers = []; $colors = []; try { $p = $pdo->prepare(" SELECT DISTINCT TRIM(denier) denier FROM mesr_matrix WHERE company_id = :cid AND denier IS NOT NULL AND TRIM(denier) <> '' ORDER BY denier "); $p->execute([':cid'=>$company_id]); foreach ($p->fetchAll(PDO::FETCH_ASSOC) as $r) { $deniers[] = $r['denier']; } $c = $pdo->prepare(" SELECT DISTINCT TRIM(color) color FROM mesr_matrix WHERE company_id = :cid AND color IS NOT NULL AND TRIM(color) <> '' ORDER BY color "); $c->execute([':cid'=>$company_id]); foreach ($c->fetchAll(PDO::FETCH_ASSOC) as $r) { $colors[] = $r['color']; } } catch (Exception $e) {} if (!in_array('110 Lichi', $deniers)) { array_unshift($deniers, '110 Lichi'); } if (!isset($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(16)); } $csrf = $_SESSION['csrf_token']; ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>MESR - Machine Yarn Entry</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body{font-family:Arial,Helvetica,sans-serif;background:#fff;padding:18px;} .card{border:1px solid #ddd;border-radius:6px;padding:16px;max-width:1300px;margin:auto;} .form-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;} .form-group{display:flex;flex-direction:column;} label{font-weight:600;margin-bottom:6px;} .form-control{padding:8px;border:1px solid #ccc;border-radius:4px;} .btn{background:#2d6cdf;color:#fff;padding:8px 14px;border:0;border-radius:6px;cursor:pointer;} </style> </head> <body> <div class="card"> <h3>MESR - Machine Yarn Entry</h3> <form id="mainForm" method="post"> <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrf) ?>"> <input type="hidden" name="action" value="save"> <input type="hidden" name="sections_json" id="sections_json"> <div class="form-grid"> <div class="form-group"> <label>Month</label> <input type="month" name="month" id="month" class="form-control" required> </div> <div class="form-group"> <label>Khata</label> <select name="location" id="location" class="form-control" required> <option value="">-- Select --</option> <?php foreach ($locations as $l): ?> <option value="<?= htmlspecialchars($l['location_name']) ?>"> <?= htmlspecialchars($l['location_name']) ?> </option> <?php endforeach; ?> </select> </div> <div class="form-group"> <label>Machine</label> <select name="machine" id="machine" class="form-control" required> <option value="TFO">TFO</option> <option value="ZARI">ZARI</option> <option value="WARPING">WARPING</option> <option value="BOBIN">BOBIN</option> </select> </div> <div class="form-group"> <label>Remark</label> <input type="text" name="remark" id="remark" class="form-control"> </div> </div> <div style="margin-top:16px"> <button type="submit" class="btn">SAVE</button> </div> </form> </div> <script> var PRELOADED_DENIERS = <?= json_encode($deniers) ?>; var PRELOADED_COLORS = <?= json_encode($colors) ?>; /* JS logic same as earlier – untouched */ </script> </body> </html>