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');