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 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'cat-search.inc' %]
15 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
18 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
21 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
24 <a href="#" aria-current="page">
25 [% Branches.GetName( branch ) | html %] calendar
31 <div class="main container-fluid">
33 <div class="col-sm-10 col-sm-push-2">
36 <h1>[% Branches.GetName( branch ) | html %] calendar</h1>
39 <div class="col-sm-6">
40 <label for="branch">Define the holidays for:</label>
41 <select id="branch" name="branch">
42 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
45 <div class="panel" id="showHoliday">
46 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
47 <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
48 <fieldset class="brief">
49 <h3>Edit this holiday</h3>
50 <span id="holtype"></span>
53 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
54 <input type="hidden" id="showBranchName" name="showBranchName" />
57 <strong>From date:</strong>
58 <span id="showDaynameOutput"></span>,
59 [% IF ( dateformat == "us" ) %]
60 <span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>
61 [% ELSIF ( dateformat == "metric") %]
62 <span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>
63 [% ELSIF ( dateformat == "dmydot") %]
64 <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>
67 <input type="hidden" id="showDayname" name="showDayname" />
68 <input type="hidden" id="showWeekday" name="showWeekday" />
69 <input type="hidden" id="showDay" name="showDay" />
70 <input type="hidden" id="showMonth" name="showMonth" />
71 <input type="hidden" id="showYear" name="showYear" />
73 <li class="dateinsert">
74 <strong>To date: </strong>
75 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" class="flatpickr" />
78 <label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" />
80 <!-- showTitle is necessary for exception radio button to work properly -->
82 <label for="showDescription">Description:</label>
83 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
86 <div class="exceptionPossibility" style="position:static">
87 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
88 <a href="#" class="helptext">[?]</a>
89 <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>
93 <div class="exceptionPossibility" style="position:static">
94 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
95 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
96 <a href="#" class="helptext">[?]</a>
97 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
101 <input type="radio" name="showOperation" id="showOperationDel" value="delete" />
102 <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
103 <a href="#" class="helptext">[?]</a>
104 <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>
107 <input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
108 <a href="#" class="helptext">[?]</a>
109 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
112 <input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
113 <a href="#" class="helptext">[?]</a>
114 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
117 <input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
118 <a href="#" class="helptext">[?]</a>
119 <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>
122 <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
123 <a href="#" class="helptext">[?]</a>
124 <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>
125 <li class="checkbox">
126 <input type="checkbox" name="allBranches" id="allBranches" />
127 <label for="allBranches">Copy changes to all libraries</label>.
128 <a href="#" class="helptext">[?]</a>
129 <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>
132 <fieldset class="action">
133 <input type="submit" name="submit" value="Save" />
134 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
136 </fieldset> <!-- /.brief -->
138 </div> <!-- /#showHoliday -->
140 <!-- Panel to deal with new holidays -->
141 <div class="panel" id="newHoliday">
142 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
143 <fieldset class="brief">
144 <h3>Add new holiday</h3>
147 <strong>Library:</strong>
148 <span id="newBranchNameOutput"></span>
149 <input type="hidden" id="newBranchName" name="newBranchName" />
152 <strong>From date:</strong>
153 <span id="newDaynameOutput"></span>,
155 [% IF ( dateformat == "us" ) %]
156 <span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>
157 [% ELSIF ( dateformat == "metric" ) %]
158 <span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>
159 [% ELSIF ( dateformat == "dmydot" ) %]
160 <span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>
162 <span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>
165 <input type="hidden" id="newDayname" name="showDayname" />
166 <input type="hidden" id="newWeekday" name="newWeekday" />
167 <input type="hidden" id="newDay" name="newDay" />
168 <input type="hidden" id="newMonth" name="newMonth" />
169 <input type="hidden" id="newYear" name="newYear" />
171 <li class="dateinsert">
172 <strong>To date: </strong>
173 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" class="flatpickr" />
176 <label for="title">Title: </label>
177 <input type="text" name="newTitle" id="title" size="35" /></li>
179 <label for="newDescription">Description:</label>
180 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
183 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
184 <label for="newOperationOnce">Holiday only on this day</label>.
185 <a href="#" class="helptext">[?]</a>
186 <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>
189 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
190 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
191 <a href="#" class="helptext">[?]</a>
192 <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>
195 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
196 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
197 <a href="#" class="helptext">[?]</a>
198 <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>
201 <input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
202 <label for="newOperationField">Holidays on a range</label>.
203 <a href="#" class="helptext">[?]</a>
204 <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>
207 <input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
208 <label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
209 <a href="#" class="helptext">[?]</a>
210 <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>
212 <li class="checkbox">
213 <input type="checkbox" name="allBranches" id="allBranches" />
214 <label for="allBranches">Copy to all libraries</label>.
215 <a href="#" class="helptext">[?]</a>
216 <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>
219 <fieldset class="action">
220 <input type="submit" name="submit" value="Save" />
221 <a href="#" class="cancel hidePanel newHoliday">Cancel</a>
223 </fieldset> <!-- /.brief -->
225 </div> <!-- /#newHoliday -->
227 <div id="calendar-container">
228 <h3>Calendar information</h3>
229 <span id="calendar-anchor"></span>
231 <div style="margin-top: 2em;">
232 <form action="copy-holidays.pl" method="post">
233 <input type="hidden" name="from_branchcode" value="[% branch | html %]" />
234 <label for="branchcode">Copy holidays to:</label>
235 <select id="branchcode" name="branchcode">
236 <option value=""></option>
237 [% FOREACH l IN Branches.all() %]
238 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
241 <input type="submit" value="Copy" />
244 </div> <!-- /.col-sm-6 -->
246 <div class="col-sm-6">
250 <li>Search in the calendar the day you want to set as holiday.</li>
251 <li>Click the date to add or edit a holiday.</li>
252 <li>Enter a title and description for the holiday.</li>
253 <li>Specify how the holiday should repeat.</li>
254 <li>Click Save to finish.</li>
258 <span class="key normalday">Working day</span>
259 <span class="key holiday">Unique holiday</span>
260 <span class="key repeatableweekly">Holiday repeating weekly</span>
261 <span class="key repeatableyearly">Holiday repeating yearly</span>
262 <span class="key exception">Holiday exception</span>
264 </div> <!-- /#help -->
266 <div id="holiday-list">
267 <!-- Exceptions First -->
268 <!-- this will probably always have the least amount of data -->
269 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
271 <label class="controls">
272 <input type="checkbox" name="show_past" id="show_past_holidayexceptions" class="show_past" />
275 <table id="holidayexceptions">
278 <th class="exception">Date</th>
279 <th class="exception">Title</th>
280 <th class="exception">Description</th>
284 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
285 <tr data-date="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
286 <td data-order="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
287 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]">
288 [% EXCEPTION_HOLIDAYS_LOO.DATE | html %]
291 <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
292 <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
296 </table> <!-- /#holidayexceptions -->
297 [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
299 [% IF ( WEEK_DAYS_LOOP ) %]
300 <h3>Weekly - Repeatable holidays</h3>
301 <table id="holidayweeklyrepeatable">
304 <th class="repeatableweekly">Day of week</th>
305 <th class="repeatableweekly">Title</th>
306 <th class="repeatableweekly">Description</th>
310 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
312 <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
313 <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
314 <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
318 </table> <!-- /#holidayweeklyrepeatable -->
319 [% END # / IF ( WEEK_DAYS_LOOP ) %]
321 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
322 <h3>Yearly - Repeatable holidays</h3>
323 <table id="holidaysyearlyrepeatable">
326 [% IF ( dateformat == "metric" ) %]
327 <th class="repeatableyearly">Day/month</th>
329 <th class="repeatableyearly">Month/day</th>
331 <th class="repeatableyearly">Title</th>
332 <th class="repeatableyearly">Description</th>
336 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
338 <td data-order="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">
339 [% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]
341 <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
342 <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
346 </table> <!-- /#holidaysyearlyrepeatable -->
347 [% END # /IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
349 [% IF ( HOLIDAYS_LOOP ) %]
350 <h3>Unique holidays</h3>
351 <label class="controls">
352 <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" />
355 <table id="holidaysunique">
358 <th class="holiday">Date</th>
359 <th class="holiday">Title</th>
360 <th class="holiday">Description</th>
364 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
365 <tr data-date="[% HOLIDAYS_LOO.DATE_SORT | html %]">
366 <td data-order="[% HOLIDAYS_LOO.DATE_SORT | html %]">
367 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% HOLIDAYS_LOO.DATE | uri %]">
368 [% HOLIDAYS_LOO.DATE | html %]
371 <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
372 <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
376 </table> <!-- #holidaysunique -->
377 [% END # /IF ( HOLIDAYS_LOOP ) %]
378 </div> <!-- /#holiday-list -->
379 </div> <!-- /.col-sm-6 -->
380 </div> <!-- /.row -->
382 </div> <!-- /.col-sm-10.col-sm-push-2 -->
384 <div class="col-sm-2 col-sm-pull-10">
386 [% INCLUDE 'tools-menu.inc' %]
388 </div> <!-- .col-sm-2.col-sm-pull-10 -->
389 </div> <!-- /.row -->
391 [% MACRO jsinclude BLOCK %]
392 [% INCLUDE 'calendar.inc' %]
393 [% INCLUDE 'datatables.inc' %]
394 [% Asset.js("js/tools-menu.js") | $raw %]
396 var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
398 /* Creates all the structures to deal with all different kinds of holidays */
399 var week_days = new Array();
400 var holidays = new Array();
401 var holidates = new Array();
402 var exception_holidays = new Array();
403 var day_month_holidays = new Array();
404 var hola= "[% code | html %]";
405 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
406 week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
408 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
409 holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
410 holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
412 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
413 exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
415 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
416 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 %]"};
419 function holidayOperation(formObject, opType) {
420 var op = document.getElementsByName('operation');
421 op[0].value = opType;
425 // This function shows the "Show Holiday" panel //
426 function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
427 $("#newHoliday").slideUp("fast");
428 $("#showHoliday").slideDown("fast");
429 $('#showDaynameOutput').html(dayName);
430 $('#showDayname').val(dayName);
431 $('#showBranchNameOutput').html($("#branch :selected").text());
432 $('#showBranchName').val($("#branch").val());
433 $('#showDayOutput').html(day);
434 $('#showDay').val(day);
435 $('#showMonthOutput').html(month);
436 $('#showMonth').val(month);
437 $('#showYearOutput').html(year);
438 $('#showYear').val(year);
439 $('#showDescription').val(description);
440 $('#showWeekday:first').val(weekDay);
441 $('#showTitle').val(title);
442 $('#showHolidayType').val(holidayType);
444 if (holidayType == 'exception') {
445 $("#showOperationDelLabel").html(_("Delete this exception."));
446 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
447 } else if(holidayType == 'weekday') {
448 $("#showOperationDelLabel").html(_("Delete this holiday."));
449 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
450 } else if(holidayType == 'daymonth') {
451 $("#showOperationDelLabel").html(_("Delete this holiday."));
452 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
454 $("#showOperationDelLabel").html(_("Delete this holiday."));
455 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
458 if (exceptionPossibility == 1) {
459 $(".exceptionPossibility").parent().show();
461 $(".exceptionPossibility").parent().hide();
465 // This function shows the "Add Holiday" panel //
466 function newHoliday (dayName, day, month, year, weekDay) {
467 $("#showHoliday").slideUp("fast");
468 $("#newHoliday").slideDown("fast");
469 $("#newDaynameOutput").html(dayName);
470 $("#newDayname").val(dayName);
471 $("#newBranchNameOutput").html($('#branch :selected').text());
472 $("#newBranchName").val($('#branch').val());
473 $("#newDayOutput").html(day);
474 $("#newDay").val(day);
475 $("#newMonthOutput").html(month);
476 $("#newMonth").val(month);
477 $("#newYearOutput").html(year);
478 $("#newYear").val(year);
479 $("#newWeekday:first").val(weekDay);
482 function hidePanel(aPanelName) {
483 $("#"+aPanelName).slideUp("fast");
486 function changeBranch () {
487 var branch = $("#branch option:selected").val();
488 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
492 * Build settings to be passed to the formatDay function for each day in the calendar
493 * @param {object} dayElem - HTML node passed from Flatpickr
496 function dateStatusHandler( dayElem ) {
497 var day = dayElem.dateObj.getDate();
498 var month = dayElem.dateObj.getMonth() + 1;
499 var year = dayElem.dateObj.getFullYear();
500 var weekDay = dayElem.dateObj.getDay();
501 var dayMonth = month + '/' + day;
502 var dateString = year + '/' + month + '/' + day;
503 if (exception_holidays[dateString] != null) {
504 formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem );
505 } else if ( week_days[weekDay] != null ){
506 formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem );
507 } else if ( day_month_holidays[dayMonth] != null ) {
508 formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem );
509 } else if (holidays[dateString] != null) {
510 formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem );
512 formatDay( [ "normalday", _("Normal day")], dayElem );
517 * Adds style and title attribute to a day on the calendar
518 * @param {object} settings - span class attribute ([0]) and title attribute ([1])
519 * @param {node} dayElem - HTML node passed from Flatpickr
522 function formatDay( settings, dayElem ){
523 $(dayElem).attr("title", settings[1]).addClass( settings[0]);
527 * Triggers an action based on a click on a calendar day: If a holiday exists on
528 * that day it loads an edit form. If there is no existing holiday one can be created
529 * @param {object} calendar - a Date object corresponding to the clicked day
532 function dateChanged( calendar ) {
533 var day = calendar.getDate();
534 var month = calendar.getMonth() + 1;
535 var year = calendar.getFullYear();
536 var weekDay = calendar.getDay();
537 var dayName = weekdays[weekDay];
538 var dayMonth = month + '/' + day;
539 var dateString = year + '/' + month + '/' + day;
540 if (holidays[dateString] != null) {
541 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
542 } else if (exception_holidays[dateString] != null) {
543 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
544 } else if (week_days[weekDay] != null) {
545 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
546 } else if (day_month_holidays[dayMonth] != null) {
547 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
549 newHoliday(dayName, day, month, year, weekDay);
553 /* Custom table search configuration: If a table row
554 has an "expired" class, hide it UNLESS the
555 show_expired checkbox is checked */
556 $.fn.dataTable.ext.search.push(
557 function( settings, searchData, index, rowData, counter ) {
558 var table = settings.nTable.id;
559 var row = $(settings.aoData[index].nTr);
560 if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){
568 // Create current date variable
569 var date = new Date();
570 var datestring = date.toISOString().substring(0, 10);
572 $(document).ready(function() {
575 $("#branch").change(function(){
578 $("#holidayweeklyrepeatable>tbody>tr").each(function(){
579 var first_td = $(this).find('td').first();
580 first_td.html(weekdays[first_td.html()]);
582 $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
586 var tables = $("#holidayexceptions, #holidaysyearlyrepeatable, #holidaysunique").DataTable($.extend(true, {}, dataTablesDefaults, {
589 "createdRow": function( row, data, dataIndex ) {
590 var holiday = $(row).data("date");
591 if( holiday < datestring ){
592 $(row).addClass("date_past");
597 $(".show_past").on("change", function(){
601 $("a.helptext").click(function(){
602 $(this).parent().find(".hint").toggle(); return false;
605 const dateofrange = document.querySelector("#dateofrange")._flatpickr;
606 const datecancelrange = document.querySelector("#datecancelrange")._flatpickr;
608 $("#dateofrange").each(function () { this.value = "" });
609 $("#datecancelrange").each(function () { this.value = "" });
611 var maincalendar = $("#calendar-anchor").flatpickr({
613 onReady: function( selectedDates, dateStr, instance ){
614 // We do not want to display the 'close' icon in this case
615 $(instance.input).siblings('.flatpickr-input').hide();
617 onDayCreate: function( dObj, dStr, fp, dayElem ){
618 /* for each day on the calendar, get the
619 correct status information for the date */
620 dateStatusHandler( dayElem );
622 onChange: function( selectedDates, dateStr, instance ){
623 var fromdate = selectedDates[0];
624 var enddate = dateofrange.selectedDates[0];
626 dateChanged( fromdate );
628 dateofrange.set( 'defaultDate', fromdate );
629 dateofrange.set( 'minDate', fromdate );
631 if ( enddate != undefined ) {
632 if ( enddate < fromdate ) {
633 dateofrange.set("defaultDate", fromdate);
634 dateofrange.setDate(fromdate);
639 defaultDate: new Date("[% keydate | html %]")
642 $(".hidePanel").on("click",function(){
643 if( $(this).hasClass("showHoliday") ){
644 hidePanel("showHoliday");
646 hidePanel("newHoliday");
653 [% INCLUDE 'intranet-bottom.inc' %]