6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>[% Branches.GetName( branch ) | html %] calendar › Tools › Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("css/calendar.css") | $raw %]
11 <body id="tools_holidays" class="tools">
12 [% WRAPPER 'header.inc' %]
13 [% INCLUDE 'cat-search.inc' %]
16 [% WRAPPER 'sub-header.inc' %]
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
23 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
26 <a href="#" aria-current="page">
27 [% Branches.GetName( branch ) | html %] calendar
34 <div class="main container-fluid">
36 <div class="col-sm-10 col-sm-push-2">
39 <h1>[% Branches.GetName( branch ) | html %] calendar</h1>
42 <div class="col-sm-6">
43 <label for="branch">Define the holidays for:</label>
44 <select id="branch" name="branch">
45 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
48 <div class="panel" id="showHoliday">
49 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
50 <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
51 <fieldset class="brief">
52 <h3>Edit this holiday</h3>
53 <span id="holtype"></span>
56 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
57 <input type="hidden" id="showBranchName" name="showBranchName" />
60 <strong>From date:</strong>
61 <span id="showDaynameOutput"></span>,
62 [% IF ( dateformat == "us" ) %]
63 <span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>
64 [% ELSIF ( dateformat == "metric") %]
65 <span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>
66 [% ELSIF ( dateformat == "dmydot") %]
67 <span id="showDayOutput"></span>.<span id="showMonthOutput"></span>.<span id="showYearOutput"></span>[% ELSE %]<span id="showYearOutput"></span>/<span id="showMonthOutput"></span>/<span id="showDayOutput"></span>
70 <input type="hidden" id="showDayname" name="showDayname" />
71 <input type="hidden" id="showWeekday" name="showWeekday" />
72 <input type="hidden" id="showDay" name="showDay" />
73 <input type="hidden" id="showMonth" name="showMonth" />
74 <input type="hidden" id="showYear" name="showYear" />
76 <li class="dateinsert">
77 <strong>To date: </strong>
78 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" class="flatpickr" />
81 <label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" />
83 <!-- showTitle is necessary for exception radio button to work properly -->
85 <label for="showDescription">Description:</label>
86 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
89 <div class="exceptionPossibility" style="position:static">
90 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
91 <a href="#" class="helptext">[?]</a>
92 <div class="hint">You can make an exception for this holiday rule. This means that you will be able to say that for a repeatable holiday there is one day which is going to be an exception.</div>
96 <div class="exceptionPossibility" style="position:static">
97 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
98 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
99 <a href="#" class="helptext">[?]</a>
100 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
104 <input type="radio" name="showOperation" id="showOperationDel" value="delete" />
105 <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
106 <a href="#" class="helptext">[?]</a>
107 <div class="hint">This will delete this holiday rule. If it is a repeatable holiday, this option checks for possible exceptions. If an exception exists, this option will remove the exception and set the date to a regular holiday.</div>
110 <input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
111 <a href="#" class="helptext">[?]</a>
112 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
115 <input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
116 <a href="#" class="helptext">[?]</a>
117 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
120 <input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
121 <a href="#" class="helptext">[?]</a>
122 <div class="hint">This will delete the exceptions inside a given range. Be careful about your scope range; if it is oversized you could slow down Koha.</div>
125 <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
126 <a href="#" class="helptext">[?]</a>
127 <div class="hint">This will save changes to the holiday's title and description. If the information for a repeatable holiday is modified, it affects all of the dates on which the holiday is repeated.</div></li>
128 <li class="checkbox">
129 <input type="checkbox" name="allBranches" id="allBranches" />
130 <label for="allBranches">Copy changes to all libraries</label>.
131 <a href="#" class="helptext">[?]</a>
132 <div class="hint">If checked, changes for this holiday will be copied to all libraries. If the holiday doesn't exists for a library, no change is made.</div>
135 <fieldset class="action">
136 <input type="submit" name="submit" value="Save" />
137 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
139 </fieldset> <!-- /.brief -->
141 </div> <!-- /#showHoliday -->
143 <!-- Panel to deal with new holidays -->
144 <div class="panel" id="newHoliday">
145 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
146 <fieldset class="brief">
147 <h3>Add new holiday</h3>
150 <strong>Library:</strong>
151 <span id="newBranchNameOutput"></span>
152 <input type="hidden" id="newBranchName" name="newBranchName" />
155 <strong>From date:</strong>
156 <span id="newDaynameOutput"></span>,
158 [% IF ( dateformat == "us" ) %]
159 <span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>
160 [% ELSIF ( dateformat == "metric" ) %]
161 <span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>
162 [% ELSIF ( dateformat == "dmydot" ) %]
163 <span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>
165 <span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>
168 <input type="hidden" id="newDayname" name="showDayname" />
169 <input type="hidden" id="newWeekday" name="newWeekday" />
170 <input type="hidden" id="newDay" name="newDay" />
171 <input type="hidden" id="newMonth" name="newMonth" />
172 <input type="hidden" id="newYear" name="newYear" />
174 <li class="dateinsert">
175 <strong>To date: </strong>
176 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" class="flatpickr" />
179 <label for="title">Title: </label>
180 <input type="text" name="newTitle" id="title" size="35" /></li>
182 <label for="newDescription">Description:</label>
183 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
186 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
187 <label for="newOperationOnce">Holiday only on this day</label>.
188 <a href="#" class="helptext">[?]</a>
189 <div class="hint">Make a single holiday. For example, selecting August 1, 2012 will make it a holiday, but will not affect August 1 in other years.</div>
192 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
193 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
194 <a href="#" class="helptext">[?]</a>
195 <div class="hint">Make this weekday a holiday, every week. For example, if your library is closed on Saturdays, use this option to make every Saturday a holiday.</div>
198 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
199 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
200 <a href="#" class="helptext">[?]</a>
201 <div class="hint">This will take this day and month as a reference to make it a holiday. Through this option, you can repeat this rule for every year. For example, selecting August 1 will make August 1 a holiday every year.</div>
204 <input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
205 <label for="newOperationField">Holidays on a range</label>.
206 <a href="#" class="helptext">[?]</a>
207 <div class="hint">Make a single holiday on a range. For example, selecting August 1, 2012 and August 10, 2012 will make all days between August 1 and 10 a holiday, but will not affect August 1-10 in other years.</div>
210 <input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
211 <label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
212 <a href="#" class="helptext">[?]</a>
213 <div class="hint">Make a single holiday on a range repeated yearly. For example, selecting August 1, 2012 and August 10, 2012 will make all days between August 1 and 10 a holiday, and will affect August 1-10 in other years.</div>
215 <li class="checkbox">
216 <input type="checkbox" name="allBranches" id="allBranches" />
217 <label for="allBranches">Copy to all libraries</label>.
218 <a href="#" class="helptext">[?]</a>
219 <div class="hint">If checked, this holiday will be copied to all libraries. If the holiday already exists for a library, no change is made.</div>
222 <fieldset class="action">
223 <input type="submit" name="submit" value="Save" />
224 <a href="#" class="cancel hidePanel newHoliday">Cancel</a>
226 </fieldset> <!-- /.brief -->
228 </div> <!-- /#newHoliday -->
230 <div id="calendar-container">
231 <h3>Calendar information</h3>
232 <span id="calendar-anchor"></span>
234 <div style="margin-top: 2em;">
235 <form action="copy-holidays.pl" method="post">
236 <input type="hidden" name="from_branchcode" value="[% branch | html %]" />
237 <label for="branchcode">Copy holidays to:</label>
238 <select id="branchcode" name="branchcode">
239 <option value=""></option>
240 [% FOREACH l IN Branches.all() %]
241 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
244 <input type="submit" value="Copy" />
247 </div> <!-- /.col-sm-6 -->
249 <div class="col-sm-6">
253 <li>Search in the calendar the day you want to set as holiday.</li>
254 <li>Click the date to add or edit a holiday.</li>
255 <li>Enter a title and description for the holiday.</li>
256 <li>Specify how the holiday should repeat.</li>
257 <li>Click Save to finish.</li>
261 <span class="key normalday">Working day</span>
262 <span class="key holiday">Unique holiday</span>
263 <span class="key repeatableweekly">Holiday repeating weekly</span>
264 <span class="key repeatableyearly">Holiday repeating yearly</span>
265 <span class="key exception">Holiday exception</span>
267 </div> <!-- /#help -->
269 <div id="holiday-list">
270 <!-- Exceptions First -->
271 <!-- this will probably always have the least amount of data -->
272 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
274 <label class="controls">
275 <input type="checkbox" name="show_past" id="show_past_holidayexceptions" class="show_past" />
278 <table id="holidayexceptions">
281 <th class="exception">Date</th>
282 <th class="exception">Title</th>
283 <th class="exception">Description</th>
287 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
288 <tr data-date="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
289 <td data-order="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
290 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]">
291 [% EXCEPTION_HOLIDAYS_LOO.DATE | html %]
294 <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
295 <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
299 </table> <!-- /#holidayexceptions -->
300 [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
302 [% IF ( WEEK_DAYS_LOOP ) %]
303 <h3>Weekly - Repeatable holidays</h3>
304 <table id="holidayweeklyrepeatable">
307 <th class="repeatableweekly">Day of week</th>
308 <th class="repeatableweekly">Title</th>
309 <th class="repeatableweekly">Description</th>
313 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
315 <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
316 <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
317 <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
321 </table> <!-- /#holidayweeklyrepeatable -->
322 [% END # / IF ( WEEK_DAYS_LOOP ) %]
324 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
325 <h3>Yearly - Repeatable holidays</h3>
326 <table id="holidaysyearlyrepeatable">
329 [% IF ( dateformat == "metric" ) %]
330 <th class="repeatableyearly">Day/month</th>
332 <th class="repeatableyearly">Month/day</th>
334 <th class="repeatableyearly">Title</th>
335 <th class="repeatableyearly">Description</th>
339 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
341 <td data-order="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">
342 [% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]
344 <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
345 <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
349 </table> <!-- /#holidaysyearlyrepeatable -->
350 [% END # /IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
352 [% IF ( HOLIDAYS_LOOP ) %]
353 <h3>Unique holidays</h3>
354 <label class="controls">
355 <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" />
358 <table id="holidaysunique">
361 <th class="holiday">Date</th>
362 <th class="holiday">Title</th>
363 <th class="holiday">Description</th>
367 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
368 <tr data-date="[% HOLIDAYS_LOO.DATE_SORT | html %]">
369 <td data-order="[% HOLIDAYS_LOO.DATE_SORT | html %]">
370 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% HOLIDAYS_LOO.DATE | uri %]">
371 [% HOLIDAYS_LOO.DATE | html %]
374 <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
375 <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
379 </table> <!-- #holidaysunique -->
380 [% END # /IF ( HOLIDAYS_LOOP ) %]
381 </div> <!-- /#holiday-list -->
382 </div> <!-- /.col-sm-6 -->
383 </div> <!-- /.row -->
385 </div> <!-- /.col-sm-10.col-sm-push-2 -->
387 <div class="col-sm-2 col-sm-pull-10">
389 [% INCLUDE 'tools-menu.inc' %]
391 </div> <!-- .col-sm-2.col-sm-pull-10 -->
392 </div> <!-- /.row -->
394 [% MACRO jsinclude BLOCK %]
395 [% INCLUDE 'calendar.inc' %]
396 [% INCLUDE 'datatables.inc' %]
397 [% Asset.js("js/tools-menu.js") | $raw %]
399 var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
401 /* Creates all the structures to deal with all different kinds of holidays */
402 var week_days = new Array();
403 var holidays = new Array();
404 var holidates = new Array();
405 var exception_holidays = new Array();
406 var day_month_holidays = new Array();
407 var hola= "[% code | html %]";
408 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
409 week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
411 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
412 holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
413 holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
415 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
416 exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
418 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
419 day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
422 function holidayOperation(formObject, opType) {
423 var op = document.getElementsByName('operation');
424 op[0].value = opType;
428 // This function shows the "Show Holiday" panel //
429 function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
430 $("#newHoliday").slideUp("fast");
431 $("#showHoliday").slideDown("fast");
432 $('#showDaynameOutput').html(dayName);
433 $('#showDayname').val(dayName);
434 $('#showBranchNameOutput').html($("#branch :selected").text());
435 $('#showBranchName').val($("#branch").val());
436 $('#showDayOutput').html(day);
437 $('#showDay').val(day);
438 $('#showMonthOutput').html(month);
439 $('#showMonth').val(month);
440 $('#showYearOutput').html(year);
441 $('#showYear').val(year);
442 $('#showDescription').val(description);
443 $('#showWeekday:first').val(weekDay);
444 $('#showTitle').val(title);
445 $('#showHolidayType').val(holidayType);
447 if (holidayType == 'exception') {
448 $("#showOperationDelLabel").html(_("Delete this exception."));
449 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
450 } else if(holidayType == 'weekday') {
451 $("#showOperationDelLabel").html(_("Delete this holiday."));
452 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
453 } else if(holidayType == 'daymonth') {
454 $("#showOperationDelLabel").html(_("Delete this holiday."));
455 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
457 $("#showOperationDelLabel").html(_("Delete this holiday."));
458 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
461 if (exceptionPossibility == 1) {
462 $(".exceptionPossibility").parent().show();
464 $(".exceptionPossibility").parent().hide();
468 // This function shows the "Add Holiday" panel //
469 function newHoliday (dayName, day, month, year, weekDay) {
470 $("#showHoliday").slideUp("fast");
471 $("#newHoliday").slideDown("fast");
472 $("#newDaynameOutput").html(dayName);
473 $("#newDayname").val(dayName);
474 $("#newBranchNameOutput").html($('#branch :selected').text());
475 $("#newBranchName").val($('#branch').val());
476 $("#newDayOutput").html(day);
477 $("#newDay").val(day);
478 $("#newMonthOutput").html(month);
479 $("#newMonth").val(month);
480 $("#newYearOutput").html(year);
481 $("#newYear").val(year);
482 $("#newWeekday:first").val(weekDay);
485 function hidePanel(aPanelName) {
486 $("#"+aPanelName).slideUp("fast");
489 function changeBranch () {
490 var branch = $("#branch option:selected").val();
491 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
495 * Build settings to be passed to the formatDay function for each day in the calendar
496 * @param {object} dayElem - HTML node passed from Flatpickr
499 function dateStatusHandler( dayElem ) {
500 var day = dayElem.dateObj.getDate();
501 var month = dayElem.dateObj.getMonth() + 1;
502 var year = dayElem.dateObj.getFullYear();
503 var weekDay = dayElem.dateObj.getDay();
504 var dayMonth = month + '/' + day;
505 var dateString = year + '/' + month + '/' + day;
506 if (exception_holidays[dateString] != null) {
507 formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem );
508 } else if ( week_days[weekDay] != null ){
509 formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem );
510 } else if ( day_month_holidays[dayMonth] != null ) {
511 formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem );
512 } else if (holidays[dateString] != null) {
513 formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem );
515 formatDay( [ "normalday", _("Normal day")], dayElem );
520 * Adds style and title attribute to a day on the calendar
521 * @param {object} settings - span class attribute ([0]) and title attribute ([1])
522 * @param {node} dayElem - HTML node passed from Flatpickr
525 function formatDay( settings, dayElem ){
526 $(dayElem).attr("title", settings[1]).addClass( settings[0]);
530 * Triggers an action based on a click on a calendar day: If a holiday exists on
531 * that day it loads an edit form. If there is no existing holiday one can be created
532 * @param {object} calendar - a Date object corresponding to the clicked day
535 function dateChanged( calendar ) {
536 var day = calendar.getDate();
537 var month = calendar.getMonth() + 1;
538 var year = calendar.getFullYear();
539 var weekDay = calendar.getDay();
540 var dayName = weekdays[weekDay];
541 var dayMonth = month + '/' + day;
542 var dateString = year + '/' + month + '/' + day;
543 if (holidays[dateString] != null) {
544 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
545 } else if (exception_holidays[dateString] != null) {
546 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
547 } else if (week_days[weekDay] != null) {
548 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
549 } else if (day_month_holidays[dayMonth] != null) {
550 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
552 newHoliday(dayName, day, month, year, weekDay);
556 /* Custom table search configuration: If a table row
557 has an "expired" class, hide it UNLESS the
558 show_expired checkbox is checked */
559 $.fn.dataTable.ext.search.push(
560 function( settings, searchData, index, rowData, counter ) {
561 var table = settings.nTable.id;
562 var row = $(settings.aoData[index].nTr);
563 if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){
571 // Create current date variable
572 var date = new Date();
573 var datestring = date.toISOString().substring(0, 10);
575 $(document).ready(function() {
578 $("#branch").change(function(){
581 $("#holidayweeklyrepeatable>tbody>tr").each(function(){
582 var first_td = $(this).find('td').first();
583 first_td.html(weekdays[first_td.html()]);
585 $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
589 var tables = $("#holidayexceptions, #holidaysyearlyrepeatable, #holidaysunique").DataTable($.extend(true, {}, dataTablesDefaults, {
592 "createdRow": function( row, data, dataIndex ) {
593 var holiday = $(row).data("date");
594 if( holiday < datestring ){
595 $(row).addClass("date_past");
600 $(".show_past").on("change", function(){
604 $("a.helptext").click(function(){
605 $(this).parent().find(".hint").toggle(); return false;
608 const dateofrange = document.querySelector("#dateofrange")._flatpickr;
609 const datecancelrange = document.querySelector("#datecancelrange")._flatpickr;
611 $("#dateofrange").each(function () { this.value = "" });
612 $("#datecancelrange").each(function () { this.value = "" });
614 var maincalendar = $("#calendar-anchor").flatpickr({
616 onReady: function( selectedDates, dateStr, instance ){
617 // We do not want to display the 'close' icon in this case
618 $(instance.input).siblings('.flatpickr-input').hide();
620 onDayCreate: function( dObj, dStr, fp, dayElem ){
621 /* for each day on the calendar, get the
622 correct status information for the date */
623 dateStatusHandler( dayElem );
625 onChange: function( selectedDates, dateStr, instance ){
626 var fromdate = selectedDates[0];
627 var enddate = dateofrange.selectedDates[0];
629 dateChanged( fromdate );
631 dateofrange.set( 'defaultDate', fromdate );
632 dateofrange.set( 'minDate', fromdate );
634 if ( enddate != undefined ) {
635 if ( enddate < fromdate ) {
636 dateofrange.set("defaultDate", fromdate);
637 dateofrange.setDate(fromdate);
642 defaultDate: new Date("[% keydate | html %]")
645 $(".hidePanel").on("click",function(){
646 if( $(this).hasClass("showHoliday") ){
647 hidePanel("showHoliday");
649 hidePanel("newHoliday");
656 [% INCLUDE 'intranet-bottom.inc' %]