<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>العطلات الرسمية <?= $year ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/hr/holidays/create" class="btn btn-primary" style="display:inline-flex;align-items:center;gap:6px;"><i data-lucide="plus" style="width:16px;height:16px;"></i> إضافة عطلة</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:20px;">
    <form method="GET" action="/hr/holidays" 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($holidays)): ?>
                <tr><td colspan="6" style="text-align:center;padding:40px;color:#9CA3AF;">لا توجد عطلات</td></tr>
                <?php else: ?>
                <?php $typeLabels = ['national' => 'وطنية', 'religious' => 'دينية', 'company' => 'خاصة بالشركة']; ?>
                <?php foreach ($holidays as $h): ?>
                <tr>
                    <td><?= e($h['name_ar']) ?></td>
                    <td><?= e($h['date']) ?></td>
                    <td><?= (int) $h['duration_days'] ?> يوم</td>
                    <td><?= e($typeLabels[$h['holiday_type']] ?? $h['holiday_type']) ?></td>
                    <td><?= $h['is_recurring'] ? 'نعم' : 'لا' ?></td>
                    <td>
                        <a href="/hr/holidays/<?= (int) $h['id'] ?>/edit" style="color:#2563EB;margin-inline-end:8px;"><i data-lucide="edit" style="width:16px;height:16px;"></i></a>
                        <form method="POST" action="/hr/holidays/<?= (int) $h['id'] ?>/archive" style="display:inline;" onsubmit="return confirm('حذف؟');">
                            <?= csrf_field() ?><button type="submit" style="border:none;background:none;color:#DC2626;cursor:pointer;"><i data-lucide="trash-2" style="width:16px;height:16px;"></i></button>
                        </form>
                    </td>
                </tr>
                <?php endforeach; ?>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<script>if(typeof lucide!=='undefined')lucide.createIcons();</script>
<?php $__template->endSection(); ?>
