« Back to History
mesr_final_report.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/../modules/auth/page_acl.php'; $ctx = page_require_access('mesr_final_report'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; $month = !empty($_GET['month']) ? date('Y-m-01', strtotime($_GET['month'].'-01')) : date('Y-m-01'); require_once __DIR__ . '/../partials/header.php'; function sumDetail($pdo,$table,$company_id,$month){ $sql = "SELECT denier,color,net_weight FROM {$table} WHERE company_id=:cid AND month=:month"; $st = $pdo->prepare($sql); $st->execute([ ':cid'=>$company_id, ':month'=>$month ]); return $st->fetchAll(PDO::FETCH_ASSOC); } /* ================= RUNNING TABLES ================= */ $running_tables = [ 'mesr_beam_to_yarn_stock', 'mesr_kasab_stock', 'mesr_yarn_in_beam_stock', 'mesr_yarn_in_bobin', 'mesr_yarn_in_open_box', 'mesr_yarn_in_closed_box', 'mesr_yarn_in_running_beam', 'mesr_yarn_in_machine' ]; $running_total = 0; $running_rows = []; foreach($running_tables as $t){ $rows = sumDetail($pdo,$t,$company_id,$month); foreach($rows as $r){ $running_rows[] = [ 'table'=>$t, 'denier'=>$r['denier'], 'color'=>$r['color'], 'weight'=>$r['net_weight'] ]; $running_total += (float)$r['net_weight']; } } /* ================= STOCK ================= */ $stock_rows = sumDetail($pdo,'mesr_yarn_in_yarn_stock',$company_id,$month); $stock_total = 0; foreach($stock_rows as $r){ $stock_total += (float)$r['net_weight']; } ?> <div class="container-fluid py-4"> <h3>MESR Final Report - <?= substr($month,0,7) ?></h3> <form method="get" class="mb-4"> <input type="month" name="month" value="<?= substr($month,0,7) ?>" class="form-control d-inline-block w-auto"> <button class="btn btn-primary">Load</button> </form> <!-- RUNNING DETAIL --> <div class="card mb-4"> <div class="card-header fw-bold">Running Detail</div> <div class="card-body table-responsive"> <table class="table table-sm table-bordered"> <thead class="table-light"> <tr> <th>Source</th> <th>Denier</th> <th>Color</th> <th class="text-end">Net Weight</th> </tr> </thead> <tbody> <?php foreach($running_rows as $r): ?> <tr> <td><?= $r['table'] ?></td> <td><?= $r['denier'] ?></td> <td><?= $r['color'] ?></td> <td class="text-end"><?= number_format($r['weight'],3) ?></td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr class="fw-bold"> <td colspan="3">Total Running</td> <td class="text-end"><?= number_format($running_total,3) ?></td> </tr> </tfoot> </table> </div> </div> <!-- STOCK DETAIL --> <div class="card mb-4"> <div class="card-header fw-bold">Yarn Stock Detail</div> <div class="card-body table-responsive"> <table class="table table-sm table-bordered"> <thead class="table-light"> <tr> <th>Denier</th> <th>Color</th> <th class="text-end">Net Weight</th> </tr> </thead> <tbody> <?php foreach($stock_rows as $r): ?> <tr> <td><?= $r['denier'] ?></td> <td><?= $r['color'] ?></td> <td class="text-end"><?= number_format($r['net_weight'],3) ?></td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr class="fw-bold"> <td colspan="2">Total Stock</td> <td class="text-end"><?= number_format($stock_total,3) ?></td> </tr> </tfoot> </table> </div> </div> <!-- GRAND --> <div class="card"> <div class="card-body text-center fw-bold fs-5"> Grand Total : <?= number_format($running_total + $stock_total,3) ?> KG </div> </div> </div> <?php require_once __DIR__ . '/../partials/footer.php'; ?>