<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلب إجازة<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/leaves" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<form method="POST" action="/hr/leaves/request">
    <?= csrf_field() ?>
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:16px;display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:16px;">
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">الموظف <span style="color:#DC2626;">*</span></label>
                <select name="employee_profile_id" class="form-control" required><option value="">-- اختر --</option>
                <?php foreach ($employees as $emp): ?><option value="<?= (int) $emp['id'] ?>" <?= old('employee_profile_id') == $emp['id'] ? 'selected' : '' ?>><?= e($emp['first_name_ar'] . ' ' . $emp['last_name_ar'] . ' (' . $emp['employee_number'] . ')') ?></option><?php endforeach; ?>
                </select>
            </div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">نوع الإجازة <span style="color:#DC2626;">*</span></label>
                <select name="leave_type_id" class="form-control" required><option value="">-- اختر --</option>
                <?php foreach ($leaveTypes as $lt): ?><option value="<?= (int) $lt['id'] ?>" <?= old('leave_type_id') == $lt['id'] ? 'selected' : '' ?>><?= e($lt['name_ar']) ?> (<?= (int) $lt['max_days_per_year'] ?> يوم)</option><?php endforeach; ?>
                </select>
            </div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">تاريخ البداية <span style="color:#DC2626;">*</span></label><input type="date" name="start_date" value="<?= e(old('start_date') ?? '') ?>" class="form-control" required></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">تاريخ النهاية <span style="color:#DC2626;">*</span></label><input type="date" name="end_date" value="<?= e(old('end_date') ?? '') ?>" class="form-control" required></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;"><input type="checkbox" name="half_day" value="1" <?= old('half_day') ? 'checked' : '' ?>> نصف يوم</label></div>
            <div style="grid-column:1/-1;"><label style="display:block;margin-bottom:4px;font-size:13px;">السبب</label><textarea name="reason" class="form-control" rows="3"><?= e(old('reason') ?? '') ?></textarea></div>
        </div>
    </div>
    <div style="display:flex;gap:10px;justify-content:flex-end;">
        <a href="/hr/leaves" class="btn btn-secondary">إلغاء</a>
        <button type="submit" class="btn btn-primary">تقديم الطلب</button>
    </div>
</form>
<?php $__template->endSection(); ?>
