Autosave: 20260304-080704

This commit is contained in:
Flatlogic Bot 2026-03-04 08:07:04 +00:00
parent a63d31ec70
commit 933409e6cf
15 changed files with 874 additions and 579 deletions

View File

@ -1,28 +1,25 @@
<?php
// includes/actions.php
$message = '';
if (isset($_SESSION['flash_message'])) {
$message = $_SESSION['flash_message'];
unset($_SESSION['flash_message']);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require_once __DIR__ . '/../db/config.php';
require_once __DIR__ . '/../helpers.php';
$db = db();
$lang = $_SESSION['lang'] ?? 'en';
$redirect = false;
if (isset($_POST['action'])) {
if ($_POST['action'] === 'add_patient') {
$name = $_POST['name'] ?? '';
$phone = $_POST['phone'] ?? '';
$dob = $_POST['dob'] ?? '';
$dob = $_POST['dob'] ?: null;
$gender = $_POST['gender'] ?? '';
$blood_group = $_POST['blood_group'] ?? '';
$address = $_POST['address'] ?? '';
$insurance_company_id = $_POST['insurance_company_id'] ?: null;
$policy_number = $_POST['policy_number'] ?? '';
$address = $_POST['address'] ?? '';
if ($name && $phone) {
$stmt = $db->prepare("INSERT INTO patients (name, phone, dob, gender, blood_group, address, insurance_company_id, policy_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name, $phone, $dob, $gender, $blood_group, $address, $insurance_company_id, $policy_number]);
if ($name) {
$stmt = $db->prepare("INSERT INTO patients (name, phone, dob, gender, blood_group, insurance_company_id, policy_number, address) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name, $phone, $dob, $gender, $blood_group, $insurance_company_id, $policy_number, $address]);
$_SESSION['flash_message'] = __('add_patient') . ' ' . __('successfully');
$redirect = true;
}
@ -30,17 +27,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? '';
$name = $_POST['name'] ?? '';
$phone = $_POST['phone'] ?? '';
$dob = $_POST['dob'] ?? '';
$dob = $_POST['dob'] ?: null;
$gender = $_POST['gender'] ?? '';
$blood_group = $_POST['blood_group'] ?? '';
$address = $_POST['address'] ?? '';
$insurance_company_id = $_POST['insurance_company_id'] ?: null;
$policy_number = $_POST['policy_number'] ?? '';
$address = $_POST['address'] ?? '';
if ($id && $name && $phone) {
$stmt = $db->prepare("UPDATE patients SET name = ?, phone = ?, dob = ?, gender = ?, blood_group = ?, address = ?, insurance_company_id = ?, policy_number = ? WHERE id = ?");
$stmt->execute([$name, $phone, $dob, $gender, $blood_group, $address, $insurance_company_id, $policy_number, $id]);
$_SESSION['flash_message'] = __('update_patient') . ' ' . __('successfully');
if ($id && $name) {
$stmt = $db->prepare("UPDATE patients SET name = ?, phone = ?, dob = ?, gender = ?, blood_group = ?, insurance_company_id = ?, policy_number = ?, address = ? WHERE id = ?");
$stmt->execute([$name, $phone, $dob, $gender, $blood_group, $insurance_company_id, $policy_number, $address, $id]);
$_SESSION['flash_message'] = __('edit_patient') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_patient') {
@ -48,21 +45,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM patients WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_patient') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_doctor') {
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
$spec_en = $_POST['specialization_en'] ?? '';
$spec_ar = $_POST['specialization_ar'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO doctors (name_en, name_ar, specialization_en, specialization_ar, department_id, tel, email) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $spec_en, $spec_ar, $dept_id, $tel, $email]);
$stmt = $db->prepare("INSERT INTO doctors (name_en, name_ar, tel, email, specialization_en, specialization_ar, department_id) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $tel, $email, $spec_en, $spec_ar, $dept_id]);
$_SESSION['flash_message'] = __('add_doctor') . ' ' . __('successfully');
$redirect = true;
}
@ -70,16 +67,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? '';
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
$spec_en = $_POST['specialization_en'] ?? '';
$spec_ar = $_POST['specialization_ar'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE doctors SET name_en = ?, name_ar = ?, specialization_en = ?, specialization_ar = ?, department_id = ?, tel = ?, email = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $spec_en, $spec_ar, $dept_id, $tel, $email, $id]);
$_SESSION['flash_message'] = __('update_doctor') . ' ' . __('successfully');
$stmt = $db->prepare("UPDATE doctors SET name_en = ?, name_ar = ?, tel = ?, email = ?, specialization_en = ?, specialization_ar = ?, department_id = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $tel, $email, $spec_en, $spec_ar, $dept_id, $id]);
$_SESSION['flash_message'] = __('edit_doctor') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_doctor') {
@ -87,19 +84,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM doctors WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_doctor') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_nurse') {
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO nurses (name_en, name_ar, department_id, tel, email) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $dept_id, $tel, $email]);
$stmt = $db->prepare("INSERT INTO nurses (name_en, name_ar, tel, email, department_id) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $tel, $email, $dept_id]);
$_SESSION['flash_message'] = __('add_nurse') . ' ' . __('successfully');
$redirect = true;
}
@ -107,14 +104,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? '';
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
$tel = $_POST['tel'] ?? '';
$email = $_POST['email'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE nurses SET name_en = ?, name_ar = ?, department_id = ?, tel = ?, email = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $dept_id, $tel, $email, $id]);
$_SESSION['flash_message'] = __('update_nurse') . ' ' . __('successfully');
$stmt = $db->prepare("UPDATE nurses SET name_en = ?, name_ar = ?, tel = ?, email = ?, department_id = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $tel, $email, $dept_id, $id]);
$_SESSION['flash_message'] = __('edit_nurse') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_nurse') {
@ -122,13 +119,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM nurses WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_nurse') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_department') {
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO departments (name_en, name_ar) VALUES (?, ?)");
$stmt->execute([$name_en, $name_ar]);
@ -139,11 +135,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? '';
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE departments SET name_en = ?, name_ar = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $id]);
$_SESSION['flash_message'] = __('update_department') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_department') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_department') {
@ -151,20 +146,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM departments WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_department') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_insurance') {
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$email = $_POST['email'] ?? '';
$phone = $_POST['phone'] ?? '';
$contact = $_POST['contact_info'] ?? '';
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO insurance_companies (name_en, name_ar, email, phone, contact_info) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $email, $phone, $contact]);
$_SESSION['flash_message'] = __('insurance_company') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'book_appointment') {
@ -192,13 +174,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$treatment = $_POST['treatment_plan'] ?? '';
if ($patient_id && $doctor_id) {
$db->beginTransaction();
$stmt = $db->prepare("INSERT INTO visits (patient_id, doctor_id, appointment_id, weight, blood_pressure, heart_rate, temperature, symptoms, diagnosis, treatment_plan) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$patient_id, $doctor_id, $appointment_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment]);
if ($appointment_id) {
$db->prepare("UPDATE appointments SET status = 'Completed' WHERE id = ?")->execute([$appointment_id]);
$stmt = $db->prepare("UPDATE appointments SET status = 'Completed' WHERE id = ?");
$stmt->execute([$appointment_id]);
}
$_SESSION['flash_message'] = __('visit_recorded');
$db->commit();
$_SESSION['flash_message'] = __('add_visit') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'edit_visit') {
@ -216,19 +201,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id && $patient_id && $doctor_id) {
$stmt = $db->prepare("UPDATE visits SET patient_id = ?, doctor_id = ?, weight = ?, blood_pressure = ?, heart_rate = ?, temperature = ?, symptoms = ?, diagnosis = ?, treatment_plan = ? WHERE id = ?");
$stmt->execute([$patient_id, $doctor_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment, $id]);
$_SESSION['flash_message'] = __('update_visit') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_visit') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'create_report') {
$visit_id = $_POST['visit_id'] ?? '';
$type = $_POST['report_type'] ?? '';
$findings = $_POST['findings'] ?? '';
$recommendations = $_POST['recommendations'] ?? '';
if ($visit_id && $type) {
$stmt = $db->prepare("INSERT INTO provisional_reports (visit_id, report_type, findings, recommendations) VALUES (?, ?, ?, ?)");
$stmt->execute([$visit_id, $type, $findings, $recommendations]);
$_SESSION['flash_message'] = __('report_created');
} elseif ($_POST['action'] === 'delete_visit') {
$id = $_POST['id'] ?? '';
if ($id) {
$stmt = $db->prepare("DELETE FROM visits WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'create_bill') {
@ -238,44 +219,52 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$amounts = $_POST['amounts'] ?? [];
if ($patient_id && !empty($items)) {
$db->beginTransaction();
$total = array_sum($amounts);
// Check if patient has insurance
$patient = $db->prepare("SELECT insurance_company_id FROM patients WHERE id = ?");
$patient->execute([$patient_id]);
$p_data = $patient->fetch();
$stmt = $db->prepare("SELECT insurance_company_id FROM patients WHERE id = ?");
$stmt->execute([$patient_id]);
$patient = $stmt->fetch();
$insurance_covered = 0;
if ($p_data && $p_data['insurance_company_id']) {
// Simple logic: insurance covers 80% if they have insurance
$insurance_covered = $total * 0.8;
if ($patient && $patient['insurance_company_id']) {
$insurance_covered = $total * 0.8; // 80% coverage
}
$patient_payable = $total - $insurance_covered;
$stmt = $db->prepare("INSERT INTO bills (patient_id, visit_id, total_amount, insurance_covered, patient_payable, status) VALUES (?, ?, ?, ?, ?, 'Pending')");
$stmt = $db->prepare("INSERT INTO bills (patient_id, visit_id, total_amount, insurance_covered, patient_payable) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$patient_id, $visit_id, $total, $insurance_covered, $patient_payable]);
$bill_id = $db->lastInsertId();
$item_stmt = $db->prepare("INSERT INTO bill_items (bill_id, description, amount) VALUES (?, ?, ?)");
$stmt = $db->prepare("INSERT INTO bill_items (bill_id, description, amount) VALUES (?, ?, ?)");
foreach ($items as $index => $desc) {
if ($desc && isset($amounts[$index])) {
$item_stmt->execute([$bill_id, $desc, $amounts[$index]]);
$stmt->execute([$bill_id, $desc, $amounts[$index]]);
}
}
$_SESSION['flash_message'] = __('bill_created');
$db->commit();
$_SESSION['flash_message'] = __('create_bill') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'mark_paid') {
$bill_id = $_POST['bill_id'] ?? '';
if ($bill_id) {
$db->prepare("UPDATE bills SET status = 'Paid' WHERE id = ?")->execute([$bill_id]);
$_SESSION['flash_message'] = __('bill_paid');
} elseif ($_POST['action'] === 'create_report') {
$visit_id = $_POST['visit_id'] ?? '';
$type = $_POST['report_type'] ?? '';
$findings = $_POST['findings'] ?? '';
$recom = $_POST['recommendations'] ?? '';
if ($visit_id && $type) {
$stmt = $db->prepare("INSERT INTO provisional_reports (visit_id, report_type, findings, recommendations) VALUES (?, ?, ?, ?)");
$stmt->execute([$visit_id, $type, $findings, $recom]);
$_SESSION['flash_message'] = __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_employee') {
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$dob = $_POST['dob'] ?? '';
$dob = $_POST['dob'] ?: null;
$mobile = $_POST['mobile'] ?? '';
$email = $_POST['email'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
@ -292,7 +281,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? '';
$name_en = $_POST['name_en'] ?? '';
$name_ar = $_POST['name_ar'] ?? '';
$dob = $_POST['dob'] ?? '';
$dob = $_POST['dob'] ?: null;
$mobile = $_POST['mobile'] ?? '';
$email = $_POST['email'] ?? '';
$dept_id = $_POST['department_id'] ?: null;
@ -302,7 +291,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE employees SET name_en = ?, name_ar = ?, dob = ?, mobile = ?, email = ?, department_id = ?, passion_en = ?, passion_ar = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $dob, $mobile, $email, $dept_id, $passion_en, $passion_ar, $id]);
$_SESSION['flash_message'] = __('update_employee') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_employee') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_employee') {
@ -310,7 +299,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM employees WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_employee') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_poison') {
@ -335,7 +324,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE poisons SET name_en = ?, name_ar = ?, description_en = ?, description_ar = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $id]);
$_SESSION['flash_message'] = __('update_poison') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_poison') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_poison') {
@ -343,7 +332,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM poisons WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_poison') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_test_group') {
@ -362,7 +351,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE test_groups SET name_en = ?, name_ar = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $id]);
$_SESSION['flash_message'] = __('update_test_group') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_test_group') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_test_group') {
@ -370,7 +359,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id) {
$stmt = $db->prepare("DELETE FROM test_groups WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete_test_group') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_test') {
@ -379,6 +368,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$group_id = $_POST['group_id'] ?: null;
$price = $_POST['price'] ?? 0;
$range = $_POST['normal_range'] ?? '';
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO laboratory_tests (name_en, name_ar, group_id, price, normal_range) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $group_id, $price, $range]);
@ -392,10 +382,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$group_id = $_POST['group_id'] ?: null;
$price = $_POST['price'] ?? 0;
$range = $_POST['normal_range'] ?? '';
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE laboratory_tests SET name_en = ?, name_ar = ?, group_id = ?, price = ?, normal_range = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $group_id, $price, $range, $id]);
$_SESSION['flash_message'] = __('update_test') . ' ' . __('successfully');
$_SESSION['flash_message'] = __('edit_test') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_test') {
@ -408,30 +399,61 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
} elseif ($_POST['action'] === 'add_inquiry') {
$patient_name = $_POST['patient_name'] ?? '';
$test_id = $_POST['test_id'] ?: null;
$test_ids = $_POST['test_ids'] ?? [];
$results = $_POST['results'] ?? [];
$ranges = $_POST['normal_ranges'] ?? [];
$source = $_POST['source'] ?? 'Internal';
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
$status = $_POST['status'] ?? 'Pending';
$notes = $_POST['notes'] ?? '';
if ($patient_name) {
$stmt = $db->prepare("INSERT INTO laboratory_inquiries (patient_name, test_id, source, inquiry_date, status, notes) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$patient_name, $test_id, $source, $date, $status, $notes]);
$db->beginTransaction();
$stmt = $db->prepare("INSERT INTO laboratory_inquiries (patient_name, source, inquiry_date, status, notes) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$patient_name, $source, $date, $status, $notes]);
$inquiry_id = $db->lastInsertId();
if (!empty($test_ids)) {
$testStmt = $db->prepare("INSERT INTO inquiry_tests (inquiry_id, test_id, result, normal_range) VALUES (?, ?, ?, ?)");
foreach ($test_ids as $index => $tid) {
if ($tid) {
$testStmt->execute([$inquiry_id, $tid, $results[$index] ?? '', $ranges[$index] ?? '']);
}
}
}
$db->commit();
$_SESSION['flash_message'] = __('add_inquiry') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'edit_inquiry') {
$id = $_POST['id'] ?? '';
$patient_name = $_POST['patient_name'] ?? '';
$test_id = $_POST['test_id'] ?: null;
$test_ids = $_POST['test_ids'] ?? [];
$results = $_POST['results'] ?? [];
$ranges = $_POST['normal_ranges'] ?? [];
$source = $_POST['source'] ?? 'Internal';
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
$status = $_POST['status'] ?? 'Pending';
$notes = $_POST['notes'] ?? '';
if ($id && $patient_name) {
$stmt = $db->prepare("UPDATE laboratory_inquiries SET patient_name = ?, test_id = ?, source = ?, inquiry_date = ?, status = ?, notes = ? WHERE id = ?");
$stmt->execute([$patient_name, $test_id, $source, $date, $status, $notes, $id]);
$db->beginTransaction();
$stmt = $db->prepare("UPDATE laboratory_inquiries SET patient_name = ?, source = ?, inquiry_date = ?, status = ?, notes = ? WHERE id = ?");
$stmt->execute([$patient_name, $source, $date, $status, $notes, $id]);
// Remove old tests and insert new ones
$stmt = $db->prepare("DELETE FROM inquiry_tests WHERE inquiry_id = ?");
$stmt->execute([$id]);
if (!empty($test_ids)) {
$testStmt = $db->prepare("INSERT INTO inquiry_tests (inquiry_id, test_id, result, normal_range) VALUES (?, ?, ?, ?)");
foreach ($test_ids as $index => $tid) {
if ($tid) {
$testStmt->execute([$id, $tid, $results[$index] ?? '', $ranges[$index] ?? '']);
}
}
}
$db->commit();
$_SESSION['flash_message'] = __('edit_inquiry') . ' ' . __('successfully');
$redirect = true;
}

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,10 @@ $message = $message ?? '';
<?php endif; ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
<!-- Select2 CSS -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />
<style>
body { font-family: 'Inter', 'Tajawal', sans-serif; background-color: #f4f7f6; }
.sidebar { min-height: 100vh; width: 250px; background-color: #002D62; color: white; transition: all 0.3s; }
@ -45,6 +49,13 @@ $message = $message ?? '';
.sidebar-link { border-left: 0; border-right: 4px solid transparent; }
.sidebar-link:hover, .sidebar-link.active { border-right-color: #4fc3f7; }
<?php endif; ?>
/* Select2 custom styling to match Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection {
border: 1px solid #dee2e6;
border-radius: 0.375rem;
min-height: calc(1.5em + 0.75rem + 2px);
}
</style>
</head>
<body>
@ -123,6 +134,6 @@ $message = $message ?? '';
<?php if ($message): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?php echo $message; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" data-bs-alert="alert" aria-label="Close"></button>
</div>
<?php endif; ?>

View File

@ -1,18 +1,6 @@
<?php
$search_name = $_GET['name'] ?? '';
$query = "SELECT * FROM departments WHERE 1=1";
$params = [];
if ($search_name) {
$query .= " AND (name_en LIKE ? OR name_ar LIKE ?)";
$params[] = "%$search_name%";
$params[] = "%$search_name%";
}
$query .= " ORDER BY id DESC";
$stmt = $db->prepare($query);
$stmt->execute($params);
$query = "SELECT * FROM departments ORDER BY id DESC";
$stmt = $db->query($query);
$departments = $stmt->fetchAll();
?>
@ -23,23 +11,6 @@ $departments = $stmt->fetchAll();
</button>
</div>
<!-- Search Bar -->
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-10">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
</div>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-secondary w-100"><?php echo __('search'); ?></button>
</div>
</form>
</div>
</div>
<div class="card shadow-sm border-0">
<div class="card-body p-0">
<div class="table-responsive">
@ -57,19 +28,19 @@ $departments = $stmt->fetchAll();
<tr>
<td colspan="4" class="text-center py-5 text-muted">
<i class="bi bi-diagram-3 display-4 d-block mb-3"></i>
<?php echo __('no_departments_found'); ?>
No departments found.
</td>
</tr>
<?php else: ?>
<?php foreach ($departments as $dept): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $dept['id']; ?></td>
<td class="px-4 text-secondary"><?php echo $dept['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($dept['name_en']); ?></td>
<td class="text-secondary"><?php echo htmlspecialchars($dept['name_ar']); ?></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditDepartmentModal(<?php echo htmlspecialchars(json_encode($dept)); ?>)"
onclick="showEditDepartmentModal(<?php echo htmlspecialchars(json_encode($dept, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -1,6 +1,5 @@
<?php
$search_name = $_GET['name'] ?? '';
$search_tel = $_GET['tel'] ?? '';
$search_dept = $_GET['department_id'] ?? '';
$query = "
@ -15,10 +14,6 @@ if ($search_name) {
$params[] = "%$search_name%";
$params[] = "%$search_name%";
}
if ($search_tel) {
$query .= " AND d.tel LIKE ?";
$params[] = "%$search_tel%";
}
if ($search_dept) {
$query .= " AND d.department_id = ?";
$params[] = $search_dept;
@ -33,7 +28,7 @@ $doctors = $stmt->fetchAll();
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('doctors'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addDoctorModal">
<i class="bi bi-person-plus me-1"></i> <?php echo __('add_doctor'); ?>
<i class="bi bi-person-plus-fill me-1"></i> <?php echo __('add_doctor'); ?>
</button>
</div>
@ -41,19 +36,13 @@ $doctors = $stmt->fetchAll();
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-4">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-telephone"></i></span>
<input type="text" name="tel" class="form-control bg-light border-start-0" placeholder="<?php echo __('phone'); ?>" value="<?php echo htmlspecialchars($search_tel); ?>">
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<select name="department_id" class="form-select bg-light">
<option value=""><?php echo __('department'); ?> (<?php echo __('all'); ?>)</option>
<?php foreach ($all_departments as $dept): ?>
@ -76,58 +65,47 @@ $doctors = $stmt->fetchAll();
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('contact_info'); ?></th>
<th class="px-4 py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('specialization'); ?></th>
<th class="py-3"><?php echo __('department'); ?></th>
<th class="py-3"><?php echo __('contact'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($doctors)): ?>
<tr>
<td colspan="6" class="text-center py-5 text-muted">
<td colspan="5" class="text-center py-5 text-muted">
<i class="bi bi-person-badge display-4 d-block mb-3"></i>
<?php echo __('no_doctors_found'); ?>
No doctors found.
</td>
</tr>
<?php else: ?>
<?php foreach ($doctors as $doc): ?>
<?php foreach ($doctors as $d): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $doc['id']; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="bg-primary bg-opacity-10 text-primary p-2 rounded-circle me-3">
<i class="bi bi-person-vcard fs-5"></i>
</div>
<div>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($doc['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($doc['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</div>
</div>
<td class="px-4">
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($d['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($d['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</td>
<td><?php echo htmlspecialchars($d['specialization_'.$lang]); ?></td>
<td>
<div class="d-flex flex-column">
<small class="text-secondary"><i class="bi bi-telephone me-1"></i><?php echo htmlspecialchars($doc['tel'] ?: '-'); ?></small>
<small class="text-muted"><i class="bi bi-envelope me-1"></i><?php echo htmlspecialchars($doc['email'] ?: '-'); ?></small>
</div>
</td>
<td>
<span class="badge bg-info bg-opacity-10 text-info border border-info border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($doc['specialization_'.$lang]); ?>
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($d['department_name'] ?: '-'); ?>
</span>
</td>
<td class="text-secondary"><?php echo htmlspecialchars($doc['department_name'] ?? '-'); ?></td>
<td>
<div class="small text-secondary"><i class="bi bi-telephone me-1"></i> <?php echo htmlspecialchars($d['tel'] ?: '-'); ?></div>
<div class="small text-secondary"><i class="bi bi-envelope me-1"></i> <?php echo htmlspecialchars($d['email'] ?: '-'); ?></div>
</td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditDoctorModal(<?php echo htmlspecialchars(json_encode($doc)); ?>)"
onclick="showEditDoctorModal(<?php echo htmlspecialchars(json_encode($d, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
<button class="btn btn-link text-danger py-1 px-2"
onclick="showDeleteDoctorModal(<?php echo $doc['id']; ?>)"
onclick="showDeleteDoctorModal(<?php echo $d['id']; ?>)"
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
<i class="bi bi-trash3"></i>
</button>

View File

@ -1,12 +1,11 @@
<?php
$search_name = $_GET['name'] ?? '';
$search_mobile = $_GET['mobile'] ?? '';
$search_dept = $_GET['department_id'] ?? '';
$query = "
SELECT e.*, dept.name_$lang as department_name
SELECT e.*, d.name_$lang as department_name
FROM employees e
LEFT JOIN departments dept ON e.department_id = dept.id
LEFT JOIN departments d ON e.department_id = d.id
WHERE 1=1";
$params = [];
@ -15,10 +14,6 @@ if ($search_name) {
$params[] = "%$search_name%";
$params[] = "%$search_name%";
}
if ($search_mobile) {
$query .= " AND e.mobile LIKE ?";
$params[] = "%$search_mobile%";
}
if ($search_dept) {
$query .= " AND e.department_id = ?";
$params[] = $search_dept;
@ -33,7 +28,7 @@ $employees = $stmt->fetchAll();
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('employees'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addEmployeeModal">
<i class="bi bi-person-plus me-1"></i> <?php echo __('add_employee'); ?>
<i class="bi bi-person-plus-fill me-1"></i> <?php echo __('add_employee'); ?>
</button>
</div>
@ -41,19 +36,13 @@ $employees = $stmt->fetchAll();
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-4">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-phone"></i></span>
<input type="text" name="mobile" class="form-control bg-light border-start-0" placeholder="<?php echo __('mobile'); ?>" value="<?php echo htmlspecialchars($search_mobile); ?>">
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<select name="department_id" class="form-select bg-light">
<option value=""><?php echo __('department'); ?> (<?php echo __('all'); ?>)</option>
<?php foreach ($all_departments as $dept): ?>
@ -76,55 +65,40 @@ $employees = $stmt->fetchAll();
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('dob'); ?></th>
<th class="py-3"><?php echo __('contact_info'); ?></th>
<th class="px-4 py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('department'); ?></th>
<th class="py-3"><?php echo __('passion'); ?></th>
<th class="py-3"><?php echo __('contact'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($employees)): ?>
<tr>
<td colspan="7" class="text-center py-5 text-muted">
<td colspan="4" class="text-center py-5 text-muted">
<i class="bi bi-person-workspace display-4 d-block mb-3"></i>
<?php echo __('no_employees_found'); ?>
No employees found.
</td>
</tr>
<?php else: ?>
<?php foreach ($employees as $emp): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $emp['id']; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="bg-primary bg-opacity-10 text-primary p-2 rounded-circle me-3">
<i class="bi bi-person fs-5"></i>
</div>
<div>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($emp['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($emp['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</div>
</div>
<td class="px-4">
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($emp['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($emp['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</td>
<td><?php echo htmlspecialchars($emp['dob'] ?: '-'); ?></td>
<td>
<div class="d-flex flex-column">
<small class="text-secondary"><i class="bi bi-phone me-1"></i><?php echo htmlspecialchars($emp['mobile'] ?: '-'); ?></small>
<small class="text-muted"><i class="bi bi-envelope me-1"></i><?php echo htmlspecialchars($emp['email'] ?: '-'); ?></small>
</div>
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($emp['department_name'] ?: '-'); ?>
</span>
</td>
<td class="text-secondary"><?php echo htmlspecialchars($emp['department_name'] ?? '-'); ?></td>
<td>
<small class="text-muted d-block" style="max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<?php echo htmlspecialchars($emp['passion_'.$lang] ?: '-'); ?>
</small>
<div class="small text-secondary"><i class="bi bi-telephone me-1"></i> <?php echo htmlspecialchars($emp['mobile'] ?: '-'); ?></div>
<div class="small text-secondary"><i class="bi bi-envelope me-1"></i> <?php echo htmlspecialchars($emp['email'] ?: '-'); ?></div>
</td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditEmployeeModal(<?php echo htmlspecialchars(json_encode($emp)); ?>)"
onclick="showEditEmployeeModal(<?php echo htmlspecialchars(json_encode($emp, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -1,31 +1,35 @@
<?php
$search_patient = $_GET['patient'] ?? '';
$search_source = $_GET['source'] ?? '';
$search_status = $_GET['status'] ?? '';
$query = "
SELECT i.*, t.name_$lang as test_name
FROM laboratory_inquiries i
LEFT JOIN laboratory_tests t ON i.test_id = t.id
WHERE 1=1";
$query = "SELECT * FROM laboratory_inquiries WHERE 1=1";
$params = [];
if ($search_patient) {
$query .= " AND i.patient_name LIKE ?";
$query .= " AND patient_name LIKE ?";
$params[] = "%$search_patient%";
}
if ($search_source) {
$query .= " AND i.source = ?";
$params[] = $search_source;
if ($search_status) {
$query .= " AND status = ?";
$params[] = $search_status;
}
$query .= " ORDER BY i.inquiry_date DESC";
$query .= " ORDER BY inquiry_date DESC";
$stmt = $db->prepare($query);
$stmt->execute($params);
$inquiries = $stmt->fetchAll();
// Get all tests for the add/edit modal
$stmt = $db->query("SELECT id, name_$lang as name FROM laboratory_tests ORDER BY name_$lang ASC");
$all_tests = $stmt->fetchAll();
// Fetch tests for each inquiry
foreach ($inquiries as &$inquiry) {
$stmt = $db->prepare("
SELECT it.*, t.name_$lang as test_name
FROM inquiry_tests it
JOIN laboratory_tests t ON it.test_id = t.id
WHERE it.inquiry_id = ?");
$stmt->execute([$inquiry['id']]);
$inquiry['tests'] = $stmt->fetchAll();
}
unset($inquiry);
?>
<div class="d-flex justify-content-between align-items-center mb-4">
@ -46,10 +50,11 @@ $all_tests = $stmt->fetchAll();
</div>
</div>
<div class="col-md-4">
<select name="source" class="form-select bg-light">
<option value=""><?php echo __('source'); ?> (<?php echo __('all'); ?>)</option>
<option value="Internal" <?php echo $search_source == 'Internal' ? 'selected' : ''; ?>><?php echo __('internal'); ?></option>
<option value="External" <?php echo $search_source == 'External' ? 'selected' : ''; ?>><?php echo __('external'); ?></option>
<select name="status" class="form-select bg-light">
<option value=""><?php echo __('status'); ?> (<?php echo __('all'); ?>)</option>
<option value="Pending" <?php echo $search_status == 'Pending' ? 'selected' : ''; ?>><?php echo __('Pending'); ?></option>
<option value="Completed" <?php echo $search_status == 'Completed' ? 'selected' : ''; ?>><?php echo __('Completed'); ?></option>
<option value="Cancelled" <?php echo $search_status == 'Cancelled' ? 'selected' : ''; ?>><?php echo __('Cancelled'); ?></option>
</select>
</div>
<div class="col-md-2">
@ -67,58 +72,49 @@ $all_tests = $stmt->fetchAll();
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('patient'); ?></th>
<th class="py-3"><?php echo __('test'); ?></th>
<th class="py-3"><?php echo __('inquiry_date'); ?></th>
<th class="py-3"><?php echo __('source'); ?></th>
<th class="py-3"><?php echo __('status'); ?></th>
<th class="py-3"><?php echo __('tests'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($inquiries)): ?>
<tr>
<td colspan="7" class="text-center py-5 text-muted">
<td colspan="6" class="text-center py-5 text-muted">
<i class="bi bi-question-circle display-4 d-block mb-3"></i>
<?php echo __('no_inquiries_found'); ?>
No inquiries found.
</td>
</tr>
<?php else: ?>
<?php foreach ($inquiries as $inquiry): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $inquiry['id']; ?></td>
<td class="px-4 text-secondary"><?php echo $inquiry['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($inquiry['patient_name']); ?></td>
<td>
<span class="badge bg-info bg-opacity-10 text-info border border-info border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($inquiry['test_name'] ?? '-'); ?>
</span>
</td>
<td class="text-secondary"><?php echo date('Y-m-d H:i', strtotime($inquiry['inquiry_date'])); ?></td>
<td>
<?php if ($inquiry['source'] == 'External'): ?>
<span class="badge bg-warning bg-opacity-10 text-warning border border-warning border-opacity-25 px-2 py-1">
<i class="bi bi-hospital me-1"></i> <?php echo __('external'); ?>
</span>
<?php else: ?>
<span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25 px-2 py-1">
<i class="bi bi-building me-1"></i> <?php echo __('internal'); ?>
</span>
<?php endif; ?>
</td>
<td class="text-secondary small"><?php echo $inquiry['inquiry_date']; ?></td>
<td>
<?php
$status_class = 'bg-secondary';
if ($inquiry['status'] == 'Pending') $status_class = 'bg-warning';
if ($inquiry['status'] == 'Completed') $status_class = 'bg-success';
if ($inquiry['status'] == 'Pending') $status_class = 'bg-warning';
if ($inquiry['status'] == 'Cancelled') $status_class = 'bg-danger';
?>
<span class="badge <?php echo $status_class; ?> bg-opacity-10 <?php echo str_replace('bg-', 'text-', $status_class); ?> border <?php echo str_replace('bg-', 'border-', $status_class); ?> border-opacity-25 px-2 py-1">
<?php echo __($inquiry['status']); ?>
</span>
<span class="badge <?php echo $status_class; ?> px-2 py-1"><?php echo __($inquiry['status']); ?></span>
</td>
<td>
<?php foreach ($inquiry['tests'] as $test): ?>
<span class="badge bg-light text-dark border me-1 small mb-1"><?php echo htmlspecialchars($test['test_name']); ?></span>
<?php endforeach; ?>
</td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-dark py-1 px-2 border-end"
onclick="printInquiry(<?php echo htmlspecialchars(json_encode($inquiry, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('print'); ?>">
<i class="bi bi-printer"></i>
</button>
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditInquiryModal(<?php echo htmlspecialchars(json_encode($inquiry)); ?>)"
onclick="showEditInquiryModal(<?php echo htmlspecialchars(json_encode($inquiry, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
@ -137,3 +133,7 @@ $all_tests = $stmt->fetchAll();
</div>
</div>
</div>
<script>
window.ALL_TESTS_DATA = <?php echo json_encode($all_tests, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE); ?>;
</script>

View File

@ -110,7 +110,7 @@ $tests = $stmt->fetchAll();
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditTestModal(<?php echo htmlspecialchars(json_encode($test)); ?>)"
onclick="showEditTestModal(<?php echo htmlspecialchars(json_encode($test, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -1,6 +1,5 @@
<?php
$search_name = $_GET['name'] ?? '';
$search_tel = $_GET['tel'] ?? '';
$search_dept = $_GET['department_id'] ?? '';
$query = "
@ -15,10 +14,6 @@ if ($search_name) {
$params[] = "%$search_name%";
$params[] = "%$search_name%";
}
if ($search_tel) {
$query .= " AND n.tel LIKE ?";
$params[] = "%$search_tel%";
}
if ($search_dept) {
$query .= " AND n.department_id = ?";
$params[] = $search_dept;
@ -33,7 +28,7 @@ $nurses = $stmt->fetchAll();
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('nurses'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addNurseModal">
<i class="bi bi-person-plus me-1"></i> <?php echo __('add_nurse'); ?>
<i class="bi bi-person-plus-fill me-1"></i> <?php echo __('add_nurse'); ?>
</button>
</div>
@ -41,19 +36,13 @@ $nurses = $stmt->fetchAll();
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-4">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-telephone"></i></span>
<input type="text" name="tel" class="form-control bg-light border-start-0" placeholder="<?php echo __('phone'); ?>" value="<?php echo htmlspecialchars($search_tel); ?>">
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<select name="department_id" class="form-select bg-light">
<option value=""><?php echo __('department'); ?> (<?php echo __('all'); ?>)</option>
<?php foreach ($all_departments as $dept): ?>
@ -76,47 +65,40 @@ $nurses = $stmt->fetchAll();
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('contact_info'); ?></th>
<th class="px-4 py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('department'); ?></th>
<th class="py-3"><?php echo __('contact'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($nurses)): ?>
<tr>
<td colspan="5" class="text-center py-5 text-muted">
<td colspan="4" class="text-center py-5 text-muted">
<i class="bi bi-person-heart display-4 d-block mb-3"></i>
<?php echo __('no_nurses_found'); ?>
No nurses found.
</td>
</tr>
<?php else: ?>
<?php foreach ($nurses as $nurse): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $nurse['id']; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="bg-primary bg-opacity-10 text-primary p-2 rounded-circle me-3">
<i class="bi bi-person-vcard fs-5"></i>
</div>
<div>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($nurse['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($nurse['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</div>
</div>
<td class="px-4">
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($nurse['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($nurse['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</td>
<td>
<div class="d-flex flex-column">
<small class="text-secondary"><i class="bi bi-telephone me-1"></i><?php echo htmlspecialchars($nurse['tel'] ?: '-'); ?></small>
<small class="text-muted"><i class="bi bi-envelope me-1"></i><?php echo htmlspecialchars($nurse['email'] ?: '-'); ?></small>
</div>
<span class="badge bg-primary bg-opacity-10 text-primary border border-primary border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($nurse['department_name'] ?: '-'); ?>
</span>
</td>
<td>
<div class="small text-secondary"><i class="bi bi-telephone me-1"></i> <?php echo htmlspecialchars($nurse['tel'] ?: '-'); ?></div>
<div class="small text-secondary"><i class="bi bi-envelope me-1"></i> <?php echo htmlspecialchars($nurse['email'] ?: '-'); ?></div>
</td>
<td class="text-secondary"><?php echo htmlspecialchars($nurse['department_name'] ?? '-'); ?></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditNurseModal(<?php echo htmlspecialchars(json_encode($nurse)); ?>)"
onclick="showEditNurseModal(<?php echo htmlspecialchars(json_encode($nurse, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -94,7 +94,7 @@ $patients = $stmt->fetchAll();
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick='showEditPatientModal(<?php echo json_encode($p); ?>)'
onclick="showEditPatientModal(<?php echo htmlspecialchars(json_encode($p, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
@ -104,12 +104,12 @@ $patients = $stmt->fetchAll();
<i class="bi bi-clipboard2-plus"></i>
</button>
<button class="btn btn-link text-success py-1 px-2 border-end"
onclick="showBillModal(null, <?php echo $p['id']; ?>, '<?php echo addslashes($p['name']); ?>')"
onclick="showBillModal(null, <?php echo $p['id']; ?>, <?php echo htmlspecialchars(json_encode($p['name'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('add_bill'); ?>">
<i class="bi bi-receipt"></i>
</button>
<button class="btn btn-link text-danger py-1 px-2"
onclick="showDeletePatientModal(<?php echo $p['id']; ?>, '<?php echo addslashes($p['name']); ?>')"
onclick="showDeletePatientModal(<?php echo $p['id']; ?>, <?php echo htmlspecialchars(json_encode($p['name'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
<i class="bi bi-trash3"></i>
</button>

View File

@ -18,8 +18,8 @@ $poisons = $stmt->fetchAll();
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('poisons'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addPoisonModal">
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_poison'); ?>
<button class="btn btn-danger shadow-sm" data-bs-toggle="modal" data-bs-target="#addPoisonModal">
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_poison'); ?>
</button>
</div>
@ -47,7 +47,8 @@ $poisons = $stmt->fetchAll();
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('name_en'); ?></th>
<th class="py-3"><?php echo __('name_ar'); ?></th>
<th class="py-3"><?php echo __('description'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
@ -55,36 +56,22 @@ $poisons = $stmt->fetchAll();
<tbody>
<?php if (empty($poisons)): ?>
<tr>
<td colspan="4" class="text-center py-5 text-muted">
<td colspan="5" class="text-center py-5 text-muted">
<i class="bi bi-radioactive display-4 d-block mb-3"></i>
<?php echo __('no_poisons_found'); ?>
No poisons found.
</td>
</tr>
<?php else: ?>
<?php foreach ($poisons as $poison): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $poison['id']; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="bg-danger bg-opacity-10 text-danger p-2 rounded-circle me-3">
<i class="bi bi-virus fs-5"></i>
</div>
<div>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($poison['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($poison['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</div>
</div>
</td>
<td>
<div class="text-secondary" style="max-width: 400px;">
<div class="text-truncate fw-medium"><?php echo htmlspecialchars($poison['description_'.$lang] ?: '-'); ?></div>
<small class="text-muted text-truncate d-block"><?php echo htmlspecialchars($poison['description_'.($lang == 'en' ? 'ar' : 'en')] ?: '-'); ?></small>
</div>
</td>
<td class="px-4 text-secondary"><?php echo $poison['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($poison['name_en']); ?></td>
<td class="text-secondary"><?php echo htmlspecialchars($poison['name_ar']); ?></td>
<td><small class="text-truncate d-inline-block text-muted" style="max-width: 300px;"><?php echo htmlspecialchars($poison['description_en']); ?></small></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditPoisonModal(<?php echo htmlspecialchars(json_encode($poison)); ?>)"
onclick="showEditPoisonModal(<?php echo htmlspecialchars(json_encode($poison, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -1,48 +1,16 @@
<?php
$search_name = $_GET['name'] ?? '';
$query = "
SELECT g.*, (SELECT COUNT(*) FROM laboratory_tests WHERE group_id = g.id) as tests_count
FROM test_groups g
WHERE 1=1";
$params = [];
if ($search_name) {
$query .= " AND (g.name_en LIKE ? OR g.name_ar LIKE ?)";
$params[] = "%$search_name%";
$params[] = "%$search_name%";
}
$query .= " ORDER BY g.id DESC";
$stmt = $db->prepare($query);
$stmt->execute($params);
$query = "SELECT * FROM test_groups ORDER BY id DESC";
$stmt = $db->query($query);
$groups = $stmt->fetchAll();
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('test_groups'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addTestGroupModal">
<i class="bi bi-collection me-1"></i> <?php echo __('add_test_group'); ?>
<i class="bi bi-plus-lg me-1"></i> <?php echo __('add_test_group'); ?>
</button>
</div>
<!-- Search Bar -->
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-10">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="name" class="form-control bg-light border-start-0" placeholder="<?php echo __('name'); ?>" value="<?php echo htmlspecialchars($search_name); ?>">
</div>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-secondary w-100"><?php echo __('search'); ?></button>
</div>
</form>
</div>
</div>
<div class="card shadow-sm border-0">
<div class="card-body p-0">
<div class="table-responsive">
@ -50,8 +18,8 @@ $groups = $stmt->fetchAll();
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('name'); ?></th>
<th class="py-3"><?php echo __('tests'); ?></th>
<th class="py-3"><?php echo __('name_en'); ?></th>
<th class="py-3"><?php echo __('name_ar'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
@ -60,33 +28,19 @@ $groups = $stmt->fetchAll();
<tr>
<td colspan="4" class="text-center py-5 text-muted">
<i class="bi bi-collection display-4 d-block mb-3"></i>
<?php echo __('no_test_groups_found'); ?>
No groups found.
</td>
</tr>
<?php else: ?>
<?php foreach ($groups as $group): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $group['id']; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="bg-primary bg-opacity-10 text-primary p-2 rounded-circle me-3">
<i class="bi bi-collection fs-5"></i>
</div>
<div>
<div class="fw-semibold text-dark"><?php echo htmlspecialchars($group['name_'.$lang]); ?></div>
<small class="text-muted"><?php echo htmlspecialchars($group['name_'.($lang == 'en' ? 'ar' : 'en')]); ?></small>
</div>
</div>
</td>
<td>
<span class="badge bg-secondary bg-opacity-10 text-secondary border border-secondary border-opacity-25 px-2 py-1">
<?php echo $group['tests_count']; ?> <?php echo __('tests'); ?>
</span>
</td>
<td class="px-4 text-secondary"><?php echo $group['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($group['name_en']); ?></td>
<td class="text-secondary"><?php echo htmlspecialchars($group['name_ar']); ?></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditTestGroupModal(<?php echo htmlspecialchars(json_encode($group)); ?>)"
onclick="showEditTestGroupModal(<?php echo htmlspecialchars(json_encode($group, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>

View File

@ -98,17 +98,17 @@ $visits = $stmt->fetchAll();
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-warning py-1 px-2 border-end"
onclick='showEditVisitModal(<?php echo json_encode($v); ?>)'
onclick="showEditVisitModal(<?php echo htmlspecialchars(json_encode($v, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick='showReportModal(<?php echo $v["id"]; ?>)'
onclick="showReportModal(<?php echo $v['id']; ?>)"
data-bs-toggle="tooltip" title="<?php echo __('new_report'); ?>">
<i class="bi bi-file-earmark-plus"></i>
</button>
<button class="btn btn-link text-success py-1 px-2"
onclick='showBillModal(<?php echo $v["id"]; ?>, <?php echo $v["patient_id"]; ?>, "<?php echo addslashes($v["patient_name"]); ?>")'
onclick="showBillModal(<?php echo $v['id']; ?>, <?php echo $v['patient_id']; ?>, <?php echo htmlspecialchars(json_encode($v['patient_name'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('create_bill'); ?>">
<i class="bi bi-receipt"></i>
</button>

View File

@ -1,16 +1,13 @@
<?php
session_start();
if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = 'en';
}
if (isset($_GET['lang'])) {
$_SESSION['lang'] = $_GET['lang'] == 'ar' ? 'ar' : 'en';
header("Location: " . strtok($_SERVER['REQUEST_URI'], '?'));
exit;
}
$section = 'laboratory_inquiries';
require_once 'includes/actions.php';
require_once 'includes/layout/header.php';
require_once 'includes/pages/laboratory_inquiries.php';
require_once 'includes/layout/footer.php';
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/helpers.php';
$db = db();
$lang = $_SESSION['lang'];
require_once __DIR__ . '/includes/actions.php';
require_once __DIR__ . '/includes/common_data.php';
require_once __DIR__ . '/includes/layout/header.php';
require_once __DIR__ . '/includes/pages/laboratory_inquiries.php';
require_once __DIR__ . '/includes/layout/footer.php';

View File

@ -32,6 +32,10 @@ $translations = [
'scheduled' => 'Scheduled',
'completed' => 'Completed',
'cancelled' => 'Cancelled',
'Scheduled' => 'Scheduled',
'Completed' => 'Completed',
'Cancelled' => 'Cancelled',
'Pending' => 'Pending',
'welcome' => 'Welcome',
'search' => 'Search',
'profile' => 'Profile',
@ -163,7 +167,10 @@ $translations = [
'external' => 'External',
'test' => 'Test',
'inquiry_date' => 'Inquiry Date',
'notes' => 'Notes'
'notes' => 'Notes',
'result' => 'Result',
'print' => 'Print',
'add_test' => 'Add Test'
],
'ar' => [
'dashboard' => 'لوحة القيادة',
@ -197,6 +204,10 @@ $translations = [
'scheduled' => 'مجدول',
'completed' => 'مكتمل',
'cancelled' => 'ملغي',
'Scheduled' => 'مجدول',
'Completed' => 'مكتمل',
'Cancelled' => 'ملغي',
'Pending' => 'قيد الانتظار',
'welcome' => 'أهلاً بك',
'search' => 'بحث',
'profile' => 'الملف الشخصي',
@ -328,6 +339,9 @@ $translations = [
'external' => 'خارجي',
'test' => 'الفحص',
'inquiry_date' => 'تاريخ الاستفسار',
'notes' => 'ملاحظات'
'notes' => 'ملاحظات',
'result' => 'النتيجة',
'print' => 'طباعة',
'add_test' => 'إضافة فحص'
]
];