diff --git a/src/appointment_management.php b/src/appointment_management.php index 33d3aa6..aa94551 100644 --- a/src/appointment_management.php +++ b/src/appointment_management.php @@ -26,6 +26,13 @@ function listHolidays($pdo){ } +function listCalendarSettings($pdo){ + $doctor = fetchDoctor($pdo); + $calendar_settings = fetchCalendarSettings($pdo, $doctor); + return $calendar_settings; +} + + function appointmentCreation(){ $data = $_POST; $pdo = connectDatabase(); diff --git a/src/calendar.js b/src/calendar.js index 5890de1..bf443b6 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -22,19 +22,29 @@ }, selectAllow: function(selectInfo){ + var daysOff = null; var holidays = null; $.ajax({ - url: 'holiday_feed.php', + url: 'holiday_feed.php' + queryString, async: false, dataType: 'json', success: function (json) { holidays = json; } }); + $.ajax({ + url: 'calendar_settings_feed.php' + queryString, + async: false, + dataType: 'json', + success: function (json) { + daysOff = json; + } + }); var date = selectInfo.start._d; var formatted_date = date.toISOString().substr(0, 10); - var found = holidays.find(el => el.start === formatted_date); - if(found == null){ + var foundHoliday = holidays.find(el => el.start === formatted_date); + var foundDayOff = daysOff.find(el => el === date.getDay()); + if(foundDayOff == null && foundHoliday == null){ return true; } return false; diff --git a/src/calendar_management.php b/src/calendar_management.php index 089cd8b..d109281 100644 --- a/src/calendar_management.php +++ b/src/calendar_management.php @@ -33,6 +33,12 @@ function holidayDeletion() function calendarConfig() { $data = $_POST; + if (!isset($data["sabado_habil"])){ + $data["sabado_habil"] = 0; + } + if (!isset($data["domingo_habil"])){ + $data["domingo_habil"] = 0; + } $pdo = connectDatabase(); configureCalendar($pdo, $data); closeDatabase($pdo); diff --git a/src/calendar_settings_feed.php b/src/calendar_settings_feed.php new file mode 100644 index 0000000..8e8d3bb --- /dev/null +++ b/src/calendar_settings_feed.php @@ -0,0 +1,28 @@ + diff --git a/src/calendar_setup_form.php b/src/calendar_setup_form.php index 9c673ea..2d05172 100644 --- a/src/calendar_setup_form.php +++ b/src/calendar_setup_form.php @@ -68,7 +68,7 @@