From a2f276f05e6eb5e01aace71f944aaef5f6ce7b15 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 1 Apr 2026 03:29:17 +0000 Subject: [PATCH] install file --- assets/css/custom.css | 2 +- display.php | 20 ++-- doctor.php | 16 +++- install.php | 214 ++++++++++++++++++++++++++++++++++++++++++ login.php | 99 +++++++++++++++++++ logout.php | 12 +++ queue_bootstrap.php | 41 +++++++- 7 files changed, 391 insertions(+), 13 deletions(-) create mode 100644 install.php create mode 100644 login.php create mode 100644 logout.php diff --git a/assets/css/custom.css b/assets/css/custom.css index 12d8fa6..039b92f 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -1309,5 +1309,5 @@ html[dir="rtl"] .news-ticker-item::after { } body { - padding-bottom: 3.5rem; + padding-bottom: 0 !important; } diff --git a/display.php b/display.php index 9479f95..a071b96 100644 --- a/display.php +++ b/display.php @@ -32,9 +32,16 @@ qh_page_start( qh_t('Public queue display.', 'شاشة طوابير عامة.') ); ?> -
+ +
-
+
<?= qh_h(qh_hospital_name()) ?> @@ -56,10 +63,11 @@ qh_page_start(
-
+ +
-
+

@@ -98,7 +106,7 @@ qh_page_start(
-
+
@@ -171,7 +179,7 @@ qh_page_start(
-
+
diff --git a/doctor.php b/doctor.php index 65f7432..1403cf4 100644 --- a/doctor.php +++ b/doctor.php @@ -85,7 +85,7 @@ qh_page_start( -
+ @@ -97,6 +97,18 @@ qh_page_start( + +
+ + +
@@ -110,4 +122,4 @@ qh_page_start(
- \ No newline at end of file + diff --git a/install.php b/install.php new file mode 100644 index 0000000..435e618 --- /dev/null +++ b/install.php @@ -0,0 +1,214 @@ + PDO::ERRMODE_EXCEPTION]); + + + // Rewrite db/config.php + $configContent = " PDO::ERRMODE_EXCEPTION,\n" . + " PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,\n" . + " ]);\n" . + " }\n" . + " return \$pdo;\n" . + "}\n"; + file_put_contents(__DIR__ . '/db/config.php', $configContent); + header('Location: install.php?step=4'); + exit; + } catch (Exception $e) { + $error = 'Database Connection Failed: ' . $e->getMessage(); + } + } elseif ($step === 4) { + require_once __DIR__ . '/db/config.php'; + $username = $_POST['username'] ?? ''; + $password = $_POST['password'] ?? ''; + + if (empty($username) || empty($password)) { + $error = 'Please provide both username and password.'; + } else { + try { + $pdo = db(); + $pdo->exec("CREATE TABLE IF NOT EXISTS users ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); + + $hash = password_hash($password, PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (:username, :password) ON DUPLICATE KEY UPDATE password = :password"); + $stmt->execute(['username' => $username, 'password' => $hash]); + + header('Location: install.php?step=5'); + exit; + } catch (Exception $e) { + $error = 'Failed to create user: ' . $e->getMessage(); + } + } + } elseif ($step === 5) { + file_put_contents(__DIR__ . '/.installed', date('Y-m-d H:i:s')); + header('Location: login.php'); + exit; + } +} +?> + + + + + Installation + + + + +
+
+
+
+
+

System Installation

+
Step of 5
+
+
+ +
+ + + +

Welcome

+

Welcome to the Hospital Queue Center installation wizard. This will set up your environment, configure the database variables, and create your super admin account so you are ready to go.

+ + + +

Environment Check

+
    + ='); + $pdoOk = extension_loaded('pdo_mysql'); + $dbWritable = is_writable(__DIR__ . '/db') || is_writable(__DIR__ . '/db/config.php'); + ?> +
  • + PHP Version (>= 8.0) + +
  • +
  • + PDO MySQL Extension + +
  • +
  • + DB Config Writable + +
  • +
+ + + +
Please fix the environment issues before proceeding.
+ + + +

Database Variables

+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +

Super Admin Credentials

+
+ +
+ + +
+
+ + +
+
+ +
+
+ + +

Ready to go!

+

The installation has been successfully completed. Your database is set up and the super admin account is ready.

+
+ + +
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..26b1ea2 --- /dev/null +++ b/login.php @@ -0,0 +1,99 @@ +prepare("SELECT id, password FROM users WHERE username = :username LIMIT 1"); + $stmt->execute(['username' => $username]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = (int) $user['id']; + $_SESSION['username'] = $username; + qh_redirect('index.php'); + } else { + $error = qh_t('Invalid username or password.', 'اسم المستخدم أو كلمة المرور غير صحيحة.'); + } + } catch (Throwable $e) { + $error = qh_t('Login failed due to a system error.', 'فشل تسجيل الدخول بسبب خطأ في النظام.'); + } + } +} + +qh_page_start( + 'login', + qh_t('Sign In', 'تسجيل الدخول'), + qh_t('Sign in to the hospital queue system.', 'تسجيل الدخول إلى نظام طوابير المستشفى.') +); +?> + + +
+ +
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..0bc3b99 --- /dev/null +++ b/logout.php @@ -0,0 +1,12 @@ +' . qh_h($link['label']) . ''; } + if (!empty($_SESSION["user_id"])) { + echo ' '; + } + echo ' '; echo '
'; foreach (['en', 'ar'] as $lang) { @@ -754,7 +771,7 @@ function qh_fetch_tickets(array $statuses = [], ?int $doctorId = null, ?int $lim FROM hospital_queue_records t LEFT JOIN hospital_queue_records c ON c.id = t.clinic_id AND c.item_type = 'clinic' LEFT JOIN hospital_queue_records d ON d.id = t.doctor_id AND d.item_type = 'doctor' - WHERE t.item_type = 'ticket'"; + WHERE t.item_type = 'ticket' AND DATE(t.created_at) = CURDATE()"; $params = []; @@ -808,9 +825,9 @@ function qh_dashboard_stats(): array $pdo = db(); return [ 'issued_today' => (int) $pdo->query("SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' AND DATE(created_at) = CURDATE()")->fetchColumn(), - 'waiting_vitals' => (int) $pdo->query("SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' AND status = 'waiting_vitals'")->fetchColumn(), - 'ready_for_doctor' => (int) $pdo->query("SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' AND status = 'ready_for_doctor'")->fetchColumn(), - 'active_rooms' => (int) $pdo->query("SELECT COUNT(DISTINCT doctor_id) FROM hospital_queue_records WHERE item_type = 'ticket' AND status IN ('called', 'in_progress') AND doctor_id IS NOT NULL")->fetchColumn(), + 'waiting_vitals' => (int) $pdo->query("SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' AND DATE(created_at) = CURDATE() AND status = 'waiting_vitals'")->fetchColumn(), + 'ready_for_doctor' => (int) $pdo->query("SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' AND DATE(created_at) = CURDATE() AND status = 'ready_for_doctor'")->fetchColumn(), + 'active_rooms' => (int) $pdo->query("SELECT COUNT(DISTINCT doctor_id) FROM hospital_queue_records WHERE item_type = 'ticket' AND DATE(created_at) = CURDATE() AND status IN ('called', 'in_progress') AND doctor_id IS NOT NULL")->fetchColumn(), ]; } @@ -858,6 +875,7 @@ function qh_generate_ticket_number(string $clinicCode): string "SELECT COUNT(*) FROM hospital_queue_records WHERE item_type = 'ticket' + AND DATE(created_at) = CURDATE() AND ticket_number LIKE :prefix" ); $stmt->execute(['prefix' => $prefix . '-%']); @@ -1326,6 +1344,21 @@ function qh_doctor_handle_request(): void ); $stmt->execute(['ticket_id' => $ticketId]); qh_set_flash('success', qh_t('Visit marked as completed.', 'تم إنهاء الزيارة.')); + } elseif ($action === 'refer_ticket') { + $referToDoctorId = (int) ( emote_POST['refer_to_doctor_id'] ?? 0); + if ($referToDoctorId <= 0 || $referToDoctorId === $doctorId) { + throw new InvalidArgumentException(qh_t('Please select a valid doctor to refer the patient to.', 'يرجى اختيار طبيب صالح لتحويل المريض إليه.')); + } + $stmt = db()->prepare( + "UPDATE hospital_queue_records + SET status = 'ready_for_doctor', doctor_id = :refer_to_doctor_id, display_note = 'Referred' + WHERE item_type = 'ticket' AND id = :ticket_id" + ); + $stmt->execute([ + 'refer_to_doctor_id' => $referToDoctorId, + 'ticket_id' => $ticketId, + ]); + qh_set_flash('success', qh_t('Patient referred successfully.', 'تم تحويل المريض بنجاح.')); } elseif ($action === 'mark_no_show') { $stmt = db()->prepare( "UPDATE hospital_queue_records