<?php $__template->layout('Layout.main'); ?>
<?php $monthNames = [1=>'يناير',2=>'فبراير',3=>'مارس',4=>'أبريل',5=>'مايو',6=>'يونيو',7=>'يوليو',8=>'أغسطس',9=>'سبتمبر',10=>'أكتوبر',11=>'نوفمبر',12=>'ديسمبر']; ?>
<?php $__template->section('title'); ?>تقويم الإجازات - <?= e($monthNames[$month] ?? '') ?> <?= $year ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/leaves" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:20px;">
    <form method="GET" action="/hr/leaves/calendar" style="display:flex;gap:10px;align-items:end;padding:16px;">
        <div><label style="display:block;margin-bottom:4px;font-size:13px;">الشهر</label>
            <select name="month" class="form-control"><?php for ($m = 1; $m <= 12; $m++): ?><option value="<?= $m ?>" <?= $month === $m ? 'selected' : '' ?>><?= $monthNames[$m] ?></option><?php endfor; ?></select>
        </div>
        <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">
    <?php if (empty($leaves)): ?>
    <div style="padding:40px;text-align:center;color:#9CA3AF;">لا توجد إجازات في هذا الشهر</div>
    <?php else: ?>
    <div class="table-responsive">
        <table class="data-table">
            <thead><tr><th>الموظف</th><th>نوع الإجازة</th><th>من</th><th>إلى</th><th>الأيام</th></tr></thead>
            <tbody>
                <?php foreach ($leaves as $lv): ?>
                <tr>
                    <td><?= e($lv['first_name_ar'] . ' ' . $lv['last_name_ar']) ?></td>
                    <td><?= e($lv['leave_type_name']) ?></td>
                    <td><?= e($lv['start_date']) ?></td>
                    <td><?= e($lv['end_date']) ?></td>
                    <td><?= number_format((float) $lv['total_days'], 1) ?></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <?php endif; ?>
</div>
<?php $__template->endSection(); ?>
