39414-vm/admin.php
2026-03-31 10:39:17 +00:00

164 lines
12 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/queue_bootstrap.php';
qh_boot();
qh_admin_handle_request();
$stats = qh_admin_stats();
$clinics = qh_fetch_clinics();
$doctors = qh_fetch_doctors();
$recentClinics = array_slice($clinics, 0, 4);
$recentDoctors = array_slice($doctors, 0, 5);
$profile = qh_fetch_hospital_profile();
qh_page_start(
'admin',
qh_t('Admin overview', 'نظرة عامة للإدارة'),
qh_t('Structured admin overview with separate pages for clinics and doctors.', 'نظرة عامة منظمة للإدارة مع صفحات مستقلة للعيادات والأطباء.')
);
?>
<div class="container-xxl px-3 px-lg-4">
<div class="admin-layout">
<aside class="admin-sidebar-column">
<?php qh_render_admin_sidebar('admin.php', $stats); ?>
</aside>
<div class="admin-content-stack">
<section class="page-header-panel admin-hero-panel mb-0">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Admin overview', 'نظرة عامة للإدارة')) ?></span>
<div class="locale-chip mt-3"><?= qh_h(qh_current_language_badge()) ?></div>
<h1 class="section-title-xl mt-2 mb-2"><?= qh_h(qh_t('A cleaner admin center with separate management pages.', 'مركز إدارة أنظف مع صفحات إدارة منفصلة.')) ?></h1>
<p class="section-copy mb-0"><?= qh_h(qh_t('Use the left sidebar to open focused pages for clinics and doctors instead of working in one long page.', 'استخدم الشريط الجانبي لفتح صفحات مركزة للعيادات والأطباء بدلاً من العمل داخل صفحة واحدة طويلة.')) ?></p>
</div>
</section>
<section class="panel-card admin-section-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('System snapshot', 'ملخص النظام')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('Current queue configuration', 'إعداد نظام الطوابير الحالي')) ?></h2>
<p class="section-copy mb-0"><?= qh_h(qh_t('Quick numbers and shortcuts for the main admin tasks.', 'أرقام سريعة واختصارات لمهام الإدارة الأساسية.')) ?></p>
</div>
</div>
<div class="admin-overview-grid mt-4">
<article class="mini-overview-card admin-overview-card"><span class="workflow-step"><?= qh_h(qh_t('Clinics', 'العيادات')) ?></span><strong><?= qh_h((string) $stats['clinics']) ?></strong><p><?= qh_h(qh_t('Configured destinations used by reception and routing.', 'الوجهات المهيأة التي يستخدمها الاستقبال ومسار المريض.')) ?></p></article>
<article class="mini-overview-card admin-overview-card"><span class="workflow-step"><?= qh_h(qh_t('Doctors', 'الأطباء')) ?></span><strong><?= qh_h((string) $stats['doctors']) ?></strong><p><?= qh_h(qh_t('Doctors currently assigned to rooms and clinics.', 'الأطباء المعينون حالياً للغرف والعيادات.')) ?></p></article>
<article class="mini-overview-card admin-overview-card"><span class="workflow-step"><?= qh_h(qh_t('Vitals first', 'العلامات أولاً')) ?></span><strong><?= qh_h((string) $stats['vitals_clinics']) ?></strong><p><?= qh_h(qh_t('Clinics that must pass through nursing before the doctor.', 'العيادات التي تمر على التمريض قبل الطبيب.')) ?></p></article>
<article class="mini-overview-card admin-overview-card"><span class="workflow-step"><?= qh_h(qh_t('Direct doctor', 'الطبيب مباشرة')) ?></span><strong><?= qh_h((string) $stats['direct_clinics']) ?></strong><p><?= qh_h(qh_t('Clinics that route patients directly to the doctor queue.', 'العيادات التي توجه المرضى مباشرة إلى انتظار الطبيب.')) ?></p></article>
</div>
</section>
<section class="admin-card-grid admin-card-grid-triple">
<article class="panel-card admin-link-card">
<span class="section-kicker"><?= qh_h(qh_t('Branding', 'الهوية')) ?></span>
<h2 class="section-title mt-2 mb-2"><?= qh_h(qh_t('Hospital profile', 'ملف المستشفى')) ?></h2>
<p class="section-copy mb-4"><?= qh_h(qh_t('Update the hospital logo, favicon, contact details, working hours, and brand colors from a dedicated profile page.', 'حدّث شعار المستشفى والأيقونة وبيانات التواصل وساعات العمل وألوان الهوية من صفحة ملف مستقلة.')) ?></p>
<a class="btn btn-dark" href="<?= qh_h(qh_url('admin_hospital.php')) ?>"><?= qh_h(qh_t('Open profile page', 'فتح صفحة الملف')) ?></a>
</article>
<article class="panel-card admin-link-card">
<span class="section-kicker"><?= qh_h(qh_t('Directory', 'الدليل')) ?></span>
<h2 class="section-title mt-2 mb-2"><?= qh_h(qh_t('Manage clinics', 'إدارة العيادات')) ?></h2>
<p class="section-copy mb-4"><?= qh_h(qh_t('Create clinics, define codes, set routing, and edit the display order from a dedicated page.', 'أنشئ العيادات وحدد الرموز ومسار العمل وعدّل ترتيب العرض من صفحة مستقلة.')) ?></p>
<a class="btn btn-dark" href="<?= qh_h(qh_url('admin_clinics.php')) ?>"><?= qh_h(qh_t('Open clinics page', 'فتح صفحة العيادات')) ?></a>
</article>
<article class="panel-card admin-link-card">
<span class="section-kicker"><?= qh_h(qh_t('Directory', 'الدليل')) ?></span>
<h2 class="section-title mt-2 mb-2"><?= qh_h(qh_t('Manage doctors', 'إدارة الأطباء')) ?></h2>
<p class="section-copy mb-4"><?= qh_h(qh_t('Search the doctor list, update room assignments, and manage records with edit and delete actions.', 'ابحث في قائمة الأطباء وحدّث الغرف والتعيينات وأدر السجلات بخيارات التعديل والحذف.')) ?></p>
<a class="btn btn-dark" href="<?= qh_h(qh_url('admin_doctors.php')) ?>"><?= qh_h(qh_t('Open doctors page', 'فتح صفحة الأطباء')) ?></a>
</article>
</section>
<div class="admin-card-grid admin-card-grid-secondary admin-card-grid-triple">
<section class="panel-card admin-section-card hospital-overview-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Hospital profile', 'ملف المستشفى')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_hospital_name()) ?></h2>
</div>
<a class="btn btn-sm btn-outline-dark" href="<?= qh_h(qh_url('admin_hospital.php')) ?>"><?= qh_h(qh_t('Edit profile', 'تعديل الملف')) ?></a>
</div>
<div class="vstack gap-3 mt-4">
<div class="admin-summary-row">
<div>
<div class="fw-semibold"><?= qh_h(qh_t('Short name', 'الاسم المختصر')) ?></div>
<div class="small text-secondary"><?= qh_h((string) ($profile['short_name'] ?? qh_t('Not set yet', 'غير محدد بعد'))) ?></div>
</div>
<span class="table-pill info"><?= qh_h(qh_t('Brand ready', 'الهوية جاهزة')) ?></span>
</div>
<div class="admin-summary-row">
<div>
<div class="fw-semibold"><?= qh_h(qh_t('Phone', 'الهاتف')) ?></div>
<div class="small text-secondary"><?= qh_h((string) (($profile['phone'] ?? '') !== '' ? $profile['phone'] : qh_t('Add a contact number', 'أضف رقم تواصل'))) ?></div>
</div>
<span class="room-badge"><?= qh_h(qh_t('Hours', 'الساعات')) ?></span>
</div>
<div class="admin-summary-row">
<div>
<div class="fw-semibold"><?= qh_h(qh_t('Working hours', 'ساعات العمل')) ?></div>
<div class="small text-secondary"><?= qh_h(qh_name($profile, 'working_hours', qh_t('Set your opening hours', 'حدّد ساعات العمل'))) ?></div>
</div>
<span class="table-pill dark"><?= qh_h(qh_t('Shared app branding', 'هوية مشتركة للتطبيق')) ?></span>
</div>
</div>
</section>
<section class="panel-card admin-section-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Clinic preview', 'معاينة العيادات')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('Latest clinic setup', 'أحدث إعدادات العيادات')) ?></h2>
</div>
<a class="btn btn-sm btn-outline-dark" href="<?= qh_h(qh_url('admin_clinics.php')) ?>"><?= qh_h(qh_t('View all', 'عرض الكل')) ?></a>
</div>
<?php if ($recentClinics === []): ?>
<div class="empty-state compact mt-4"><strong><?= qh_h(qh_t('No clinics configured yet.', 'لم يتم إعداد أي عيادات بعد.')) ?></strong><span><?= qh_h(qh_t('Open the clinics page to add your first clinic.', 'افتح صفحة العيادات لإضافة أول عيادة.')) ?></span></div>
<?php else: ?>
<div class="vstack gap-3 mt-4">
<?php foreach ($recentClinics as $clinic): ?>
<div class="admin-summary-row">
<div>
<div class="fw-semibold"><?= qh_h(qh_name($clinic)) ?></div>
<div class="small text-secondary"><?= qh_h(qh_t('Code', 'الرمز')) ?>: <?= qh_h((string) $clinic['code']) ?></div>
</div>
<span class="table-pill <?= (int) $clinic['requires_vitals'] === 1 ? 'warning' : 'info' ?>"><?= qh_h((int) $clinic['requires_vitals'] === 1 ? qh_t('Vitals first', 'العلامات أولاً') : qh_t('Direct doctor', 'الطبيب مباشرة')) ?></span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="panel-card admin-section-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Doctor preview', 'معاينة الأطباء')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('Latest doctor assignments', 'أحدث تعيينات الأطباء')) ?></h2>
</div>
<a class="btn btn-sm btn-outline-dark" href="<?= qh_h(qh_url('admin_doctors.php')) ?>"><?= qh_h(qh_t('View all', 'عرض الكل')) ?></a>
</div>
<?php if ($recentDoctors === []): ?>
<div class="empty-state compact mt-4"><strong><?= qh_h(qh_t('No doctors configured yet.', 'لم يتم إعداد أي أطباء بعد.')) ?></strong><span><?= qh_h(qh_t('Open the doctors page to add your first doctor profile.', 'افتح صفحة الأطباء لإضافة أول ملف طبيب.')) ?></span></div>
<?php else: ?>
<div class="vstack gap-3 mt-4">
<?php foreach ($recentDoctors as $doctor): ?>
<div class="admin-summary-row">
<div>
<div class="fw-semibold"><?= qh_h(qh_name($doctor)) ?></div>
<div class="small text-secondary"><?= qh_h(qh_name($doctor, 'clinic_name', qh_t('Unassigned clinic', 'عيادة غير محددة'))) ?></div>
</div>
<span class="room-badge"><?= qh_h(qh_t('Room', 'الغرفة')) ?> <?= qh_h((string) $doctor['room_number']) ?></span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
</div>
</div>
</div>
</div>
<?php qh_page_end(); ?>