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

123 lines
7.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
require_once __DIR__ . '/queue_bootstrap.php';
qh_boot();
qh_reception_handle_request();
$clinics = qh_fetch_clinics();
$doctors = qh_fetch_doctors();
$currentTicket = isset($_GET['ticket_id']) ? qh_fetch_ticket((int) $_GET['ticket_id']) : null;
$todayTickets = qh_fetch_tickets(['waiting_vitals', 'ready_for_doctor', 'called', 'in_progress', 'done', 'no_show'], null, 12);
qh_page_start(
'reception',
qh_t('Reception ticket issuance', 'إصدار التذاكر في الاستقبال'),
qh_t('Reception page with separated language views.', 'صفحة الاستقبال مع فصل واضح بين اللغتين.')
);
?>
<div class="container-xxl px-3 px-lg-4">
<section class="page-header-panel mb-4">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Reception', 'الاستقبال')) ?></span>
<div class="locale-chip mt-3"><?= qh_h(qh_current_language_badge()) ?></div>
<h1 class="section-title-xl mt-2"><?= qh_h(qh_t('Issue one ticket for the full visit.', 'أصدر تذكرة واحدة لكامل الزيارة.')) ?></h1>
<p class="section-copy mb-0"><?= qh_h(qh_t('Reception selects the clinic and doctor once. The system routes to nursing only when the clinic requires vitals.', 'يقوم الاستقبال باختيار العيادة والطبيب مرة واحدة. ويوجه النظام إلى التمريض فقط عندما تتطلب العيادة العلامات الحيوية.')) ?></p>
</div>
</section>
<div class="row g-4">
<div class="col-xl-5">
<div class="panel-card h-100">
<h2 class="section-title mb-3"><?= qh_h(qh_t('New patient ticket', 'تذكرة مريض جديدة')) ?></h2>
<form method="post" class="vstack gap-3" novalidate>
<div>
<label class="form-label"><?= qh_h(qh_t('Patient name', 'اسم المريض')) ?></label>
<input class="form-control" type="text" name="patient_name" placeholder="Maha Ali" required>
</div>
<div>
<label class="form-label"><?= qh_h(qh_t('Clinic', 'العيادة')) ?></label>
<select class="form-select js-clinic-select" name="clinic_id" required>
<option value=""><?= qh_h(qh_t('Choose clinic', 'اختر العيادة')) ?></option>
<?php foreach ($clinics as $clinic): ?>
<option value="<?= qh_h((string) $clinic['id']) ?>"><?= qh_h(qh_name($clinic)) ?><?php if ((int) $clinic['requires_vitals'] === 1): ?> · <?= qh_h(qh_t('Vitals first', 'العلامات أولاً')) ?><?php endif; ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label"><?= qh_h(qh_t('Doctor', 'الطبيب')) ?></label>
<select class="form-select js-doctor-select" name="doctor_id" required>
<option value=""><?= qh_h(qh_t('Choose doctor', 'اختر الطبيب')) ?></option>
<?php foreach ($doctors as $doctor): ?>
<option value="<?= qh_h((string) $doctor['id']) ?>" data-clinic-id="<?= qh_h((string) $doctor['clinic_id']) ?>"><?= qh_h(qh_name($doctor)) ?> · <?= qh_h(qh_t('Room', 'غرفة')) ?> <?= qh_h($doctor['room_number']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label"><?= qh_h(qh_t('Preferred language', 'اللغة المفضلة')) ?></label>
<select class="form-select" name="language_pref">
<option value="en">English</option>
<option value="ar">العربية</option>
</select>
</div>
<button class="btn btn-dark" type="submit"><?= qh_h(qh_t('Issue ticket', 'إصدار التذكرة')) ?></button>
</form>
</div>
</div>
<div class="col-xl-7">
<?php if ($currentTicket): ?>
<div class="panel-card ticket-card mb-4">
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap">
<div>
<div class="section-kicker"><?= qh_h(qh_t('Issued ticket', 'التذكرة الصادرة')) ?></div>
<div class="ticket-number mt-2"><?= qh_h($currentTicket['ticket_number']) ?></div>
<div class="mt-2 fw-semibold"><?= qh_h($currentTicket['patient_name']) ?></div>
<div class="text-secondary"><?= qh_h(qh_name($currentTicket, 'clinic_name')) ?> · <?= qh_h(qh_name($currentTicket, 'doctor_name')) ?> · <?= qh_h(qh_t('Room', 'غرفة')) ?> <?= qh_h($currentTicket['doctor_room'] ?? '--') ?></div>
</div>
<div class="d-flex flex-column align-items-lg-end gap-2">
<?= qh_status_badge($currentTicket['status']) ?>
<button class="btn btn-outline-dark btn-sm js-print-ticket" type="button"><?= qh_h(qh_t('Print ticket', 'طباعة التذكرة')) ?></button>
</div>
</div>
<hr>
<div class="row g-3 small">
<div class="col-md-4"><strong><?= qh_h(qh_t('Issued', 'وقت الإصدار')) ?>:</strong><br><?= qh_format_datetime($currentTicket['created_at']) ?></div>
<div class="col-md-4"><strong><?= qh_h(qh_t('Language', 'اللغة')) ?>:</strong><br><?= qh_h(qh_locale_label($currentTicket['language_pref'] ?? 'en')) ?></div>
<div class="col-md-4"><strong><?= qh_h(qh_t('Next stop', 'المحطة التالية')) ?>:</strong><br><?= qh_h(qh_ticket_next_stop($currentTicket)) ?></div>
</div>
</div>
<?php endif; ?>
<div class="panel-card h-100">
<h2 class="section-title mb-1"><?= qh_h(qh_t('Todays tickets', 'تذاكر اليوم')) ?></h2>
<p class="section-copy mb-3"><?= qh_h(qh_t('Latest tickets and where they currently sit in the visit flow.', 'أحدث التذاكر وموقعها الحالي في مسار الزيارة.')) ?></p>
<div class="table-responsive">
<table class="table align-middle mb-0">
<thead>
<tr>
<th><?= qh_h(qh_t('Ticket', 'التذكرة')) ?></th>
<th><?= qh_h(qh_t('Patient', 'المريض')) ?></th>
<th><?= qh_h(qh_t('Clinic', 'العيادة')) ?></th>
<th><?= qh_h(qh_t('Status', 'الحالة')) ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($todayTickets as $ticket): ?>
<tr>
<td class="fw-semibold"><?= qh_h($ticket['ticket_number']) ?></td>
<td><?= qh_h($ticket['patient_name']) ?></td>
<td><?= qh_h(qh_name($ticket, 'clinic_name')) ?></td>
<td><?= qh_status_badge($ticket['status']) ?></td>
<td class="text-end"><a class="btn btn-sm btn-outline-dark" href="<?= qh_h(qh_url('ticket.php', ['id' => (int) $ticket['id']])) ?>"><?= qh_h(qh_t('View', 'عرض')) ?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php qh_page_end(); ?>