diff --git a/cities.php b/cities.php new file mode 100644 index 0000000..55963e9 --- /dev/null +++ b/cities.php @@ -0,0 +1,13 @@ +prepare("INSERT INTO cities (name_en, name_ar) VALUES (?, ?)"); + $stmt->execute([$name_en, $name_ar]); + $_SESSION['flash_message'] = __('add_city') . ' ' . __('successfully'); + $redirect = true; + } + } elseif ($_POST['action'] === 'edit_city') { + $id = $_POST['id'] ?? ''; + $name_en = $_POST['name_en'] ?? ''; + $name_ar = $_POST['name_ar'] ?? ''; + if ($id && $name_en && $name_ar) { + $stmt = $db->prepare("UPDATE cities SET name_en = ?, name_ar = ? WHERE id = ?"); + $stmt->execute([$name_en, $name_ar, $id]); + $_SESSION['flash_message'] = __('edit_city') . ' ' . __('successfully'); + $redirect = true; + } + } elseif ($_POST['action'] === 'delete_city') { + $id = $_POST['id'] ?? ''; + if ($id) { + $stmt = $db->prepare("DELETE FROM cities WHERE id = ?"); + $stmt->execute([$id]); + $_SESSION['flash_message'] = __('delete') . ' ' . __('successfully'); + $redirect = true; + } } elseif ($_POST['action'] === 'book_appointment') { $patient_id = $_POST['patient_id'] ?? ''; $doctor_id = $_POST['doctor_id'] ?? ''; diff --git a/includes/common_data.php b/includes/common_data.php index 4bbc484..93afd91 100644 --- a/includes/common_data.php +++ b/includes/common_data.php @@ -20,3 +20,5 @@ $scheduled_appointments = $db->query(" JOIN patients p ON a.patient_id = p.id WHERE a.status = 'Scheduled' ORDER BY a.start_time ASC")->fetchAll();$all_countries = require __DIR__ . "/countries.php"; + +$all_cities = $db->query("SELECT id, name_$lang as name FROM cities")->fetchAll(); \ No newline at end of file diff --git a/includes/layout/footer.php b/includes/layout/footer.php index f647784..32d222f 100644 --- a/includes/layout/footer.php +++ b/includes/layout/footer.php @@ -6,7 +6,7 @@