« Back to History
override_beam_card.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors',1); require dirname(__DIR__).'/modules/auth/auth.php'; require_login(); $u = auth_user(); $company_id=(int)$u['company_id']; $user_id=(int)$u['id']; $pdo = $GLOBALS['pdo'] ?? null; if(!$pdo){ require dirname(__DIR__).'/core/db.php'; } function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function qall($pdo,$sql,$p=[]){ $st=$pdo->prepare($sql); $st->execute($p); return $st->fetchAll(PDO::FETCH_ASSOC); } $msg = null; if ($_SERVER['REQUEST_METHOD']==='POST') { $beam = trim($_POST['beam_no'] ?? ''); $mach = strlen($_POST['machine_no']??'') ? (int)$_POST['machine_no'] : null; $slot = $_POST['slot_override'] ?? null; $status = $_POST['status_override'] ?? null; $ins = $_POST['install_override'] ?: null; $fin = $_POST['finish_override'] ?: null; $note = trim($_POST['note'] ?? ''); $sql = "INSERT INTO beam_card_overrides (company_id, beam_no, machine_no, slot_override, status_override, install_override, finish_override, note, updated_by) VALUES (:c,:b,:m,:s,:st,:i,:f,:n,:u) ON DUPLICATE KEY UPDATE machine_no=VALUES(machine_no), slot_override=VALUES(slot_override), status_override=VALUES(status_override), install_override=VALUES(install_override), finish_override=VALUES(finish_override), note=VALUES(note), updated_by=VALUES(updated_by), updated_at=CURRENT_TIMESTAMP"; $ok = $pdo->prepare($sql)->execute([ ':c'=>$company_id, ':b'=>$beam, ':m'=>$mach, ':s'=>$slot, ':st'=>$status, ':i'=>$ins, ':f'=>$fin, ':n'=>$note, ':u'=>$user_id ]); $msg = $ok ? "Saved override for beam $beam" : "Save failed"; } $rows = qall($pdo," SELECT o.*, (SELECT machine_no FROM beam_card WHERE company_id=o.company_id AND beam_no=o.beam_no LIMIT 1) AS live_machine FROM beam_card_overrides o WHERE o.company_id=:c ORDER BY o.updated_at DESC ", [':c'=>$company_id]); ?> <!doctype html> <html><head><meta charset="utf-8"/> <title>Beam Card Overrides</title> <style> body{font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif;background:#f6f8f9;margin:0;color:#111} .wrap{max-width:900px;margin:22px auto;padding:0 16px} .card{background:#fff;border:1px solid #e5e7eb;border-radius:14px;padding:18px 16px;margin-bottom:16px} label{display:block;margin:8px 0 4px} input,select,textarea{width:100%;border:1px solid #e5e7eb;border-radius:10px;padding:8px;background:#fff} .btn{border:1px solid #e5e7eb;border-radius:10px;padding:8px 12px;background:#fff;font-weight:600;cursor:pointer} table{width:100%;border-collapse:separate;border-spacing:0 8px} th,td{padding:10px 12px} tr{background:#fff;border:1px solid #eef2f5} </style> </head> <body> <div class="wrap"> <div class="card"> <h2>Add / Update Override</h2> <?php if($msg): ?><p><b><?=h($msg)?></b></p><?php endif; ?> <form method="post"> <label>Beam No.</label> <input name="beam_no" required placeholder="e.g. 3215"/> <label>Machine No. (optional)</label> <input name="machine_no" type="number" placeholder="leave blank to keep live value"/> <div style="display:flex;gap:12px"> <div style="flex:1"> <label>Slot (override)</label> <select name="slot_override"> <option value="">— keep —</option> <option>Primary</option><option>Secondary</option><option>Unknown</option> </select> </div> <div style="flex:1"> <label>Status (override)</label> <select name="status_override"> <option value="">— keep —</option> <option>INSTALLED_ADVANCE</option><option>RUNNING</option> <option>CUT</option><option>FINISHED</option> </select> </div> </div> <div style="display:flex;gap:12px"> <div style="flex:1"> <label>Install Date (override)</label> <input type="date" name="install_override"/> </div> <div style="flex:1"> <label>Finish Date (override)</label> <input type="date" name="finish_override"/> </div> </div> <label>Note</label> <textarea name="note" rows="2" placeholder="why overriding?"></textarea> <div style="margin-top:10px"> <button class="btn" type="submit">Save Override</button> <a class="btn" href="../beam_card_report.php">Back to Report</a> </div> </form> </div> <div class="card"> <h3>Existing Overrides</h3> <table> <thead><tr> <th>Beam</th><th>Machine</th><th>Slot</th><th>Status</th> <th>Install</th><th>Finish</th><th>Note</th><th>Updated</th> </tr></thead> <tbody> <?php foreach($rows as $r): ?> <tr> <td><b><?=h($r['beam_no'])?></b></td> <td><?=h($r['machine_no'] ?? $r['live_machine'])?></td> <td><?=h($r['slot_override'] ?: '—')?></td> <td><?=h($r['status_override'] ?: '—')?></td> <td><?=h($r['install_override'] ?: '—')?></td> <td><?=h($r['finish_override'] ?: '—')?></td> <td><?=h($r['note'] ?: '')?></td> <td><?=h($r['updated_at'])?></td> </tr> <?php endforeach; if(empty($rows)): ?> <tr><td colspan="8">No overrides yet.</td></tr> <?php endif; ?> </tbody> </table> </div> </div> </body> </html>