39669-vm/applications.php
2026-04-16 06:19:26 +00:00

89 lines
4.1 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());
render_page_start('لوحة الطلبات', 'applications', 'قائمة موحدة لطلبات فتح المراكز الصيفية مع فلترة حسب حالة المراجعة.');
render_flash($flash);
?>
<section class="py-4 py-lg-5">
<div class="container-xxl">
<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">
<?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>
<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>
<a class="btn btn-dark" href="center_application.php">إنشاء طلب</a>
</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>
</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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php render_page_end(); ?>