« Back to History
packing_pouch_out_report.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('packing_pouch_out'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; function e($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } /* |-------------------------------------------------------------------------- | FILTERS |-------------------------------------------------------------------------- */ $today = date('Y-m-d'); $from = $_GET['from'] ?? date('Y-m-01'); $to = $_GET['to'] ?? $today; $type = $_GET['pouch_type'] ?? ''; $size = $_GET['pouch_size'] ?? ''; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $from)) $from = date('Y-m-01'); if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $to)) $to = $today; /* |-------------------------------------------------------------------------- | BUILD QUERY |-------------------------------------------------------------------------- */ $sql = " SELECT * FROM packing_pouch_out WHERE company_id = :cid AND entry_date BETWEEN :f AND :t "; $params = [ ':cid' => $company_id, ':f' => $from, ':t' => $to ]; if ($type !== '') { $sql .= " AND pouch_type = :type"; $params[':type'] = $type; } if ($size !== '') { $sql .= " AND pouch_size = :size"; $params[':size'] = $size; } $sql .= " ORDER BY entry_date DESC"; $stmt = $pdo->prepare($sql); $stmt->execute($params); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); /* |-------------------------------------------------------------------------- | TOTAL |-------------------------------------------------------------------------- */ $total_qty = 0; foreach ($rows as $r) { $total_qty += (int)$r['quantity']; } require_once __DIR__ . '/partials/header.php'; ?> <div class="container-fluid py-4"> <!-- FILTER CARD --> <div class="card shadow-sm mb-4"> <div class="card-body"> <form method="get" class="row g-3 align-items-end"> <div class="col-md-2"> <label class="form-label fw-semibold">From</label> <input type="date" name="from" value="<?= e($from) ?>" class="form-control"> </div> <div class="col-md-2"> <label class="form-label fw-semibold">To</label> <input type="date" name="to" value="<?= e($to) ?>" class="form-control"> </div> <div class="col-md-3"> <label class="form-label fw-semibold">Pouch Type</label> <input type="text" name="pouch_type" value="<?= e($type) ?>" class="form-control" placeholder="Beauty"> </div> <div class="col-md-2"> <label class="form-label fw-semibold">Pouch Size</label> <input type="text" name="pouch_size" value="<?= e($size) ?>" class="form-control" placeholder="12*16"> </div> <div class="col-md-3"> <button class="btn btn-primary w-100">Show Report</button> </div> </form> </div> </div> <!-- TITLE --> <div class="text-center mb-3"> <h4 class="fw-bold">Packing Pouch Out Report</h4> <div class="text-muted"> <?= e($from) ?> — <?= e($to) ?> </div> </div> <!-- SUMMARY --> <div class="card shadow-sm mb-4"> <div class="card-body d-flex justify-content-between align-items-center"> <div> <strong>Total Entries:</strong> <?= count($rows) ?> </div> <div class="fs-5 fw-bold text-danger"> Total Quantity Out: <?= number_format($total_qty) ?> </div> </div> </div> <!-- TABLE --> <div class="card shadow-sm"> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-bordered table-striped align-middle mb-0"> <thead class="table-dark text-center"> <tr> <th>#</th> <th>Date</th> <th>Pouch Type</th> <th>Pouch Size</th> <th class="text-end">Quantity</th> <th>Remarks</th> <th>Created At</th> </tr> </thead> <tbody> <?php if(empty($rows)): ?> <tr> <td colspan="7" class="text-center py-4"> No data found. </td> </tr> <?php else: ?> <?php $i = 1; foreach($rows as $r): ?> <tr> <td><?= $i++ ?></td> <td><?= e($r['entry_date']) ?></td> <td><?= e($r['pouch_type']) ?></td> <td><?= e($r['pouch_size']) ?></td> <td class="text-end fw-semibold text-danger"> <?= number_format($r['quantity']) ?> </td> <td><?= e($r['remarks']) ?></td> <td><?= e($r['created_at']) ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> <?php require_once __DIR__ . '/partials/footer.php'; ?>