« Back to History
pissing_entry_manage.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors', 1); /* ================= AUTH + DB ================= */ require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('pissing_entry_manage'); $pdo = $ctx['pdo'] ?? null; $company_id = (int)($ctx['company_id'] ?? 0); if (!$pdo) { require_once __DIR__ . '/core/db.php'; } /* ================= HELPERS ================= */ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } /* ================= FILTER INPUT ================= */ $f_machine = trim($_GET['machine_no'] ?? ''); $f_quality = (int)($_GET['quality_id'] ?? 0); $f_slot = trim($_GET['beam_slot'] ?? ''); /* ================= MACHINE LIST ================= */ $mStmt = $pdo->prepare(" SELECT DISTINCT machine_no FROM pissing_entry WHERE company_id = ? AND machine_no IS NOT NULL AND machine_no <> '' ORDER BY machine_no "); $mStmt->execute([$company_id]); $machines = $mStmt->fetchAll(PDO::FETCH_COLUMN); /* ================= QUALITY LIST ================= */ $qStmt = $pdo->prepare(" SELECT id, name FROM beam_qualities WHERE company_id = ? ORDER BY name "); $qStmt->execute([$company_id]); $qualities = $qStmt->fetchAll(PDO::FETCH_ASSOC); /* ================= WHERE ================= */ $where = ["p.company_id = :cid"]; $params = [':cid' => $company_id]; if ($f_machine !== '') { $where[] = "p.machine_no = :mno"; $params[':mno'] = $f_machine; } if ($f_quality > 0) { $where[] = "b.quality_id = :qid"; $params[':qid'] = $f_quality; } if ($f_slot !== '') { $where[] = "b.beam_type = :slot"; $params[':slot'] = $f_slot; } $where_sql = implode(' AND ', $where); /* ================= MAIN QUERY ================= */ /* NOTE: entry_date column assumed because YOU CONFIRMED it is required. Agar column ka naam 'date' ho to bas yahi ek jagah change hoga. */ $sql = " SELECT p.id, p.entry_date, p.machine_no, p.beam_no, q.name AS beam_quality, b.beam_type AS beam_slot FROM pissing_entry p LEFT JOIN beam_entry b ON b.beam_no = p.beam_no AND b.company_id = p.company_id LEFT JOIN beam_qualities q ON q.id = b.quality_id AND q.company_id = p.company_id WHERE $where_sql ORDER BY p.entry_date DESC, p.id DESC "; $stmt = $pdo->prepare($sql); $stmt->execute($params); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); /* ================= HEADER ================= */ $page_title = 'Pissing entry manage'; require_once __DIR__ . '/partials/header.php'; ?> <style> /* ===== PAGE-LOCAL ONLY ===== */ .badge-slot-primary { background:#1976d2; color:#fff; } .badge-slot-secondary { background:#2e7d32; color:#fff; } .badge-slot-either { background:#6d4c41; color:#fff; } .badge-slot-unknown { background:#777; color:#fff; } .beam-link { cursor:pointer; color:#0b57d0; text-decoration:underline; } </style> <div class="card"> <h3 class="page-title">Pissing Entry – Manage</h3> <!-- ================= FILTER BAR ================= --> <form method="get" class="no-print" style="display:flex;gap:12px;align-items:end;margin-bottom:12px;flex-wrap:wrap;"> <div> <label>Machine</label> <select name="machine_no"> <option value="">All</option> <?php foreach ($machines as $m): ?> <option value="<?= h($m) ?>" <?= $m===$f_machine?'selected':'' ?>> <?= h($m) ?> </option> <?php endforeach; ?> </select> </div> <div> <label>Quality</label> <select name="quality_id"> <option value="">All</option> <?php foreach ($qualities as $q): ?> <option value="<?= (int)$q['id'] ?>" <?= $q['id']===$f_quality?'selected':'' ?>> <?= h($q['name']) ?> </option> <?php endforeach; ?> </select> </div> <div> <label>Slot</label> <select name="beam_slot"> <option value="">All</option> <option value="primary" <?= $f_slot==='primary'?'selected':'' ?>>Primary</option> <option value="secondary" <?= $f_slot==='secondary'?'selected':'' ?>>Secondary</option> <option value="either" <?= $f_slot==='either'?'selected':'' ?>>Either</option> </select> </div> <div> <button class="btn btn-pri" type="submit">Apply</button> <a class="btn" href="pissing_entry_manage.php">Reset</a> </div> </form> <!-- ================= TABLE ================= --> <div class="table-responsive"> <table class="table"> <thead> <tr> <th>Entry Date</th> <th>Machine</th> <th>Beam No</th> <th>Quality</th> <th>Slot</th> </tr> </thead> <tbody> <?php if (!$rows): ?> <tr><td colspan="5">No records found</td></tr> <?php endif; ?> <?php foreach ($rows as $r): ?> <?php $slot = strtolower((string)($r['beam_slot'] ?? '')); if ($slot === 'primary') $slotClass = 'badge-slot-primary'; elseif ($slot === 'secondary')$slotClass = 'badge-slot-secondary'; elseif ($slot === 'either') $slotClass = 'badge-slot-either'; else $slotClass = 'badge-slot-unknown'; ?> <tr> <td><?= h(substr((string)$r['entry_date'],0,10)) ?></td> <td><?= h($r['machine_no']) ?></td> <td> <span class="beam-link" onclick="openBeamBook(<?= (int)$r['beam_no'] ?>)"> <?= h($r['beam_no']) ?> </span> </td> <td><?= h($r['beam_quality']) ?></td> <td> <span class="badge <?= $slotClass ?>"> <?= h(ucfirst($slot ?: 'Unknown')) ?> </span> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> <script> function openBeamBook(beamNo){ window.open( '/erp/beam_book.php?beam_no=' + beamNo, 'beamBook', 'width=1200,height=800,scrollbars=yes' ); } </script> <?php require_once __DIR__ . '/partials/footer.php'; ?>