« Back to History
pending_meter_report.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php /* ============================================================ Pending Meter Report (Quality Wise) Source of truth: beam_book (READ ONLY) ============================================================ */ require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('pending_meter_report'); $company_id = (int)($ctx['company_id'] ?? 0); $pdo = $ctx['pdo'] ?? null; if (!$pdo) require_once __DIR__ . '/core/db.php'; function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } /* ============================================================ QUALITY-WISE PENDING METER beam_book -> beam_entry -> beam_qualities ============================================================ */ $stmt = $pdo->prepare(" SELECT bq.name AS quality, SUM(bb.pending_meter) AS total_pending_meter FROM beam_book bb JOIN beam_entry be ON be.company_id = bb.company_id AND be.beam_no = bb.beam_no JOIN beam_qualities bq ON bq.company_id = be.company_id AND bq.id = be.quality_id WHERE bb.company_id = :cid AND bb.pending_meter > 0 GROUP BY bq.name ORDER BY total_pending_meter DESC "); $stmt->execute([':cid' => $company_id]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); require_once __DIR__ . '/partials/header.php'; ?> <div class="wrap"> <div class="card"> <div class="card-head"> <h2>Pending Meter Report (Quality Wise)</h2> <div class="no-print"> <button class="btn" onclick="window.print()">Print</button> </div> </div> <div class="tablewrap"> <table class="table"> <thead> <tr> <th>Quality</th> <th class="text-right">Total Pending Meter</th> </tr> </thead> <tbody> <?php if (!$rows): ?> <tr> <td colspan="2" class="muted">No pending meter found.</td> </tr> <?php else: ?> <?php foreach ($rows as $r): ?> <tr> <td><?= h($r['quality']) ?></td> <td class="text-right"> <?= number_format((float)$r['total_pending_meter'], 2) ?> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> <?php require_once __DIR__ . '/partials/footer.php'; ?>