<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= $action ? 'تعديل إجراء تأديبي' : 'إجراء تأديبي جديد' ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/disciplinary" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<form method="POST" action="<?= $action ? '/hr/disciplinary/' . (int) $action->id : '/hr/disciplinary' ?>">
    <?= 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;">
            <?php if (!$action): ?>
            <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']) ?></option><?php endforeach; ?>
                </select>
            </div>
            <?php endif; ?>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">تاريخ الواقعة <span style="color:#DC2626;">*</span></label><input type="date" name="incident_date" value="<?= e(old('incident_date') ?? ($action->incident_date ?? date('Y-m-d'))) ?>" class="form-control" required></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">نوع المخالفة</label>
                <?php $vtypes = ['attendance'=>'حضور وانصراف','misconduct'=>'سوء سلوك','negligence'=>'إهمال','insubordination'=>'عصيان','safety'=>'سلامة مهنية','other'=>'أخرى']; ?>
                <select name="violation_type" class="form-control">
                    <option value="">-- اختر --</option>
                    <?php foreach ($vtypes as $k => $v): ?><option value="<?= $k ?>" <?= (old('violation_type') ?? ($action->violation_type ?? '')) === $k ? 'selected' : '' ?>><?= $v ?></option><?php endforeach; ?>
                </select>
            </div>
            <div style="grid-column:1/-1;"><label style="display:block;margin-bottom:4px;font-size:13px;">وصف الواقعة <span style="color:#DC2626;">*</span></label><textarea name="incident_description" class="form-control" rows="3" required><?= e(old('incident_description') ?? ($action->incident_description ?? '')) ?></textarea></div>
            <div style="grid-column:1/-1;"><label style="display:block;margin-bottom:4px;font-size:13px;">ملاحظات التحقيق</label><textarea name="investigation_notes" class="form-control" rows="2"><?= e(old('investigation_notes') ?? ($action->investigation_notes ?? '')) ?></textarea></div>
        </div>
    </div>
    <div style="display:flex;gap:10px;justify-content:flex-end;">
        <a href="/hr/disciplinary" class="btn btn-secondary">إلغاء</a>
        <button type="submit" class="btn btn-primary"><?= $action ? 'حفظ التعديلات' : 'تسجيل الإجراء' ?></button>
    </div>
</form>
<?php $__template->endSection(); ?>
