« Back to History
beam_load_2.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php /* ============================================================ File: beam_load_2.php Purpose: Simple Beam Load → beam_load_data_2 ONLY (Manual machine no + manual beam no) ============================================================ */ error_reporting(E_ALL); ini_set('display_errors', 1); /* ---------- AUTH / CONTEXT ---------- */ require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('beam_load_2'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; $user_id = (int)$ctx['user']['id']; function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } require_once __DIR__ . '/helpers/activity_helper.php'; /* ============================================================ MASTER DATA ============================================================ */ /* ---------- PISSING QUALITIES ---------- */ $st = $pdo->prepare(" SELECT id, quality FROM pissing_quality WHERE company_id = ? AND is_active = 1 ORDER BY quality "); $st->execute([$company_id]); $qualities = $st->fetchAll(PDO::FETCH_ASSOC); /* ---------- EMPLOYEES ---------- */ $st = $pdo->prepare(" SELECT id, name FROM company_employee_master WHERE company_id = ? AND is_active = 1 AND designation_name = 'Pissing' ORDER BY name "); $st->execute([$company_id]); $employees = $st->fetchAll(PDO::FETCH_ASSOC); /* ============================================================ SUBMIT ============================================================ */ $msg = $err = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $beam_no = trim($_POST['beam_no'] ?? ''); $machine_no = (int)($_POST['machine_no'] ?? 0); $machine_type = $_POST['machine_type'] ?? ''; $quality_id = (int)($_POST['quality_id'] ?? 0); $employee_id = (int)($_POST['employee_id'] ?? 0); $load_date = $_POST['load_date'] ?? date('Y-m-d'); try { if (!$beam_no || !$machine_no || !$machine_type || !$quality_id || !$employee_id) { throw new Exception('All fields are required.'); } /* ---------- RAPIEr RULE ---------- */ if ($machine_type === 'rapier' && ($machine_no < 1 || $machine_no > 12)) { throw new Exception('Rapier machine number must be between 1 and 12.'); } $pdo->prepare(" INSERT INTO beam_load_data_2 (company_id, beam_no, event_type, event_date, machine_no, machine_type, quality_id, load_type, employee_id, load_date, created_by) VALUES (:cid, :bno, 'loaded', :dt, :mno, :mtype, :qid, 'pissing', :eid, :dt, :uid) ")->execute([ ':cid' => $company_id, ':bno' => $beam_no, ':dt' => $load_date, ':mno' => $machine_no, ':mtype' => $machine_type, ':qid' => $quality_id, ':eid' => $employee_id, ':uid' => $user_id ]); activity_create('beam', 'beam_load_2_create', (int)$pdo->lastInsertId(), 'Recorded beam load (manual)'); $msg = 'Data saved successfully.'; } catch (Exception $e) { $err = $e->getMessage(); } } /* ============================================================ VIEW ============================================================ */ require_once __DIR__ . '/partials/header.php'; ?> <div class="wrap container-fluid py-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <div> <h2 class="fw-bold m-0 text-dark"> <i class="bi bi-box-arrow-in-right text-primary me-2"></i> Beam Load 2 </h2> <p class="text-muted small mb-0 font-monospace text-uppercase">Manual Entry Mode</p> </div> <div class="text-end"> <span class="badge bg-dark px-3 py-2">Manual Entry</span> </div> </div> <?php if ($msg): ?> <div class="alert alert-success shadow-sm border-0 border-start border-4 border-success d-flex align-items-center mb-4" role="alert"> <i class="bi bi-check-circle-fill me-2 fs-5"></i> <div><?= h($msg) ?></div> </div> <?php endif; ?> <?php if ($err): ?> <div class="alert alert-danger shadow-sm border-0 border-start border-4 border-danger mb-4" role="alert"> <i class="bi bi-exclamation-octagon-fill me-2 fs-5"></i> <div><?= h($err) ?></div> </div> <?php endif; ?> <div class="card shadow-sm border-0"> <div class="card-header bg-white py-3 border-bottom"> <h6 class="m-0 fw-bold text-muted small text-uppercase"> <i class="bi bi-info-circle me-2 text-primary"></i> Beam & Machine Allocation </h6> </div> <div class="card-body p-4"> <form method="post" autocomplete="off" class="row g-4"> <div class="col-md-3"> <label class="form-label small fw-bold text-muted text-uppercase">Beam No</label> <div class="input-group shadow-sm-hover"> <span class="input-group-text bg-light text-primary border-end-0"><i class="bi bi-qr-code"></i></span> <input type="text" name="beam_no" class="form-control border-start-0" required placeholder="Enter beam number"> </div> </div> <div class="col-md-3"> <label class="form-label small fw-bold text-muted text-uppercase">Machine Type</label> <select name="machine_type" class="form-select shadow-sm-hover" required> <option value="">Select Type</option> <option value="loom">Loom</option> <option value="rapier">Rapier</option> </select> </div> <div class="col-md-3"> <label class="form-label small fw-bold text-muted text-uppercase">Machine No</label> <div class="input-group shadow-sm-hover"> <span class="input-group-text bg-light border-end-0"><i class="bi bi-cpu"></i></span> <input type="number" name="machine_no" class="form-control border-start-0" min="1" required placeholder="Machine #"> </div> </div> <div class="col-md-3"> <label class="form-label small fw-bold text-muted text-uppercase">Load Date</label> <div class="input-group shadow-sm-hover"> <span class="input-group-text bg-light border-end-0"><i class="bi bi-calendar-check"></i></span> <input type="date" name="load_date" class="form-control border-start-0" value="<?= h(date('Y-m-d')) ?>"> </div> </div> <div class="col-md-6"> <label class="form-label small fw-bold text-muted text-uppercase">Pissing Quality</label> <div class="input-group shadow-sm-hover"> <span class="input-group-text bg-light border-end-0"><i class="bi bi-stars"></i></span> <select name="quality_id" class="form-select border-start-0" required> <option value="">Select Quality...</option> <?php foreach ($qualities as $q): ?> <option value="<?= $q['id'] ?>"><?= h($q['quality']) ?></option> <?php endforeach; ?> </select> </div> </div> <div class="col-md-6"> <label class="form-label small fw-bold text-muted text-uppercase">Employee / Operator</label> <div class="input-group shadow-sm-hover"> <span class="input-group-text bg-light border-end-0"><i class="bi bi-person-gear"></i></span> <select name="employee_id" class="form-select border-start-0" required> <option value="">Select Employee...</option> <?php foreach ($employees as $e): ?> <option value="<?= $e['id'] ?>"><?= h($e['name']) ?></option> <?php endforeach; ?> </select> </div> </div> <div class="col-12 mt-5 text-end"> <hr class="mb-4 opacity-10"> <button type="reset" class="btn btn-outline-secondary px-4 me-2 rounded-pill">Clear</button> <button type="submit" class="btn btn-primary px-5 fw-bold shadow-sm rounded-pill"> <i class="bi bi-cloud-upload-fill me-2"></i> Save Load Entry </button> </div> </form> </div> </div> </div> <style> /* Custom Layout Styling */ .shadow-sm-hover { transition: all 0.2s; } .shadow-sm-hover:focus-within { box-shadow: 0 4px 8px rgba(0,0,0,0.05) !important; } .input-group-text { border-color: #dee2e6; color: #6c757d; } .form-control:focus, .form-select:focus { border-color: #0d6efd; box-shadow: none; } .input-group:focus-within .input-group-text { border-color: #0d6efd; color: #0d6efd; background-color: #f8faff !important; } </style> <?php require_once __DIR__ . '/partials/footer.php'; ?>