39669-vm/applications.php
2026-04-16 06:58:53 +00:00

131 lines
7.7 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/app.php';
$flash = consume_flash();
$statusFilter = clean_text((string) ($_GET['status'] ?? 'all'), 50);
$applications = list_applications($statusFilter);
$stats = dashboard_metrics();
$statusTabs = ['all' => 'الكل'] + array_map(fn ($meta) => $meta['label'], status_map());
$currentCount = count($applications);
$reviewBacklog = $stats['submitted'] + $stats['under_review'];
$approvalRate = $stats['all'] > 0 ? (int) round(($stats['approved'] / $stats['all']) * 100) : 0;
render_page_start('لوحة الطلبات', 'applications', 'قائمة موحدة لطلبات فتح المراكز الصيفية مع فلترة حسب حالة المراجعة.');
render_flash($flash);
?>
<section class="py-4 py-lg-5">
<div class="container-xxl">
<div class="page-banner mb-4 mb-lg-5">
<div class="row g-4 align-items-start">
<div class="col-lg-8">
<span class="eyebrow mb-3">صفحة مستقلة للمراجعة</span>
<h1 class="page-title mb-3">لوحة طلبات فتح المراكز</h1>
<p class="page-copy mb-0">تم تخصيص هذه الصفحة بالكامل لمتابعة الطلبات: مؤشرات سريعة، فلاتر واضحة، وجدول مراجعة عملي يقود مباشرة إلى صفحة التفاصيل واتخاذ القرار.</p>
</div>
<div class="col-lg-4">
<div class="page-banner-panel h-100">
<div class="mini-stat-label">الحمل التشغيلي الحالي</div>
<div class="mini-stat-value"><?= e((string) $reviewBacklog) ?></div>
<div class="mini-stat-copy">طلبات تحتاج عملاً من المشرف العام الآن، مع نسبة اعتماد إجمالية تبلغ <?= e((string) $approvalRate) ?>٪.</div>
</div>
</div>
</div>
</div>
<div class="row g-3 mb-4">
<div class="col-md-6 col-xl-3"><div class="app-card stat-tile"><div class="mini-stat-label">إجمالي الطلبات</div><div class="mini-stat-value"><?= e((string) $stats['all']) ?></div><div class="mini-stat-copy">جميع الطلبات في قاعدة البيانات.</div></div></div>
<div class="col-md-6 col-xl-3"><div class="app-card stat-tile"><div class="mini-stat-label">بانتظار الاستلام</div><div class="mini-stat-value"><?= e((string) $stats['submitted']) ?></div><div class="mini-stat-copy">طلبات جديدة لم يبدأ تقييمها بعد.</div></div></div>
<div class="col-md-6 col-xl-3"><div class="app-card stat-tile"><div class="mini-stat-label">تحت المراجعة</div><div class="mini-stat-value"><?= e((string) $stats['under_review']) ?></div><div class="mini-stat-copy">ملفات قيد التحقق والملاحظات.</div></div></div>
<div class="col-md-6 col-xl-3"><div class="app-card stat-tile"><div class="mini-stat-label">معتمد</div><div class="mini-stat-value"><?= e((string) $stats['approved']) ?></div><div class="mini-stat-copy">مراكز جاهزة للانتقال لمرحلة التشغيل.</div></div></div>
</div>
<div class="app-card mb-4">
<div class="section-head flex-column flex-lg-row align-items-start align-items-lg-center gap-3 mb-3">
<div>
<div class="section-title">أدوات الفرز والمتابعة</div>
<div class="section-copy">اختر حالة محددة للتركيز على شريحة واحدة من الطلبات، أو ارجع إلى الكل لمراجعة الصورة العامة.</div>
</div>
<div class="d-flex flex-wrap gap-2">
<a class="btn btn-dark btn-sm px-3" href="center_application.php">طلب جديد</a>
<a class="btn btn-outline-secondary btn-sm px-3" href="applications.php">إعادة ضبط</a>
</div>
</div>
<div class="filter-pills mb-3">
<?php foreach ($statusTabs as $value => $label): ?>
<a class="filter-pill <?= $statusFilter === $value ? 'active' : '' ?>" href="applications.php?status=<?= e($value) ?>">
<?= e($label) ?>
<span class="pill-count">
<?= e((string) ($value === 'all' ? $stats['all'] : ($stats[$value] ?? 0))) ?>
</span>
</a>
<?php endforeach; ?>
</div>
<div class="table-toolbar">
<div class="table-toolbar-copy">الفلتر الحالي: <strong><?= e($statusTabs[$statusFilter] ?? 'الكل') ?></strong></div>
<div class="table-toolbar-copy">عدد السجلات المعروضة: <strong><?= e((string) $currentCount) ?></strong></div>
</div>
</div>
<div class="app-card">
<?php if ($applications === []): ?>
<div class="empty-state text-center py-5">
<div class="empty-title mb-2">لا توجد طلبات ضمن هذا التصنيف.</div>
<p class="text-muted mb-3">يمكنك إنشاء طلب جديد أو العودة إلى جميع الطلبات لاستكمال المراجعة.</p>
<div class="d-flex flex-wrap justify-content-center gap-2">
<a class="btn btn-dark" href="center_application.php">إنشاء طلب</a>
<a class="btn btn-outline-secondary" href="applications.php">عرض الكل</a>
</div>
</div>
<?php else: ?>
<div class="table-responsive">
<table class="table app-table align-middle mb-0">
<thead>
<tr>
<th>المرجع</th>
<th>المركز</th>
<th>المدينة</th>
<th>المسؤول</th>
<th>الفترة</th>
<th>الحالة</th>
<th>التقييم</th>
<th>إجراء</th>
</tr>
</thead>
<tbody>
<?php foreach ($applications as $application): ?>
<tr>
<td><a class="table-link" href="application_detail.php?id=<?= e((string) $application['id']) ?>">#<?= e((string) $application['id']) ?></a></td>
<td>
<div class="fw-semibold"><?= e((string) $application['center_name']) ?></div>
<div class="text-muted small">سعة متوقعة: <?= e((string) $application['expected_students']) ?> طالب</div>
</td>
<td><?= e((string) $application['city']) ?></td>
<td>
<div><?= e((string) $application['director_name']) ?></div>
<div class="text-muted small"><?= e((string) $application['phone']) ?></div>
</td>
<td>
<div><?= e((string) $application['start_date']) ?></div>
<div class="text-muted small">حتى <?= e((string) $application['end_date']) ?></div>
</td>
<td><?= status_badge((string) $application['status']) ?></td>
<td><?= $application['evaluation_score'] !== null ? e((string) $application['evaluation_score']) . '%' : '—' ?></td>
<td>
<?php if ((string) $application['status'] === 'approved'): ?>
<a class="btn btn-dark btn-sm px-3" href="approved_school.php?id=<?= e((string) $application['id']) ?>">صفحة المركز</a>
<?php else: ?>
<a class="btn btn-outline-secondary btn-sm px-3" href="application_detail.php?id=<?= e((string) $application['id']) ?>">فتح الملف</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php render_page_end(); ?>