« Back to History
jobwork_send_report.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php ini_set('display_errors', 1); error_reporting(E_ALL); /* ================= AUTH ================= */ require_once __DIR__ . '/../modules/auth/page_acl.php'; $ctx = page_require_access('jobwork_send', []); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; $u = $ctx['user'] ?? null; /* ================= HEADER INCLUDE ================= */ $page_title = "Job Work Send Report"; require_once __DIR__ . '/../partials/header.php'; /* ================= INPUT ================= */ $from = $_GET['from'] ?? date('Y-m-01'); $to = $_GET['to'] ?? date('Y-m-d'); $from_disp = date('d-m-Y', strtotime($from)); $to_disp = date('d-m-Y', strtotime($to)); /* ================= MAIN QUERY ================= */ $sql = " SELECT j.stock_type, j.denier, j.color, SUM(j.boxes) AS total_boxes, SUM(j.weight) AS total_weight, COALESCE(r.rate,0) AS rate FROM jobwork_send j LEFT JOIN yarn_rates r ON r.company_id = j.company_id AND r.denier = j.denier AND r.color = j.color WHERE j.company_id = ? AND j.entry_date BETWEEN ? AND ? GROUP BY j.stock_type, j.denier, j.color, r.rate ORDER BY j.stock_type, j.denier, j.color "; $st = $pdo->prepare($sql); $st->execute([$company_id, $from, $to]); $rows = $st->fetchAll(PDO::FETCH_ASSOC); /* ================= TOTALS ================= */ $grand_boxes = 0; $grand_weight = 0; $grand_value = 0; $group = []; foreach ($rows as $r) { $key = $r['stock_type'].'|'.$r['denier']; if (!isset($group[$key])) { $group[$key] = [ 'stock_type' => $r['stock_type'], 'denier' => $r['denier'], 'boxes' => 0, 'weight' => 0, 'value' => 0, ]; } $value = $r['total_weight'] * $r['rate']; $group[$key]['boxes'] += $r['total_boxes']; $group[$key]['weight'] += $r['total_weight']; $group[$key]['value'] += $value; } ?> <div class="container py-4"> <h4 class="fw-bold text-center mb-2">JOB WORK SEND REPORT</h4> <div class="text-center fw-bold mb-3"> Period: <?= htmlspecialchars($from_disp) ?> to <?= htmlspecialchars($to_disp) ?> </div> <div class="mb-3"> <form method="get" class="row g-3 align-items-end"> <div class="col-md-3"> <label class="form-label">From</label> <input type="date" name="from" value="<?= htmlspecialchars($from) ?>" class="form-control"> </div> <div class="col-md-3"> <label class="form-label">To</label> <input type="date" name="to" value="<?= htmlspecialchars($to) ?>" class="form-control"> </div> <div class="col-md-2"> <button type="submit" class="btn btn-primary w-100">Filter</button> </div> <div class="col-md-2"> <button type="button" onclick="window.print()" class="btn btn-secondary w-100">Print</button> </div> </form> </div> <!-- ================= SECTION 1 ================= --> <div class="card mb-4"> <div class="card-header fw-bold">1️⃣ Job Work Send Summary (Color Wise)</div> <div class="card-body table-responsive"> <table class="table table-bordered table-sm"> <thead class="table-light text-center"> <tr> <th>Stock Type</th> <th>Denier</th> <th>Color</th> <th>Box / Roll</th> <th>Total Weight</th> <th>Rate</th> <th>Value</th> </tr> </thead> <tbody> <?php foreach ($rows as $r): $value = $r['total_weight'] * $r['rate']; $grand_boxes += $r['total_boxes']; $grand_weight += $r['total_weight']; $grand_value += $value; ?> <tr class="text-center"> <td><?= htmlspecialchars($r['stock_type']) ?></td> <td><?= htmlspecialchars($r['denier']) ?></td> <td><?= htmlspecialchars($r['color']) ?></td> <td><?= $r['total_boxes'] ?></td> <td><?= number_format($r['total_weight'],2) ?></td> <td><?= number_format($r['rate'],2) ?></td> <td><?= number_format($value,2) ?></td> </tr> <?php endforeach; ?> <tr class="fw-bold text-center"> <td colspan="3">TOTAL</td> <td><?= $grand_boxes ?></td> <td><?= number_format($grand_weight,2) ?></td> <td></td> <td><?= number_format($grand_value,2) ?></td> </tr> </tbody> </table> </div> </div> <!-- ================= SECTION 2 ================= --> <div class="card"> <div class="card-header fw-bold">2️⃣ Group Report (Denier Wise – All Colors Combined)</div> <div class="card-body table-responsive"> <table class="table table-bordered table-sm"> <thead class="table-light text-center"> <tr> <th>Stock Type</th> <th>Denier</th> <th>Total Boxes / Rolls</th> <th>Total Weight</th> <th>Total Value</th> </tr> </thead> <tbody> <?php $g_boxes = $g_weight = $g_value = 0; foreach ($group as $g): $g_boxes += $g['boxes']; $g_weight += $g['weight']; $g_value += $g['value']; ?> <tr class="text-center"> <td><?= htmlspecialchars($g['stock_type']) ?></td> <td><?= htmlspecialchars($g['denier']) ?></td> <td><?= $g['boxes'] ?></td> <td><?= number_format($g['weight'],2) ?></td> <td><?= number_format($g['value'],2) ?></td> </tr> <?php endforeach; ?> <tr class="fw-bold text-center"> <td colspan="2">GRAND TOTAL</td> <td><?= $g_boxes ?></td> <td><?= number_format($g_weight,2) ?></td> <td><?= number_format($g_value,2) ?></td> </tr> </tbody> </table> </div> </div> </div> <?php require_once __DIR__ . '/../partials/footer.php'; ?>