Commit e83886e0 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(hr): add missing permission request views (index + form)

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 35dce489
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلب إذن جديد<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<form method="POST" action="/hr/permissions" style="max-width:600px;">
<?= csrf_field() ?>
<div class="card" style="margin-bottom:20px;">
<div style="padding:16px;border-bottom:1px solid #E5E7EB;font-weight:600;">بيانات الإذن</div>
<div style="padding:20px;display:grid;grid-template-columns:1fr 1fr;gap:16px;">
<div style="grid-column:1/-1;">
<label style="display:block;margin-bottom:4px;font-size:13px;font-weight:500;">الموظف <span style="color:#DC2626;">*</span></label>
<select name="employee_id" class="form-control" required>
<option value="">— اختر موظف —</option>
<?php foreach ($employees as $emp): ?>
<option value="<?= (int) $emp['id'] ?>"><?= e($emp['full_name_ar']) ?> (<?= e($emp['employee_number']) ?>)</option>
<?php endforeach; ?>
</select>
</div>
<div>
<label style="display:block;margin-bottom:4px;font-size:13px;font-weight:500;">تاريخ الإذن <span style="color:#DC2626;">*</span></label>
<input type="date" name="permission_date" value="<?= date('Y-m-d') ?>" class="form-control" required>
</div>
<div></div>
<div>
<label style="display:block;margin-bottom:4px;font-size:13px;font-weight:500;">من الساعة <span style="color:#DC2626;">*</span></label>
<input type="time" name="start_time" class="form-control" required>
</div>
<div>
<label style="display:block;margin-bottom:4px;font-size:13px;font-weight:500;">إلى الساعة <span style="color:#DC2626;">*</span></label>
<input type="time" name="end_time" class="form-control" required>
</div>
<div style="grid-column:1/-1;">
<label style="display:block;margin-bottom:4px;font-size:13px;font-weight:500;">السبب <span style="color:#DC2626;">*</span></label>
<textarea name="reason" class="form-control" rows="3" required placeholder="سبب طلب الإذن..."></textarea>
</div>
</div>
</div>
<div style="display:flex;gap:12px;">
<button type="submit" class="btn btn-primary">تقديم الطلب</button>
<a href="/hr/permissions" class="btn btn-secondary">إلغاء</a>
</div>
</form>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلبات الأذونات<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<?php if (can('hr.permissions.create')): ?>
<a href="/hr/permissions/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 endif; ?>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:20px;">
<form method="GET" action="/hr/permissions" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;padding:16px;">
<div style="min-width:160px;">
<label style="display:block;margin-bottom:4px;font-size:13px;color:#6B7280;">الشهر</label>
<input type="month" name="month" value="<?= e($month) ?>" class="form-control">
</div>
<div style="min-width:140px;">
<label style="display:block;margin-bottom:4px;font-size:13px;color:#6B7280;">الحالة</label>
<select name="status" class="form-control">
<option value="">الكل</option>
<option value="pending" <?= $status === 'pending' ? 'selected' : '' ?>>معلّق</option>
<option value="approved" <?= $status === 'approved' ? 'selected' : '' ?>>معتمد</option>
<option value="rejected" <?= $status === 'rejected' ? 'selected' : '' ?>>مرفوض</option>
</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><th>السبب</th><th>الحالة</th><th>المعتمد</th><th>إجراءات</th></tr>
</thead>
<tbody>
<?php if (empty($permissions)): ?>
<tr><td colspan="10" style="text-align:center;padding:40px;color:#9CA3AF;">لا يوجد طلبات</td></tr>
<?php else: ?>
<?php foreach ($permissions as $p): ?>
<?php
$statusMap = ['pending' => ['معلّق', '#FEF3C7;color:#92400E'], 'approved' => ['معتمد', '#DEF7EC;color:#03543F'], 'rejected' => ['مرفوض', '#FDE8E8;color:#9B1C1C']];
$st = $statusMap[$p['status']] ?? ['—', '#E5E7EB;color:#374151'];
?>
<tr>
<td><?= e($p['employee_name'] ?? '-') ?></td>
<td><code><?= e($p['employee_number'] ?? '-') ?></code></td>
<td><?= e($p['permission_date']) ?></td>
<td><?= e(substr($p['start_time'], 0, 5)) ?></td>
<td><?= e(substr($p['end_time'], 0, 5)) ?></td>
<td><?= number_format((float)$p['hours'], 1) ?></td>
<td style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><?= e($p['reason'] ?? '') ?></td>
<td><span style="display:inline-block;padding:2px 8px;border-radius:9999px;font-size:12px;background:<?= $st[1] ?>;"><?= $st[0] ?></span></td>
<td><?= e($p['approved_by_name'] ?? '-') ?></td>
<td style="white-space:nowrap;">
<?php if ($p['status'] === 'pending' && can('hr.permissions.approve')): ?>
<form method="POST" action="/hr/permissions/<?= (int)$p['id'] ?>/approve" style="display:inline;">
<?= csrf_field() ?>
<button type="submit" class="btn btn-sm btn-success" title="اعتماد" style="padding:2px 8px;font-size:12px;"></button>
</form>
<form method="POST" action="/hr/permissions/<?= (int)$p['id'] ?>/reject" style="display:inline;margin-inline-start:4px;">
<?= csrf_field() ?>
<button type="submit" class="btn btn-sm btn-danger" title="رفض" style="padding:2px 8px;font-size:12px;"></button>
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<script>if(typeof lucide!=='undefined')lucide.createIcons();</script>
<?php $__template->endSection(); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment