« Back to History
rapier_salary_report.php
|
20260722_120325.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('rapier_salary_report'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; $u = $ctx['user'] ?? null; require_once __DIR__ . '/partials/header.php'; function h($v){ return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8'); } // ========================== // 📅 FILTER (MONTH) // ========================== $month = $_GET['month'] ?? date('Y-m'); $start = $month . '-01'; $end = date('Y-m-t', strtotime($start)); // ========================== // 💰 FETCH RATE // ========================== $stmtRate = $pdo->prepare(" SELECT per_shift_rate FROM rapier_rate WHERE company_id = :cid LIMIT 1 "); $stmtRate->execute([':cid' => $company_id]); $rate = (float)($stmtRate->fetchColumn() ?: 0); // ========================== // 📊 SALARY DATA // ========================== $sql = " SELECT r.employee_id, COUNT(*) AS total_machines, COUNT(*) * :rate AS total_salary FROM rapier_machine_shift_log r WHERE r.company_id = :cid AND r.date BETWEEN :start AND :end GROUP BY r.employee_id ORDER BY total_salary DESC "; $stmt = $pdo->prepare($sql); $stmt->execute([ ':cid' => $company_id, ':start' => $start, ':end' => $end, ':rate' => $rate ]); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <div class="container-fluid mt-3"> <div class="card"> <div class="card-header d-flex justify-content-between align-items-center"> <h5 class="mb-0">Rapier Salary Report</h5> <form method="get" class="d-flex gap-2"> <input type="month" name="month" value="<?= h($month) ?>" class="form-control"> <button class="btn btn-primary">Filter</button> </form> </div> <div class="card-body"> <div class="mb-3"> <strong>Per Shift Rate:</strong> ₹<?= number_format($rate, 2) ?> </div> <div class="table-responsive"> <table class="table table-bordered table-sm"> <thead class="table-light"> <tr> <th>Employee ID</th> <th>Total Machines</th> <th>Total Salary</th> </tr> </thead> <tbody> <?php if (!$data): ?> <tr><td colspan="3" class="text-center">No data found</td></tr> <?php else: ?> <?php foreach ($data as $row): ?> <tr> <td><?= h($row['employee_id']) ?></td> <td><?= h($row['total_machines']) ?></td> <td>₹<?= number_format($row['total_salary'], 2) ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> <?php require_once __DIR__ . '/partials/footer.php'; ?>