<?php $__template->layout('Layout.main'); ?>
<?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/leave-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>إجمالي الأيام</th><th>معتمد</th><th>مرفوض</th><th>معلق</th></tr></thead>
            <tbody>
                <?php if (empty($summary)): ?>
                <tr><td colspan="6" style="text-align:center;padding:40px;color:#9CA3AF;">لا توجد بيانات</td></tr>
                <?php else: ?>
                <?php $tReq = $tDays = $tApp = $tRej = $tPen = 0; ?>
                <?php foreach ($summary as $s): ?>
                <?php $tReq += (int) $s['request_count']; $tDays += (float) $s['total_days']; $tApp += (int) $s['approved_count']; $tRej += (int) $s['rejected_count']; $tPen += (int) $s['pending_count']; ?>
                <tr>
                    <td style="font-weight:600;"><?= e($s['leave_type_name']) ?></td>
                    <td><?= (int) $s['request_count'] ?></td>
                    <td style="font-weight:700;"><?= number_format((float) $s['total_days'], 1) ?></td>
                    <td style="color:#059669;"><?= (int) $s['approved_count'] ?></td>
                    <td style="color:#DC2626;"><?= (int) $s['rejected_count'] ?></td>
                    <td style="color:#D97706;"><?= (int) $s['pending_count'] ?></td>
                </tr>
                <?php endforeach; ?>
                <tr style="background:#F3F4F6;font-weight:700;">
                    <td>الإجمالي</td>
                    <td><?= $tReq ?></td>
                    <td><?= number_format($tDays, 1) ?></td>
                    <td style="color:#059669;"><?= $tApp ?></td>
                    <td style="color:#DC2626;"><?= $tRej ?></td>
                    <td style="color:#D97706;"><?= $tPen ?></td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__template->endSection(); ?>
