« Back to History
kasab_stock_report_txn.php
|
20260721_154032.php
Initial Bulk Import
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('kasab_stock_report'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; require_once __DIR__ . '/partials/header.php'; /* ================= STOCK QUERY ================= */ $sql = " SELECT roll_type, color, SUM(CASE WHEN txn_type='IN' THEN rolls ELSE 0 END) - SUM(CASE WHEN txn_type='OUT' THEN rolls ELSE 0 END) AS stock_rolls, SUM(CASE WHEN txn_type='IN' THEN weight ELSE 0 END) - SUM(CASE WHEN txn_type='OUT' THEN weight ELSE 0 END) AS stock_weight FROM kasab_stock_txn WHERE company_id = :cid GROUP BY roll_type,color ORDER BY roll_type,color "; $stmt = $pdo->prepare($sql); $stmt->execute([':cid'=>$company_id]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $total_rolls = 0; $total_weight = 0; ?> <div class="card"> <div class="card-header fw-bold"> Kasab Stock Report </div> <div class="card-body"> <table class="table table-bordered table-sm"> <thead> <tr> <th>Roll Type</th> <th>Color</th> <th class="text-end">Stock Rolls</th> <th class="text-end">Stock Weight</th> </tr> </thead> <tbody> <?php foreach($rows as $r): $total_rolls += $r['stock_rolls']; $total_weight += $r['stock_weight']; ?> <tr> <td><?=htmlspecialchars($r['roll_type'])?></td> <td><?=htmlspecialchars($r['color'])?></td> <td class="text-end"> <?=number_format($r['stock_rolls'])?> </td> <td class="text-end"> <?=number_format($r['stock_weight'],3)?> </td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr class="fw-bold"> <td colspan="2">Total</td> <td class="text-end"> <?=number_format($total_rolls)?> </td> <td class="text-end"> <?=number_format($total_weight,3)?> </td> </tr> </tfoot> </table> </div> </div> <?php require_once __DIR__ . '/partials/footer.php'; ?>