« Back to History
cash_payment_detail_print.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('cash_payment_detail_manage'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; /* ================= FILTER ================= */ $year = (int)($_GET['year'] ?? date('Y')); $month = (int)($_GET['month'] ?? date('n')); $period = $_GET['period'] ?? '16-End'; $month_name = date('F', mktime(0,0,0,$month,1)); if (!function_exists('h')) { function h($v){ return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8'); } } /* ================= FETCH DATA ================= */ $st = $pdo->prepare(" SELECT person_name, salary_type, amount, is_paid FROM cash_payment_person WHERE company_id = ? AND year = ? AND month = ? AND period = ? ORDER BY is_paid, salary_type, person_name "); $st->execute([$company_id,$year,$month,$period]); $rows = $st->fetchAll(PDO::FETCH_ASSOC); /* ================= TOTALS ================= */ $total_paid = 0; $total_not_paid = 0; foreach ($rows as $r) { if ((int)$r['is_paid'] === 1) { $total_paid += (int)$r['amount']; } else { $total_not_paid += (int)$r['amount']; } } $grand_total = $total_paid + $total_not_paid; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Cash Payment Detail</title> <style> body{ font-family: Arial, Helvetica, sans-serif; font-size: 12px; } h2,h3{ text-align:center; margin:0; } .meta{ text-align:center; margin-bottom:10px; font-weight:bold; } table{ width:100%; border-collapse:collapse; margin-top:10px; } th,td{ border:1px solid #000; padding:6px; } th{ background:#f0f0f0; } .right{ text-align:right; } .center{ text-align:center; } .total-row th{ background:#e8e8e8; } .paid{ background:#dff0d8; } .not-paid{ background:#fbe3e4; } @media print{ .no-print{ display:none; } } </style> </head> <body onload="window.print()"> <h2>Cash Payment Detail</h2> <div class="meta"> <?= h($month_name) ?> <?= $year ?> (<?= h($period) ?>) </div> <table> <thead> <tr> <th>#</th> <th>Name</th> <th>Salary Type</th> <th>Status</th> <th class="right">Amount</th> </tr> </thead> <tbody> <?php $i = 1; foreach ($rows as $r): $is_paid = (int)$r['is_paid']; ?> <tr class="<?= $is_paid ? 'paid' : 'not-paid' ?>"> <td class="center"><?= $i++ ?></td> <td><?= h($r['person_name']) ?></td> <td><?= h($r['salary_type']) ?></td> <td class="center"><?= $is_paid ? 'PAID' : 'NOT PAID' ?></td> <td class="right"><?= number_format($r['amount']) ?></td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr class="total-row"> <th colspan="4" class="right">TOTAL PAID</th> <th class="right"><?= number_format($total_paid) ?></th> </tr> <tr class="total-row"> <th colspan="4" class="right">TOTAL NOT PAID</th> <th class="right"><?= number_format($total_not_paid) ?></th> </tr> <tr class="total-row"> <th colspan="4" class="right">GRAND TOTAL</th> <th class="right"><?= number_format($grand_total) ?></th> </tr> </tfoot> </table> </body> </html>