<?php $__template->layout('Layout.main'); ?>
<?php $mn = [1=>'يناير',2=>'فبراير',3=>'مارس',4=>'أبريل',5=>'مايو',6=>'يونيو',7=>'يوليو',8=>'أغسطس',9=>'سبتمبر',10=>'أكتوبر',11=>'نوفمبر',12=>'ديسمبر']; ?>
<?php $__template->section('title'); ?>ملخص التأمينات - <?= $year ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/reports" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:20px;">
    <form method="GET" action="/hr/reports/insurance-summary" style="display:flex;gap:10px;align-items:end;padding:16px;">
        <div><label style="display:block;margin-bottom:4px;font-size:13px;">السنة</label><input type="number" name="year" value="<?= $year ?>" class="form-control" style="max-width:100px;"></div>
        <button type="submit" class="btn btn-secondary">عرض</button>
    </form>
</div>
<div class="card">
    <div class="table-responsive">
        <table class="data-table">
            <thead><tr><th>الشهر</th><th>الموظفين</th><th>حصة الموظف (11%)</th><th>حصة صاحب العمل (18.75%)</th><th>الإجمالي</th></tr></thead>
            <tbody>
                <?php if (empty($monthlySummary)): ?>
                <tr><td colspan="5" style="text-align:center;padding:40px;color:#9CA3AF;">لا توجد بيانات</td></tr>
                <?php else: ?>
                <?php $tEmp = $tEmr = $tComb = 0; ?>
                <?php foreach ($monthlySummary as $m): ?>
                <?php $tEmp += (float) ($m['total_employee_share'] ?? 0); $tEmr += (float) ($m['total_employer_share'] ?? 0); $tComb += (float) ($m['total_combined'] ?? 0); ?>
                <tr>
                    <td style="font-weight:600;"><?= e($mn[(int) $m['month']] ?? '') ?></td>
                    <td><?= (int) ($m['employee_count'] ?? 0) ?></td>
                    <td><?= number_format((float) ($m['total_employee_share'] ?? 0), 2) ?></td>
                    <td><?= number_format((float) ($m['total_employer_share'] ?? 0), 2) ?></td>
                    <td style="font-weight:700;"><?= number_format((float) ($m['total_combined'] ?? 0), 2) ?></td>
                </tr>
                <?php endforeach; ?>
                <tr style="background:#F3F4F6;font-weight:700;">
                    <td>الإجمالي</td><td></td>
                    <td><?= number_format($tEmp, 2) ?></td>
                    <td><?= number_format($tEmr, 2) ?></td>
                    <td><?= number_format($tComb, 2) ?></td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__template->endSection(); ?>
