Files
HRM-System/scratch/format_may_simulation.php

68 lines
3.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$json = file_get_contents(__DIR__ . '/simulation_output.json');
$data = json_decode($json, true);
echo "# Pay Period Simulation Results (May 1125, 2026)\n\n";
foreach (['daily', 'semi-monthly'] as $freq) {
echo "## " . strtoupper($freq) . " EMPLOYEES\n\n";
foreach ($data as $emp) {
if ($emp['frequency'] !== $freq) continue;
echo "### Employee: " . $emp['name'] . " (" . $emp['employee_code'] . " / Biometric ID: " . $emp['biometric_emp_id'] . ")\n";
echo "- **Branch:** " . $emp['branch_name'] . "\n";
echo "- **Shift:** " . $emp['shift_name'] . "\n";
echo "- **Rate/Base:** ₱" . number_format($emp['rate'], 2) . "\n";
echo "- **Pay Type:** " . $emp['frequency'] . "\n";
$sim = $emp['simulation'];
if (isset($sim['error'])) {
echo "- **Simulation Error:** " . $sim['error'] . "\n";
} else {
echo "#### Simulation Payroll Summary:\n";
echo "| Metric | Value |\n";
echo "| :--- | :--- |\n";
echo "| **Basic Salary** | ₱" . number_format($sim['basic_salary'], 2) . " |\n";
echo "| **Total Earnings (Gross)** | ₱" . number_format($sim['total_earnings'], 2) . " |\n";
echo "| **Total Deductions** | ₱" . number_format($sim['total_deductions'], 2) . " |\n";
echo "| **Net Pay** | ₱" . number_format($sim['net_pay'], 2) . " |\n";
echo "\n**Earnings Breakdown:**\n";
foreach ($sim['earnings'] as $earning) {
echo "- " . $earning['name'] . ": ₱" . number_format($earning['amount'], 2) . "\n";
}
echo "\n**Deductions Breakdown:**\n";
foreach ($sim['deductions'] as $deduction) {
echo "- " . $deduction['name'] . ": ₱" . number_format($deduction['amount'], 2) . "\n";
}
echo "\n**Attendance Summary:**\n";
$sum = $sim['summary'];
echo "- Expected Days: " . $sum['expected_working_days'] . "\n";
echo "- Days Worked: " . $sum['days_worked'] . "\n";
echo "- Rendered Hours: " . $sum['rendered_hours'] . " hrs\n";
echo "- Night Diff Hours: " . $sum['night_diff_hours'] . " hrs (Amount: ₱" . number_format($sum['night_diff_amount'], 2) . ")\n";
echo "- Absences: " . $sum['absences'] . "\n";
echo "- Leaves: " . $sum['leaves'] . "\n";
echo "- Overtime Hours: " . $sum['reg_ot_hours'] . " hrs (Amount: ₱" . number_format($sum['reg_ot_amount'], 2) . ")\n";
}
echo "\n#### Attendance Records (May 1125, 2026):\n";
echo "| Date | Status | Rest Day? | Clock In | Clock Out | Total Hours | Late (hrs) | Early (hrs) | Remarks |\n";
echo "| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |\n";
foreach ($emp['attendance'] as $att) {
echo "| " . $att['date'] .
" | " . $att['status'] .
" | " . ($att['is_rest_day'] ? 'Yes' : 'No') .
" | " . ($att['clock_in'] ?? 'N/A') .
" | " . ($att['clock_out'] ?? 'N/A') .
" | " . $att['total_hours'] .
" | " . $att['late_hours'] .
" | " . $att['early_hours'] .
" | " . ($att['remarks'] ?? '') . " |\n";
}
echo "\n" . str_repeat("-", 40) . "\n\n";
}
}