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">
36 [% INCLUDE 'messages.inc' %]
38 <h1>[% tx("{library} calendar", { library = Branches.GetName( branch ) }) | html %]</h1>
41 <div class="col-sm-6">
42 <div class="page-section">
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 [% INCLUDE 'csrf-token.inc' %]
51 <input type="hidden" name="op" value="cud-edit" />
52 <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
53 <fieldset class="brief">
54 <h3>Edit this holiday</h3>
55 <span id="holtype"></span>
58 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
59 <input type="hidden" id="showBranchName" name="showBranchName" />
62 <strong>From date:</strong>
63 <span id="showDaynameOutput"></span>,
64 [% IF ( dateformat == "us" ) %]
65 <span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>
66 [% ELSIF ( dateformat == "metric") %]
67 <span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>
68 [% ELSIF ( dateformat == "dmydot") %]
69 <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>
72 <input type="hidden" id="showDayname" name="showDayname" />
73 <input type="hidden" id="showWeekday" name="showWeekday" />
74 <input type="hidden" id="showDay" name="showDay" />
75 <input type="hidden" id="showMonth" name="showMonth" />
76 <input type="hidden" id="showYear" name="showYear" />
78 <li class="dateinsert">
79 <strong>To date: </strong>
80 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" class="flatpickr" />
83 <label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" />
85 <!-- showTitle is necessary for exception radio button to work properly -->
87 <label for="showDescription">Description:</label>
88 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
91 <div class="exceptionPossibility" style="position:static">
92 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
93 <a href="#" class="helptext">[?]</a>
94 <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>
98 <div class="exceptionPossibility" style="position:static">
99 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
100 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
101 <a href="#" class="helptext">[?]</a>
102 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
106 <input type="radio" name="showOperation" id="showOperationDel" value="cud-delete" />
107 <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
108 <a href="#" class="helptext">[?]</a>
109 <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>
112 <input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
113 <a href="#" class="helptext">[?]</a>
114 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
117 <input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
118 <a href="#" class="helptext">[?]</a>
119 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
122 <input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
123 <a href="#" class="helptext">[?]</a>
124 <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>
127 <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
128 <a href="#" class="helptext">[?]</a>
129 <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>
130 <li class="checkbox">
131 <input type="checkbox" name="allBranches" id="allBranches" />
132 <label for="allBranches">Copy changes to all libraries</label>.
133 <a href="#" class="helptext">[?]</a>
134 <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>
137 <fieldset class="action">
138 <input type="submit" name="submit" class="btn btn-primary" value="Save" />
139 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
141 </fieldset> <!-- /.brief -->
143 </div> <!-- /#showHoliday -->
145 <!-- Panel to deal with new holidays -->
146 <div class="panel" id="newHoliday">
147 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
148 [% INCLUDE 'csrf-token.inc' %]
149 <input type="hidden" name="op" value="cud-add" />
150 <fieldset class="brief">
151 <h3>Add new holiday</h3>
154 <strong>Library:</strong>
155 <span id="newBranchNameOutput"></span>
156 <input type="hidden" id="newBranchName" name="newBranchName" />
159 <strong>From date:</strong>
160 <span id="newDaynameOutput"></span>,
162 [% IF ( dateformat == "us" ) %]
163 <span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>
164 [% ELSIF ( dateformat == "metric" ) %]
165 <span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>
166 [% ELSIF ( dateformat == "dmydot" ) %]
167 <span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>
169 <span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>
172 <input type="hidden" id="newDayname" name="showDayname" />
173 <input type="hidden" id="newWeekday" name="newWeekday" />
174 <input type="hidden" id="newDay" name="newDay" />
175 <input type="hidden" id="newMonth" name="newMonth" />
176 <input type="hidden" id="newYear" name="newYear" />
178 <li class="dateinsert">
179 <strong>To date: </strong>
180 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" class="flatpickr" />
181 <div class="hint">This field only applies when holidays are added on a range.</div>
184 <label for="title">Title: </label>
185 <input type="text" name="newTitle" id="title" size="35" /></li>
187 <label for="newDescription">Description:</label>
188 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
191 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
192 <label for="newOperationOnce">Holiday only on this day</label>.
193 <a href="#" class="helptext">[?]</a>
194 <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>
197 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
198 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
199 <a href="#" class="helptext">[?]</a>
200 <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>
203 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
204 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
205 <a href="#" class="helptext">[?]</a>
206 <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>
209 <input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
210 <label for="newOperationField">Holidays on a range</label>.
211 <a href="#" class="helptext">[?]</a>
212 <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>
215 <input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
216 <label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
217 <a href="#" class="helptext">[?]</a>
218 <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>
220 <li class="checkbox">
221 <input type="checkbox" name="allBranches" id="allBranches" />
222 <label for="allBranches">Copy to all libraries</label>.
223 <a href="#" class="helptext">[?]</a>
224 <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>
227 <fieldset class="action">
228 <input type="submit" name="submit" class="btn btn-primary" value="Save" />
229 <a href="#" class="cancel hidePanel newHoliday">Cancel</a>
231 </fieldset> <!-- /.brief -->
233 </div> <!-- /#newHoliday -->
235 <div id="calendar-container">
236 <h3>Calendar information</h3>
237 <span id="calendar-anchor"></span>
239 <div style="margin-top: 2em;">
240 <form action="copy-holidays.pl" method="post">
241 [% INCLUDE 'csrf-token.inc' %]
242 <input type="hidden" name="op" value="cud-copy" />
243 <input type="hidden" name="from_branchcode" value="[% branch | html %]" />
244 <label for="branchcode">Copy holidays to:</label>
245 <select id="branchcode" name="branchcode">
246 <option value=""></option>
247 [% FOREACH l IN Branches.all() %]
248 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
251 <input type="submit" class="btn btn-primary" value="Copy" />
254 </div> <!-- /.page-section -->
255 </div> <!-- /.col-sm-6 -->
257 <div class="col-sm-6">
258 <div class="page-section">
262 <li>Search in the calendar the day you want to set as holiday.</li>
263 <li>Click the date to add or edit a holiday.</li>
264 <li>Enter a title and description for the holiday.</li>
265 <li>Specify how the holiday should repeat.</li>
266 <li>Click Save to finish.</li>
270 <span class="key normalday">Working day</span>
271 <span class="key holiday">Unique holiday</span>
272 <span class="key repeatableweekly">Holiday repeating weekly</span>
273 <span class="key repeatableyearly">Holiday repeating yearly</span>
274 <span class="key exception">Holiday exception</span>
276 </div> <!-- /#help -->
278 <div id="holiday-list">
279 <!-- Exceptions First -->
280 <!-- this will probably always have the least amount of data -->
281 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
283 <label class="controls">
284 <input type="checkbox" name="show_past" id="show_past_holidayexceptions" class="show_past" />
287 <table id="holidayexceptions">
290 <th class="exception">Date</th>
291 <th class="exception">Title</th>
292 <th class="exception">Description</th>
296 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
297 <tr data-date="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
298 <td data-order="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
299 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]">
300 [% EXCEPTION_HOLIDAYS_LOO.DATE | html %]
303 <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
304 <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
308 </table> <!-- /#holidayexceptions -->
309 [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
311 [% IF ( WEEK_DAYS_LOOP ) %]
312 <h3>Weekly - Repeatable holidays</h3>
313 <table id="holidayweeklyrepeatable">
316 <th class="repeatableweekly">Day of week</th>
317 <th class="repeatableweekly">Title</th>
318 <th class="repeatableweekly">Description</th>
322 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
324 <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
325 <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
326 <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
330 </table> <!-- /#holidayweeklyrepeatable -->
331 [% END # / IF ( WEEK_DAYS_LOOP ) %]
333 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
334 <h3>Yearly - Repeatable holidays</h3>
335 <table id="holidaysyearlyrepeatable">
338 [% IF ( dateformat == "metric" ) %]
339 <th class="repeatableyearly">Day/month</th>
341 <th class="repeatableyearly">Month/day</th>
343 <th class="repeatableyearly">Title</th>
344 <th class="repeatableyearly">Description</th>
348 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
350 <td data-order="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">
351 [% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]
353 <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
354 <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
358 </table> <!-- /#holidaysyearlyrepeatable -->
359 [% END # /IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
361 [% IF ( HOLIDAYS_LOOP ) %]
362 <h3>Unique holidays</h3>
363 <label class="controls">
364 <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" />
367 <table id="holidaysunique">
370 <th class="holiday">Date</th>
371 <th class="holiday">Title</th>
372 <th class="holiday">Description</th>
376 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
377 <tr data-date="[% HOLIDAYS_LOO.DATE_SORT | html %]">
378 <td data-order="[% HOLIDAYS_LOO.DATE_SORT | html %]">
379 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% HOLIDAYS_LOO.DATE | uri %]">
380 [% HOLIDAYS_LOO.DATE | html %]
383 <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
384 <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
388 </table> <!-- #holidaysunique -->
389 [% END # /IF ( HOLIDAYS_LOOP ) %]
390 </div> <!-- /#holiday-list -->
391 </div> <!-- /.page-section -->
392 </div> <!-- /.col-sm-6 -->
393 </div> <!-- /.row -->
395 </div> <!-- /.col-sm-10.col-sm-push-2 -->
397 <div class="col-sm-2 col-sm-pull-10">
399 [% INCLUDE 'tools-menu.inc' %]
401 </div> <!-- .col-sm-2.col-sm-pull-10 -->
402 </div> <!-- /.row -->
404 [% MACRO jsinclude BLOCK %]
405 [% INCLUDE 'calendar.inc' %]
406 [% INCLUDE 'datatables.inc' %]
407 [% Asset.js("js/tools-menu.js") | $raw %]
409 var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
411 /* Creates all the structures to deal with all different kinds of holidays */
412 var week_days = new Array();
413 var holidays = new Array();
414 var holidates = new Array();
415 var exception_holidays = new Array();
416 var day_month_holidays = new Array();
417 var hola= "[% code | html %]";
418 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
419 week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
421 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
422 holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
423 holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
425 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
426 exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
428 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
429 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 %]"};
432 function holidayOperation(formObject, opType) {
433 var op = document.getElementsByName('operation');
434 op[0].value = opType;
438 // This function shows the "Show Holiday" panel //
439 function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
440 $("#newHoliday").slideUp("fast");
441 $("#showHoliday").slideDown("fast");
442 $('#showDaynameOutput').html(dayName);
443 $('#showDayname').val(dayName);
444 $('#showBranchNameOutput').html($("#branch :selected").text());
445 $('#showBranchName').val($("#branch").val());
446 $('#showDayOutput').html(day);
447 $('#showDay').val(day);
448 $('#showMonthOutput').html(month);
449 $('#showMonth').val(month);
450 $('#showYearOutput').html(year);
451 $('#showYear').val(year);
452 $('#showDescription').val(description);
453 $('#showWeekday:first').val(weekDay);
454 $('#showTitle').val(title);
455 $('#showHolidayType').val(holidayType);
457 if (holidayType == 'exception') {
458 $("#showOperationDelLabel").html(_("Delete this exception."));
459 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
460 } else if(holidayType == 'weekday') {
461 $("#showOperationDelLabel").html(_("Delete this holiday."));
462 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
463 } else if(holidayType == 'daymonth') {
464 $("#showOperationDelLabel").html(_("Delete this holiday."));
465 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
467 $("#showOperationDelLabel").html(_("Delete this holiday."));
468 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
471 if (exceptionPossibility == 1) {
472 $(".exceptionPossibility").parent().show();
474 $(".exceptionPossibility").parent().hide();
478 // This function shows the "Add Holiday" panel //
479 function newHoliday (dayName, day, month, year, weekDay) {
480 $("#showHoliday").slideUp("fast");
481 $("#newHoliday").slideDown("fast");
482 $("#newDaynameOutput").html(dayName);
483 $("#newDayname").val(dayName);
484 $("#newBranchNameOutput").html($('#branch :selected').text());
485 $("#newBranchName").val($('#branch').val());
486 $("#newDayOutput").html(day);
487 $("#newDay").val(day);
488 $("#newMonthOutput").html(month);
489 $("#newMonth").val(month);
490 $("#newYearOutput").html(year);
491 $("#newYear").val(year);
492 $("#newWeekday:first").val(weekDay);
495 function hidePanel(aPanelName) {
496 $("#"+aPanelName).slideUp("fast");
499 function changeBranch () {
500 var branch = $("#branch option:selected").val();
501 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
505 * Build settings to be passed to the formatDay function for each day in the calendar
506 * @param {object} dayElem - HTML node passed from Flatpickr
509 function dateStatusHandler( dayElem ) {
510 var day = dayElem.dateObj.getDate();
511 var month = dayElem.dateObj.getMonth() + 1;
512 var year = dayElem.dateObj.getFullYear();
513 var weekDay = dayElem.dateObj.getDay();
514 var dayMonth = month + '/' + day;
515 var dateString = year + '/' + month + '/' + day;
516 if (exception_holidays[dateString] != null) {
517 formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem );
518 } else if ( week_days[weekDay] != null ){
519 formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem );
520 } else if ( day_month_holidays[dayMonth] != null ) {
521 formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem );
522 } else if (holidays[dateString] != null) {
523 formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem );
525 formatDay( [ "normalday", _("Normal day")], dayElem );
530 * Adds style and title attribute to a day on the calendar
531 * @param {object} settings - span class attribute ([0]) and title attribute ([1])
532 * @param {node} dayElem - HTML node passed from Flatpickr
535 function formatDay( settings, dayElem ){
536 $(dayElem).attr("title", settings[1]).addClass( settings[0]);
540 * Triggers an action based on a click on a calendar day: If a holiday exists on
541 * that day it loads an edit form. If there is no existing holiday one can be created
542 * @param {object} calendar - a Date object corresponding to the clicked day
545 function dateChanged( calendar ) {
546 var day = calendar.getDate();
547 var month = calendar.getMonth() + 1;
548 var year = calendar.getFullYear();
549 var weekDay = calendar.getDay();
550 var dayName = weekdays[weekDay];
551 var dayMonth = month + '/' + day;
552 var dateString = year + '/' + month + '/' + day;
553 if (holidays[dateString] != null) {
554 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
555 } else if (exception_holidays[dateString] != null) {
556 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
557 } else if (week_days[weekDay] != null) {
558 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
559 } else if (day_month_holidays[dayMonth] != null) {
560 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
562 newHoliday(dayName, day, month, year, weekDay);
566 /* Custom table search configuration: If a table row
567 has an "expired" class, hide it UNLESS the
568 show_expired checkbox is checked */
569 $.fn.dataTable.ext.search.push(
570 function( settings, searchData, index, rowData, counter ) {
571 var table = settings.nTable.id;
572 var row = $(settings.aoData[index].nTr);
573 if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){
581 // Create current date variable
582 var date = new Date();
583 var datestring = date.toISOString().substring(0, 10);
585 $(document).ready(function() {
587 $(".helptext + .hint").hide();
588 $("#branch").change(function(){
591 $("#holidayweeklyrepeatable>tbody>tr").each(function(){
592 var first_td = $(this).find('td').first();
593 first_td.html(weekdays[first_td.html()]);
595 $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
599 var tables = $("#holidayexceptions, #holidaysyearlyrepeatable, #holidaysunique").DataTable($.extend(true, {}, dataTablesDefaults, {
602 "createdRow": function( row, data, dataIndex ) {
603 var holiday = $(row).data("date");
604 if( holiday < datestring ){
605 $(row).addClass("date_past");
610 $(".show_past").on("change", function(){
614 $("a.helptext").click(function(){
615 $(this).parent().find(".helptext + .hint").toggle(); return false;
618 const dateofrange = document.querySelector("#dateofrange")._flatpickr;
619 const datecancelrange = document.querySelector("#datecancelrange")._flatpickr;
621 $("#dateofrange").each(function () { this.value = "" });
622 $("#datecancelrange").each(function () { this.value = "" });
624 var maincalendar = $("#calendar-anchor").flatpickr({
626 onReady: function( selectedDates, dateStr, instance ){
627 // We do not want to display the 'close' icon in this case
628 $(instance.input).siblings('.flatpickr-input').hide();
630 onDayCreate: function( dObj, dStr, fp, dayElem ){
631 /* for each day on the calendar, get the
632 correct status information for the date */
633 dateStatusHandler( dayElem );
635 onChange: function( selectedDates, dateStr, instance ){
636 var fromdate = selectedDates[0];
637 var enddate = dateofrange.selectedDates[0];
639 dateChanged( fromdate );
641 dateofrange.set( 'defaultDate', fromdate );
642 dateofrange.set( 'minDate', fromdate );
644 if ( enddate != undefined ) {
645 if ( enddate < fromdate ) {
646 dateofrange.set("defaultDate", fromdate);
647 dateofrange.setDate(fromdate);
652 defaultDate: new Date("[% keydate | html %]")
655 $(".hidePanel").on("click",function(){
656 if( $(this).hasClass("showHoliday") ){
657 hidePanel("showHoliday");
659 hidePanel("newHoliday");
666 [% INCLUDE 'intranet-bottom.inc' %]