From adc8aae5d0fb1471a05fcae82726d6f905cfc8fb Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 16 Mar 2026 13:06:37 +0000 Subject: [PATCH] Autosave: 20260316-130637 --- api/appointments.php | 35 +++++++++++++++++++++++++++++++-- includes/pages/appointments.php | 32 ++++++++++++++++++++++++++---- test_groups.php | 23 ++++++++++++++++++++++ 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 test_groups.php diff --git a/api/appointments.php b/api/appointments.php index d2e9529..9e1694d 100644 --- a/api/appointments.php +++ b/api/appointments.php @@ -81,6 +81,19 @@ if ($method === 'GET') { $holidays = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($holidays as $h) { + // Render a visible block event in the time grid + $events[] = [ + 'id' => 'hol_block_' . $h['start'], + 'title' => __('holiday') . ': ' . $h['title'], + 'start' => $h['start'] . 'T' . $global_start . ':00', + 'end' => $h['start'] . 'T' . $global_end . ':00', + 'allDay' => false, + 'color' => '#dc3545', + 'textColor' => '#fff', + 'className' => 'public-holiday-event', + 'extendedProps' => ['type' => 'public_holiday_block', 'blocks_selection' => true] + ]; + // Render daily blocks for time grid $events[] = [ 'id' => 'hol_bg_' . $h['start'], @@ -142,6 +155,24 @@ if ($method === 'GET') { $isFilteredDoctor = ($doctor_id && $doctor_id == $dh['doctor_id']); + // Render a visible block event in the time grid so it's super obvious + $s = get_system_settings(); + $global_start = $s['working_hours_start'] ?? '08:00'; + $global_end = $s['working_hours_end'] ?? '17:00'; + + $events[] = [ + 'id' => 'doc_hol_block_' . $dh['id'] . '_' . $dateStr, + 'title' => 'Holiday: ' . $dh['doctor_name'], + 'start' => $dateStr . 'T' . $global_start . ':00', + 'end' => $dateStr . 'T' . $global_end . ':00', + 'allDay' => false, + 'color' => '#ffc107', + 'textColor' => '#000', + 'className' => 'doctor-holiday-event', + 'extendedProps' => ['type' => 'doctor_holiday_block', 'doctor_id' => $dh['doctor_id'], 'blocks_selection' => $isFilteredDoctor] + ]; + + // Keep the background shading $events[] = [ 'id' => 'doc_hol_bg_' . $dh['id'] . '_' . $dateStr, 'start' => $dateStr . 'T00:00:00', @@ -150,7 +181,7 @@ if ($method === 'GET') { 'allDay' => false, 'backgroundColor' => $isFilteredDoctor ? 'rgba(255, 193, 7, 0.5)' : 'rgba(255, 193, 7, 0.15)', 'overlap' => !$isFilteredDoctor, - 'extendedProps' => ['type' => 'doctor_holiday', 'doctor_id' => $dh['doctor_id'], 'blocks_selection' => $isFilteredDoctor] + 'extendedProps' => ['type' => 'doctor_holiday', 'doctor_id' => $dh['doctor_id'], 'blocks_selection' => $isFilteredDoctor, 'blocks_selection' => $isFilteredDoctor] ]; $currentDate = strtotime('+1 day', $currentDate); @@ -165,7 +196,7 @@ if ($method === 'GET') { 'allDay' => true, 'color' => '#ffc107', 'textColor' => '#000', - 'extendedProps' => ['type' => 'doctor_holiday', 'doctor_id' => $dh['doctor_id']] + 'extendedProps' => ['type' => 'doctor_holiday', 'doctor_id' => $dh['doctor_id'], 'blocks_selection' => $isFilteredDoctor] ]; } diff --git a/includes/pages/appointments.php b/includes/pages/appointments.php index 5fc16e3..db961f8 100644 --- a/includes/pages/appointments.php +++ b/includes/pages/appointments.php @@ -243,10 +243,7 @@ document.addEventListener('DOMContentLoaded', function() { fetch('api/appointments.php?start=' + fetchInfo.startStr + '&end=' + fetchInfo.endStr + '&doctor_id=' + doctorFilter.value) .then(response => response.json()) .then(data => { - if (data.businessHours) { - calendar.setOption('businessHours', data.businessHours); - } - console.log('Events fetched:', data.events); // Debug log + // We DO NOT setOption('businessHours') here to prevent FullCalendar from re-rendering and clearing events. successCallback(data.events); }) .catch(error => failureCallback(error)); @@ -354,6 +351,33 @@ document.addEventListener('DOMContentLoaded', function() {