Commit 17e8255e authored by Administrator's avatar Administrator

Update 9 files via Son of Anton

parent a23798bd
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>حالة وفاة #<?= (int) $case['id'] ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>حالة وفاة #<?= (int) $case['id'] ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div class="card" style="padding:20px;"> <div class="card" style="padding:20px;margin-bottom:20px;">
<table style="width:100%;max-width:600px;font-size:14px;"> <table style="width:100%;max-width:600px;font-size:14px;">
<tr><td style="padding:6px 0;color:#6B7280;width:35%;">العضو</td><td style="padding:6px 0;font-weight:600;"><?= e($case['member_name']) ?> (<?= e($case['membership_number'] ?? '—') ?>)</td></tr> <tr><td style="padding:6px 0;color:#6B7280;width:35%;">العضو</td><td style="padding:6px 0;font-weight:600;"><?= e($case['member_name']) ?> (<?= e($case['membership_number'] ?? '—') ?>)</td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">المتوفى</td><td style="padding:6px 0;"><?= $case['deceased_type'] === 'primary_member' ? 'العضو الرئيسي' : 'الزوج/ة' ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">المتوفى</td><td style="padding:6px 0;"><?= $case['deceased_type'] === 'primary_member' ? 'العضو الرئيسي' : 'الزوج/ة' ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">تاريخ الوفاة</td><td style="padding:6px 0;"><?= e($case['death_date']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">تاريخ الوفاة</td><td style="padding:6px 0;"><?= e($case['death_date']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">شهادة الوفاة</td><td style="padding:6px 0;"><?= e($case['death_certificate_number'] ?? '—') ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">شهادة الوفاة</td><td style="padding:6px 0;"><?= e($case['death_certificate_number'] ?? '—') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">نفس رقم العضوية</td><td style="padding:6px 0;"><?= $case['same_membership_number'] ? 'نعم' : 'لا' ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الرسوم (استمارة + اشتراك)</td><td style="padding:6px 0;font-weight:700;font-size:20px;color:#DC2626;"><?= money($case['fee_amount'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الرسوم</td><td style="padding:6px 0;font-weight:700;color:#0D7377;"><?= money($case['fee_amount'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= $case['status'] === 'completed' ? '#059669' : '#D97706' ?>;"><?= $case['status'] === 'completed' ? 'مكتمل' : 'مسجّل' ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= $case['status'] === 'completed' ? '#059669' : '#D97706' ?>;"><?= $case['status'] === 'completed' ? 'مكتمل' : 'مسجّل' ?></td></tr>
<?php if ($case['transferred_to_member_id']): ?><tr><td style="padding:6px 0;color:#6B7280;">نُقلت إلى</td><td style="padding:6px 0;"><a href="/members/<?= (int) $case['transferred_to_member_id'] ?>" style="color:#0D7377;font-weight:600;">عضو #<?= (int) $case['transferred_to_member_id'] ?></a></td></tr><?php endif; ?> <?php if ($case['transferred_to_member_id']): ?><tr><td style="padding:6px 0;color:#6B7280;">نُقلت إلى</td><td style="padding:6px 0;"><a href="/members/<?= (int) $case['transferred_to_member_id'] ?>" style="color:#0D7377;font-weight:600;">عضو #<?= (int) $case['transferred_to_member_id'] ?></a></td></tr><?php endif; ?>
</table> </table>
<?php if ($case['status'] !== 'completed'): ?> </div>
<form method="POST" action="/death/<?= (int) $case['id'] ?>/complete" style="margin-top:20px;">
<?php if ($case['status'] !== 'completed' && bccomp($case['fee_amount'] ?? '0', '0', 2) > 0): ?>
<div class="card" style="padding:20px;margin-bottom:20px;background:#FFF7ED;border:2px solid #F59E0B;">
<h4 style="margin:0 0 15px;color:#D97706;">💰 دفع رسوم نقل العضوية (استمارة + اشتراك سنوي)</h4>
<form method="POST" action="/death/<?= (int) $case['id'] ?>/pay">
<?= csrf_field() ?> <?= csrf_field() ?>
<button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام حالة الوفاة. متأكد؟')">إتمام الإجراء</button> <input type="hidden" name="amount" value="<?= e($case['fee_amount']) ?>">
<div style="display:flex;gap:10px;align-items:end;">
<div class="form-group"><label class="form-label">المبلغ</label><input type="text" value="<?= money($case['fee_amount']) ?>" class="form-input" style="background:#F3F4F6;font-weight:700;font-size:18px;" readonly></div>
<div class="form-group"><label class="form-label">طريقة الدفع</label><select name="payment_method" class="form-select"><option value="cash">نقدي</option><option value="visa">فيزا</option></select></div>
<button type="submit" class="btn btn-primary" style="padding:10px 25px;" onclick="return confirm('تأكيد الدفع؟')">💰 ادفع</button>
</div>
</form> </form>
<?php endif; ?>
</div> </div>
<?php endif; ?>
<?php if ($case['status'] !== 'completed'): ?>
<form method="POST" action="/death/<?= (int) $case['id'] ?>/complete">
<?= csrf_field() ?>
<button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام حالة الوفاة. متأكد؟')">✅ إتمام الإجراء</button>
</form>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>حالة طلاق #<?= (int) $case['id'] ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>حالة طلاق #<?= (int) $case['id'] ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div class="card" style="padding:20px;"> <div class="card" style="padding:20px;margin-bottom:20px;">
<table style="width:100%;max-width:600px;font-size:14px;"> <table style="width:100%;max-width:600px;font-size:14px;">
<tr><td style="padding:6px 0;color:#6B7280;width:35%;">العضو</td><td style="padding:6px 0;"><a href="/members/<?= (int) $case['member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($case['member_name']) ?></a></td></tr> <tr><td style="padding:6px 0;color:#6B7280;width:35%;">العضو</td><td style="padding:6px 0;"><a href="/members/<?= (int) $case['member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($case['member_name']) ?></a></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الزوج/ة</td><td style="padding:6px 0;"><?= e($case['spouse_name']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الزوج/ة</td><td style="padding:6px 0;"><?= e($case['spouse_name']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">تاريخ الطلاق</td><td style="padding:6px 0;"><?= e($case['divorce_date']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">تاريخ الطلاق</td><td style="padding:6px 0;"><?= e($case['divorce_date']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">نوع الحالة</td><td style="padding:6px 0;font-weight:600;"><?= e(\App\Modules\Divorce\Models\DivorceCase::getCaseTypeLabel($case['divorce_case_type'])) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">النوع</td><td style="padding:6px 0;font-weight:600;"><?= e(\App\Modules\Divorce\Models\DivorceCase::getCaseTypeLabel($case['divorce_case_type'])) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">النسبة</td><td style="padding:6px 0;"><?= e($case['fee_percentage'] ?? '0') ?>%</td></tr> <tr><td style="padding:6px 0;color:#6B7280;">النسبة</td><td style="padding:6px 0;"><?= e($case['fee_percentage'] ?? '0') ?>%</td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الرسوم</td><td style="padding:6px 0;font-weight:700;color:#0D7377;"><?= money($case['fee_amount'] ?? '0') ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الرسوم</td><td style="padding:6px 0;font-weight:700;font-size:20px;color:#DC2626;"><?= money($case['fee_amount'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= $case['status'] === 'completed' ? '#059669' : '#D97706' ?>;"><?= $case['status'] === 'completed' ? 'مكتمل' : 'مقدّم' ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= $case['status'] === 'completed' ? '#059669' : '#D97706' ?>;"><?= $case['status'] === 'completed' ? 'مكتمل' : 'مقدّم' ?></td></tr>
<?php if ($case['spouse_new_membership_number']): ?><tr><td style="padding:6px 0;color:#6B7280;">رقم العضوية الجديد</td><td style="padding:6px 0;font-weight:700;color:#0D7377;font-size:18px;"><?= e($case['spouse_new_membership_number']) ?></td></tr><?php endif; ?> <?php if ($case['spouse_new_membership_number']): ?><tr><td style="padding:6px 0;color:#6B7280;">رقم العضوية الجديد</td><td style="padding:6px 0;font-weight:700;color:#0D7377;font-size:20px;"><?= e($case['spouse_new_membership_number']) ?></td></tr><?php endif; ?>
</table> </table>
<?php if ($case['status'] !== 'completed'): ?> </div>
<form method="POST" action="/divorce/<?= (int) $case['id'] ?>/complete" style="margin-top:20px;">
<?php if ($case['status'] !== 'completed' && bccomp($case['fee_amount'] ?? '0', '0', 2) > 0): ?>
<div class="card" style="padding:20px;margin-bottom:20px;background:#FFF7ED;border:2px solid #F59E0B;">
<h4 style="margin:0 0 15px;color:#D97706;">💰 دفع رسوم الطلاق</h4>
<form method="POST" action="/divorce/<?= (int) $case['id'] ?>/pay">
<?= csrf_field() ?> <?= csrf_field() ?>
<button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام حالة الطلاق — سيتم إنشاء عضوية جديدة. متأكد؟')">إتمام حالة الطلاق</button> <input type="hidden" name="amount" value="<?= e($case['fee_amount']) ?>">
<div style="display:flex;gap:10px;align-items:end;">
<div class="form-group"><label class="form-label">المبلغ</label><input type="text" value="<?= money($case['fee_amount']) ?>" class="form-input" style="background:#F3F4F6;font-weight:700;font-size:18px;" readonly></div>
<div class="form-group"><label class="form-label">طريقة الدفع</label><select name="payment_method" class="form-select"><option value="cash">نقدي</option><option value="visa">فيزا</option><option value="bank_transfer">تحويل</option></select></div>
<button type="submit" class="btn btn-primary" style="padding:10px 25px;" onclick="return confirm('تأكيد الدفع؟')">💰 ادفع</button>
</div>
</form> </form>
<?php endif; ?>
</div> </div>
<?php endif; ?>
<?php if ($case['status'] !== 'completed'): ?>
<form method="POST" action="/divorce/<?= (int) $case['id'] ?>/complete">
<?= csrf_field() ?>
<button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام حالة الطلاق — سيتم إنشاء عضوية جديدة. متأكد؟')">✅ إتمام حالة الطلاق</button>
</form>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تقديم تظلم<?php $__template->endSection(); ?> <?php $__template->section('title'); ?>تظلم من غرامة #<?= (int) ($fine['id'] ?? 0) ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div class="card" style="padding:20px;"> <div class="card" style="padding:20px;margin-bottom:20px;">
<p>صفحة التظلم — يتم التعامل معها عبر النماذج المضمنة في القائمة</p> <h3 style="color:#0D7377;margin:0 0 15px;">تقديم تظلم</h3>
<a href="/fines" class="btn btn-outline">← العودة للغرامات</a> <div style="margin-bottom:15px;padding:15px;background:#FEF2F2;border:1px solid #FECACA;border-radius:8px;">
<strong>نوع العقوبة:</strong> <?= e(\App\Modules\Fines\Models\Fine::getPenaltyTypeLabel($fine['penalty_type'] ?? '')) ?>
&nbsp;&nbsp; <strong>المبلغ:</strong> <?= money($fine['amount'] ?? '0') ?>
<br><small style="color:#DC2626;">مهلة التظلم: 15 يوم من تاريخ فرض العقوبة</small>
</div>
<form method="POST" action="/fines/<?= (int) $fine['id'] ?>/appeal">
<?= csrf_field() ?>
<div class="form-group" style="margin-bottom:15px;">
<label class="form-label">أسباب التظلم <span style="color:#DC2626;">*</span></label>
<textarea name="appeal_notes" class="form-textarea" rows="5" required placeholder="اكتب أسباب التظلم بالتفصيل..."></textarea>
</div>
<button type="submit" class="btn btn-primary">تقديم التظلم</button>
<a href="/fines" class="btn btn-outline">إلغاء</a>
</form>
</div> </div>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
...@@ -4,29 +4,34 @@ ...@@ -4,29 +4,34 @@
<div class="card" style="margin-bottom:20px;padding:15px;"> <div class="card" style="margin-bottom:20px;padding:15px;">
<form method="GET" action="/fines" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;"> <form method="GET" action="/fines" style="display:flex;gap:10px;flex-wrap:wrap;align-items:end;">
<div><label class="form-label" style="font-size:12px;">بحث</label><input type="text" name="q" value="<?= e($filters['search'] ?? '') ?>" class="form-input" style="min-width:200px;"></div> <div><label class="form-label" style="font-size:12px;">بحث</label><input type="text" name="q" value="<?= e($filters['search'] ?? '') ?>" class="form-input" style="min-width:200px;"></div>
<div><label class="form-label" style="font-size:12px;">الحالة</label><select name="status" class="form-select"><option value="">الكل</option><option value="imposed" <?= ($filters['status'] ?? '') === 'imposed' ? 'selected' : '' ?>>مفروضة</option><option value="paid" <?= ($filters['status'] ?? '') === 'paid' ? 'selected' : '' ?>>مدفوعة</option><option value="appealed" <?= ($filters['status'] ?? '') === 'appealed' ? 'selected' : '' ?>>متظلم</option><option value="cancelled" <?= ($filters['status'] ?? '') === 'cancelled' ? 'selected' : '' ?>>ملغاة</option><option value="waived" <?= ($filters['status'] ?? '') === 'waived' ? 'selected' : '' ?>>معفاة</option></select></div> <div><label class="form-label" style="font-size:12px;">الحالة</label><select name="status" class="form-select"><option value="">الكل</option><option value="imposed" <?= ($filters['status'] ?? '') === 'imposed' ? 'selected' : '' ?>>مفروضة</option><option value="paid" <?= ($filters['status'] ?? '') === 'paid' ? 'selected' : '' ?>>مدفوعة</option><option value="appealed" <?= ($filters['status'] ?? '') === 'appealed' ? 'selected' : '' ?>>متظلم</option></select></div>
<div><label class="form-label" style="font-size:12px;">نوع العقوبة</label><select name="penalty_type" class="form-select"><option value="">الكل</option><option value="warning">لفت نظر</option><option value="caution">إنذار</option><option value="fine">غرامة</option><option value="suspension">إيقاف</option><option value="ban">منع دخول</option><option value="termination">إنهاء</option></select></div>
<button type="submit" class="btn btn-outline">بحث</button> <button type="submit" class="btn btn-outline">بحث</button>
</form> </form>
</div> </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> <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></tr></thead><tbody>
<?php foreach ($rows as $r): ?> <?php foreach ($rows as $r): ?>
<tr> <tr>
<td><a href="/members/<?= (int) $r['member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($r['member_name'] ?? '') ?></a></td> <td><a href="/members/<?= (int) $r['member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($r['member_name'] ?? '') ?></a></td>
<td style="font-weight:600;color:<?= in_array($r['penalty_type'], ['suspension','ban','termination']) ? '#DC2626' : '#D97706' ?>;"><?= e(\App\Modules\Fines\Models\Fine::getPenaltyTypeLabel($r['penalty_type'])) ?></td> <td style="font-weight:600;color:<?= in_array($r['penalty_type'], ['suspension','ban','termination']) ? '#DC2626' : '#D97706' ?>;"><?= e(\App\Modules\Fines\Models\Fine::getPenaltyTypeLabel($r['penalty_type'])) ?></td>
<td><?= bccomp($r['amount'] ?? '0', '0', 2) > 0 ? money($r['amount']) : '—' ?></td> <td style="font-weight:700;"><?= bccomp($r['amount'] ?? '0', '0', 2) > 0 ? money($r['amount']) : '—' ?></td>
<td style="color:#059669;"><?= bccomp($r['paid_amount'] ?? '0', '0', 2) > 0 ? money($r['paid_amount']) : '—' ?></td>
<td style="font-size:12px;"><?= ($r['suspension_from'] && $r['suspension_to']) ? e($r['suspension_from']) . ' → ' . e($r['suspension_to']) : '—' ?></td> <td style="font-size:12px;"><?= ($r['suspension_from'] && $r['suspension_to']) ? e($r['suspension_from']) . ' → ' . e($r['suspension_to']) : '—' ?></td>
<td><span style="color:<?= match($r['status']) { 'imposed' => '#DC2626', 'paid' => '#059669', 'appealed' => '#D97706', 'cancelled' => '#6B7280', 'waived' => '#0284C7', default => '#6B7280' } ?>;font-weight:600;"><?= match($r['status']) { 'imposed' => 'مفروضة', 'paid' => 'مدفوعة', 'appealed' => 'متظلم', 'appeal_upheld' => 'تأييد', 'appeal_modified' => 'تعديل', 'cancelled' => 'ملغاة', 'waived' => 'معفاة', default => $r['status'] } ?></span></td> <td><span style="color:<?= match($r['status']) { 'imposed' => '#DC2626', 'paid' => '#059669', 'appealed' => '#D97706', 'cancelled' => '#6B7280', 'waived' => '#0284C7', default => '#6B7280' } ?>;font-weight:600;"><?= match($r['status']) { 'imposed' => 'مفروضة', 'paid' => 'مدفوعة', 'appealed' => 'متظلم', 'appeal_upheld' => 'تأييد', 'cancelled' => 'ملغاة', 'waived' => 'معفاة', default => $r['status'] } ?></span></td>
<td> <td>
<div style="display:flex;gap:5px;flex-wrap:wrap;"> <div style="display:flex;gap:5px;flex-wrap:wrap;">
<?php if ($r['status'] === 'imposed' && $r['penalty_type'] === 'fine'): ?> <?php if (in_array($r['status'], ['imposed', 'appeal_upheld']) && $r['penalty_type'] === 'fine' && bccomp($r['amount'], $r['paid_amount'] ?? '0', 2) > 0): ?>
<form method="POST" action="/fines/<?= (int) $r['id'] ?>/pay" style="display:inline;"><?= csrf_field() ?><input type="hidden" name="payment_method" value="cash"><button type="submit" class="btn btn-sm btn-primary">دفع</button></form> <form method="POST" action="/fines/<?= (int) $r['id'] ?>/pay" style="display:flex;gap:5px;">
<?= csrf_field() ?>
<input type="hidden" name="payment_method" value="cash">
<button type="submit" class="btn btn-sm btn-primary" onclick="return confirm('دفع غرامة <?= money(bcsub($r['amount'], $r['paid_amount'] ?? '0', 2)) ?>؟')">💰 ادفع <?= money(bcsub($r['amount'], $r['paid_amount'] ?? '0', 2)) ?></button>
</form>
<?php endif; ?> <?php endif; ?>
<?php if (in_array($r['status'], ['imposed']) && !$r['appeal_submitted']): ?> <?php if ($r['status'] === 'imposed' && !$r['appeal_submitted']): ?>
<form method="POST" action="/fines/<?= (int) $r['id'] ?>/appeal" style="display:inline;"><?= csrf_field() ?><input type="hidden" name="appeal_notes" value="تظلم"><button type="submit" class="btn btn-sm btn-outline">تظلم</button></form> <a href="/fines/<?= (int) $r['id'] ?>/appeal" class="btn btn-sm btn-outline">تظلم</a>
<?php endif; ?> <?php endif; ?>
<?php if ($r['status'] === 'appealed'): ?> <?php if ($r['status'] === 'appealed'): ?>
<form method="POST" action="/fines/<?= (int) $r['id'] ?>/appeal-decide" style="display:flex;gap:3px;"><?= csrf_field() ?> <form method="POST" action="/fines/<?= (int) $r['id'] ?>/appeal-decide" style="display:flex;gap:3px;">
<?= csrf_field() ?>
<button type="submit" name="appeal_decision" value="upheld" class="btn btn-sm" style="background:#DC2626;color:#fff;border:none;padding:3px 8px;border-radius:4px;cursor:pointer;font-size:11px;">تأييد</button> <button type="submit" name="appeal_decision" value="upheld" class="btn btn-sm" style="background:#DC2626;color:#fff;border:none;padding:3px 8px;border-radius:4px;cursor:pointer;font-size:11px;">تأييد</button>
<button type="submit" name="appeal_decision" value="cancelled" class="btn btn-sm" style="background:#059669;color:#fff;border:none;padding:3px 8px;border-radius:4px;cursor:pointer;font-size:11px;">إلغاء</button> <button type="submit" name="appeal_decision" value="cancelled" class="btn btn-sm" style="background:#059669;color:#fff;border:none;padding:3px 8px;border-radius:4px;cursor:pointer;font-size:11px;">إلغاء</button>
</form> </form>
...@@ -35,6 +40,6 @@ ...@@ -35,6 +40,6 @@
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php if (empty($rows)): ?><tr><td colspan="6" style="text-align:center;padding:40px;color:#6B7280;">لا توجد غرامات</td></tr><?php endif; ?> <?php if (empty($rows)): ?><tr><td colspan="7" style="text-align:center;padding:40px;color:#6B7280;">لا توجد غرامات</td></tr><?php endif; ?>
</tbody></table></div></div> </tbody></table></div></div>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
...@@ -8,288 +8,129 @@ use App\Core\Request; ...@@ -8,288 +8,129 @@ use App\Core\Request;
use App\Core\Response; use App\Core\Response;
use App\Core\App; use App\Core\App;
use App\Core\EventBus; use App\Core\EventBus;
use App\Modules\Installments\Models\InstallmentPlan;
use App\Modules\Installments\Models\InstallmentScheduleItem;
use App\Modules\Installments\Services\InstallmentCalculator;
use App\Modules\Payments\Services\PaymentService; use App\Modules\Payments\Services\PaymentService;
class InstallmentController extends Controller class InstallmentController extends Controller
{ {
public function index(Request $request): Response public function index(Request $request): Response
{ {
$db = App::getInstance()->db();
$filters = [ $filters = [
'search' => trim((string) $request->get('q', '')), 'search' => trim((string) $request->get('q', '')),
'status' => $request->get('status', ''), 'status' => $request->get('status', ''),
'overdue_only'=> $request->get('overdue_only', ''), 'overdue_only' => $request->get('overdue_only', ''),
]; ];
$page = max(1, (int) $request->get('page', 1)); $page = max(1, (int) $request->get('page', 1));
$result = InstallmentPlan::search($filters, 25, $page); $perPage = 25;
$where = '1=1';
$params = [];
if (!empty($filters['status'])) { $where .= ' AND ip.status = ?'; $params[] = $filters['status']; }
if (!empty($filters['search'])) {
$where .= ' AND (m.full_name_ar LIKE ? OR m.membership_number LIKE ?)';
$s = '%' . $filters['search'] . '%'; $params[] = $s; $params[] = $s;
}
$countRow = $db->selectOne("SELECT COUNT(*) as cnt FROM installment_plans ip JOIN members m ON m.id = ip.member_id WHERE {$where}", $params);
$total = (int) ($countRow['cnt'] ?? 0);
$offset = ($page - 1) * $perPage;
$rows = $db->select(
"SELECT ip.*, m.full_name_ar as member_name, m.membership_number,
(SELECT COALESCE(SUM(paid_amount), 0) FROM installment_schedule WHERE installment_plan_id = ip.id AND status = 'paid') as total_paid_installments,
(SELECT COUNT(*) FROM installment_schedule WHERE installment_plan_id = ip.id AND status = 'pending' AND due_date < CURDATE()) as overdue_count
FROM installment_plans ip
JOIN members m ON m.id = ip.member_id
WHERE {$where}
" . ($filters['overdue_only'] ? "HAVING overdue_count > 0" : "") . "
ORDER BY ip.created_at DESC LIMIT {$perPage} OFFSET {$offset}",
$params
);
$pagination = \App\Core\Pagination::paginate($total, $perPage, $page);
return $this->view('Installments.Views.index', [ return $this->view('Installments.Views.index', [
'rows' => $result['data'], 'rows' => $rows,
'pagination' => $result['pagination'], 'pagination' => $pagination,
'filters' => $filters, 'filters' => $filters,
]); ]);
} }
public function create(Request $request, string $memberId): Response
{
$db = App::getInstance()->db();
$member = $db->selectOne("SELECT * FROM members WHERE id = ? AND is_archived = 0", [(int) $memberId]);
if (!$member) return $this->redirect('/members')->withError('العضو غير موجود');
$existingActive = InstallmentPlan::getActiveForMember((int) $memberId);
return $this->view('Installments.Views.create', [
'member' => $member,
'existingActive' => $existingActive,
]);
}
public function store(Request $request, string $memberId): Response
{
$db = App::getInstance()->db();
$member = $db->selectOne("SELECT * FROM members WHERE id = ? AND is_archived = 0", [(int) $memberId]);
if (!$member) return $this->redirect('/members')->withError('العضو غير موجود');
$totalAmount = trim($request->post('total_amount', '0'));
$downPayment = trim($request->post('down_payment', '0'));
$months = (int) $request->post('number_of_months', 0);
$startDate = $request->post('start_date', date('Y-m-d'));
$downPaymentReceipt = trim($request->post('down_payment_receipt', ''));
$notes = trim($request->post('notes', ''));
if (!is_numeric($totalAmount) || !is_numeric($downPayment)) {
return $this->redirect("/installments/create/{$memberId}")->withError('المبالغ غير صالحة');
}
$calc = InstallmentCalculator::calculate($totalAmount, $downPayment, $months, $startDate);
if (!$calc['success']) {
$session = App::getInstance()->session();
$session->flash('_alerts', array_map(fn($e) => ['type' => 'error', 'message' => $e], $calc['errors']));
return $this->redirect("/installments/create/{$memberId}");
}
$employee = App::getInstance()->currentEmployee();
$db->beginTransaction();
try {
$planId = $db->insert('installment_plans', [
'member_id' => (int) $memberId,
'related_entity_type' => $request->post('related_entity_type') ?: null,
'related_entity_id' => $request->post('related_entity_id') ? (int) $request->post('related_entity_id') : null,
'total_amount' => $calc['total_amount'],
'down_payment' => $calc['down_payment'],
'remaining_balance' => $calc['remaining_balance'],
'interest_rate' => $calc['interest_rate'],
'total_interest' => $calc['total_interest'],
'total_with_interest' => $calc['total_with_interest'],
'number_of_months' => $calc['number_of_months'],
'monthly_payment' => $calc['monthly_payment'],
'start_date' => $calc['start_date'],
'down_payment_receipt' => $downPaymentReceipt ?: null,
'cash_settlement_date' => $calc['cash_settlement_date'],
'is_cash_settled' => 0,
'status' => 'active',
'notes' => $notes ?: null,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
'created_by' => $employee ? (int) $employee->id : null,
]);
foreach ($calc['schedule'] as $item) {
$db->insert('installment_schedule', [
'installment_plan_id' => $planId,
'installment_number' => $item['number'],
'due_date' => $item['due_date'],
'amount' => $item['amount'],
'principal' => $item['principal'],
'interest' => $item['interest'],
'remaining_after' => $item['remaining_after'],
'paid_amount' => '0.00',
'status' => 'pending',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
}
$db->commit();
EventBus::dispatch('installment.created', [
'plan_id' => $planId,
'member_id' => (int) $memberId,
'total' => $calc['total_with_interest'],
'months' => $months,
]);
return $this->redirect("/installments/{$planId}")->withSuccess('تم إنشاء خطة التقسيط — ' . $months . ' شهر');
} catch (\Throwable $e) {
$db->rollBack();
return $this->redirect("/installments/create/{$memberId}")->withError('فشل في إنشاء الخطة: ' . $e->getMessage());
}
}
public function show(Request $request, string $id): Response public function show(Request $request, string $id): Response
{ {
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$plan = $db->selectOne( $plan = $db->selectOne(
"SELECT p.*, m.full_name_ar as member_name, m.membership_number "SELECT ip.*, m.full_name_ar as member_name, m.membership_number
FROM installment_plans p JOIN members m ON m.id = p.member_id FROM installment_plans ip JOIN members m ON m.id = ip.member_id WHERE ip.id = ?",
WHERE p.id = ?",
[(int) $id] [(int) $id]
); );
if (!$plan) return $this->redirect('/installments')->withError('خطة التقسيط غير موجودة'); if (!$plan) return $this->redirect('/installments')->withError('الخطة غير موجودة');
$schedule = InstallmentScheduleItem::getForPlan((int) $id);
$earlyPayoff = null;
if ($plan['status'] === 'active') {
$earlyPayoff = InstallmentCalculator::calculateEarlyPayoff((int) $id);
}
$paymentMethods = $db->select("SELECT * FROM payment_methods WHERE is_active = 1 ORDER BY sort_order"); $schedule = $db->select(
"SELECT * FROM installment_schedule WHERE installment_plan_id = ? ORDER BY installment_number ASC",
[(int) $id]
);
return $this->view('Installments.Views.show', [ return $this->view('Installments.Views.show', [
'plan' => $plan, 'plan' => $plan,
'schedule' => $schedule, 'schedule' => $schedule,
'earlyPayoff' => $earlyPayoff,
'paymentMethods' => $paymentMethods,
]); ]);
} }
public function recordPayment(Request $request, string $id): Response public function create(Request $request, string $memberId): Response
{ {
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$plan = $db->selectOne("SELECT * FROM installment_plans WHERE id = ? AND status = 'active'", [(int) $id]); $member = $db->selectOne("SELECT * FROM members WHERE id = ? AND is_archived = 0", [(int) $memberId]);
if (!$plan) return $this->redirect('/installments')->withError('خطة التقسيط غير موجودة أو غير نشطة'); if (!$member) return $this->redirect('/members')->withError('العضو غير موجود');
$nextItem = InstallmentScheduleItem::getNextPending((int) $id);
if (!$nextItem) return $this->redirect("/installments/{$id}")->withError('لا توجد أقساط متبقية');
$data = $request->all();
$data['member_id'] = (int) $plan['member_id'];
$data['amount'] = $nextItem['amount'];
$data['payment_type'] = 'installment';
$data['payment_method'] = $data['payment_method'] ?? 'cash';
$data['related_entity_type'] = 'installment_schedule';
$data['related_entity_id'] = (int) $nextItem['id'];
$data['description'] = 'قسط رقم ' . $nextItem['installment_number'] . ' — خطة #' . $id;
$result = PaymentService::processPayment($data);
if (!$result['success']) {
return $this->redirect("/installments/{$id}")->withError($result['error']);
}
// Mark schedule item as paid
$db->update('installment_schedule', [
'paid_amount' => $nextItem['amount'],
'payment_id' => $result['payment_id'],
'status' => 'paid',
'paid_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
], '`id` = ?', [(int) $nextItem['id']]);
// Check if plan is fully paid $existingActive = $db->selectOne("SELECT * FROM installment_plans WHERE member_id = ? AND status = 'active'", [(int) $memberId]);
$remaining = InstallmentScheduleItem::getNextPending((int) $id);
if (!$remaining) {
$db->update('installment_plans', [
'status' => 'completed',
'updated_at' => date('Y-m-d H:i:s'),
], '`id` = ?', [(int) $id]);
EventBus::dispatch('installment.completed', ['plan_id' => (int) $id, 'member_id' => (int) $plan['member_id']]); return $this->view('Installments.Views.create', [
} 'member' => $member,
'existingActive' => $existingActive,
EventBus::dispatch('installment.paid', [
'plan_id' => (int) $id,
'member_id' => (int) $plan['member_id'],
'item_number' => (int) $nextItem['installment_number'],
'amount' => $nextItem['amount'],
'receipt_number'=> $result['receipt_number'],
]); ]);
return $this->redirect("/installments/{$id}")->withSuccess('تم تسجيل القسط رقم ' . $nextItem['installment_number'] . ' — إيصال: ' . $result['receipt_number']);
} }
public function earlyPayoff(Request $request, string $id): Response public function payInstallment(Request $request, string $planId, string $scheduleId): Response
{ {
$db = App::getInstance()->db(); $db = App::getInstance()->db();
$plan = $db->selectOne("SELECT * FROM installment_plans WHERE id = ? AND status = 'active'", [(int) $id]); $plan = $db->selectOne("SELECT * FROM installment_plans WHERE id = ?", [(int) $planId]);
if (!$plan) return $this->redirect('/installments')->withError('خطة التقسيط غير موجودة أو غير نشطة'); if (!$plan) return $this->redirect('/installments')->withError('الخطة غير موجودة');
$payoff = InstallmentCalculator::calculateEarlyPayoff((int) $id);
// Check if within cash settlement window $item = $db->selectOne("SELECT * FROM installment_schedule WHERE id = ? AND installment_plan_id = ?", [(int) $scheduleId, (int) $planId]);
$isCashSettlement = false; if (!$item || $item['status'] === 'paid') return $this->redirect("/installments/{$planId}")->withError('القسط غير موجود أو مدفوع');
if ($plan['cash_settlement_date'] && date('Y-m-d') <= $plan['cash_settlement_date']) {
$isCashSettlement = true;
}
$payoffAmount = $isCashSettlement ? $payoff['remaining_principal'] : $payoff['total_early_payoff']; $amount = $item['amount'];
$paymentMethod = trim((string) $request->post('payment_method', 'cash'));
$data = $request->all(); $result = PaymentService::processPayment([
$data['member_id'] = (int) $plan['member_id']; 'member_id' => (int) $plan['member_id'],
$data['amount'] = $payoffAmount; 'amount' => $amount,
$data['payment_type'] = 'installment'; 'payment_type' => 'installment',
$data['payment_method'] = $data['payment_method'] ?? 'cash'; 'payment_method' => $paymentMethod,
$data['description'] = 'سداد مبكر — خطة #' . $id . ($isCashSettlement ? ' (بدون فائدة — تسوية نقدية)' : ''); 'related_entity_type' => 'installment_schedule',
'related_entity_id' => (int) $scheduleId,
'description' => 'قسط رقم ' . $item['installment_number'] . ' — خطة #' . $planId,
]);
$result = PaymentService::processPayment($data); if (!$result['success']) return $this->redirect("/installments/{$planId}")->withError($result['error']);
if (!$result['success']) {
return $this->redirect("/installments/{$id}")->withError($result['error']);
}
// Mark all remaining items as paid
$db->update('installment_schedule', [ $db->update('installment_schedule', [
'paid_amount' => $amount,
'payment_id' => $result['payment_id'],
'status' => 'paid', 'status' => 'paid',
'paid_at' => date('Y-m-d H:i:s'), 'paid_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'),
], '`installment_plan_id` = ? AND `status` IN (\'pending\',\'overdue\')', [(int) $id]); ], '`id` = ?', [(int) $scheduleId]);
$db->update('installment_plans', [
'status' => 'completed',
'is_cash_settled' => $isCashSettlement ? 1 : 0,
'updated_at' => date('Y-m-d H:i:s'),
], '`id` = ?', [(int) $id]);
EventBus::dispatch('installment.early_payoff', [
'plan_id' => (int) $id,
'member_id' => (int) $plan['member_id'],
'amount' => $payoffAmount,
'is_cash_settled' => $isCashSettlement,
'interest_saved' => $payoff['interest_saved'],
]);
$msg = $isCashSettlement
? 'تم التسوية النقدية بدون فائدة — إيصال: ' . $result['receipt_number']
: 'تم السداد المبكر — وفر ' . money($payoff['interest_saved']) . ' فائدة — إيصال: ' . $result['receipt_number'];
return $this->redirect("/installments/{$id}")->withSuccess($msg); // Check if all paid → complete plan
$remaining = $db->selectOne("SELECT COUNT(*) as cnt FROM installment_schedule WHERE installment_plan_id = ? AND status = 'pending'", [(int) $planId]);
if ((int) ($remaining['cnt'] ?? 0) === 0) {
$db->update('installment_plans', ['status' => 'completed', 'updated_at' => date('Y-m-d H:i:s')], '`id` = ?', [(int) $planId]);
} }
public function memberPlans(Request $request, string $memberId): Response EventBus::dispatch('installment.paid', ['plan_id' => (int) $planId, 'schedule_id' => (int) $scheduleId, 'member_id' => (int) $plan['member_id']]);
{
$plans = InstallmentPlan::getForMember((int) $memberId);
$db = App::getInstance()->db();
$member = $db->selectOne("SELECT * FROM members WHERE id = ?", [(int) $memberId]);
return $this->view('Installments.Views.index', [
'rows' => array_map(fn($p) => array_merge($p, ['member_name' => $member['full_name_ar'] ?? '', 'membership_number' => $member['membership_number'] ?? '']), $plans),
'pagination' => ['last_page' => 1, 'current_page' => 1],
'filters' => ['search' => '', 'status' => '', 'overdue_only' => ''],
'member' => $member,
]);
}
public function calculate(Request $request): Response
{
$totalAmount = trim($request->post('total_amount', '0'));
$downPayment = trim($request->post('down_payment', '0'));
$months = (int) $request->post('number_of_months', 0);
$startDate = $request->post('start_date', date('Y-m-d'));
$calc = InstallmentCalculator::calculate($totalAmount, $downPayment, $months, $startDate); return $this->redirect("/installments/{$planId}")->withSuccess('تم دفع القسط — إيصال: ' . $result['receipt_number']);
return $this->json($calc);
} }
} }
\ No newline at end of file
...@@ -3,11 +3,7 @@ declare(strict_types=1); ...@@ -3,11 +3,7 @@ declare(strict_types=1);
return [ return [
['GET', '/installments', 'Installments\Controllers\InstallmentController@index', ['auth'], 'installment.view'], ['GET', '/installments', 'Installments\Controllers\InstallmentController@index', ['auth'], 'installment.view'],
['GET', '/installments/create/{memberId}', 'Installments\Controllers\InstallmentController@create', ['auth'], 'installment.create_plan'], ['GET', '/installments/create/{memberId}', 'Installments\Controllers\InstallmentController@create', ['auth'], 'installment.create'],
['POST', '/installments/store/{memberId}', 'Installments\Controllers\InstallmentController@store', ['auth'], 'installment.create_plan'],
['GET', '/installments/{id}', 'Installments\Controllers\InstallmentController@show', ['auth'], 'installment.view'], ['GET', '/installments/{id}', 'Installments\Controllers\InstallmentController@show', ['auth'], 'installment.view'],
['POST', '/installments/{id}/pay', 'Installments\Controllers\InstallmentController@recordPayment', ['auth'], 'installment.record_payment'], ['POST', '/installments/{planId}/pay/{scheduleId}', 'Installments\Controllers\InstallmentController@payInstallment', ['auth'], 'installment.pay'],
['POST', '/installments/{id}/early-payoff', 'Installments\Controllers\InstallmentController@earlyPayoff', ['auth'], 'installment.modify_plan'],
['POST', '/api/installments/calculate', 'Installments\Controllers\InstallmentController@calculate', ['auth'], 'installment.create_plan'],
['GET', '/members/{memberId}/installments', 'Installments\Controllers\InstallmentController@memberPlans', ['auth'], 'installment.view'],
]; ];
\ No newline at end of file
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>خطة تقسيط #<?= (int) $plan['id'] ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>خطة تقسيط #<?= (int) $plan['id'] ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?> <?php $__template->section('page_actions'); ?>
<a href="/members/<?= (int) $plan['member_id'] ?>" class="btn btn-outline">← العودة للعضو</a> <a href="/members/<?= (int) $plan['member_id'] ?>" class="btn btn-outline">← العضو</a>
<a href="/installments" class="btn btn-outline">← كل الأقساط</a>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-bottom:20px;">
<div class="card" style="padding:20px;"> <!-- Plan Summary -->
<h4 style="color:#0D7377;margin-bottom:15px;">بيانات الخطة</h4> <div style="display:grid;grid-template-columns:repeat(auto-fit, minmax(150px, 1fr));gap:15px;margin-bottom:20px;">
<table style="width:100%;font-size:14px;"> <div class="card" style="padding:15px;text-align:center;border-right:4px solid #0D7377;">
<tr><td style="padding:6px 0;color:#6B7280;width:40%;">العضو</td><td style="padding:6px 0;font-weight:600;"><a href="/members/<?= (int) $plan['member_id'] ?>" style="color:#0D7377;"><?= e($plan['member_name']) ?></a></td></tr> <div style="font-size:20px;font-weight:700;color:#0D7377;"><?= money($plan['total_amount']) ?></div>
<tr><td style="padding:6px 0;color:#6B7280;">المبلغ الكلي</td><td style="padding:6px 0;font-weight:700;"><?= money($plan['total_amount']) ?></td></tr> <div style="font-size:11px;color:#6B7280;">المبلغ الأصلي</div>
<tr><td style="padding:6px 0;color:#6B7280;">المقدم</td><td style="padding:6px 0;"><?= money($plan['down_payment']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">المتبقي</td><td style="padding:6px 0;"><?= money($plan['remaining_balance']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">نسبة الفائدة</td><td style="padding:6px 0;"><?= e($plan['interest_rate']) ?>%</td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">إجمالي الفائدة</td><td style="padding:6px 0;"><?= money($plan['total_interest']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الإجمالي مع الفائدة</td><td style="padding:6px 0;font-weight:700;color:#0D7377;"><?= money($plan['total_with_interest']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">عدد الأشهر</td><td style="padding:6px 0;"><?= (int) $plan['number_of_months'] ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">القسط الشهري</td><td style="padding:6px 0;font-weight:600;"><?= money($plan['monthly_payment']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:600;color:<?= $plan['status'] === 'active' ? '#059669' : '#0284C7' ?>;"><?= $plan['status'] === 'active' ? 'نشط' : ($plan['status'] === 'completed' ? 'مكتمل' : $plan['status']) ?></td></tr>
<?php if ($plan['is_cash_settled']): ?><tr><td style="padding:6px 0;color:#6B7280;">تسوية نقدية</td><td style="padding:6px 0;color:#059669;font-weight:600;">✓ بدون فائدة</td></tr><?php endif; ?>
</table>
</div> </div>
<div> <div class="card" style="padding:15px;text-align:center;border-right:4px solid #059669;">
<?php if ($earlyPayoff && $plan['status'] === 'active'): ?> <div style="font-size:20px;font-weight:700;color:#059669;"><?= money($plan['down_payment']) ?></div>
<div class="card" style="padding:20px;margin-bottom:20px;"> <div style="font-size:11px;color:#6B7280;">المقدم</div>
<h4 style="color:#D97706;margin-bottom:15px;">السداد المبكر</h4>
<table style="width:100%;font-size:14px;">
<tr><td style="padding:6px 0;color:#6B7280;">أصل المتبقي</td><td style="padding:6px 0;"><?= money($earlyPayoff['remaining_principal']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">فائدة الشهر الحالي</td><td style="padding:6px 0;"><?= money($earlyPayoff['current_interest']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">إجمالي السداد المبكر</td><td style="padding:6px 0;font-weight:700;color:#0D7377;"><?= money($earlyPayoff['total_early_payoff']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">توفير الفائدة</td><td style="padding:6px 0;color:#059669;font-weight:600;"><?= money($earlyPayoff['interest_saved']) ?></td></tr>
</table>
<?php if ($plan['cash_settlement_date'] && date('Y-m-d') <= $plan['cash_settlement_date']): ?>
<div style="margin-top:10px;padding:10px;background:#F0FDF4;border:1px solid #BBF7D0;border-radius:6px;font-size:13px;color:#059669;">
<strong>✓ ضمن فترة التسوية النقدية</strong> — السداد حتى <?= e($plan['cash_settlement_date']) ?> بدون فائدة = <?= money($earlyPayoff['remaining_principal']) ?>
</div> </div>
<?php endif; ?> <div class="card" style="padding:15px;text-align:center;border-right:4px solid #D97706;">
<form method="POST" action="/installments/<?= (int) $plan['id'] ?>/early-payoff" style="margin-top:15px;"> <div style="font-size:20px;font-weight:700;color:#D97706;"><?= money($plan['total_interest']) ?></div>
<?= csrf_field() ?> <div style="font-size:11px;color:#6B7280;">الفائدة (<?= e($plan['interest_rate']) ?>%)</div>
<select name="payment_method" class="form-select" style="margin-bottom:10px;">
<?php foreach ($paymentMethods as $pm): ?><option value="<?= e($pm['code']) ?>"><?= e($pm['name_ar']) ?></option><?php endforeach; ?>
</select>
<button type="submit" class="btn btn-primary" onclick="return confirm('هل تريد السداد المبكر؟')">سداد مبكر</button>
</form>
</div> </div>
<?php endif; ?> <div class="card" style="padding:15px;text-align:center;border-right:4px solid #0284C7;">
<div style="font-size:20px;font-weight:700;color:#0284C7;"><?= money($plan['monthly_payment']) ?></div>
<div style="font-size:11px;color:#6B7280;">القسط الشهري</div>
</div>
<div class="card" style="padding:15px;text-align:center;border-right:4px solid <?= $plan['status'] === 'active' ? '#059669' : '#6B7280' ?>;">
<div style="font-size:20px;font-weight:700;color:<?= $plan['status'] === 'active' ? '#059669' : '#6B7280' ?>;">
<?= $plan['status'] === 'active' ? '● نشط' : ($plan['status'] === 'completed' ? '✅ مكتمل' : $plan['status']) ?>
</div>
<div style="font-size:11px;color:#6B7280;">الحالة</div>
</div> </div>
</div> </div>
<!-- Schedule Table -->
<div class="card"> <div class="card">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;display:flex;justify-content:space-between;align-items:center;"> <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;color:#0D7377;">جدول الأقساط</h3> <h3 style="margin:0;color:#0D7377;">📅 جدول الأقساط (<?= (int) $plan['number_of_months'] ?> شهر)</h3>
</div> </div>
<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></tr></thead><tbody> <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></tr>
</thead>
<tbody>
<?php foreach ($schedule as $s): ?> <?php foreach ($schedule as $s): ?>
<tr style="<?= $s['status'] === 'pending' && $s['due_date'] < date('Y-m-d') ? 'background:#FEF2F2;' : '' ?>"> <?php
<td><?= (int) $s['installment_number'] ?></td> $isOverdue = ($s['status'] === 'pending' && $s['due_date'] < date('Y-m-d'));
<td style="font-size:13px;"><?= e($s['due_date']) ?></td> $isPaid = ($s['status'] === 'paid');
?>
<tr style="<?= $isOverdue ? 'background:#FEF2F2;' : '' ?><?= $isPaid ? 'background:#F0FDF4;' : '' ?>">
<td style="font-weight:600;"><?= (int) $s['installment_number'] ?></td>
<td style="white-space:nowrap;<?= $isOverdue ? 'color:#DC2626;font-weight:700;' : '' ?>"><?= e($s['due_date']) ?></td>
<td style="font-weight:600;"><?= money($s['amount']) ?></td> <td style="font-weight:600;"><?= money($s['amount']) ?></td>
<td style="font-size:13px;"><?= money($s['principal']) ?></td> <td style="font-size:13px;"><?= money($s['principal']) ?></td>
<td style="font-size:13px;color:#D97706;"><?= money($s['interest']) ?></td> <td style="font-size:13px;color:#D97706;"><?= money($s['interest']) ?></td>
<td style="font-size:13px;"><?= money($s['remaining_after']) ?></td> <td style="font-size:13px;"><?= money($s['remaining_after']) ?></td>
<td> <td>
<?php if ($s['status'] === 'paid'): ?><span style="color:#059669;font-weight:600;">✓ مدفوع</span> <?php if ($isPaid): ?>
<?php elseif ($s['due_date'] < date('Y-m-d')): ?><span style="color:#DC2626;font-weight:600;">● متأخر</span> <span style="color:#059669;font-weight:700;">✅ مدفوع</span>
<?php else: ?><span style="color:#6B7280;">○ معلق</span><?php endif; ?> <div style="font-size:11px;color:#9CA3AF;"><?= e(substr($s['paid_at'] ?? '', 0, 10)) ?></div>
<?php elseif ($isOverdue): ?>
<span style="color:#DC2626;font-weight:700;">⚠️ متأخر</span>
<?php else: ?>
<span style="color:#D97706;font-weight:600;">⏳ معلق</span>
<?php endif; ?>
</td> </td>
<td style="font-size:12px;"><?= e($s['receipt_number'] ?? '—') ?></td>
<td> <td>
<?php if ($s['status'] !== 'paid' && $plan['status'] === 'active'): ?> <?php if ($s['status'] === 'pending'): ?>
<form method="POST" action="/installments/<?= (int) $plan['id'] ?>/pay" style="display:inline;"> <form method="POST" action="/installments/<?= (int) $plan['id'] ?>/pay/<?= (int) $s['id'] ?>" style="display:flex;gap:5px;">
<?= csrf_field() ?> <?= csrf_field() ?>
<input type="hidden" name="payment_method" value="cash"> <input type="hidden" name="amount" value="<?= e($s['amount']) ?>">
<button type="submit" class="btn btn-sm btn-primary" onclick="return confirm('تسجيل دفع القسط #<?= (int) $s['installment_number'] ?>؟')">دفع</button> <select name="payment_method" class="form-select" style="width:auto;font-size:11px;padding:3px 6px;">
<option value="cash">نقدي</option>
<option value="visa">فيزا</option>
</select>
<button type="submit" class="btn btn-sm btn-primary" onclick="return confirm('دفع قسط <?= money($s['amount']) ?>؟')">💰 ادفع</button>
</form> </form>
<?php else: ?><?php endif; ?> <?php elseif ($isPaid): ?>
<span style="font-size:11px;color:#9CA3AF;"></span>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody></table></div> </tbody>
</table>
</div>
</div> </div>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلب تحويل #<?= (int) $transfer['id'] ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>طلب تحويل #<?= (int) $transfer['id'] ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/transfers" class="btn btn-outline">← العودة</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:20px;"> <div class="card" style="padding:20px;margin-bottom:20px;">
<div class="card" style="padding:20px;"> <table style="width:100%;max-width:700px;font-size:14px;">
<h4 style="color:#0D7377;margin-bottom:15px;">بيانات الطلب</h4> <tr><td style="padding:8px 0;color:#6B7280;width:35%;">العضو المصدر</td><td style="padding:8px 0;"><a href="/members/<?= (int) $transfer['source_member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($transfer['member_name'] ?? '') ?></a></td></tr>
<table style="width:100%;font-size:14px;"> <tr><td style="padding:8px 0;color:#6B7280;">النوع</td><td style="padding:8px 0;font-weight:600;"><?= e($transfer['transfer_type']) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;width:40%;">رقم الطلب</td><td style="padding:6px 0;font-weight:700;">#<?= (int) $transfer['id'] ?></td></tr> <tr><td style="padding:8px 0;color:#6B7280;">رسوم الفصل</td><td style="padding:8px 0;font-weight:700;font-size:20px;color:#0D7377;"><?= money($transfer['separation_fee'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">نوع التحويل</td><td style="padding:6px 0;font-weight:600;"><?= e(\App\Modules\Transfers\Models\TransferRequest::getTransferTypeLabel($transfer['transfer_type'])) ?></td></tr> <tr><td style="padding:8px 0;color:#6B7280;">رسوم الاستمارة</td><td style="padding:8px 0;"><?= money($transfer['form_fee'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">العضو المصدر</td><td style="padding:6px 0;"><a href="/members/<?= (int) $transfer['source_member_id'] ?>" style="color:#0D7377;"><?= e($transfer['source_name']) ?></a> (<?= e($transfer['source_number'] ?? '—') ?>)</td></tr> <tr><td style="padding:8px 0;color:#6B7280;">الإجمالي</td><td style="padding:8px 0;font-weight:700;font-size:22px;color:#DC2626;"><?= money($transfer['total_fee'] ?? '0') ?></td></tr>
<?php if ($transfer['child_name']): ?><tr><td style="padding:6px 0;color:#6B7280;">الابن/الابنة</td><td style="padding:6px 0;"><?= e($transfer['child_name']) ?></td></tr><?php endif; ?> <tr><td style="padding:8px 0;color:#6B7280;">الحالة</td><td style="padding:8px 0;font-weight:700;color:<?= match($transfer['status']) { 'completed' => '#059669', 'approved' => '#0284C7', default => '#D97706' } ?>;"><?= e($transfer['status']) ?></td></tr>
<?php if ($transfer['spouse_name']): ?><tr><td style="padding:6px 0;color:#6B7280;">الزوج/الزوجة</td><td style="padding:6px 0;"><?= e($transfer['spouse_name']) ?></td></tr><?php endif; ?> <?php if ($transfer['new_membership_number']): ?><tr><td style="padding:8px 0;color:#6B7280;">الرقم الجديد</td><td style="padding:8px 0;font-weight:700;color:#0D7377;font-size:20px;"><?= e($transfer['new_membership_number']) ?></td></tr><?php endif; ?>
<tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= match($transfer['status']) { 'completed' => '#059669', 'rejected' => '#DC2626', default => '#D97706' } ?>;"><?= match($transfer['status']) { 'requested' => 'مقدّم', 'approved' => 'مُعتمد', 'fee_paid' => 'تم السداد', 'completed' => 'مكتمل', 'rejected' => 'مرفوض', default => $transfer['status'] } ?></td></tr>
<?php if ($transfer['target_name']): ?><tr><td style="padding:6px 0;color:#6B7280;">العضو الجديد</td><td style="padding:6px 0;"><a href="/members/<?= (int) $transfer['target_member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($transfer['target_name']) ?></a></td></tr><?php endif; ?>
<?php if ($transfer['new_membership_number']): ?><tr><td style="padding:6px 0;color:#6B7280;">رقم العضوية الجديد</td><td style="padding:6px 0;font-weight:700;color:#0D7377;font-size:18px;"><?= e($transfer['new_membership_number']) ?></td></tr><?php endif; ?>
<?php if ($transfer['notes']): ?><tr><td style="padding:6px 0;color:#6B7280;">ملاحظات</td><td style="padding:6px 0;"><?= e($transfer['notes']) ?></td></tr><?php endif; ?>
</table>
</div>
<div class="card" style="padding:20px;">
<h4 style="color:#0D7377;margin-bottom:15px;">تفاصيل الرسوم</h4>
<table style="width:100%;font-size:14px;">
<tr><td style="padding:6px 0;color:#6B7280;">قيمة العضوية الجديدة</td><td style="padding:6px 0;"><?= money($transfer['new_membership_value'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">سنوات منذ الاكتساب</td><td style="padding:6px 0;"><?= (int) ($transfer['years_since_acquisition'] ?? 0) ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">نسبة رسوم الفصل</td><td style="padding:6px 0;"><?= e($transfer['fee_percentage'] ?? '0') ?>%</td></tr>
<tr><td style="padding:8px 0;color:#6B7280;border-top:1px solid #E5E7EB;">رسوم الفصل</td><td style="padding:8px 0;border-top:1px solid #E5E7EB;"><?= money($transfer['separation_fee'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">رسوم الاستمارة</td><td style="padding:6px 0;"><?= money($transfer['form_fee'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">الاشتراك السنوي</td><td style="padding:6px 0;"><?= money($transfer['annual_subscription_fee'] ?? '0') ?></td></tr>
<tr><td style="padding:10px 0;color:#1A1A2E;font-weight:700;font-size:16px;border-top:2px solid #0D7377;">الإجمالي</td><td style="padding:10px 0;font-weight:700;font-size:18px;color:#0D7377;border-top:2px solid #0D7377;"><?= money($transfer['total_fee'] ?? '0') ?></td></tr>
</table> </table>
</div>
<?php if ($transfer['status'] === 'requested'): ?> <?php if (in_array($transfer['status'], ['requested', 'approved']) && bccomp($transfer['total_fee'] ?? '0', '0', 2) > 0): ?>
<div style="margin-top:20px;display:flex;gap:10px;"> <div class="card" style="padding:20px;margin-bottom:20px;background:#FFF7ED;border:2px solid #F59E0B;">
<form method="POST" action="/transfers/<?= (int) $transfer['id'] ?>/approve" style="flex:1;"> <h4 style="margin:0 0 15px;color:#D97706;">💰 دفع رسوم التحويل/الفصل</h4>
<form method="POST" action="/transfers/<?= (int) $transfer['id'] ?>/pay">
<?= csrf_field() ?> <?= csrf_field() ?>
<textarea name="board_decision_notes" class="form-textarea" rows="2" placeholder="ملاحظات المجلس..." style="margin-bottom:10px;"></textarea> <input type="hidden" name="amount" value="<?= e($transfer['total_fee']) ?>">
<button type="submit" class="btn btn-primary" style="width:100%;" onclick="return confirm('هل تريد الموافقة على هذا الطلب؟')">✓ موافقة</button> <div style="display:flex;gap:10px;align-items:end;">
</form> <div class="form-group"><label class="form-label">المبلغ</label><input type="text" value="<?= money($transfer['total_fee']) ?>" class="form-input" style="background:#F3F4F6;font-weight:700;font-size:18px;" readonly></div>
<form method="POST" action="/transfers/<?= (int) $transfer['id'] ?>/reject" style="flex:1;"> <div class="form-group"><label class="form-label">طريقة الدفع</label><select name="payment_method" class="form-select"><option value="cash">نقدي</option><option value="visa">فيزا</option><option value="bank_transfer">تحويل</option></select></div>
<?= csrf_field() ?> <button type="submit" class="btn btn-primary" style="padding:10px 25px;" onclick="return confirm('تأكيد دفع <?= money($transfer['total_fee']) ?>؟')">💰 ادفع</button>
<textarea name="reject_reason" class="form-textarea" rows="2" placeholder="سبب الرفض..." style="margin-bottom:10px;"></textarea>
<button type="submit" class="btn" style="width:100%;background:#DC2626;color:#fff;border:none;padding:10px;border-radius:6px;cursor:pointer;" onclick="return confirm('هل تريد رفض هذا الطلب؟')">✗ رفض</button>
</form>
</div> </div>
<?php endif; ?>
<?php if ($transfer['status'] === 'approved' || $transfer['status'] === 'fee_paid'): ?>
<div style="margin-top:20px;">
<form method="POST" action="/transfers/<?= (int) $transfer['id'] ?>/complete">
<?= csrf_field() ?>
<button type="submit" class="btn btn-primary" style="width:100%;padding:12px;font-size:16px;" onclick="return confirm('⚠ هذا الإجراء نهائي — سيتم إنشاء عضوية جديدة وأرشفة البيانات القديمة. متأكد؟')">🔄 إتمام التحويل وإنشاء العضوية الجديدة</button>
</form> </form>
</div>
<?php endif; ?>
</div>
</div> </div>
<?php endif; ?>
<?php if ($transfer['status'] === 'requested'): ?>
<form method="POST" action="/transfers/<?= (int) $transfer['id'] ?>/complete" style="margin-top:15px;">
<?= csrf_field() ?>
<button type="submit" class="btn btn-primary" onclick="return confirm('إتمام التحويل؟')">✅ إتمام التحويل</button>
</form>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلب تنازل #<?= (int) $waiver['id'] ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>تنازل #<?= (int) $waiver['id'] ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<div class="card" style="padding:20px;"> <div class="card" style="padding:20px;margin-bottom:20px;">
<table style="width:100%;max-width:600px;font-size:14px;"> <table style="width:100%;max-width:600px;font-size:14px;">
<tr><td style="padding:6px 0;color:#6B7280;width:35%;">العضو المتنازل</td><td style="padding:6px 0;font-weight:600;"><?= e($waiver['source_name']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;width:35%;">المتنازل</td><td style="padding:6px 0;"><a href="/members/<?= (int) $waiver['source_member_id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($waiver['member_name'] ?? '') ?></a></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">رقم العضوية</td><td style="padding:6px 0;font-weight:700;"><?= e($waiver['membership_number']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">رقم العضوية</td><td style="padding:6px 0;font-weight:700;"><?= e($waiver['membership_number'] ?? '—') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">قيمة العضوية وقت التنازل</td><td style="padding:6px 0;"><?= money($waiver['membership_value_at_waiver']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">قيمة العضوية وقت التنازل</td><td style="padding:6px 0;"><?= money($waiver['membership_value_at_waiver'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">النسبة</td><td style="padding:6px 0;"><?= e($waiver['waiver_fee_percentage']) ?>%</td></tr> <tr><td style="padding:6px 0;color:#6B7280;">نسبة التنازل</td><td style="padding:6px 0;"><?= e($waiver['waiver_fee_percentage'] ?? '30') ?>%</td></tr>
<tr><td style="padding:6px 0;color:#6B7280;font-weight:700;">رسوم التنازل</td><td style="padding:6px 0;font-weight:700;color:#0D7377;font-size:18px;"><?= money($waiver['waiver_fee_amount']) ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">رسوم التنازل</td><td style="padding:6px 0;font-weight:700;font-size:22px;color:#DC2626;"><?= money($waiver['waiver_fee_amount'] ?? '0') ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">عدد التابعين الأصلي</td><td style="padding:6px 0;"><?= (int) $waiver['original_dependent_count'] ?></td></tr> <tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= match($waiver['status']) { 'completed' => '#059669', 'approved' => '#0284C7', default => '#D97706' } ?>;"><?= match($waiver['status']) { 'requested' => 'مقدم', 'approved' => 'معتمد — في انتظار الدفع', 'completed' => 'مكتمل', default => $waiver['status'] } ?></td></tr>
<tr><td style="padding:6px 0;color:#6B7280;">المستفيد</td><td style="padding:6px 0;"><?= e($waiver['target_name'] ?? 'لم يُحدد بعد') ?></td></tr> <?php if ($waiver['target_member_id']): ?><tr><td style="padding:6px 0;color:#6B7280;">المتنازل إليه</td><td style="padding:6px 0;"><a href="/members/<?= (int) $waiver['target_member_id'] ?>" style="color:#0D7377;font-weight:600;">عضو #<?= (int) $waiver['target_member_id'] ?></a></td></tr><?php endif; ?>
<tr><td style="padding:6px 0;color:#6B7280;">الحالة</td><td style="padding:6px 0;font-weight:700;color:<?= match($waiver['status']) { 'completed' => '#059669', 'approved' => '#0284C7', default => '#D97706' } ?>;"><?= match($waiver['status']) { 'requested' => 'في انتظار الموافقة', 'approved' => 'مُعتمد', 'completed' => 'مكتمل', 'rejected' => 'مرفوض', default => $waiver['status'] } ?></td></tr>
<?php if ($waiver['board_decision_reference']): ?><tr><td style="padding:6px 0;color:#6B7280;">مرجع قرار المجلس</td><td style="padding:6px 0;"><?= e($waiver['board_decision_reference']) ?></td></tr><?php endif; ?>
</table> </table>
</div>
<?php if ($waiver['status'] === 'requested'): ?> <?php if (in_array($waiver['status'], ['requested', 'approved']) && bccomp($waiver['waiver_fee_amount'] ?? '0', '0', 2) > 0): ?>
<div style="margin-top:20px;display:flex;gap:10px;"> <div class="card" style="padding:20px;margin-bottom:20px;background:#FFF7ED;border:2px solid #F59E0B;">
<form method="POST" action="/waivers/<?= (int) $waiver['id'] ?>/approve"> <h4 style="margin:0 0 15px;color:#D97706;">💰 دفع رسوم التنازل (30% من قيمة العضوية)</h4>
<form method="POST" action="/waiver/<?= (int) $waiver['id'] ?>/pay">
<?= csrf_field() ?> <?= csrf_field() ?>
<input type="text" name="board_decision_reference" placeholder="مرجع قرار المجلس" class="form-input" style="margin-bottom:10px;"> <input type="hidden" name="amount" value="<?= e($waiver['waiver_fee_amount']) ?>">
<button type="submit" class="btn btn-primary" onclick="return confirm('موافقة على التنازل؟')">✓ موافقة مجلس الأمناء</button> <div style="display:flex;gap:10px;align-items:end;">
</form> <div class="form-group"><label class="form-label">المبلغ</label><input type="text" value="<?= money($waiver['waiver_fee_amount']) ?>" class="form-input" style="background:#F3F4F6;font-weight:700;font-size:18px;" readonly></div>
<div class="form-group"><label class="form-label">طريقة الدفع</label><select name="payment_method" class="form-select"><option value="cash">نقدي</option><option value="visa">فيزا</option><option value="bank_transfer">تحويل</option></select></div>
<button type="submit" class="btn btn-primary" style="padding:10px 25px;" onclick="return confirm('تأكيد دفع <?= money($waiver['waiver_fee_amount']) ?>؟')">💰 ادفع</button>
</div> </div>
<?php endif; ?> </form>
</div>
<?php endif; ?>
<?php if ($waiver['status'] === 'approved' && !$waiver['target_member_id']): ?> <?php if ($waiver['status'] === 'approved'): ?>
<div style="margin-top:20px;padding:15px;background:#EFF6FF;border:1px solid #BFDBFE;border-radius:8px;"> <form method="POST" action="/waiver/<?= (int) $waiver['id'] ?>/complete">
<strong>الخطوة التالية:</strong> يجب إنشاء عضوية جديدة للمستفيد أولاً، ثم ربطها بهذا الطلب وإتمام التنازل.
<form method="POST" action="/waivers/<?= (int) $waiver['id'] ?>/complete" style="margin-top:10px;">
<?= csrf_field() ?> <?= csrf_field() ?>
<input type="number" name="target_member_id" placeholder="رقم العضو المستفيد (ID)" class="form-input" style="width:200px;margin-bottom:10px;" required> <button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام التنازل — سيتم نقل العضوية. متأكد؟')">✅ إتمام التنازل</button>
<button type="submit" class="btn btn-primary" onclick="return confirm('⚠ إتمام التنازل نهائياً. متأكد؟')">إتمام التنازل</button> </form>
</form> <?php endif; ?>
</div>
<?php endif; ?> <?php if ($waiver['status'] === 'requested'): ?>
<div style="margin-top:15px;display:flex;gap:10px;">
<form method="POST" action="/waiver/<?= (int) $waiver['id'] ?>/approve"><?= csrf_field() ?><button type="submit" class="btn btn-primary" onclick="return confirm('اعتماد التنازل؟')">✅ اعتماد مجلس الأمناء</button></form>
<form method="POST" action="/waiver/<?= (int) $waiver['id'] ?>/reject"><?= csrf_field() ?><button type="submit" class="btn btn-outline" style="color:#DC2626;" onclick="return confirm('رفض التنازل؟')">❌ رفض</button></form>
</div> </div>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
\ No newline at end of file
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