From 88c06ce169f06e62cf6b5e930ea7ec671f54123f Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 15 Jul 2020 16:52:10 +0200 Subject: [PATCH] Disable appointment selection for holidays --- src/calendar.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/calendar.js b/src/calendar.js index 57573f2..5890de1 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -1,7 +1,7 @@ $(document).ready(function() { var queryString = window.location.search; var calendar = $('#calendar').fullCalendar({ - + selectable: true, editable: false, header: { @@ -15,15 +15,31 @@ "holiday_feed.php" + queryString ], - selectable: true, - selectHelper: true, - select: function(start, end) { $("#dialog-form").dialog({ modal: true, width:450}); var date = $.fullCalendar.formatDate(start, 'YYYY-MM-DD'); $("#fecha").val(date); }, + selectAllow: function(selectInfo){ + var holidays = null; + $.ajax({ + url: 'holiday_feed.php', + async: false, + dataType: 'json', + success: function (json) { + holidays = 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){ + return true; + } + return false; + }, + eventClick: function(event) { var start = $.fullCalendar.formatDate(event.start, 'HH:mm'); var end = $.fullCalendar.formatDate(event.end, 'HH:mm');