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

244 lines
16 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/queue_bootstrap.php';
qh_boot();
qh_admin_handle_request();
$stats = qh_admin_stats();
$profile = qh_fetch_hospital_profile();
$logoUrl = qh_hospital_logo_url();
$faviconUrl = qh_hospital_favicon_url();
$tagline = qh_hospital_tagline();
$website = trim((string) ($profile['website'] ?? ''));
$websiteIsValid = $website !== '' && filter_var($website, FILTER_VALIDATE_URL) !== false;
qh_page_start(
'admin',
qh_t('Hospital profile', 'ملف المستشفى'),
qh_t('Manage the hospital brand, logo, favicon, contact details, and presentation settings.', 'إدارة هوية المستشفى والشعار والأيقونة وبيانات التواصل وإعدادات العرض.')
);
?>
<div class="container-xxl px-3 px-lg-4">
<div class="admin-layout">
<aside class="admin-sidebar-column">
<?php qh_render_admin_sidebar('admin_hospital.php', $stats); ?>
</aside>
<div class="admin-content-stack">
<section class="page-header-panel admin-hero-panel mb-0 hospital-hero-panel">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Brand settings', 'إعدادات الهوية')) ?></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('Hospital profile and branding.', 'ملف المستشفى والهوية البصرية.')) ?></h1>
<p class="section-copy mb-0"><?= qh_h(qh_t('Set the hospital name, logo, favicon, contact details, working hours, and brand colors from one dedicated page.', 'اضبط اسم المستشفى والشعار والأيقونة وبيانات التواصل وساعات العمل وألوان الهوية من صفحة مخصصة واحدة.')) ?></p>
</div>
<div class="hospital-brand-preview">
<div class="hospital-brand-mark">
<?php if ($logoUrl !== ''): ?>
<img src="<?= qh_h($logoUrl) ?>" alt="<?= qh_h(qh_hospital_name()) ?>">
<?php else: ?>
<span><?= qh_h(qh_hospital_brand_initials()) ?></span>
<?php endif; ?>
</div>
<div>
<div class="section-kicker mb-2"><?= qh_h(qh_t('Live preview', 'معاينة مباشرة')) ?></div>
<h2 class="section-title mb-1"><?= qh_h(qh_hospital_name()) ?></h2>
<?php if ($tagline !== ''): ?>
<p class="section-copy mb-2"><?= qh_h($tagline) ?></p>
<?php endif; ?>
<div class="hospital-color-pills">
<span class="hospital-color-pill"><span class="hospital-color-swatch" style="background: <?= qh_h(qh_hospital_primary_color()) ?>"></span><?= qh_h(qh_hospital_primary_color()) ?></span>
<span class="hospital-color-pill"><span class="hospital-color-swatch" style="background: <?= qh_h(qh_hospital_secondary_color()) ?>"></span><?= qh_h(qh_hospital_secondary_color()) ?></span>
</div>
</div>
</div>
</section>
<div class="admin-directory-layout hospital-profile-layout">
<section class="panel-card admin-form-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Profile editor', 'تحرير الملف')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('Update hospital details', 'تحديث بيانات المستشفى')) ?></h2>
<p class="section-copy mb-0"><?= qh_h(qh_t('Use image URLs for the logo and favicon. The saved branding is reused in the top navigation and browser tab.', 'استخدم روابط صور للشعار والأيقونة. سيتم استخدام الهوية المحفوظة في شريط التنقل العلوي وتبويب المتصفح.')) ?></p>
</div>
</div>
<form method="post" class="vstack gap-4 mt-4">
<input type="hidden" name="action" value="save_hospital_profile">
<input type="hidden" name="return_to" value="admin_hospital.php">
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalNameEn"><?= qh_h(qh_t('Hospital name (English)', 'اسم المستشفى بالإنجليزية')) ?></label>
<input id="hospitalNameEn" class="form-control" type="text" name="name_en" value="<?= qh_h((string) ($profile['name_en'] ?? '')) ?>" required>
</div>
<div class="col-lg-6">
<label class="form-label" for="hospitalNameAr"><?= qh_h(qh_t('Hospital name (Arabic)', 'اسم المستشفى بالعربية')) ?></label>
<input id="hospitalNameAr" class="form-control" type="text" name="name_ar" value="<?= qh_h((string) ($profile['name_ar'] ?? '')) ?>" required>
</div>
</div>
<div class="row g-3">
<div class="col-lg-4">
<label class="form-label" for="hospitalShortName"><?= qh_h(qh_t('Short name', 'الاسم المختصر')) ?></label>
<input id="hospitalShortName" class="form-control" type="text" maxlength="40" name="short_name" value="<?= qh_h((string) ($profile['short_name'] ?? '')) ?>">
</div>
<div class="col-lg-4">
<label class="form-label" for="hospitalPhone"><?= qh_h(qh_t('Phone number', 'رقم الهاتف')) ?></label>
<input id="hospitalPhone" class="form-control" type="text" name="phone" value="<?= qh_h((string) ($profile['phone'] ?? '')) ?>">
</div>
<div class="col-lg-4">
<label class="form-label" for="hospitalEmail"><?= qh_h(qh_t('Email address', 'البريد الإلكتروني')) ?></label>
<input id="hospitalEmail" class="form-control" type="email" name="email" value="<?= qh_h((string) ($profile['email'] ?? '')) ?>">
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalTaglineEn"><?= qh_h(qh_t('Tagline (English)', 'الشعار النصي بالإنجليزية')) ?></label>
<input id="hospitalTaglineEn" class="form-control" type="text" name="tagline_en" value="<?= qh_h((string) ($profile['tagline_en'] ?? '')) ?>">
</div>
<div class="col-lg-6">
<label class="form-label" for="hospitalTaglineAr"><?= qh_h(qh_t('Tagline (Arabic)', 'الشعار النصي بالعربية')) ?></label>
<input id="hospitalTaglineAr" class="form-control" type="text" name="tagline_ar" value="<?= qh_h((string) ($profile['tagline_ar'] ?? '')) ?>">
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalAddressEn"><?= qh_h(qh_t('Address (English)', 'العنوان بالإنجليزية')) ?></label>
<textarea id="hospitalAddressEn" class="form-control" name="address_en" rows="3"><?= qh_h((string) ($profile['address_en'] ?? '')) ?></textarea>
</div>
<div class="col-lg-6">
<label class="form-label" for="hospitalAddressAr"><?= qh_h(qh_t('Address (Arabic)', 'العنوان بالعربية')) ?></label>
<textarea id="hospitalAddressAr" class="form-control" name="address_ar" rows="3"><?= qh_h((string) ($profile['address_ar'] ?? '')) ?></textarea>
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalHoursEn"><?= qh_h(qh_t('Working hours (English)', 'ساعات العمل بالإنجليزية')) ?></label>
<input id="hospitalHoursEn" class="form-control" type="text" name="working_hours_en" value="<?= qh_h((string) ($profile['working_hours_en'] ?? '')) ?>">
</div>
<div class="col-lg-6">
<label class="form-label" for="hospitalHoursAr"><?= qh_h(qh_t('Working hours (Arabic)', 'ساعات العمل بالعربية')) ?></label>
<input id="hospitalHoursAr" class="form-control" type="text" name="working_hours_ar" value="<?= qh_h((string) ($profile['working_hours_ar'] ?? '')) ?>">
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalWebsite"><?= qh_h(qh_t('Website URL', 'رابط الموقع الإلكتروني')) ?></label>
<input id="hospitalWebsite" class="form-control" type="url" name="website" placeholder="https://example.com" value="<?= qh_h((string) ($profile['website'] ?? '')) ?>">
</div>
<div class="col-lg-6">
<label class="form-label" for="hospitalLogoUrl"><?= qh_h(qh_t('Logo image URL', 'رابط صورة الشعار')) ?></label>
<input id="hospitalLogoUrl" class="form-control" type="url" name="logo_url" placeholder="https://.../logo.png" value="<?= qh_h((string) ($profile['logo_url'] ?? '')) ?>">
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<label class="form-label" for="hospitalFaviconUrl"><?= qh_h(qh_t('Favicon URL', 'رابط الأيقونة')) ?></label>
<input id="hospitalFaviconUrl" class="form-control" type="url" name="favicon_url" placeholder="https://.../favicon.png" value="<?= qh_h((string) ($profile['favicon_url'] ?? '')) ?>">
</div>
<div class="col-lg-3">
<label class="form-label" for="hospitalPrimaryColor"><?= qh_h(qh_t('Primary color', 'اللون الأساسي')) ?></label>
<input id="hospitalPrimaryColor" class="form-control form-control-color w-100" type="color" name="primary_color" value="<?= qh_h(qh_hospital_primary_color()) ?>">
</div>
<div class="col-lg-3">
<label class="form-label" for="hospitalSecondaryColor"><?= qh_h(qh_t('Secondary color', 'اللون الثانوي')) ?></label>
<input id="hospitalSecondaryColor" class="form-control form-control-color w-100" type="color" name="secondary_color" value="<?= qh_h(qh_hospital_secondary_color()) ?>">
</div>
</div>
<div class="d-flex flex-wrap gap-2 pt-2">
<button class="btn btn-dark" type="submit"><?= qh_h(qh_t('Save hospital profile', 'حفظ ملف المستشفى')) ?></button>
<a class="btn btn-outline-dark" href="<?= qh_h(qh_url('admin.php')) ?>"><?= qh_h(qh_t('Back to overview', 'العودة إلى النظرة العامة')) ?></a>
</div>
</form>
</section>
<div class="vstack gap-4">
<section class="panel-card hospital-preview-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Brand preview', 'معاينة الهوية')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('What staff will see', 'ما الذي سيراه الطاقم')) ?></h2>
<p class="section-copy mb-0"><?= qh_h(qh_t('This preview mirrors the saved logo, brand colors, and hospital details used by the app shell.', 'تعكس هذه المعاينة الشعار والألوان وبيانات المستشفى المستخدمة في واجهة التطبيق.')) ?></p>
</div>
</div>
<div class="hospital-preview-stack mt-4">
<div class="hospital-preview-header">
<div class="hospital-preview-logo">
<?php if ($logoUrl !== ''): ?>
<img src="<?= qh_h($logoUrl) ?>" alt="<?= qh_h(qh_hospital_name()) ?>">
<?php else: ?>
<span><?= qh_h(qh_hospital_brand_initials()) ?></span>
<?php endif; ?>
</div>
<div>
<strong><?= qh_h(qh_hospital_name()) ?></strong>
<?php if ($tagline !== ''): ?>
<p class="section-copy mb-0"><?= qh_h($tagline) ?></p>
<?php endif; ?>
</div>
</div>
<dl class="hospital-detail-list mb-0">
<?php if (qh_hospital_contact_value('phone') !== ''): ?>
<div><dt><?= qh_h(qh_t('Phone', 'الهاتف')) ?></dt><dd><?= qh_h(qh_hospital_contact_value('phone')) ?></dd></div>
<?php endif; ?>
<?php if (qh_hospital_contact_value('email') !== ''): ?>
<div><dt><?= qh_h(qh_t('Email', 'البريد الإلكتروني')) ?></dt><dd><?= qh_h(qh_hospital_contact_value('email')) ?></dd></div>
<?php endif; ?>
<?php if ($websiteIsValid): ?>
<div><dt><?= qh_h(qh_t('Website', 'الموقع الإلكتروني')) ?></dt><dd><a href="<?= qh_h($website) ?>" target="_blank" rel="noreferrer"><?= qh_h($website) ?></a></dd></div>
<?php endif; ?>
<?php if (qh_hospital_contact_value(qh_is_ar() ? 'address_ar' : 'address_en') !== ''): ?>
<div><dt><?= qh_h(qh_t('Address', 'العنوان')) ?></dt><dd><?= nl2br(qh_h(qh_hospital_contact_value(qh_is_ar() ? 'address_ar' : 'address_en'))) ?></dd></div>
<?php endif; ?>
<?php if (qh_hospital_contact_value(qh_is_ar() ? 'working_hours_ar' : 'working_hours_en') !== ''): ?>
<div><dt><?= qh_h(qh_t('Working hours', 'ساعات العمل')) ?></dt><dd><?= qh_h(qh_hospital_contact_value(qh_is_ar() ? 'working_hours_ar' : 'working_hours_en')) ?></dd></div>
<?php endif; ?>
</dl>
</div>
</section>
<section class="panel-card hospital-preview-card">
<div class="admin-section-head">
<div>
<span class="section-kicker"><?= qh_h(qh_t('Assets', 'الأصول')) ?></span>
<h2 class="section-title mt-2 mb-1"><?= qh_h(qh_t('Logo and favicon status', 'حالة الشعار والأيقونة')) ?></h2>
</div>
</div>
<div class="hospital-asset-grid mt-4">
<div class="hospital-asset-box">
<span class="workflow-step"><?= qh_h(qh_t('Logo', 'الشعار')) ?></span>
<?php if ($logoUrl !== ''): ?>
<img class="hospital-asset-image" src="<?= qh_h($logoUrl) ?>" alt="<?= qh_h(qh_t('Hospital logo preview', 'معاينة شعار المستشفى')) ?>">
<?php else: ?>
<div class="empty-state compact mt-3"><strong><?= qh_h(qh_t('No logo yet.', 'لا يوجد شعار حتى الآن.')) ?></strong><span><?= qh_h(qh_t('Add a logo URL to replace the initials badge in the top header.', 'أضف رابط شعار لاستبدال شارة الأحرف في الترويسة العلوية.')) ?></span></div>
<?php endif; ?>
</div>
<div class="hospital-asset-box">
<span class="workflow-step"><?= qh_h(qh_t('Favicon', 'الأيقونة')) ?></span>
<?php if ($faviconUrl !== ''): ?>
<img class="hospital-asset-image hospital-asset-favicon" src="<?= qh_h($faviconUrl) ?>" alt="<?= qh_h(qh_t('Favicon preview', 'معاينة الأيقونة')) ?>">
<?php else: ?>
<div class="empty-state compact mt-3"><strong><?= qh_h(qh_t('No custom favicon yet.', 'لا توجد أيقونة مخصصة حتى الآن.')) ?></strong><span><?= qh_h(qh_t('If left empty, the app will reuse the logo as the browser icon when available.', 'إذا تُرك الحقل فارغاً، سيعيد التطبيق استخدام الشعار كأيقونة للمتصفح عند توفره.')) ?></span></div>
<?php endif; ?>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
</div>
<?php qh_page_end(); ?>