Commit 31671ce5 authored by DevPilot's avatar DevPilot

fix: create 6 missing views and repair view-level crashes found by the smoke sweep

- ٦ شاشات كانت بتقع بـ View not found: طلب عروض الأسعار، أنواع العمل الإضافي،
  سجل عهدة الأصل، تقرير حضور المرفق، مندوب المبيعات، وأسعار العملاء الخاصة.
- مكوّن الترقيم المشترك بقى بيكمّل المفاتيح الناقصة لوحده، لأن ٢٠+ موديل
  بيبنوا مصفوفة الترقيم بإيدهم وبيبعتوا الأساسي بس.
- شاشة الملاعب بترجّع 404 لما الملعب مش موجود بدل ما تقع على null.
- تقرير الأبناء وسجل البوابة كانوا بيقروا مفاتيح مش موجودة.
parent 49ccc60a
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تقرير حضور المرفق<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/facility-grids/<?= (int) $grid_id ?>/attendance" class="btn btn-outline">تسجيل الحضور</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<?php
$typeLabels = ['player' => 'لاعب', 'member' => 'عضو', 'coach' => 'مدرب', 'guest' => 'ضيف'];
$totals = ['present' => 0, 'absent' => 0, 'late' => 0, 'excused' => 0, 'days' => 0];
foreach ($report as $r) {
$totals['present'] += (int) $r['present_count'];
$totals['absent'] += (int) $r['absent_count'];
$totals['late'] += (int) $r['late_count'];
$totals['excused'] += (int) $r['excused_count'];
$totals['days'] += (int) $r['total_days'];
}
?>
<!-- الفترة -->
<div class="card" style="margin-bottom:18px;">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;"><strong style="font-size:14px;">الفترة</strong></div>
<div style="padding:14px 16px;">
<form method="GET" style="display:flex;gap:12px;align-items:end;flex-wrap:wrap;">
<div class="form-group" style="margin:0;">
<label class="form-label" style="font-size:12px;">من تاريخ</label>
<input type="date" name="from" class="form-input" value="<?= e($date_from) ?>">
</div>
<div class="form-group" style="margin:0;">
<label class="form-label" style="font-size:12px;">إلى تاريخ</label>
<input type="date" name="to" class="form-input" value="<?= e($date_to) ?>">
</div>
<button type="submit" class="btn btn-primary">عرض</button>
</form>
</div>
</div>
<!-- ملخص -->
<div style="display:grid;grid-template-columns:repeat(5,1fr);gap:12px;margin-bottom:18px;">
<?php foreach ([
['إجمالي السجلات', $totals['days'], '#374151'],
['حاضر', $totals['present'], '#059669'],
['غائب', $totals['absent'], '#DC2626'],
['متأخر', $totals['late'], '#D97706'],
['بعذر', $totals['excused'], '#6B7280'],
] as [$label, $value, $color]): ?>
<div class="card" style="padding:12px 14px;">
<div style="color:#6B7280;font-size:11.5px;"><?= e($label) ?></div>
<div style="font-size:22px;font-weight:800;color:<?= $color ?>;"><?= (int) $value ?></div>
</div>
<?php endforeach; ?>
</div>
<!-- التفصيل -->
<div class="card">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">تفصيل لكل شخص (<?= count($report) ?>)</strong>
</div>
<?php if (!empty($report)): ?>
<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 ($report as $r): ?>
<?php
$days = max(1, (int) $r['total_days']);
$rate = round(((int) $r['present_count'] / $days) * 100);
$rateColor = $rate >= 80 ? '#059669' : ($rate >= 50 ? '#D97706' : '#DC2626');
?>
<tr>
<td style="font-weight:600;"><?= e($r['entity_name_cache'] ?: '—') ?></td>
<td><?= e($typeLabels[$r['entity_type']] ?? $r['entity_type']) ?></td>
<td><?= (int) $r['total_days'] ?></td>
<td style="color:#059669;"><?= (int) $r['present_count'] ?></td>
<td style="color:#DC2626;"><?= (int) $r['absent_count'] ?></td>
<td style="color:#D97706;"><?= (int) $r['late_count'] ?></td>
<td style="color:#6B7280;"><?= (int) $r['excused_count'] ?></td>
<td style="font-weight:700;color:<?= $rateColor ?>;"><?= $rate ?>%</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div style="padding:30px 20px;text-align:center;color:#6B7280;">
مفيش سجلات حضور في الفترة دي.
</div>
<?php endif; ?>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>أنواع العمل الإضافي<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/hr/overtime" class="btn btn-outline">طلبات العمل الإضافي</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<!-- إضافة نوع -->
<div class="card" style="margin-bottom:18px;">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">إضافة نوع عمل إضافي</strong>
</div>
<form method="POST" action="/hr/overtime/types">
<?= csrf_field() ?>
<div style="padding:14px 16px;">
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px;">
<div class="form-group">
<label class="form-label" style="font-size:12px;">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
<input type="text" name="name_ar" class="form-input" required value="<?= e(old('name_ar')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">الاسم بالإنجليزي</label>
<input type="text" name="name_en" class="form-input" value="<?= e(old('name_en')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">معامل الأجر <span style="color:#DC2626;">*</span></label>
<input type="number" step="0.01" min="1" name="rate_multiplier" class="form-input" value="<?= e(old('rate_multiplier', '1.50')) ?>" required>
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">أقصى ساعات في اليوم</label>
<input type="number" step="0.5" min="0" name="max_hours_per_day" class="form-input" value="<?= e(old('max_hours_per_day')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">أقصى ساعات في الشهر</label>
<input type="number" step="0.5" min="0" name="max_hours_per_month" class="form-input" value="<?= e(old('max_hours_per_month')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">يحتاج اعتماد</label>
<select name="requires_approval" class="form-select">
<option value="1">نعم</option>
<option value="0">لا</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">إضافة النوع</button>
</div>
</form>
</div>
<!-- الأنواع المسجّلة -->
<div class="card">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">الأنواع المسجّلة (<?= count($types) ?>)</strong>
</div>
<?php if (!empty($types)): ?>
<div class="table-responsive">
<table class="data-table">
<thead>
<tr>
<th>الاسم</th>
<th>معامل الأجر</th>
<th>أقصى ساعات/يوم</th>
<th>أقصى ساعات/شهر</th>
<th>يحتاج اعتماد</th>
<th>الحالة</th>
</tr>
</thead>
<tbody>
<?php foreach ($types as $t): ?>
<tr>
<td>
<strong><?= e($t['name_ar']) ?></strong>
<?php if (!empty($t['name_en'])): ?>
<span style="display:block;color:#6B7280;font-size:11.5px;"><?= e($t['name_en']) ?></span>
<?php endif; ?>
</td>
<td style="direction:ltr;text-align:left;font-weight:600;">× <?= e($t['rate_multiplier']) ?></td>
<td><?= $t['max_hours_per_day'] !== null ? e($t['max_hours_per_day']) : '—' ?></td>
<td><?= $t['max_hours_per_month'] !== null ? e($t['max_hours_per_month']) : '—' ?></td>
<td><?= (int) $t['requires_approval'] === 1 ? 'نعم' : 'لا' ?></td>
<td>
<?php $on = (int) ($t['is_active'] ?? 1) === 1; ?>
<span style="background:<?= $on ? '#ECFDF5' : '#F3F4F6' ?>;color:<?= $on ? '#059669' : '#6B7280' ?>;padding:2px 10px;border-radius:10px;font-size:12px;">
<?= $on ? 'نشط' : 'موقوف' ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div style="padding:30px 20px;text-align:center;color:#6B7280;">
مفيش أنواع عمل إضافي مسجّلة. ضيف نوع من الفورم فوق — المعامل هو اللي بيتحسب بيه أجر الساعة الإضافية.
</div>
<?php endif; ?>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>سجل عهدة الأصل<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/inventory/assets/custody" class="btn btn-outline">عهدة الأصول</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<?php if (empty($asset)): ?>
<div class="card"><div style="padding:30px;text-align:center;color:#6B7280;">الأصل غير موجود.</div></div>
<?php else: ?>
<!-- بيانات الأصل -->
<div class="card" style="margin-bottom:18px;">
<div style="padding:14px 18px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;"><?= e($asset['item_name'] ?: $asset['asset_tag']) ?></h3>
<p style="margin:4px 0 0;color:#6B7280;font-size:13px;">
كود الأصل: <code><?= e($asset['asset_tag']) ?></code>
</p>
</div>
<div style="padding:16px 18px;display:grid;grid-template-columns:repeat(4,1fr);gap:14px;font-size:13px;">
<div>
<div style="color:#6B7280;font-size:11px;">الموقع الحالي</div>
<strong><?= e($asset['site_location'] ?: '—') ?></strong>
</div>
<div>
<div style="color:#6B7280;font-size:11px;">تاريخ العهدة</div>
<strong><?= e($asset['custody_date'] ?: '—') ?></strong>
</div>
<div>
<div style="color:#6B7280;font-size:11px;">القيمة الدفترية</div>
<strong style="direction:ltr;display:inline-block;"><?= money($asset['book_value'] ?? 0) ?></strong>
</div>
<div>
<div style="color:#6B7280;font-size:11px;">الحالة</div>
<strong><?= e($asset['status'] ?: '—') ?></strong>
</div>
</div>
</div>
<!-- سجل التنقلات -->
<div class="card">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;display:flex;justify-content:space-between;align-items:center;">
<strong style="font-size:14px;">سجل تنقلات العهدة (<?= count($history) ?>)</strong>
<span style="font-size:12px;color:#6B7280;">كل نقل بيتسجّل بتاريخه ومين نقله — مفيش حركة بتتحذف</span>
</div>
<?php if (!empty($history)): ?>
<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 ($history as $h): ?>
<tr>
<td style="white-space:nowrap;"><?= e($h['transfer_date'] ?: '—') ?></td>
<td><?= e($h['from_employee_name'] ?: '—') ?></td>
<td style="font-weight:600;"><?= e($h['to_employee_name'] ?: '—') ?></td>
<td style="font-size:12.5px;color:#6B7280;"><?= e($h['from_location'] ?: '—') ?></td>
<td style="font-size:12.5px;"><?= e($h['to_location'] ?: '—') ?></td>
<td style="font-size:12.5px;"><?= e($h['reason'] ?: '—') ?></td>
<td style="font-size:12.5px;color:#6B7280;"><?= e($h['created_by_name'] ?: '—') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div style="padding:30px 20px;text-align:center;color:#6B7280;">
الأصل ده لسه ما اتنقلش بين عُهد. أول نقل هيظهر هنا بتاريخه.
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php $__template->endSection(); ?>
......@@ -230,7 +230,8 @@ final class AutoFreezeService
$sixMonthsLater = $today->modify('+6 months');
$children = $db->select(
"SELECT c.id, c.full_name_ar, c.date_of_birth, c.gender, c.member_id, m.full_name_ar as parent_name
"SELECT c.id, c.full_name_ar, c.date_of_birth, c.gender, c.member_id,
m.full_name_ar as parent_name, m.membership_number
FROM children c
JOIN members m ON m.id = c.member_id AND m.is_archived = 0
WHERE c.gender = 'male'
......@@ -251,6 +252,10 @@ final class AutoFreezeService
$nearThreshold[] = [
'child_id' => (int) $child['id'],
'name' => $child['full_name_ar'],
// الشاشة بتقرا بالأسماء دي، فبنرجّعها جنب المفاتيح القديمة
'full_name_ar' => $child['full_name_ar'],
'date_of_birth' => $child['date_of_birth'],
'membership_number' => $child['membership_number'],
'parent_name' => $child['parent_name'],
'member_id' => (int) $child['member_id'],
'current_age' => $currentAge,
......
......@@ -24,6 +24,9 @@ final class PlaygroundScheduleController extends Controller
$db = App::getInstance()->db();
$playground = $db->selectOne("SELECT * FROM playground_configurations WHERE id = ?", [(int) $id]);
if (!$playground) {
throw new \RuntimeException('الملعب غير موجود', 404);
}
return $this->view('PlaygroundAdmin.Views.schedules', [
'playground' => $playground,
......@@ -36,6 +39,9 @@ final class PlaygroundScheduleController extends Controller
$this->authorize('playground.schedule');
$db = App::getInstance()->db();
$playground = $db->selectOne("SELECT * FROM playground_configurations WHERE id = ?", [(int) $id]);
if (!$playground) {
throw new \RuntimeException('الملعب غير موجود', 404);
}
return $this->view('PlaygroundAdmin.Views.schedule_edit', [
'playground' => $playground,
......@@ -75,6 +81,9 @@ final class PlaygroundScheduleController extends Controller
$db = App::getInstance()->db();
$playground = $db->selectOne("SELECT * FROM playground_configurations WHERE id = ?", [(int) $id]);
if (!$playground) {
throw new \RuntimeException('الملعب غير موجود', 404);
}
$schedule = $db->selectOne("SELECT * FROM playground_monthly_schedules WHERE id = ? AND playground_id = ?", [(int) $schedId, (int) $id]);
if (!$schedule) {
......@@ -98,6 +107,9 @@ final class PlaygroundScheduleController extends Controller
$db = App::getInstance()->db();
$playground = $db->selectOne("SELECT * FROM playground_configurations WHERE id = ?", [(int) $id]);
if (!$playground) {
throw new \RuntimeException('الملعب غير موجود', 404);
}
$schedule = $db->selectOne("SELECT * FROM playground_monthly_schedules WHERE id = ? AND playground_id = ?", [(int) $schedId, (int) $id]);
return $this->view('PlaygroundAdmin.Views.schedule_edit', [
......@@ -140,6 +152,9 @@ final class PlaygroundScheduleController extends Controller
$db = App::getInstance()->db();
$playground = $db->selectOne("SELECT * FROM playground_configurations WHERE id = ?", [(int) $id]);
if (!$playground) {
throw new \RuntimeException('الملعب غير موجود', 404);
}
$slots = PlaygroundScheduleSlot::getForDateAndHour((int) $schedId, $date, $hour . ':00');
$coaches = $db->select("SELECT id, full_name_ar AS name_ar FROM coaches WHERE is_archived = 0 ORDER BY full_name_ar");
......
......@@ -46,7 +46,7 @@ class VendorPaymentController extends Controller
ORDER BY vi.`due_date` ASC"
);
$bankAccounts = $db->select("SELECT * FROM `bank_accounts` WHERE `is_active` = 1 ORDER BY `name_ar`");
$bankAccounts = $db->select("SELECT * FROM `bank_accounts` WHERE `is_active` = 1 ORDER BY `account_name_ar`");
return $this->view('Procurement.Views.payments.form', [
'suppliers' => Supplier::allActive(),
......
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>طلب عروض أسعار<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/procurement/quotes" class="btn btn-outline">عروض الأسعار</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<!-- اختيار طلب الشراء -->
<div class="card" style="margin-bottom:18px;">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">١. اختار طلب الشراء</strong>
</div>
<div style="padding:14px 16px;">
<form method="GET" action="/procurement/quotes/request" style="display:flex;gap:10px;align-items:end;flex-wrap:wrap;">
<div class="form-group" style="flex:1;margin:0;min-width:280px;">
<label class="form-label" style="font-size:12px;">طلب الشراء المعتمد</label>
<select name="requisition_id" class="form-select" onchange="this.form.submit()">
<option value="">— اختار طلب شراء —</option>
<?php foreach ($requisitions as $r): ?>
<option value="<?= (int) $r['id'] ?>" <?= !empty($requisition) && (int) $requisition['id'] === (int) $r['id'] ? 'selected' : '' ?>>
<?= e($r['requisition_number']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<button type="submit" class="btn btn-outline">عرض</button>
</form>
<?php if (empty($requisitions)): ?>
<p style="margin:10px 0 0;color:#6B7280;font-size:13px;">
مفيش طلبات شراء معتمدة دلوقتي. لازم الطلب يتعتمد الأول عشان تقدر تطلب عليه عروض أسعار.
</p>
<?php endif; ?>
</div>
</div>
<?php if (!empty($requisition)): ?>
<!-- أصناف الطلب -->
<div class="card" style="margin-bottom:18px;">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;display:flex;justify-content:space-between;align-items:center;">
<strong style="font-size:14px;">أصناف الطلب <?= e($requisition['pr_number'] ?? '') ?></strong>
<span style="font-size:12px;color:#6B7280;">عدد الأصناف: <?= count($requisitionItems) ?></span>
</div>
<?php if (!empty($requisitionItems)): ?>
<div class="table-responsive">
<table class="data-table">
<thead>
<tr><th>الصنف</th><th>الكود</th><th>الكمية</th><th>التقدير</th></tr>
</thead>
<tbody>
<?php foreach ($requisitionItems as $it): ?>
<tr>
<td><?= e($it['item_name'] ?? '—') ?></td>
<td><code style="font-size:12px;"><?= e($it['sku'] ?? '—') ?></code></td>
<td><?= e($it['quantity'] ?? '—') ?></td>
<td style="direction:ltr;text-align:left;"><?= isset($it['estimated_line_total']) ? money($it['estimated_line_total']) : '—' ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div style="padding:24px;text-align:center;color:#6B7280;">مفيش أصناف على الطلب ده.</div>
<?php endif; ?>
</div>
<!-- اختيار الموردين -->
<div class="card">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">٢. اختار الموردين اللي هتطلب منهم عروض</strong>
</div>
<form method="POST" action="/procurement/quotes/request">
<?= csrf_field() ?>
<input type="hidden" name="requisition_id" value="<?= (int) $requisition['id'] ?>">
<div style="padding:14px 16px;">
<?php if (!empty($suppliers)): ?>
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;">
<?php foreach ($suppliers as $sup): ?>
<label style="display:flex;align-items:center;gap:8px;border:1px solid #E5E7EB;border-radius:6px;padding:10px 12px;cursor:pointer;">
<input type="checkbox" name="supplier_ids[]" value="<?= (int) $sup['id'] ?>">
<span>
<span style="font-weight:600;font-size:13px;"><?= e($sup['name_ar']) ?></span>
<span style="display:block;color:#6B7280;font-size:11.5px;"><?= e($sup['code'] ?? '') ?></span>
</span>
</label>
<?php endforeach; ?>
</div>
<p style="margin:12px 0 0;color:#6B7280;font-size:12.5px;">
كل مورد بتختاره هيتفتح له ملف عرض سعر لوحده — حتى لو رفض أو ما ردّش، الملف بيفضل متسجّل.
</p>
<button type="submit" class="btn btn-primary" style="margin-top:12px;">إرسال طلبات عروض الأسعار</button>
<?php else: ?>
<p style="margin:0;color:#6B7280;font-size:13px;">مفيش موردين مسجّلين ونشطين. سجّل مورد الأول من شاشة الموردين.</p>
<?php endif; ?>
</div>
</form>
</div>
<?php endif; ?>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>أسعار العملاء الخاصة<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/sales/commissions/representatives" class="btn btn-outline">مندوبو المبيعات</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;display:flex;justify-content:space-between;align-items:center;">
<strong style="font-size:14px;">الأسعار الخاصة السارية (<?= count($prices) ?>)</strong>
<span style="font-size:12px;color:#6B7280;">السعر الخاص بيسبق سعر البيع العادي وقت إصدار الفاتورة</span>
</div>
<?php if (!empty($prices)): ?>
<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 ($prices as $p): ?>
<tr>
<td style="font-weight:600;"><?= e($p['member_name'] ?: '—') ?></td>
<td><?= e($p['item_name'] ?: '—') ?></td>
<td style="font-size:12.5px;color:#6B7280;"><?= e($p['list_name'] ?: '—') ?></td>
<td style="font-size:12.5px;">
<?php
$types = ['fixed_price' => 'سعر ثابت', 'percentage' => 'نسبة خصم', 'amount' => 'خصم بمبلغ'];
echo e($types[$p['discount_type'] ?? ''] ?? ($p['discount_type'] ?: '—'));
?>
</td>
<td style="direction:ltr;text-align:left;font-weight:700;">
<?= $p['special_price'] !== null ? money($p['special_price']) : '—' ?>
</td>
<td style="white-space:nowrap;"><?= e($p['start_date'] ?: '—') ?></td>
<td style="white-space:nowrap;"><?= e($p['end_date'] ?: 'مفتوح') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div style="padding:30px 20px;text-align:center;color:#6B7280;">
مفيش أسعار خاصة سارية دلوقتي. الأسعار الخاصة بتتسجّل لكل عضو على مستوى الصنف.
</div>
<?php endif; ?>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= empty($rep) ? 'إضافة مندوب مبيعات' : 'تعديل مندوب المبيعات' ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/sales/commissions/representatives" class="btn btn-outline">مندوبو المبيعات</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="max-width:860px;">
<div style="padding:12px 16px;border-bottom:1px solid #E5E7EB;">
<strong style="font-size:14px;">بيانات المندوب</strong>
</div>
<form method="POST" action="/sales/commissions/representatives">
<?= csrf_field() ?>
<div style="padding:14px 16px;">
<div style="display:grid;grid-template-columns:repeat(2,1fr);gap:12px;">
<div class="form-group">
<label class="form-label" style="font-size:12px;">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
<input type="text" name="name_ar" class="form-input" required
value="<?= e(old('name_ar', $rep['name_ar'] ?? '')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">الاسم بالإنجليزي</label>
<input type="text" name="name_en" class="form-input"
value="<?= e(old('name_en', $rep['name_en'] ?? '')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">الكود <span style="color:#DC2626;">*</span></label>
<input type="text" name="code" class="form-input" required
value="<?= e(old('code', $rep['code'] ?? '')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">الموظف المرتبط</label>
<select name="employee_id" class="form-select">
<option value="">— غير مرتبط بموظف —</option>
<?php foreach ($employees as $emp): ?>
<option value="<?= (int) $emp['id'] ?>"
<?= (int) ($rep['employee_id'] ?? 0) === (int) $emp['id'] ? 'selected' : '' ?>>
<?= e($emp['full_name_ar']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">التليفون</label>
<input type="text" name="phone" class="form-input"
value="<?= e(old('phone', $rep['phone'] ?? '')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">البريد الإلكتروني</label>
<input type="email" name="email" class="form-input"
value="<?= e(old('email', $rep['email'] ?? '')) ?>">
</div>
</div>
<hr style="margin:16px 0;border:none;border-top:1px solid #E5E7EB;">
<strong style="font-size:13px;display:block;margin-bottom:10px;">العمولة</strong>
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px;">
<div class="form-group">
<label class="form-label" style="font-size:12px;">نوع العمولة</label>
<select name="commission_type" class="form-select">
<option value="percentage" <?= ($rep['commission_type'] ?? 'percentage') === 'percentage' ? 'selected' : '' ?>>نسبة من قيمة البيع</option>
<option value="fixed" <?= ($rep['commission_type'] ?? '') === 'fixed' ? 'selected' : '' ?>>مبلغ ثابت لكل عملية</option>
</select>
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">قيمة العمولة</label>
<input type="number" step="0.01" min="0" name="commission_rate" class="form-input"
value="<?= e(old('commission_rate', $rep['commission_rate'] ?? '0')) ?>">
</div>
<div class="form-group">
<label class="form-label" style="font-size:12px;">التارجت الشهري</label>
<input type="number" step="0.01" min="0" name="target_amount" class="form-input"
value="<?= e(old('target_amount', $rep['target_amount'] ?? '')) ?>">
</div>
</div>
<button type="submit" class="btn btn-primary">حفظ المندوب</button>
</div>
</form>
</div>
<?php $__template->endSection(); ?>
......@@ -81,9 +81,9 @@
</table>
</div>
<?php if (isset($pagination) && $pagination && $pagination['total_pages'] > 1): ?>
<?php if (isset($pagination) && $pagination && $pagination['last_page'] > 1): ?>
<div style="margin-top:15px;display:flex;justify-content:center;gap:5px;">
<?php for ($p = 1; $p <= $pagination['total_pages']; $p++): ?>
<?php for ($p = 1; $p <= $pagination['last_page']; $p++): ?>
<a href="?<?= http_build_query(array_merge($filters, ['page' => $p])) ?>" class="btn <?= $p === $pagination['current_page'] ? 'btn-primary' : 'btn-outline' ?>" style="padding:6px 12px;font-size:12px;"><?= $p ?></a>
<?php endfor; ?>
</div>
......
......@@ -85,9 +85,13 @@ class SportsDashboardController extends Controller
// Session count
$sessionCount = $db->selectOne("
SELECT COUNT(*) AS cnt FROM facility_zone_schedules
WHERE discipline_id = ? AND schedule_date BETWEEN ? AND ?
", [(int) $id, $start, $end]);
SELECT COUNT(*) AS cnt
FROM facility_zone_schedules fzs
JOIN sport_disciplines d ON d.code = fzs.activity_type
WHERE d.id = ?
AND fzs.effective_from <= ?
AND (fzs.effective_to IS NULL OR fzs.effective_to >= ?)
", [(int) $id, $end, $start]);
// Linked academies
$academies = $db->select("
......
......@@ -9,6 +9,43 @@ $pagination = $pagination ?? [];
if (empty($pagination) || ($pagination['last_page'] ?? 1) <= 1) return;
$baseUrl = $baseUrl ?? '?';
$separator = str_contains($baseUrl, '?') ? '&' : '?';
// في أماكن كتير بيبنوا مصفوفة الترقيم بإيدهم وبيبعتوا الأساسي بس
// (current_page / last_page / per_page / total). فبنكمّل الباقي هنا بدل
// ما الشاشة تقع على مفتاح ناقص.
$pagination['current_page'] = (int) ($pagination['current_page'] ?? 1);
$pagination['last_page'] = (int) ($pagination['last_page'] ?? 1);
$pagination['per_page'] = (int) ($pagination['per_page'] ?? 25);
$pagination['total'] = (int) ($pagination['total'] ?? 0);
if (!isset($pagination['from'])) {
$pagination['from'] = $pagination['total'] === 0
? 0
: (($pagination['current_page'] - 1) * $pagination['per_page']) + 1;
}
if (!isset($pagination['to'])) {
$pagination['to'] = min($pagination['current_page'] * $pagination['per_page'], $pagination['total']);
}
$pagination['has_prev'] = $pagination['has_prev'] ?? ($pagination['current_page'] > 1);
$pagination['has_next'] = $pagination['has_next'] ?? ($pagination['current_page'] < $pagination['last_page']);
$pagination['prev_page'] = $pagination['prev_page'] ?? ($pagination['current_page'] > 1 ? $pagination['current_page'] - 1 : null);
$pagination['next_page'] = $pagination['next_page'] ?? ($pagination['current_page'] < $pagination['last_page'] ? $pagination['current_page'] + 1 : null);
if (!isset($pagination['pages'])) {
$pages = [];
$start = max(1, $pagination['current_page'] - 2);
$end = min($pagination['last_page'], $pagination['current_page'] + 2);
if ($start > 1) {
$pages[] = 1;
if ($start > 2) $pages[] = '...';
}
for ($i = $start; $i <= $end; $i++) $pages[] = $i;
if ($end < $pagination['last_page']) {
if ($end < $pagination['last_page'] - 1) $pages[] = '...';
$pages[] = $pagination['last_page'];
}
$pagination['pages'] = $pages;
}
?>
<nav class="pagination-wrapper">
<div class="pagination-info">
......
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