prepare("INSERT INTO doctor_holidays (doctor_id, start_date, end_date, note) VALUES (?, ?, ?, ?)"); $stmt->execute([$doctor_id, $start_date, $end_date, $note]); $_SESSION['flash_message'] = __('holiday_added_successfully'); } else { $stmt = $db->prepare("UPDATE doctor_holidays SET doctor_id = ?, start_date = ?, end_date = ?, note = ? WHERE id = ?"); $stmt->execute([$doctor_id, $start_date, $end_date, $note, $id]); $_SESSION['flash_message'] = __('holiday_updated_successfully'); } } } elseif ($action === 'delete') { $id = $_POST['id'] ?? ''; if ($id) { $stmt = $db->prepare("DELETE FROM doctor_holidays WHERE id = ?"); $stmt->execute([$id]); $_SESSION['flash_message'] = __('holiday_deleted_successfully'); } } // Redirect to avoid resubmission echo ""; exit; } // Fetch Doctors for dropdown $doctors = $db->query("SELECT id, name_$lang as name FROM doctors ORDER BY name_$lang ASC")->fetchAll(PDO::FETCH_ASSOC); // Fetch Holidays $holidays = $db->query("SELECT dh.*, d.name_$lang as doctor_name FROM doctor_holidays dh JOIN doctors d ON dh.doctor_id = d.id ORDER BY dh.start_date DESC")->fetchAll(PDO::FETCH_ASSOC); ?>