5 [% PROCESS 'i18n.inc' %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% FILTER collapse %]
9 [% tx("{library} calendar", { library = Branches.GetName( branch ) }) | html %] ›
10 [% t("Tools") | html %] ›
11 [% t("Koha") | html %]
13 [% INCLUDE 'doc-head-close.inc' %]
14 [% Asset.css("css/calendar.css") | $raw %]
16 <body id="tools_holidays" class="tools">
17 [% WRAPPER 'header.inc' %]
18 [% INCLUDE 'cat-search.inc' %]
21 [% WRAPPER 'sub-header.inc' %]
22 [% WRAPPER breadcrumbs %]
23 [% WRAPPER breadcrumb_item %]
24 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
26 [% WRAPPER breadcrumb_item bc_active= 1 %]
27 [% tx("{library} calendar", { library = Branches.GetName( branch ) }) | html %]
29 [% END #/ WRAPPER breadcrumbs %]
30 [% END #/ WRAPPER sub-header.inc %]
32 <div class="main container-fluid">
34 <div class="col-sm-10 col-sm-push-2">
37 <h1>[% tx("{library} calendar", { library = Branches.GetName( branch ) }) | html %]</h1>
40 <div class="col-sm-6">
41 <div class="page-section">
42 <label for="branch">Define the holidays for:</label>
43 <select id="branch" name="branch">
44 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
47 <div class="panel" id="showHoliday">
48 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
49 <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
50 <fieldset class="brief">
51 <h3>Edit this holiday</h3>
52 <span id="holtype"></span>
55 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
56 <input type="hidden" id="showBranchName" name="showBranchName" />
59 <strong>From date:</strong>
60 <span id="showDaynameOutput"></span>,
61 [% IF ( dateformat == "us" ) %]
62 <span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>
63 [% ELSIF ( dateformat == "metric") %]
64 <span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>
65 [% ELSIF ( dateformat == "dmydot") %]
66 <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>
69 <input type="hidden" id="showDayname" name="showDayname" />
70 <input type="hidden" id="showWeekday" name="showWeekday" />
71 <input type="hidden" id="showDay" name="showDay" />
72 <input type="hidden" id="showMonth" name="showMonth" />
73 <input type="hidden" id="showYear" name="showYear" />
75 <li class="dateinsert">
76 <strong>To date: </strong>
77 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" class="flatpickr" />
80 <label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" />
82 <!-- showTitle is necessary for exception radio button to work properly -->
84 <label for="showDescription">Description:</label>
85 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
88 <div class="exceptionPossibility" style="position:static">
89 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
90 <a href="#" class="helptext">[?]</a>
91 <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>
95 <div class="exceptionPossibility" style="position:static">
96 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
97 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
98 <a href="#" class="helptext">[?]</a>
99 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
103 <input type="radio" name="showOperation" id="showOperationDel" value="delete" />
104 <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
105 <a href="#" class="helptext">[?]</a>
106 <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>
109 <input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
110 <a href="#" class="helptext">[?]</a>
111 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
114 <input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
115 <a href="#" class="helptext">[?]</a>
116 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
119 <input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
120 <a href="#" class="helptext">[?]</a>
121 <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>
124 <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
125 <a href="#" class="helptext">[?]</a>
126 <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>
127 <li class="checkbox">
128 <input type="checkbox" name="allBranches" id="allBranches" />
129 <label for="allBranches">Copy changes to all libraries</label>.
130 <a href="#" class="helptext">[?]</a>
131 <div class="hint">If checked, changes for this holiday will be copied to all libraries. If the holiday doesn't exists for a library, holiday is added to calendar. NOTE! This might overwrite existing holidays in other calendars.</div>
134 <fieldset class="action">
135 <input type="submit" name="submit" class="btn btn-primary" value="Save" />
136 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
138 </fieldset> <!-- /.brief -->
140 </div> <!-- /#showHoliday -->
142 <!-- Panel to deal with new holidays -->
143 <div class="panel" id="newHoliday">
144 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
145 <fieldset class="brief">
146 <h3>Add new holiday</h3>
149 <strong>Library:</strong>
150 <span id="newBranchNameOutput"></span>
151 <input type="hidden" id="newBranchName" name="newBranchName" />
154 <strong>From date:</strong>
155 <span id="newDaynameOutput"></span>,
157 [% IF ( dateformat == "us" ) %]
158 <span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>
159 [% ELSIF ( dateformat == "metric" ) %]
160 <span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>
161 [% ELSIF ( dateformat == "dmydot" ) %]
162 <span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>
164 <span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>
167 <input type="hidden" id="newDayname" name="showDayname" />
168 <input type="hidden" id="newWeekday" name="newWeekday" />
169 <input type="hidden" id="newDay" name="newDay" />
170 <input type="hidden" id="newMonth" name="newMonth" />
171 <input type="hidden" id="newYear" name="newYear" />
173 <li class="dateinsert">
174 <strong>To date: </strong>
175 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" class="flatpickr" />
176 <div class="hint">This field only applies when holidays are added on a range.</div>
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" class="btn btn-primary" 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" class="btn btn-primary" value="Copy" />
247 </div> <!-- /.page-section -->
248 </div> <!-- /.col-sm-6 -->
250 <div class="col-sm-6">
251 <div class="page-section">
255 <li>Search in the calendar the day you want to set as holiday.</li>
256 <li>Click the date to add or edit a holiday.</li>
257 <li>Enter a title and description for the holiday.</li>
258 <li>Specify how the holiday should repeat.</li>
259 <li>Click Save to finish.</li>
263 <span class="key normalday">Working day</span>
264 <span class="key holiday">Unique holiday</span>
265 <span class="key repeatableweekly">Holiday repeating weekly</span>
266 <span class="key repeatableyearly">Holiday repeating yearly</span>
267 <span class="key exception">Holiday exception</span>
269 </div> <!-- /#help -->
271 <div id="holiday-list">
272 <!-- Exceptions First -->
273 <!-- this will probably always have the least amount of data -->
274 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
276 <label class="controls">
277 <input type="checkbox" name="show_past" id="show_past_holidayexceptions" class="show_past" />
280 <table id="holidayexceptions">
283 <th class="exception">Date</th>
284 <th class="exception">Title</th>
285 <th class="exception">Description</th>
289 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
290 <tr data-date="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
291 <td data-order="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
292 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]">
293 [% EXCEPTION_HOLIDAYS_LOO.DATE | html %]
296 <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
297 <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
301 </table> <!-- /#holidayexceptions -->
302 [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
304 [% IF ( WEEK_DAYS_LOOP ) %]
305 <h3>Weekly - Repeatable holidays</h3>
306 <table id="holidayweeklyrepeatable">
309 <th class="repeatableweekly">Day of week</th>
310 <th class="repeatableweekly">Title</th>
311 <th class="repeatableweekly">Description</th>
315 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
317 <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
318 <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
319 <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
323 </table> <!-- /#holidayweeklyrepeatable -->
324 [% END # / IF ( WEEK_DAYS_LOOP ) %]
326 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
327 <h3>Yearly - Repeatable holidays</h3>
328 <table id="holidaysyearlyrepeatable">
331 [% IF ( dateformat == "metric" ) %]
332 <th class="repeatableyearly">Day/month</th>
334 <th class="repeatableyearly">Month/day</th>
336 <th class="repeatableyearly">Title</th>
337 <th class="repeatableyearly">Description</th>
341 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
343 <td data-order="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">
344 [% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]
346 <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
347 <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
351 </table> <!-- /#holidaysyearlyrepeatable -->
352 [% END # /IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
354 [% IF ( HOLIDAYS_LOOP ) %]
355 <h3>Unique holidays</h3>
356 <label class="controls">
357 <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" />
360 <table id="holidaysunique">
363 <th class="holiday">Date</th>
364 <th class="holiday">Title</th>
365 <th class="holiday">Description</th>
369 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
370 <tr data-date="[% HOLIDAYS_LOO.DATE_SORT | html %]">
371 <td data-order="[% HOLIDAYS_LOO.DATE_SORT | html %]">
372 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% HOLIDAYS_LOO.DATE | uri %]">
373 [% HOLIDAYS_LOO.DATE | html %]
376 <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
377 <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
381 </table> <!-- #holidaysunique -->
382 [% END # /IF ( HOLIDAYS_LOOP ) %]
383 </div> <!-- /#holiday-list -->
384 </div> <!-- /.page-section -->
385 </div> <!-- /.col-sm-6 -->
386 </div> <!-- /.row -->
388 </div> <!-- /.col-sm-10.col-sm-push-2 -->
390 <div class="col-sm-2 col-sm-pull-10">
392 [% INCLUDE 'tools-menu.inc' %]
394 </div> <!-- .col-sm-2.col-sm-pull-10 -->
395 </div> <!-- /.row -->
397 [% MACRO jsinclude BLOCK %]
398 [% INCLUDE 'calendar.inc' %]
399 [% INCLUDE 'datatables.inc' %]
400 [% Asset.js("js/tools-menu.js") | $raw %]
402 var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
404 /* Creates all the structures to deal with all different kinds of holidays */
405 var week_days = new Array();
406 var holidays = new Array();
407 var holidates = new Array();
408 var exception_holidays = new Array();
409 var day_month_holidays = new Array();
410 var hola= "[% code | html %]";
411 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
412 week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
414 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
415 holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
416 holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
418 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
419 exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
421 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
422 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 %]"};
425 function holidayOperation(formObject, opType) {
426 var op = document.getElementsByName('operation');
427 op[0].value = opType;
431 // This function shows the "Show Holiday" panel //
432 function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
433 $("#newHoliday").slideUp("fast");
434 $("#showHoliday").slideDown("fast");
435 $('#showDaynameOutput').html(dayName);
436 $('#showDayname').val(dayName);
437 $('#showBranchNameOutput').html($("#branch :selected").text());
438 $('#showBranchName').val($("#branch").val());
439 $('#showDayOutput').html(day);
440 $('#showDay').val(day);
441 $('#showMonthOutput').html(month);
442 $('#showMonth').val(month);
443 $('#showYearOutput').html(year);
444 $('#showYear').val(year);
445 $('#showDescription').val(description);
446 $('#showWeekday:first').val(weekDay);
447 $('#showTitle').val(title);
448 $('#showHolidayType').val(holidayType);
450 if (holidayType == 'exception') {
451 $("#showOperationDelLabel").html(_("Delete this exception."));
452 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
453 } else if(holidayType == 'weekday') {
454 $("#showOperationDelLabel").html(_("Delete this holiday."));
455 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
456 } else if(holidayType == 'daymonth') {
457 $("#showOperationDelLabel").html(_("Delete this holiday."));
458 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
460 $("#showOperationDelLabel").html(_("Delete this holiday."));
461 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
464 if (exceptionPossibility == 1) {
465 $(".exceptionPossibility").parent().show();
467 $(".exceptionPossibility").parent().hide();
471 // This function shows the "Add Holiday" panel //
472 function newHoliday (dayName, day, month, year, weekDay) {
473 $("#showHoliday").slideUp("fast");
474 $("#newHoliday").slideDown("fast");
475 $("#newDaynameOutput").html(dayName);
476 $("#newDayname").val(dayName);
477 $("#newBranchNameOutput").html($('#branch :selected').text());
478 $("#newBranchName").val($('#branch').val());
479 $("#newDayOutput").html(day);
480 $("#newDay").val(day);
481 $("#newMonthOutput").html(month);
482 $("#newMonth").val(month);
483 $("#newYearOutput").html(year);
484 $("#newYear").val(year);
485 $("#newWeekday:first").val(weekDay);
488 function hidePanel(aPanelName) {
489 $("#"+aPanelName).slideUp("fast");
492 function changeBranch () {
493 var branch = $("#branch option:selected").val();
494 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
498 * Build settings to be passed to the formatDay function for each day in the calendar
499 * @param {object} dayElem - HTML node passed from Flatpickr
502 function dateStatusHandler( dayElem ) {
503 var day = dayElem.dateObj.getDate();
504 var month = dayElem.dateObj.getMonth() + 1;
505 var year = dayElem.dateObj.getFullYear();
506 var weekDay = dayElem.dateObj.getDay();
507 var dayMonth = month + '/' + day;
508 var dateString = year + '/' + month + '/' + day;
509 if (exception_holidays[dateString] != null) {
510 formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem );
511 } else if ( week_days[weekDay] != null ){
512 formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem );
513 } else if ( day_month_holidays[dayMonth] != null ) {
514 formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem );
515 } else if (holidays[dateString] != null) {
516 formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem );
518 formatDay( [ "normalday", _("Normal day")], dayElem );
523 * Adds style and title attribute to a day on the calendar
524 * @param {object} settings - span class attribute ([0]) and title attribute ([1])
525 * @param {node} dayElem - HTML node passed from Flatpickr
528 function formatDay( settings, dayElem ){
529 $(dayElem).attr("title", settings[1]).addClass( settings[0]);
533 * Triggers an action based on a click on a calendar day: If a holiday exists on
534 * that day it loads an edit form. If there is no existing holiday one can be created
535 * @param {object} calendar - a Date object corresponding to the clicked day
538 function dateChanged( calendar ) {
539 var day = calendar.getDate();
540 var month = calendar.getMonth() + 1;
541 var year = calendar.getFullYear();
542 var weekDay = calendar.getDay();
543 var dayName = weekdays[weekDay];
544 var dayMonth = month + '/' + day;
545 var dateString = year + '/' + month + '/' + day;
546 if (holidays[dateString] != null) {
547 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
548 } else if (exception_holidays[dateString] != null) {
549 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
550 } else if (week_days[weekDay] != null) {
551 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
552 } else if (day_month_holidays[dayMonth] != null) {
553 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
555 newHoliday(dayName, day, month, year, weekDay);
559 /* Custom table search configuration: If a table row
560 has an "expired" class, hide it UNLESS the
561 show_expired checkbox is checked */
562 $.fn.dataTable.ext.search.push(
563 function( settings, searchData, index, rowData, counter ) {
564 var table = settings.nTable.id;
565 var row = $(settings.aoData[index].nTr);
566 if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){
574 // Create current date variable
575 var date = new Date();
576 var datestring = date.toISOString().substring(0, 10);
578 $(document).ready(function() {
580 $(".helptext + .hint").hide();
581 $("#branch").change(function(){
584 $("#holidayweeklyrepeatable>tbody>tr").each(function(){
585 var first_td = $(this).find('td').first();
586 first_td.html(weekdays[first_td.html()]);
588 $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
592 var tables = $("#holidayexceptions, #holidaysyearlyrepeatable, #holidaysunique").DataTable($.extend(true, {}, dataTablesDefaults, {
595 "createdRow": function( row, data, dataIndex ) {
596 var holiday = $(row).data("date");
597 if( holiday < datestring ){
598 $(row).addClass("date_past");
603 $(".show_past").on("change", function(){
607 $("a.helptext").click(function(){
608 $(this).parent().find(".helptext + .hint").toggle(); return false;
611 const dateofrange = document.querySelector("#dateofrange")._flatpickr;
612 const datecancelrange = document.querySelector("#datecancelrange")._flatpickr;
614 $("#dateofrange").each(function () { this.value = "" });
615 $("#datecancelrange").each(function () { this.value = "" });
617 var maincalendar = $("#calendar-anchor").flatpickr({
619 onReady: function( selectedDates, dateStr, instance ){
620 // We do not want to display the 'close' icon in this case
621 $(instance.input).siblings('.flatpickr-input').hide();
623 onDayCreate: function( dObj, dStr, fp, dayElem ){
624 /* for each day on the calendar, get the
625 correct status information for the date */
626 dateStatusHandler( dayElem );
628 onChange: function( selectedDates, dateStr, instance ){
629 var fromdate = selectedDates[0];
630 var enddate = dateofrange.selectedDates[0];
632 dateChanged( fromdate );
634 dateofrange.set( 'defaultDate', fromdate );
635 dateofrange.set( 'minDate', fromdate );
637 if ( enddate != undefined ) {
638 if ( enddate < fromdate ) {
639 dateofrange.set("defaultDate", fromdate);
640 dateofrange.setDate(fromdate);
645 defaultDate: new Date("[% keydate | html %]")
648 $(".hidePanel").on("click",function(){
649 if( $(this).hasClass("showHoliday") ){
650 hidePanel("showHoliday");
652 hidePanel("newHoliday");
659 [% INCLUDE 'intranet-bottom.inc' %]