« Back to History
rapier_production_report.php
|
20261118_125741.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('rapier_production_report'); $pdo = $ctx['pdo'] ?? null; $company_id = (int)($ctx['company_id'] ?? 0); if (!$pdo) { require_once __DIR__ . '/core/db.php'; $pdo = $GLOBALS['pdo']; } $today = date('Y-m-d'); /* ── 1. Today's Report Data ── */ $st_today = $pdo->prepare("SELECT SUM(meter) as total_meter, SUM(saree) as total_saree FROM rapier_daily_production WHERE company_id = ? AND production_date = ?"); $st_today->execute([$company_id, $today]); $today_stats = $st_today->fetch(PDO::FETCH_ASSOC); /* ── 2. Full History Data ── */ $st_list = $pdo->prepare("SELECT * FROM rapier_daily_production WHERE company_id = ? ORDER BY production_date DESC"); $st_list->execute([$company_id]); $all_data = $st_list->fetchAll(PDO::FETCH_ASSOC); require_once __DIR__ . '/partials/header.php'; ?> <div class="container-fluid mt-3" id="capture-area" style="max-width: 1000px; background: #f8f9fa; padding: 20px; border-radius: 10px;"> <!-- Header Section --> <div class="d-flex justify-content-between align-items-center mb-4 no-print-section"> <div> <h4 class="fw-bold mb-0 text-primary">Rapier Daily Production Report</h4> <p class="text-muted small mb-0">Generated on: <?= date('d-m-Y H:i') ?></p> </div> <div class="btn-group"> <button onclick="takeScreenshot()" class="btn btn-dark shadow-sm"> <i class="bi bi-camera"></i> Save as Image </button> <button onclick="window.print()" class="btn btn-outline-dark shadow-sm"> <i class="bi bi-printer"></i> Print </button> </div> </div> <!-- ── Today's Summary Card ── --> <div class="row g-3 mb-4"> <div class="col-md-6"> <div class="card border-0 shadow-sm bg-primary text-white h-100"> <div class="card-body text-center py-4"> <h6 class="text-uppercase small fw-bold opacity-75">Today's Total Meters</h6> <h2 class="display-5 fw-bold mb-0"><?= number_format($today_stats['total_meter'] ?? 0, 2) ?></h2> <p class="mb-0 mt-1 small">Date: <?= date('d-m-Y') ?></p> </div> </div> </div> <div class="col-md-6"> <div class="card border-0 shadow-sm bg-success text-white h-100"> <div class="card-body text-center py-4"> <h6 class="text-uppercase small fw-bold opacity-75">Today's Saree Pieces</h6> <h2 class="display-5 fw-bold mb-0"><?= number_format($today_stats['total_saree'] ?? 0, 2) ?></h2> <p class="mb-0 mt-1 small">Date: <?= date('d-m-Y') ?></p> </div> </div> </div> </div> <!-- ── Detailed History Table ── --> <div class="card border-0 shadow-sm"> <div class="card-header bg-white py-3"> <h6 class="mb-0 fw-bold text-muted text-uppercase small">Production History</h6> </div> <div class="table-responsive"> <table class="table table-hover align-middle mb-0"> <thead class="table-light text-uppercase small fw-bold"> <tr> <th class="ps-3">Production Date</th> <th class="text-end">Meter</th> <th class="text-end">Saree</th> <th>Remarks</th> <th class="text-end pe-3">Entry Time</th> </tr> </thead> <tbody> <?php if(empty($all_data)): ?> <tr><td colspan="5" class="text-center py-5 text-muted">No records found.</td></tr> <?php else: foreach($all_data as $row): ?> <tr class="<?= $row['production_date'] == $today ? 'table-warning' : '' ?>"> <td class="ps-3 fw-bold"><?= date('d-m-Y', strtotime($row['production_date'])) ?></td> <td class="text-end font-monospace text-primary fw-bold"><?= number_format($row['meter'], 2) ?></td> <td class="text-end font-monospace text-success fw-bold"><?= number_format($row['saree'], 2) ?></td> <td class="text-muted small"><?= htmlspecialchars($row['remarks'] ?: '-') ?></td> <td class="text-end pe-3 text-muted" style="font-size: 0.75rem;"> <?= date('d/m H:i', strtotime($row['created_at'])) ?> </td> </tr> <?php endforeach; endif; ?> </tbody> </table> </div> </div> </div> <!-- Screenshot Library --> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script> <script> function takeScreenshot() { const btnGroup = document.querySelector('.no-print-section'); // Hide buttons during screenshot btnGroup.style.display = 'none'; html2canvas(document.querySelector("#capture-area")).then(canvas => { const link = document.createElement('a'); link.download = 'Rapier_Production_Report_' + new Date().toLocaleDateString() + '.png'; link.href = canvas.toDataURL("image/png"); link.click(); // Show buttons back btnGroup.style.display = 'flex'; }); } </script> <style> @media print { .no-print-section { display: none !important; } #capture-area { padding: 0 !important; background: white !important; } body { background: white !important; } } </style> <?php require_once __DIR__ . '/partials/footer.php'; ?>