diff --git a/includes/actions.php b/includes/actions.php index 5e53836..249fac8 100644 --- a/includes/actions.php +++ b/includes/actions.php @@ -378,9 +378,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name_ar = $_POST['name_ar'] ?? ''; $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) VALUES (?, ?, ?, ?)"); - $stmt->execute([$name_en, $name_ar, $group_id, $price]); + $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]); $_SESSION['flash_message'] = __('add_test') . ' ' . __('successfully'); $redirect = true; } @@ -390,9 +391,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name_ar = $_POST['name_ar'] ?? ''; $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 = ? WHERE id = ?"); - $stmt->execute([$name_en, $name_ar, $group_id, $price, $id]); + $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'); $redirect = true; } @@ -404,6 +406,43 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $_SESSION['flash_message'] = __('delete_test') . ' ' . __('successfully'); $redirect = true; } + } elseif ($_POST['action'] === 'add_inquiry') { + $patient_name = $_POST['patient_name'] ?? ''; + $test_id = $_POST['test_id'] ?: null; + $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]); + $_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; + $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]); + $_SESSION['flash_message'] = __('edit_inquiry') . ' ' . __('successfully'); + $redirect = true; + } + } elseif ($_POST['action'] === 'delete_inquiry') { + $id = $_POST['id'] ?? ''; + if ($id) { + $stmt = $db->prepare("DELETE FROM laboratory_inquiries WHERE id = ?"); + $stmt->execute([$id]); + $_SESSION['flash_message'] = __('delete') . ' ' . __('successfully'); + $redirect = true; + } } } diff --git a/includes/layout/footer.php b/includes/layout/footer.php index 39b91f5..5ec797f 100644 --- a/includes/layout/footer.php +++ b/includes/layout/footer.php @@ -905,6 +905,10 @@ +