Commit bf80fb97 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(pricing): rebuild board offers UI with proper pagination, stats, and live preview

- Fixed crash: pagination used `total_pages` key but Pagination class returns `last_page`
- Board offers index: card-based layout with status indicators, usage counts, branch
  names (joined), days-until-expiry warnings, and stat summary at top
- Board offers form: two-column layout with live preview sidebar that shows real-time
  calculation examples, date validation warnings, and contextual help
- Model search now joins branches table and counts payment_request usage per offer
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 60733923
...@@ -47,23 +47,29 @@ class BoardOffer extends Model ...@@ -47,23 +47,29 @@ class BoardOffer extends Model
$params = []; $params = [];
if (!empty($filters['search'])) { if (!empty($filters['search'])) {
$where .= ' AND (`title_ar` LIKE ? OR `title_en` LIKE ? OR `board_decision_number` LIKE ?)'; $where .= ' AND (bo.`title_ar` LIKE ? OR bo.`title_en` LIKE ? OR bo.`board_decision_number` LIKE ?)';
$s = '%' . $filters['search'] . '%'; $s = '%' . $filters['search'] . '%';
$params[] = $s; $params[] = $s;
$params[] = $s; $params[] = $s;
$params[] = $s; $params[] = $s;
} }
if (($filters['is_active'] ?? '') !== '') { if (($filters['is_active'] ?? '') !== '') {
$where .= ' AND `is_active` = ?'; $where .= ' AND bo.`is_active` = ?';
$params[] = (int) $filters['is_active']; $params[] = (int) $filters['is_active'];
} }
$countRow = $db->selectOne("SELECT COUNT(*) as cnt FROM `board_offers` WHERE {$where}", $params); $countRow = $db->selectOne("SELECT COUNT(*) as cnt FROM `board_offers` bo WHERE {$where}", $params);
$total = (int) ($countRow['cnt'] ?? 0); $total = (int) ($countRow['cnt'] ?? 0);
$offset = ($page - 1) * $perPage; $offset = ($page - 1) * $perPage;
$data = $db->select( $data = $db->select(
"SELECT * FROM `board_offers` WHERE {$where} ORDER BY `effective_from` DESC LIMIT {$perPage} OFFSET {$offset}", "SELECT bo.*, b.name_ar as branch_name,
(SELECT COUNT(*) FROM payment_requests pr WHERE pr.board_offer_id = bo.id AND pr.is_voided = 0) as usage_count
FROM `board_offers` bo
LEFT JOIN `branches` b ON b.id = bo.branch_id
WHERE {$where}
ORDER BY bo.`is_active` DESC, bo.`effective_from` DESC
LIMIT {$perPage} OFFSET {$offset}",
$params $params
); );
......
<?php $__template->layout('Layout.main'); ?> <?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= $offer ? 'تعديل عرض: ' . e($offer['title_ar']) : ضافة عرض مجلس إدارة جديد' ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?><?= $offer ? 'تعديل عرض: ' . e($offer['title_ar']) : نشاء عرض مجلس إدارة جديد' ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?> <?php $__template->section('page_actions'); ?>
<a href="/pricing/board-offers" class="btn btn-outline"> <a href="/pricing/board-offers" class="btn btn-outline" style="display:inline-flex;align-items:center;gap:6px;">
<i data-lucide="arrow-right" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i> العودة للقائمة <i data-lucide="arrow-right" style="width:15px;height:15px;"></i> العودة للقائمة
</a> </a>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
...@@ -18,25 +18,24 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months' ...@@ -18,25 +18,24 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months'
<form method="POST" action="<?= $offer ? '/pricing/board-offers/' . (int) $offer['id'] : '/pricing/board-offers' ?>"> <form method="POST" action="<?= $offer ? '/pricing/board-offers/' . (int) $offer['id'] : '/pricing/board-offers' ?>">
<?= csrf_field() ?> <?= csrf_field() ?>
<div style="display:grid;grid-template-columns:1fr 340px;gap:20px;align-items:start;">
<!-- Main Form -->
<div>
<!-- Basic Info --> <!-- Basic Info -->
<div class="card" style="padding:20px;margin-bottom:20px;"> <div class="card" style="padding:20px;margin-bottom:16px;">
<div style="display:flex;align-items:center;gap:8px;margin-bottom:20px;"> <div style="display:flex;align-items:center;gap:8px;margin-bottom:16px;">
<i data-lucide="award" style="width:18px;height:18px;color:#0D7377;"></i> <i data-lucide="award" style="width:18px;height:18px;color:#0D7377;"></i>
<h3 style="margin:0;color:#0D7377;font-size:15px;">بيانات العرض</h3> <h3 style="margin:0;color:#0D7377;font-size:15px;">بيانات العرض</h3>
</div> </div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;">
<div class="form-group"> <div class="form-group" style="grid-column:1/-1;">
<label class="form-label">عنوان العرض بالعربي <span style="color:#DC2626;">*</span></label> <label class="form-label">عنوان العرض <span style="color:#DC2626;">*</span></label>
<input type="text" name="title_ar" value="<?= $v('title_ar') ?>" class="form-input" required maxlength="200" placeholder="مثال: عرض الصيف 2026"> <input type="text" name="title_ar" value="<?= $v('title_ar') ?>" class="form-input" required maxlength="200" placeholder="مثال: عرض الصيف — خصم 10% كاش" id="offer_title">
</div>
<div class="form-group">
<label class="form-label">عنوان العرض بالإنجليزي</label>
<input type="text" name="title_en" value="<?= $v('title_en') ?>" class="form-input" maxlength="200" placeholder="e.g. Summer 2026 Offer">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">رقم قرار مجلس الإدارة</label> <label class="form-label">رقم قرار مجلس الإدارة</label>
<input type="text" name="board_decision_number" value="<?= $v('board_decision_number') ?>" class="form-input" maxlength="50" placeholder="مثال: 2026/15"> <input type="text" name="board_decision_number" value="<?= $v('board_decision_number') ?>" class="form-input" maxlength="50" placeholder="2026/15">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">تاريخ القرار</label> <label class="form-label">تاريخ القرار</label>
...@@ -47,131 +46,129 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months' ...@@ -47,131 +46,129 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months'
<select name="branch_id" class="form-select"> <select name="branch_id" class="form-select">
<option value="">كل الفروع</option> <option value="">كل الفروع</option>
<?php foreach ($branches as $b): ?> <?php foreach ($branches as $b): ?>
<option value="<?= (int) $b['id'] ?>" <?= ((int) ($offer['branch_id'] ?? 0)) === (int) $b['id'] ? 'selected' : '' ?>><?= e($b['name_ar']) ?></option> <option value="<?= (int) $b['id'] ?>" <?= ((int) ($old['branch_id'] ?? $offer['branch_id'] ?? 0)) === (int) $b['id'] ? 'selected' : '' ?>><?= e($b['name_ar']) ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<small style="color:#6B7280;font-size:11px;">اتركه فارغاً ليسري على كل الفروع</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">يُطبَّق على</label> <label class="form-label">مجال التطبيق</label>
<select name="applies_to" class="form-select"> <select name="applies_to" class="form-select">
<option value="membership_fee" <?= $v('applies_to', 'membership_fee') === 'membership_fee' ? 'selected' : '' ?>>قيمة العضوية</option> <option value="membership_fee" <?= $v('applies_to', 'membership_fee') === 'membership_fee' ? 'selected' : '' ?>>قيمة العضوية فقط</option>
<option value="all" <?= $v('applies_to') === 'all' ? 'selected' : '' ?>>الكل</option> <option value="all" <?= $v('applies_to') === 'all' ? 'selected' : '' ?>>الكل (عضوية + إضافات)</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" style="margin-top:15px;">
<label class="form-label">وصف / ملاحظات</label>
<textarea name="description" class="form-input" rows="2" placeholder="وصف مختصر للعرض..."><?= $v('description') ?></textarea>
</div>
</div> </div>
<!-- Date Range --> <!-- Date Range -->
<div class="card" style="padding:20px;margin-bottom:20px;"> <div class="card" style="padding:20px;margin-bottom:16px;">
<div style="display:flex;align-items:center;gap:8px;margin-bottom:20px;"> <div style="display:flex;align-items:center;gap:8px;margin-bottom:16px;">
<i data-lucide="calendar-range" style="width:18px;height:18px;color:#7C3AED;"></i> <i data-lucide="calendar-range" style="width:18px;height:18px;color:#7C3AED;"></i>
<h3 style="margin:0;color:#7C3AED;font-size:15px;">فترة السريان <span style="color:#DC2626;">*</span></h3> <h3 style="margin:0;color:#7C3AED;font-size:15px;">فترة السريان <span style="color:#DC2626;">*</span></h3>
</div> </div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;">
<div class="form-group"> <div class="form-group">
<label class="form-label">تاريخ البداية <span style="color:#DC2626;">*</span></label> <label class="form-label">من تاريخ</label>
<input type="date" name="effective_from" value="<?= $v('effective_from') ?>" class="form-input" required style="direction:ltr;text-align:left;"> <input type="date" name="effective_from" value="<?= $v('effective_from') ?>" class="form-input" required style="direction:ltr;text-align:left;" id="date_from">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">تاريخ الانتهاء <span style="color:#DC2626;">*</span></label> <label class="form-label">إلى تاريخ</label>
<input type="date" name="effective_to" value="<?= $v('effective_to') ?>" class="form-input" required style="direction:ltr;text-align:left;"> <input type="date" name="effective_to" value="<?= $v('effective_to') ?>" class="form-input" required style="direction:ltr;text-align:left;" id="date_to">
</div> </div>
</div> </div>
<div id="date_warning" style="display:none;margin-top:8px;background:#FEF3C7;border:1px solid #FCD34D;border-radius:6px;padding:8px 12px;font-size:12px;color:#92400E;">
<i data-lucide="alert-triangle" style="width:13px;height:13px;vertical-align:middle;margin-left:4px;"></i>
<span id="date_warning_text"></span>
</div>
</div> </div>
<!-- Cash Path --> <!-- Cash Path -->
<div class="card" style="padding:20px;margin-bottom:20px;"> <div class="card" style="padding:20px;margin-bottom:16px;">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:15px;"> <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;">
<div style="display:flex;align-items:center;gap:8px;"> <div style="display:flex;align-items:center;gap:8px;">
<i data-lucide="banknote" style="width:18px;height:18px;color:#059669;"></i> <i data-lucide="banknote" style="width:18px;height:18px;color:#059669;"></i>
<h3 style="margin:0;color:#059669;font-size:15px;">مسار الكاش (الدفع الفوري)</h3> <h3 style="margin:0;color:#059669;font-size:15px;">مسار الكاش</h3>
</div> </div>
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;"> <label style="display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none;">
<input type="checkbox" name="has_cash_path" value="1" id="toggle_cash" <?= $hasCashPath ? 'checked' : '' ?> onchange="toggleSection('cash_section', this.checked)"> <input type="checkbox" name="has_cash_path" value="1" id="toggle_cash" <?= $hasCashPath ? 'checked' : '' ?> onchange="toggleSection('cash_section', this.checked)">
<span style="font-size:13px;color:#6B7280;">تفعيل</span> <span style="font-size:13px;color:#6B7280;">تفعيل خصم الكاش</span>
</label> </label>
</div> </div>
<p style="font-size:12px;color:#9CA3AF;margin:0 0 12px;">خصم يُطبَّق عند السداد الكامل نقداً (بدون تقسيط)</p>
<div id="cash_section" style="<?= $hasCashPath ? '' : 'display:none;' ?>"> <div id="cash_section" style="<?= $hasCashPath ? '' : 'display:none;' ?>">
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;">
<div class="form-group"> <div class="form-group">
<label class="form-label">نوع الخصم</label> <label class="form-label">نوع الخصم</label>
<select name="cash_discount_type" class="form-select"> <select name="cash_discount_type" class="form-select" id="cash_type">
<option value="percentage" <?= $v('cash_discount_type') === 'percentage' ? 'selected' : '' ?>>نسبة مئوية (%)</option> <option value="percentage" <?= $v('cash_discount_type') === 'percentage' ? 'selected' : '' ?>>نسبة مئوية (%)</option>
<option value="fixed_amount" <?= $v('cash_discount_type') === 'fixed_amount' ? 'selected' : '' ?>>مبلغ ثابت (ج.م)</option> <option value="fixed_amount" <?= $v('cash_discount_type') === 'fixed_amount' ? 'selected' : '' ?>>مبلغ ثابت (ج.م)</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">القيمة</label> <label class="form-label" id="cash_value_label">القيمة</label>
<input type="number" name="cash_discount_value" value="<?= $v('cash_discount_value') ?>" class="form-input" min="0.01" step="0.01" style="direction:ltr;text-align:left;" placeholder="مثال: 15"> <input type="number" name="cash_discount_value" value="<?= $v('cash_discount_value') ?>" class="form-input" min="0.01" step="0.01" style="direction:ltr;text-align:left;" placeholder="10" id="cash_value">
<small style="color:#6B7280;font-size:11px;">نسبة أو مبلغ حسب النوع المختار</small>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Installment Path --> <!-- Installment Path -->
<div class="card" style="padding:20px;margin-bottom:20px;"> <div class="card" style="padding:20px;margin-bottom:16px;">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:15px;"> <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;">
<div style="display:flex;align-items:center;gap:8px;"> <div style="display:flex;align-items:center;gap:8px;">
<i data-lucide="layers" style="width:18px;height:18px;color:#D97706;"></i> <i data-lucide="layers" style="width:18px;height:18px;color:#D97706;"></i>
<h3 style="margin:0;color:#D97706;font-size:15px;">مسار التقسيط</h3> <h3 style="margin:0;color:#D97706;font-size:15px;">مسار التقسيط</h3>
</div> </div>
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;"> <label style="display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none;">
<input type="checkbox" name="has_inst_path" value="1" id="toggle_inst" <?= $hasInstPath ? 'checked' : '' ?> onchange="toggleSection('inst_section', this.checked)"> <input type="checkbox" name="has_inst_path" value="1" id="toggle_inst" <?= $hasInstPath ? 'checked' : '' ?> onchange="toggleSection('inst_section', this.checked)">
<span style="font-size:13px;color:#6B7280;">تفعيل</span> <span style="font-size:13px;color:#6B7280;">تفعيل شروط تقسيط خاصة</span>
</label> </label>
</div> </div>
<p style="font-size:12px;color:#9CA3AF;margin:0 0 12px;">يتجاوز الإعدادات الافتراضية (مقدم 25%، فائدة 22%، 30 شهر)</p>
<div id="inst_section" style="<?= $hasInstPath ? '' : 'display:none;' ?>"> <div id="inst_section" style="<?= $hasInstPath ? '' : 'display:none;' ?>">
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px;">
<div class="form-group"> <div class="form-group">
<label class="form-label">نسبة المقدم (%)</label> <label class="form-label">نسبة المقدم (%)</label>
<input type="number" name="inst_down_payment_pct" value="<?= $v('inst_down_payment_pct') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="الافتراضي: 25%"> <input type="number" name="inst_down_payment_pct" value="<?= $v('inst_down_payment_pct') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="25">
<small style="color:#6B7280;font-size:11px;">اتركه فارغاً لاستخدام الافتراضي (25%)</small> <small style="color:#9CA3AF;font-size:11px;">فارغ = 25% (الافتراضي)</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">عدد الأشهر</label> <label class="form-label">عدد الأشهر</label>
<input type="number" name="inst_months" value="<?= $v('inst_months') ?>" class="form-input" min="1" max="120" style="direction:ltr;text-align:left;" placeholder="الافتراضي: 30"> <input type="number" name="inst_months" value="<?= $v('inst_months') ?>" class="form-input" min="1" max="120" style="direction:ltr;text-align:left;" placeholder="30">
<small style="color:#6B7280;font-size:11px;">اتركه فارغاً لاستخدام الافتراضي (30 شهر)</small> <small style="color:#9CA3AF;font-size:11px;">فارغ = 30 شهر</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">نسبة الفائدة السنوية (%)</label> <label class="form-label">نسبة الفائدة (%)</label>
<input type="number" name="inst_interest_rate" value="<?= $v('inst_interest_rate') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="الافتراضي: 22%"> <input type="number" name="inst_interest_rate" value="<?= $v('inst_interest_rate') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="22">
<small style="color:#6B7280;font-size:11px;">اتركه فارغاً لاستخدام الافتراضي (22%)</small> <small style="color:#9CA3AF;font-size:11px;">فارغ = 22%</small>
</div> </div>
</div> </div>
<!-- Grace Period --> <!-- Grace Period -->
<div style="margin-top:20px;padding-top:15px;border-top:1px solid #E5E7EB;"> <div style="margin-top:14px;padding-top:14px;border-top:1px solid #E5E7EB;">
<div style="display:flex;align-items:center;gap:8px;margin-bottom:15px;"> <div style="display:flex;align-items:center;gap:6px;margin-bottom:12px;">
<i data-lucide="clock" style="width:16px;height:16px;color:#7C3AED;"></i> <i data-lucide="clock" style="width:14px;height:14px;color:#7C3AED;"></i>
<h4 style="margin:0;color:#7C3AED;font-size:14px;">فترة السماح (اختياري)</h4> <span style="font-size:13px;font-weight:600;color:#7C3AED;">فترة السماح (اختياري)</span>
</div> </div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px;">
<div class="form-group"> <div class="form-group">
<label class="form-label">نوع فترة السماح</label> <label class="form-label">نوع فترة السماح</label>
<select name="inst_grace_type" id="grace_type_select" class="form-select" onchange="toggleGraceDetails()"> <select name="inst_grace_type" id="grace_type_select" class="form-select" onchange="toggleGraceDetails()">
<option value="" <?= !$v('inst_grace_type') ? 'selected' : '' ?>>بدون فترة سماح</option> <option value="" <?= !$v('inst_grace_type') ? 'selected' : '' ?>>بدون</option>
<option value="first_n_months" <?= $v('inst_grace_type') === 'first_n_months' ? 'selected' : '' ?>>أول N شهر بدون فوائد</option> <option value="first_n_months" <?= $v('inst_grace_type') === 'first_n_months' ? 'selected' : '' ?>>أول N شهر بدون فوائد</option>
<option value="full_free_under_n" <?= $v('inst_grace_type') === 'full_free_under_n' ? 'selected' : '' ?>>إعفاء كامل إذا الأقساط ≤ N شهر</option> <option value="full_free_under_n" <?= $v('inst_grace_type') === 'full_free_under_n' ? 'selected' : '' ?>>إعفاء كامل إذا الأقساط &#x2264; N</option>
</select> </select>
</div> </div>
<div class="form-group" id="grace_months_group" style="<?= $v('inst_grace_type') ? '' : 'display:none;' ?>"> <div class="form-group" id="grace_months_group" style="<?= $v('inst_grace_type') ? '' : 'display:none;' ?>">
<label class="form-label">عدد أشهر السماح</label> <label class="form-label">أشهر السماح</label>
<input type="number" name="inst_grace_months" value="<?= $v('inst_grace_months', 0) ?>" class="form-input" min="1" max="60" style="direction:ltr;text-align:left;" placeholder="مثال: 6"> <input type="number" name="inst_grace_months" value="<?= $v('inst_grace_months', 0) ?>" class="form-input" min="1" max="60" style="direction:ltr;text-align:left;" placeholder="6">
</div> </div>
<div class="form-group" id="post_grace_rate_group" style="<?= $v('inst_grace_type') === 'first_n_months' ? '' : 'display:none;' ?>"> <div class="form-group" id="post_grace_rate_group" style="<?= $v('inst_grace_type') === 'first_n_months' ? '' : 'display:none;' ?>">
<label class="form-label">فائدة ما بعد السماح (%)</label> <label class="form-label">فائدة بعد السماح (%)</label>
<input type="number" name="inst_post_grace_rate" value="<?= $v('inst_post_grace_rate') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="اتركه فارغاً لنفس الفائدة أعلاه"> <input type="number" name="inst_post_grace_rate" value="<?= $v('inst_post_grace_rate') ?>" class="form-input" min="0" max="100" step="0.01" style="direction:ltr;text-align:left;" placeholder="نفس الأساسية">
<small style="color:#6B7280;font-size:11px;">فارغ = نفس نسبة الفائدة الأساسية</small>
</div> </div>
</div> </div>
</div> </div>
...@@ -179,42 +176,156 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months' ...@@ -179,42 +176,156 @@ $hasInstPath = !empty($old['has_inst_path']) || ($offer && ($offer['inst_months'
</div> </div>
<!-- Notes --> <!-- Notes -->
<div class="card" style="padding:20px;margin-bottom:20px;"> <div class="card" style="padding:20px;margin-bottom:16px;">
<div class="form-group" style="margin:0;"> <div class="form-group" style="margin:0;">
<label class="form-label">ملاحظات إضافية</label> <label class="form-label">ملاحظات</label>
<textarea name="notes" class="form-input" rows="2"><?= $v('notes') ?></textarea> <textarea name="notes" class="form-input" rows="2" placeholder="ملاحظات داخلية (لن تظهر للعضو)..."><?= $v('notes') ?></textarea>
</div> </div>
<input type="hidden" name="title_en" value="<?= $v('title_en') ?>">
<input type="hidden" name="description" value="<?= $v('description') ?>">
</div> </div>
<?php if ($offer): ?> <?php if ($offer): ?>
<div class="card" style="padding:15px;margin-bottom:20px;background:#F9FAFB;"> <div class="card" style="padding:14px 20px;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;">
<div class="form-group" style="margin:0;"> <label style="display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;">
<input type="checkbox" name="is_active" value="1" <?= $offer['is_active'] ? 'checked' : '' ?>> <input type="checkbox" name="is_active" value="1" <?= $offer['is_active'] ? 'checked' : '' ?>>
<span class="form-label" style="margin:0;">العرض مفعّل</span> <span style="font-size:14px;font-weight:600;color:#374151;">العرض مفعّل</span>
</label> </label>
</div> <span style="font-size:12px;color:#9CA3AF;">آخر تعديل: <?= e($offer['updated_at'] ?? $offer['created_at']) ?></span>
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- Submit --> <!-- Submit -->
<div style="display:flex;gap:10px;justify-content:flex-start;"> <div style="display:flex;gap:10px;">
<button type="submit" class="btn btn-primary" style="min-width:140px;"> <button type="submit" class="btn btn-primary" style="min-width:140px;">
<i data-lucide="check" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i> <i data-lucide="check" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i>
<?= $offer ? 'تحديث العرض' : 'حفظ العرض' ?> <?= $offer ? 'حفظ التعديلات' : 'إنشاء العرض' ?>
</button> </button>
<a href="/pricing/board-offers" class="btn btn-outline">إلغاء</a> <a href="/pricing/board-offers" class="btn btn-outline">إلغاء</a>
</div> </div>
</div>
<!-- Live Preview Sidebar -->
<div style="position:sticky;top:20px;">
<div class="card" style="padding:16px;border:2px solid #E5E7EB;">
<div style="font-size:12px;color:#6B7280;margin-bottom:10px;text-transform:uppercase;letter-spacing:1px;font-weight:600;">معاينة العرض</div>
<div style="background:linear-gradient(135deg,#FEF3C7,#FDE68A);border-radius:8px;padding:10px 14px;margin-bottom:12px;">
<strong style="color:#92400E;font-size:13px;" id="preview_title"><?= $v('title_ar') ?: 'عنوان العرض' ?></strong>
<div style="font-size:11px;color:#92400E;margin-top:2px;" id="preview_dates"></div>
</div>
<div id="preview_cash" style="<?= $hasCashPath ? '' : 'display:none;' ?>margin-bottom:10px;">
<div style="background:#F0FDF4;border:1px solid #BBF7D0;border-radius:6px;padding:8px 10px;">
<div style="font-size:11px;color:#166534;font-weight:600;">مسار الكاش</div>
<div style="font-size:14px;font-weight:700;color:#059669;margin-top:2px;" id="preview_cash_val"></div>
<div style="font-size:11px;color:#6B7280;margin-top:2px;">مثال: عضوية 150,000 = <span id="preview_cash_example"></span></div>
</div>
</div>
<div id="preview_inst" style="<?= $hasInstPath ? '' : 'display:none;' ?>">
<div style="background:#EFF6FF;border:1px solid #BFDBFE;border-radius:6px;padding:8px 10px;">
<div style="font-size:11px;color:#1E40AF;font-weight:600;">مسار التقسيط</div>
<div style="font-size:12px;color:#374151;margin-top:4px;line-height:1.6;" id="preview_inst_details"></div>
</div>
</div>
<div id="preview_empty" style="<?= ($hasCashPath || $hasInstPath) ? 'display:none;' : '' ?>text-align:center;padding:20px 0;color:#9CA3AF;font-size:13px;">
فعّل مسار واحد على الأقل
</div>
</div>
<!-- Help -->
<div class="card" style="padding:14px;margin-top:12px;background:#F9FAFB;border:1px solid #E5E7EB;">
<div style="font-size:12px;font-weight:600;color:#374151;margin-bottom:8px;"><i data-lucide="info" style="width:13px;height:13px;vertical-align:middle;margin-left:4px;color:#6B7280;"></i>كيف يعمل العرض</div>
<ul style="font-size:11px;color:#6B7280;margin:0;padding-right:16px;line-height:1.8;">
<li>يظهر تلقائياً في صفحة العضو عند إنشاء طلب دفع</li>
<li>العرض الأكثر تحديداً (بفرع) يتقدم على العام</li>
<li>يُحفظ كـ snapshot عند الطلب — تغيير العرض لا يؤثر على الطلبات السابقة</li>
<li>الخصم الكاش يُطرح من المبلغ قبل الإرسال للخزينة</li>
<li>التقسيط يتجاوز القيم الافتراضية (25% مقدم، 22% فائدة، 30 شهر)</li>
</ul>
</div>
</div>
</div>
</form> </form>
<script> <script>
function toggleSection(id, show) { function toggleSection(id, show) {
document.getElementById(id).style.display = show ? '' : 'none'; document.getElementById(id).style.display = show ? '' : 'none';
updatePreview();
} }
function toggleGraceDetails() { function toggleGraceDetails() {
var val = document.getElementById('grace_type_select').value; var val = document.getElementById('grace_type_select').value;
document.getElementById('grace_months_group').style.display = val ? '' : 'none'; document.getElementById('grace_months_group').style.display = val ? '' : 'none';
document.getElementById('post_grace_rate_group').style.display = (val === 'first_n_months') ? '' : 'none'; document.getElementById('post_grace_rate_group').style.display = (val === 'first_n_months') ? '' : 'none';
updatePreview();
} }
function updatePreview() {
var title = document.getElementById('offer_title').value || 'عنوان العرض';
document.getElementById('preview_title').textContent = title;
var from = document.getElementById('date_from').value;
var to = document.getElementById('date_to').value;
document.getElementById('preview_dates').textContent = (from && to) ? ('من ' + from + ' إلى ' + to) : '—';
// Date validation
var warn = document.getElementById('date_warning');
var warnText = document.getElementById('date_warning_text');
if (from && to && from > to) {
warn.style.display = '';
warnText.textContent = 'تاريخ البداية بعد تاريخ الانتهاء!';
} else if (to && to < new Date().toISOString().slice(0,10)) {
warn.style.display = '';
warnText.textContent = 'تاريخ الانتهاء في الماضي — العرض لن يكون ساري.';
} else {
warn.style.display = 'none';
}
var hasCash = document.getElementById('toggle_cash').checked;
var hasInst = document.getElementById('toggle_inst').checked;
document.getElementById('preview_cash').style.display = hasCash ? '' : 'none';
document.getElementById('preview_inst').style.display = hasInst ? '' : 'none';
document.getElementById('preview_empty').style.display = (!hasCash && !hasInst) ? '' : 'none';
if (hasCash) {
var ctype = document.getElementById('cash_type').value;
var cval = parseFloat(document.getElementById('cash_value').value) || 0;
if (ctype === 'percentage') {
document.getElementById('preview_cash_val').textContent = 'خصم ' + cval + '%';
var saved = (150000 * cval / 100);
document.getElementById('preview_cash_example').textContent = 'يدفع ' + (150000 - saved).toLocaleString() + ' (وفّر ' + saved.toLocaleString() + ')';
} else {
document.getElementById('preview_cash_val').textContent = 'خصم ' + cval.toLocaleString() + ' ج.م';
document.getElementById('preview_cash_example').textContent = 'يدفع ' + (150000 - cval).toLocaleString();
}
}
if (hasInst) {
var dp = document.querySelector('[name=inst_down_payment_pct]').value || '25';
var mo = document.querySelector('[name=inst_months]').value || '30';
var ir = document.querySelector('[name=inst_interest_rate]').value || '22';
var gt = document.getElementById('grace_type_select').value;
var gm = document.querySelector('[name=inst_grace_months]').value || '0';
var lines = 'مقدم ' + dp + '% — ' + mo + ' شهر — فائدة ' + ir + '%';
if (gt === 'first_n_months' && parseInt(gm) > 0) {
lines += '\nأول ' + gm + ' شهر بدون فوائد';
} else if (gt === 'full_free_under_n' && parseInt(gm) > 0) {
lines += '\nإعفاء كامل إذا الأقساط ≤ ' + gm + ' شهر';
}
document.getElementById('preview_inst_details').textContent = lines;
}
}
document.addEventListener('DOMContentLoaded', function() {
updatePreview();
document.querySelectorAll('input, select, textarea').forEach(function(el) {
el.addEventListener('input', updatePreview);
el.addEventListener('change', updatePreview);
});
});
</script> </script>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
...@@ -2,142 +2,202 @@ ...@@ -2,142 +2,202 @@
<?php $__template->section('title'); ?>عروض مجلس الإدارة<?php $__template->endSection(); ?> <?php $__template->section('title'); ?>عروض مجلس الإدارة<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?> <?php $__template->section('page_actions'); ?>
<a href="/pricing" class="btn btn-outline" style="display:inline-flex;align-items:center;gap:6px;">
<i data-lucide="arrow-right" style="width:15px;height:15px;"></i> التسعير
</a>
<?php if (can('pricing.board_offers.create')): ?>
<a href="/pricing/board-offers/create" class="btn btn-primary" style="display:inline-flex;align-items:center;gap:6px;"> <a href="/pricing/board-offers/create" class="btn btn-primary" style="display:inline-flex;align-items:center;gap:6px;">
<i data-lucide="plus" style="width:15px;height:15px;"></i> إضافة عرض جديد <i data-lucide="plus" style="width:15px;height:15px;"></i> عرض جديد
</a> </a>
<?php endif; ?>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<?php
$today = date('Y-m-d');
$activeCount = 0;
$expiredCount = 0;
$disabledCount = 0;
foreach ($rows as $r) {
$exp = $r['effective_to'] < $today;
if ($r['is_active'] && !$exp) $activeCount++;
elseif ($exp) $expiredCount++;
else $disabledCount++;
}
?>
<!-- Stats -->
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:20px;">
<div style="background:#fff;border:1px solid #E5E7EB;border-radius:10px;padding:14px 18px;display:flex;align-items:center;gap:12px;">
<div style="width:36px;height:36px;border-radius:8px;background:#D1FAE5;display:flex;align-items:center;justify-content:center;">
<i data-lucide="check-circle" style="width:18px;height:18px;color:#059669;"></i>
</div>
<div>
<div style="font-size:22px;font-weight:700;color:#059669;"><?= $activeCount ?></div>
<div style="font-size:12px;color:#6B7280;">عروض مفعّلة</div>
</div>
</div>
<div style="background:#fff;border:1px solid #E5E7EB;border-radius:10px;padding:14px 18px;display:flex;align-items:center;gap:12px;">
<div style="width:36px;height:36px;border-radius:8px;background:#FEE2E2;display:flex;align-items:center;justify-content:center;">
<i data-lucide="clock" style="width:18px;height:18px;color:#DC2626;"></i>
</div>
<div>
<div style="font-size:22px;font-weight:700;color:#DC2626;"><?= $expiredCount ?></div>
<div style="font-size:12px;color:#6B7280;">منتهية</div>
</div>
</div>
<div style="background:#fff;border:1px solid #E5E7EB;border-radius:10px;padding:14px 18px;display:flex;align-items:center;gap:12px;">
<div style="width:36px;height:36px;border-radius:8px;background:#F3F4F6;display:flex;align-items:center;justify-content:center;">
<i data-lucide="pause-circle" style="width:18px;height:18px;color:#6B7280;"></i>
</div>
<div>
<div style="font-size:22px;font-weight:700;color:#6B7280;"><?= $disabledCount ?></div>
<div style="font-size:12px;color:#6B7280;">معطّلة</div>
</div>
</div>
</div>
<!-- Filters --> <!-- Filters -->
<div class="card" style="padding:15px;margin-bottom:20px;"> <div class="card" style="padding:12px 15px;margin-bottom:16px;">
<form method="GET" action="/pricing/board-offers" style="display:flex;gap:12px;align-items:end;flex-wrap:wrap;"> <form method="GET" action="/pricing/board-offers" style="display:flex;gap:10px;align-items:end;flex-wrap:wrap;">
<div class="form-group" style="margin:0;flex:1;min-width:200px;"> <div class="form-group" style="margin:0;flex:1;min-width:200px;">
<label class="form-label" style="font-size:12px;">بحث</label> <input type="text" name="q" value="<?= e($filters['search'] ?? '') ?>" class="form-input" placeholder="بحث بعنوان العرض أو رقم القرار..." style="height:36px;">
<input type="text" name="q" value="<?= e($filters['search'] ?? '') ?>" class="form-input" placeholder="عنوان العرض أو رقم القرار...">
</div> </div>
<div class="form-group" style="margin:0;width:150px;"> <div class="form-group" style="margin:0;width:130px;">
<label class="form-label" style="font-size:12px;">الحالة</label> <select name="is_active" class="form-select" style="height:36px;">
<select name="is_active" class="form-select"> <option value="">كل الحالات</option>
<option value="">الكل</option>
<option value="1" <?= ($filters['is_active'] ?? '') === '1' ? 'selected' : '' ?>>مفعّل</option> <option value="1" <?= ($filters['is_active'] ?? '') === '1' ? 'selected' : '' ?>>مفعّل</option>
<option value="0" <?= ($filters['is_active'] ?? '') === '0' ? 'selected' : '' ?>>معطّل</option> <option value="0" <?= ($filters['is_active'] ?? '') === '0' ? 'selected' : '' ?>>معطّل</option>
</select> </select>
</div> </div>
<button type="submit" class="btn btn-outline" style="height:38px;"> <button type="submit" class="btn btn-outline" style="height:36px;padding:0 14px;">
<i data-lucide="search" style="width:14px;height:14px;"></i> <i data-lucide="search" style="width:14px;height:14px;"></i>
</button> </button>
</form> </form>
</div> </div>
<!-- Table --> <!-- Offers List -->
<div class="card" style="overflow-x:auto;"> <?php if (empty($rows)): ?>
<table class="table"> <div class="card" style="padding:60px 20px;text-align:center;">
<thead> <div style="margin-bottom:15px;"><i data-lucide="award" style="width:48px;height:48px;color:#D1D5DB;"></i></div>
<tr> <h3 style="color:#374151;margin:0 0 8px;">لا توجد عروض مجلس إدارة</h3>
<th>العرض</th> <p style="color:#6B7280;font-size:14px;margin:0 0 20px;">عروض مجلس الإدارة تتحكم في شروط الدفع — خصومات الكاش، نسب المقدم، عدد الأشهر، وفترات السماح.</p>
<th>مسار الكاش</th> <?php if (can('pricing.board_offers.create')): ?>
<th>مسار التقسيط</th> <a href="/pricing/board-offers/create" class="btn btn-primary">
<th>الفرع</th> <i data-lucide="plus" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> إنشاء أول عرض
<th>الفترة</th> </a>
<th>الحالة</th> <?php endif; ?>
<th>إجراءات</th> </div>
</tr> <?php else: ?>
</thead> <div style="display:flex;flex-direction:column;gap:12px;">
<tbody> <?php foreach ($rows as $row):
<?php if (empty($rows)): ?> $isExpired = $row['effective_to'] < $today;
<tr><td colspan="7" style="text-align:center;color:#6B7280;padding:40px;">لا توجد عروض حالياً</td></tr> $isFuture = $row['effective_from'] > $today;
<?php else: ?> $isActive = $row['is_active'] && !$isExpired && !$isFuture;
<?php foreach ($rows as $row): ?> $hasCash = !empty($row['cash_discount_type']) && !empty($row['cash_discount_value']);
<tr> $hasInst = ($row['inst_months'] || $row['inst_interest_rate'] !== null || $row['inst_down_payment_pct'] !== null);
<td> $usageCount = (int) ($row['usage_count'] ?? 0);
<strong style="color:#1F2937;"><?= e($row['title_ar']) ?></strong>
if ($isActive) {
$borderColor = '#059669'; $statusBg = '#D1FAE5'; $statusColor = '#065F46'; $statusLabel = 'ساري';
} elseif ($isFuture) {
$borderColor = '#2563EB'; $statusBg = '#DBEAFE'; $statusColor = '#1E40AF'; $statusLabel = 'قادم';
} elseif ($isExpired) {
$borderColor = '#DC2626'; $statusBg = '#FEE2E2'; $statusColor = '#991B1B'; $statusLabel = 'منتهي';
} else {
$borderColor = '#9CA3AF'; $statusBg = '#F3F4F6'; $statusColor = '#6B7280'; $statusLabel = 'معطّل';
}
$daysLeft = $isActive ? (int) ((strtotime($row['effective_to']) - strtotime($today)) / 86400) : 0;
?>
<div class="card" style="padding:0;border-right:4px solid <?= $borderColor ?>;overflow:hidden;<?= !$isActive && !$isFuture ? 'opacity:0.75;' : '' ?>">
<div style="padding:16px 20px;display:flex;align-items:flex-start;gap:16px;">
<!-- Main Info -->
<div style="flex:1;min-width:0;">
<div style="display:flex;align-items:center;gap:10px;margin-bottom:6px;">
<h4 style="margin:0;font-size:15px;color:#1F2937;"><?= e($row['title_ar']) ?></h4>
<span style="background:<?= $statusBg ?>;color:<?= $statusColor ?>;padding:2px 10px;border-radius:10px;font-size:11px;font-weight:600;white-space:nowrap;"><?= $statusLabel ?></span>
<?php if ($isActive && $daysLeft <= 14): ?>
<span style="background:#FEF3C7;color:#92400E;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:600;">ينتهي خلال <?= $daysLeft ?> يوم</span>
<?php endif; ?>
</div>
<div style="display:flex;align-items:center;gap:12px;font-size:12px;color:#6B7280;margin-bottom:10px;">
<?php if ($row['board_decision_number']): ?> <?php if ($row['board_decision_number']): ?>
<br><small style="color:#6B7280;">قرار رقم: <?= e($row['board_decision_number']) ?></small> <span><i data-lucide="file-text" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i>قرار <?= e($row['board_decision_number']) ?><?= $row['board_decision_date'] ? ' — ' . e($row['board_decision_date']) : '' ?></span>
<?php endif; ?> <?php endif; ?>
</td> <span><i data-lucide="calendar" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i><?= e($row['effective_from']) ?> إلى <?= e($row['effective_to']) ?></span>
<td> <span><i data-lucide="map-pin" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i><?= $row['branch_name'] ? e($row['branch_name']) : 'كل الفروع' ?></span>
<?php if ($row['cash_discount_type']): ?> <?php if ($usageCount > 0): ?>
<span style="background:#ECFDF5;color:#065F46;padding:2px 8px;border-radius:4px;font-size:12px;"> <span style="color:#0D7377;font-weight:600;"><i data-lucide="users" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i><?= $usageCount ?> استخدام</span>
<?php endif; ?>
</div>
<!-- Paths -->
<div style="display:flex;gap:16px;flex-wrap:wrap;">
<?php if ($hasCash): ?>
<div style="background:#F0FDF4;border:1px solid #BBF7D0;border-radius:8px;padding:8px 12px;min-width:160px;">
<div style="font-size:11px;color:#166534;font-weight:600;margin-bottom:3px;"><i data-lucide="banknote" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i>مسار الكاش</div>
<div style="font-size:16px;font-weight:700;color:#059669;">
<?php if ($row['cash_discount_type'] === 'percentage'): ?> <?php if ($row['cash_discount_type'] === 'percentage'): ?>
<?= e($row['cash_discount_value']) ?>% خصم <?= e($row['cash_discount_value']) ?>%
<?php else: ?> <?php else: ?>
<?= money($row['cash_discount_value']) ?> خصم <?= money($row['cash_discount_value']) ?>
<?php endif; ?> <?php endif; ?>
</span> </div>
<?php else: ?> </div>
<span style="color:#9CA3AF;"></span>
<?php endif; ?> <?php endif; ?>
</td>
<td> <?php if ($hasInst): ?>
<?php if ($row['inst_months'] || $row['inst_interest_rate'] !== null || $row['inst_down_payment_pct'] !== null): ?> <div style="background:#EFF6FF;border:1px solid #BFDBFE;border-radius:8px;padding:8px 12px;min-width:200px;">
<div style="font-size:12px;line-height:1.6;"> <div style="font-size:11px;color:#1E40AF;font-weight:600;margin-bottom:3px;"><i data-lucide="layers" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i>مسار التقسيط</div>
<div style="display:flex;gap:8px;flex-wrap:wrap;font-size:12px;">
<?php if ($row['inst_down_payment_pct'] !== null): ?> <?php if ($row['inst_down_payment_pct'] !== null): ?>
<span style="background:#EFF6FF;color:#1E40AF;padding:1px 6px;border-radius:3px;">مقدم <?= e($row['inst_down_payment_pct']) ?>%</span> <span style="background:#fff;padding:2px 6px;border-radius:4px;border:1px solid #BFDBFE;">مقدم <?= e($row['inst_down_payment_pct']) ?>%</span>
<?php endif; ?> <?php endif; ?>
<?php if ($row['inst_months']): ?> <?php if ($row['inst_months']): ?>
<span style="background:#FEF3C7;color:#92400E;padding:1px 6px;border-radius:3px;"><?= (int) $row['inst_months'] ?> شهر</span> <span style="background:#fff;padding:2px 6px;border-radius:4px;border:1px solid #BFDBFE;"><?= (int) $row['inst_months'] ?> شهر</span>
<?php endif; ?> <?php endif; ?>
<?php if ($row['inst_interest_rate'] !== null): ?> <?php if ($row['inst_interest_rate'] !== null): ?>
<span style="background:#FEE2E2;color:#991B1B;padding:1px 6px;border-radius:3px;">فائدة <?= e($row['inst_interest_rate']) ?>%</span> <span style="background:#fff;padding:2px 6px;border-radius:4px;border:1px solid #BFDBFE;">فائدة <?= e($row['inst_interest_rate']) ?>%</span>
<?php endif; ?> <?php endif; ?>
<?php if ($row['inst_grace_months'] > 0): ?> <?php if ($row['inst_grace_months'] > 0): ?>
<br><span style="background:#F3E8FF;color:#6B21A8;padding:1px 6px;border-radius:3px;margin-top:3px;display:inline-block;"> <span style="background:#F3E8FF;padding:2px 6px;border-radius:4px;border:1px solid #E9D5FF;color:#6B21A8;">
<?= (int) $row['inst_grace_months'] ?> شهر سماح <?= (int) $row['inst_grace_months'] ?> شهر سماح<?= $row['inst_grace_type'] === 'full_free_under_n' ? ' (إعفاء كامل)' : '' ?>
<?= $row['inst_grace_type'] === 'full_free_under_n' ? '(إعفاء كامل)' : '' ?>
</span> </span>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php else: ?> </div>
<span style="color:#9CA3AF;"></span>
<?php endif; ?>
</td>
<td>
<?php if ($row['branch_id']): ?>
<span style="font-size:12px;"><?= e($row['branch_name'] ?? 'فرع #' . $row['branch_id']) ?></span>
<?php else: ?>
<span style="color:#6B7280;font-size:12px;">كل الفروع</span>
<?php endif; ?> <?php endif; ?>
</td>
<td style="font-size:12px;white-space:nowrap;"> <?php if (!$hasCash && !$hasInst): ?>
<?= e($row['effective_from']) ?><br> <div style="color:#9CA3AF;font-size:13px;padding:8px 0;">لم يتم تحديد مسار دفع</div>
<span style="color:#6B7280;">إلى</span> <?= e($row['effective_to']) ?>
</td>
<td>
<?php
$today = date('Y-m-d');
$isExpired = $row['effective_to'] < $today;
$isActive = $row['is_active'] && !$isExpired;
?>
<?php if ($isActive): ?>
<span style="background:#D1FAE5;color:#065F46;padding:3px 10px;border-radius:12px;font-size:11px;font-weight:600;">مفعّل</span>
<?php elseif ($isExpired): ?>
<span style="background:#FEE2E2;color:#991B1B;padding:3px 10px;border-radius:12px;font-size:11px;font-weight:600;">منتهي</span>
<?php else: ?>
<span style="background:#F3F4F6;color:#6B7280;padding:3px 10px;border-radius:12px;font-size:11px;font-weight:600;">معطّل</span>
<?php endif; ?> <?php endif; ?>
</td> </div>
<td style="white-space:nowrap;"> </div>
<a href="/pricing/board-offers/<?= (int) $row['id'] ?>/edit" class="btn btn-sm btn-outline" title="تعديل">
<i data-lucide="pencil" style="width:13px;height:13px;"></i> <!-- Actions -->
<div style="display:flex;flex-direction:column;gap:6px;align-items:flex-end;">
<?php if (can('pricing.board_offers.edit')): ?>
<a href="/pricing/board-offers/<?= (int) $row['id'] ?>/edit" class="btn btn-sm btn-outline" style="font-size:12px;padding:5px 12px;white-space:nowrap;">
<i data-lucide="pencil" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i> تعديل
</a> </a>
<form method="POST" action="/pricing/board-offers/<?= (int) $row['id'] ?>/toggle" style="display:inline;"> <form method="POST" action="/pricing/board-offers/<?= (int) $row['id'] ?>/toggle" style="margin:0;">
<?= csrf_field() ?> <?= csrf_field() ?>
<button type="submit" class="btn btn-sm btn-outline" title="<?= $row['is_active'] ? 'تعطيل' : 'تفعيل' ?>"> <button type="submit" class="btn btn-sm btn-outline" style="font-size:12px;padding:5px 12px;white-space:nowrap;<?= $row['is_active'] ? 'color:#DC2626;border-color:#FCA5A5;' : 'color:#059669;border-color:#86EFAC;' ?>">
<i data-lucide="<?= $row['is_active'] ? 'pause' : 'play' ?>" style="width:13px;height:13px;"></i> <i data-lucide="<?= $row['is_active'] ? 'pause' : 'play' ?>" style="width:12px;height:12px;vertical-align:middle;margin-left:3px;"></i>
<?= $row['is_active'] ? 'تعطيل' : 'تفعيل' ?>
</button> </button>
</form> </form>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
</tbody> </div>
</table> </div>
</div>
<?php endforeach; ?>
</div> </div>
<?php if (!empty($pagination) && $pagination['total_pages'] > 1): ?> <?php if (!empty($pagination) && $pagination['last_page'] > 1): ?>
<div style="display:flex;justify-content:center;gap:6px;margin-top:20px;"> <div style="display:flex;justify-content:center;gap:6px;margin-top:20px;">
<?php for ($p = 1; $p <= $pagination['total_pages']; $p++): ?> <?php for ($p = 1; $p <= $pagination['last_page']; $p++): ?>
<a href="?page=<?= $p ?>&q=<?= urlencode($filters['search'] ?? '') ?>&is_active=<?= urlencode($filters['is_active'] ?? '') ?>" <a href="?page=<?= $p ?>&q=<?= urlencode($filters['search'] ?? '') ?>&is_active=<?= urlencode($filters['is_active'] ?? '') ?>"
class="btn btn-sm <?= $p === $pagination['current_page'] ? 'btn-primary' : 'btn-outline' ?>"> class="btn btn-sm <?= $p === $pagination['current_page'] ? 'btn-primary' : 'btn-outline' ?>">
<?= $p ?> <?= $p ?>
...@@ -145,5 +205,6 @@ ...@@ -145,5 +205,6 @@
<?php endfor; ?> <?php endfor; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
<?php $__template->endSection(); ?> <?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