« Back to History
salary_report_print.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php require_once __DIR__ . '/modules/auth/page_acl.php'; $ctx = page_require_access('salary_report_print'); $pdo = $ctx['pdo']; $company_id = (int)$ctx['company_id']; $u = $ctx['user']; require_once __DIR__ . '/partials/header.php'; // ===== Month + Windows ===== $month = $_GET['month'] ?? date('Y-m'); $period = $_GET['period'] ?? ''; $start1 = $month . '-01'; $end1 = $month . '-15'; $start2 = $month . '-16'; $end2 = date('Y-m-t', strtotime($month . '-01')); $all_windows = [ [ 'label' => '1-15', 'start' => $start1, 'end' => $end1, 'is_monthly' => 0 ], [ 'label' => '16-end', 'start' => $start2, 'end' => $end2, 'is_monthly' => 1 ] ]; $windows = $all_windows; if ($period === '1-15') { $windows = [$all_windows[0]]; } elseif ($period === '16-End') { $windows = [$all_windows[1]]; } $filters = [ 'month' => $month, 'period' => $period, 'windows' => $windows ]; // ===== Load Modules ===== $stmt = $pdo->prepare(" SELECT * FROM salary_report_modules WHERE company_id = :cid AND is_enabled = 1 ORDER BY sort_order ASC "); $stmt->execute([':cid' => $company_id]); $modules = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <div class="card"> <form method="get" class="form-grid"> <div> <label>Month</label> <input type="month" name="month" value="<?= htmlspecialchars($month) ?>"> </div> <div> <label>Period</label> <select name="period"> <option value="">All</option> <option value="1-15" <?= $period === '1-15' ? 'selected' : '' ?>>1-15</option> <option value="16-End" <?= $period === '16-End' ? 'selected' : '' ?>>16-End</option> </select> </div> <div> <button class="btn btn-primary">Load</button> <button type="button" onclick="window.print()" class="btn">Print</button> </div> </form> </div> <div class="print-container"> <?php foreach ($modules as $m) { $file = $_SERVER['DOCUMENT_ROOT'] . $m['file_path']; if (!file_exists($file)) { echo "<div class='print-page'>Missing file: {$m['file_path']}</div>"; continue; } require_once $file; $fn = $m['function_name']; if (!function_exists($fn)) { echo "<div class='print-page'>Missing function: {$fn}</div>"; continue; } try { echo $fn($ctx, $filters); } catch (Throwable $e) { echo "<div class='print-page'>Error in {$m['code']}: " . htmlspecialchars($e->getMessage()) . "</div>"; } } ?> </div> <?php require_once __DIR__ . '/partials/footer.php'; ?>