<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>الإجراءات التأديبية<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/disciplinary/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'); ?>
<?php $sl = ['investigation'=>'تحت التحقيق','pending_decision'=>'في انتظار القرار','decided'=>'تم تحديد العقوبة','appealed'=>'متظلم','appeal_reviewed'=>'تم مراجعة التظلم','enforced'=>'منفذ','cancelled'=>'ملغى']; ?>
<?php $sc = ['investigation'=>'#DBEAFE;color:#1E40AF','pending_decision'=>'#FEF3C7;color:#92400E','decided'=>'#FDE8E8;color:#9B1C1C','appealed'=>'#E0E7FF;color:#3730A3','appeal_reviewed'=>'#E0E7FF;color:#3730A3','enforced'=>'#DEF7EC;color:#03543F','cancelled'=>'#E5E7EB;color:#374151']; ?>
<?php $pl = ['warning'=>'إنذار','wage_deduction'=>'خصم من الراتب','raise_postponement'=>'تأجيل علاوة','suspension'=>'إيقاف','demotion'=>'تنزيل درجة','termination'=>'فصل']; ?>
<div class="card" style="margin-bottom:20px;">
    <form method="GET" action="/hr/disciplinary" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;padding:16px;">
        <div style="flex:1;min-width:160px;"><label style="display:block;margin-bottom:4px;font-size:13px;color:#6B7280;">بحث</label><input type="text" name="q" value="<?= e($filters['q']) ?>" placeholder="اسم الموظف..." class="form-control"></div>
        <div style="min-width:130px;"><label style="display:block;margin-bottom:4px;font-size:13px;color:#6B7280;">الحالة</label>
            <select name="status" class="form-control"><option value="">الكل</option>
            <?php foreach ($sl as $k => $v): ?><option value="<?= $k ?>" <?= $filters['status'] === $k ? 'selected' : '' ?>><?= $v ?></option><?php endforeach; ?>
            </select>
        </div>
        <div style="min-width:130px;"><label style="display:block;margin-bottom:4px;font-size:13px;color:#6B7280;">نوع الجزاء</label>
            <select name="penalty_type" class="form-control"><option value="">الكل</option>
            <?php foreach ($pl as $k => $v): ?><option value="<?= $k ?>" <?= $filters['penalty_type'] === $k ? 'selected' : '' ?>><?= $v ?></option><?php endforeach; ?>
            </select>
        </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($actions)): ?>
                <tr><td colspan="6" style="text-align:center;padding:40px;color:#9CA3AF;">لا توجد إجراءات تأديبية</td></tr>
                <?php else: ?>
                <?php foreach ($actions as $a): ?>
                <tr>
                    <td><a href="/hr/employees/<?= (int) $a['employee_profile_id'] ?>"><?= e(($a['first_name_ar'] ?? '') . ' ' . ($a['last_name_ar'] ?? '')) ?></a></td>
                    <td><?= e($a['incident_date'] ?? '') ?></td>
                    <td><?= e(mb_substr($a['incident_description'] ?? '-', 0, 50)) ?></td>
                    <td><?php if (!empty($a['penalty_type'])): ?><span style="font-weight:600;"><?= e($pl[$a['penalty_type']] ?? $a['penalty_type']) ?></span><?php $pd = (int) ($a['wage_deduction_days'] ?? $a['suspension_days'] ?? 0); if ($pd > 0): ?> (<?= $pd ?> يوم)<?php endif; ?><?php else: ?>-<?php endif; ?></td>
                    <td><span style="display:inline-block;padding:2px 8px;border-radius:9999px;font-size:12px;background:<?= $sc[$a['status']] ?? '#E5E7EB;color:#374151' ?>;"><?= e($sl[$a['status']] ?? $a['status']) ?></span></td>
                    <td><a href="/hr/disciplinary/<?= (int) $a['id'] ?>" style="color:#2563EB;"><i data-lucide="eye" style="width:16px;height:16px;"></i></a></td>
                </tr>
                <?php endforeach; ?>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
    <?php if (!empty($pagination)): ?><?php $__template->include('Shared.Components.pagination', ['pagination' => $pagination]); ?><?php endif; ?>
</div>
<script>if(typeof lucide!=='undefined')lucide.createIcons();</script>
<?php $__template->endSection(); ?>
