5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>[% Branches.GetName( branch ) | html %] calendar › Tools › Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("css/calendar.css") | $raw %]
10 <body id="tools_holidays" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
14 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
17 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
20 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23 <a href="#" aria-current="page">
24 [% Branches.GetName( branch ) | html %] calendar
30 <div class="main container-fluid">
32 <div class="col-sm-10 col-sm-push-2">
35 <h1>[% Branches.GetName( branch ) | html %] calendar</h1>
38 <div class="col-sm-6">
39 <label for="branch">Define the holidays for:</label>
40 <select id="branch" name="branch">
41 [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
44 <div class="panel" id="showHoliday">
45 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
46 <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
47 <fieldset class="brief">
48 <h3>Edit this holiday</h3>
49 <span id="holtype"></span>
52 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
53 <input type="hidden" id="showBranchName" name="showBranchName" />
56 <strong>From date:</strong>
57 <span id="showDaynameOutput"></span>,
58 [% IF ( dateformat == "us" ) %]
59 <span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>
60 [% ELSIF ( dateformat == "metric") %]
61 <span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>
62 [% ELSIF ( dateformat == "dmydot") %]
63 <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>
66 <input type="hidden" id="showDayname" name="showDayname" />
67 <input type="hidden" id="showWeekday" name="showWeekday" />
68 <input type="hidden" id="showDay" name="showDay" />
69 <input type="hidden" id="showMonth" name="showMonth" />
70 <input type="hidden" id="showYear" name="showYear" />
72 <li class="dateinsert">
73 <strong>To date: </strong>
74 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" />
77 <label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" />
79 <!-- showTitle is necessary for exception radio button to work properly -->
81 <label for="showDescription">Description:</label>
82 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
85 <div class="exceptionPossibility" style="position:static">
86 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
87 <a href="#" class="helptext">[?]</a>
88 <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>
92 <div class="exceptionPossibility" style="position:static">
93 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
94 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
95 <a href="#" class="helptext">[?]</a>
96 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
100 <input type="radio" name="showOperation" id="showOperationDel" value="delete" />
101 <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
102 <a href="#" class="helptext">[?]</a>
103 <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>
106 <input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
107 <a href="#" class="helptext">[?]</a>
108 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
111 <input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
112 <a href="#" class="helptext">[?]</a>
113 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
116 <input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
117 <a href="#" class="helptext">[?]</a>
118 <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>
121 <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
122 <a href="#" class="helptext">[?]</a>
123 <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>
124 <li class="checkbox">
125 <input type="checkbox" name="allBranches" id="allBranches" />
126 <label for="allBranches">Copy changes to all libraries</label>.
127 <a href="#" class="helptext">[?]</a>
128 <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>
131 <fieldset class="action">
132 <input type="submit" name="submit" value="Save" />
133 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
135 </fieldset> <!-- /.brief -->
137 </div> <!-- /#showHoliday -->
139 <!-- Panel to deal with new holidays -->
140 <div class="panel" id="newHoliday">
141 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
142 <fieldset class="brief">
143 <h3>Add new holiday</h3>
146 <strong>Library:</strong>
147 <span id="newBranchNameOutput"></span>
148 <input type="hidden" id="newBranchName" name="newBranchName" />
151 <strong>From date:</strong>
152 <span id="newDaynameOutput"></span>,
154 [% IF ( dateformat == "us" ) %]
155 <span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>
156 [% ELSIF ( dateformat == "metric" ) %]
157 <span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>
158 [% ELSIF ( dateformat == "dmydot" ) %]
159 <span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>
161 <span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>
164 <input type="hidden" id="newDayname" name="showDayname" />
165 <input type="hidden" id="newWeekday" name="newWeekday" />
166 <input type="hidden" id="newDay" name="newDay" />
167 <input type="hidden" id="newMonth" name="newMonth" />
168 <input type="hidden" id="newYear" name="newYear" />
170 <li class="dateinsert">
171 <strong>To date: </strong>
172 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" />
175 <label for="title">Title: </label>
176 <input type="text" name="newTitle" id="title" size="35" /></li>
178 <label for="newDescription">Description:</label>
179 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
182 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
183 <label for="newOperationOnce">Holiday only on this day</label>.
184 <a href="#" class="helptext">[?]</a>
185 <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>
188 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
189 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
190 <a href="#" class="helptext">[?]</a>
191 <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>
194 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
195 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
196 <a href="#" class="helptext">[?]</a>
197 <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>
200 <input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
201 <label for="newOperationField">Holidays on a range</label>.
202 <a href="#" class="helptext">[?]</a>
203 <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>
206 <input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
207 <label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
208 <a href="#" class="helptext">[?]</a>
209 <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>
211 <li class="checkbox">
212 <input type="checkbox" name="allBranches" id="allBranches" />
213 <label for="allBranches">Copy to all libraries</label>.
214 <a href="#" class="helptext">[?]</a>
215 <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>
218 <fieldset class="action">
219 <input type="submit" name="submit" value="Save" />
220 <a href="#" class="cancel hidePanel newHoliday">Cancel</a>
222 </fieldset> <!-- /.brief -->
224 </div> <!-- /#newHoliday -->
226 <div id="calendar-container">
227 <h3>Calendar information</h3>
228 <span id="calendar-anchor"></span>
230 <div style="margin-top: 2em;">
231 <form action="copy-holidays.pl" method="post">
232 <input type="hidden" name="from_branchcode" value="[% branch | html %]" />
233 <label for="branchcode">Copy holidays to:</label>
234 <select id="branchcode" name="branchcode">
235 <option value=""></option>
236 [% FOREACH l IN Branches.all() %]
237 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
240 <input type="submit" value="Copy" />
243 </div> <!-- /.col-sm-6 -->
245 <div class="col-sm-6">
249 <li>Search in the calendar the day you want to set as holiday.</li>
250 <li>Click the date to add or edit a holiday.</li>
251 <li>Enter a title and description for the holiday.</li>
252 <li>Specify how the holiday should repeat.</li>
253 <li>Click Save to finish.</li>
257 <span class="key normalday">Working day</span>
258 <span class="key holiday">Unique holiday</span>
259 <span class="key repeatableweekly">Holiday repeating weekly</span>
260 <span class="key repeatableyearly">Holiday repeating yearly</span>
261 <span class="key exception">Holiday exception</span>
263 </div> <!-- /#help -->
265 <div id="holiday-list">
266 <!-- Exceptions First -->
267 <!-- this will probably always have the least amount of data -->
268 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
270 <label class="controls">
271 <input type="checkbox" name="show_past" id="show_past_holidayexceptions" class="show_past" />
274 <table id="holidayexceptions">
277 <th class="exception">Date</th>
278 <th class="exception">Title</th>
279 <th class="exception">Description</th>
283 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
284 <tr data-date="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
285 <td data-order="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">
286 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]">
287 [% EXCEPTION_HOLIDAYS_LOO.DATE | html %]
290 <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
291 <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
295 </table> <!-- /#holidayexceptions -->
296 [% END # /IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
298 [% IF ( WEEK_DAYS_LOOP ) %]
299 <h3>Weekly - Repeatable holidays</h3>
300 <table id="holidayweeklyrepeatable">
303 <th class="repeatableweekly">Day of week</th>
304 <th class="repeatableweekly">Title</th>
305 <th class="repeatableweekly">Description</th>
309 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
311 <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
312 <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
313 <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
317 </table> <!-- /#holidayweeklyrepeatable -->
318 [% END # / IF ( WEEK_DAYS_LOOP ) %]
320 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
321 <h3>Yearly - Repeatable holidays</h3>
322 <table id="holidaysyearlyrepeatable">
325 [% IF ( dateformat == "metric" ) %]
326 <th class="repeatableyearly">Day/month</th>
328 <th class="repeatableyearly">Month/day</th>
330 <th class="repeatableyearly">Title</th>
331 <th class="repeatableyearly">Description</th>
335 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
337 <td data-order="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">
338 [% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]
340 <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
341 <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
345 </table> <!-- /#holidaysyearlyrepeatable -->
346 [% END # /IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
348 [% IF ( HOLIDAYS_LOOP ) %]
349 <h3>Unique holidays</h3>
350 <label class="controls">
351 <input type="checkbox" name="show_past" id="show_past_holidaysunique" class="show_past" />
354 <table id="holidaysunique">
357 <th class="holiday">Date</th>
358 <th class="holiday">Title</th>
359 <th class="holiday">Description</th>
363 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
364 <tr data-date="[% HOLIDAYS_LOO.DATE_SORT | html %]">
365 <td data-order="[% HOLIDAYS_LOO.DATE_SORT | html %]">
366 <a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&calendardate=[% HOLIDAYS_LOO.DATE | uri %]">
367 [% HOLIDAYS_LOO.DATE | html %]
370 <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
371 <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
375 </table> <!-- #holidaysunique -->
376 [% END # /IF ( HOLIDAYS_LOOP ) %]
377 </div> <!-- /#holiday-list -->
378 </div> <!-- /.col-sm-6 -->
379 </div> <!-- /.row -->
381 </div> <!-- /.col-sm-10.col-sm-push-2 -->
383 <div class="col-sm-2 col-sm-pull-10">
385 [% INCLUDE 'tools-menu.inc' %]
387 </div> <!-- .col-sm-2.col-sm-pull-10 -->
388 </div> <!-- /.row -->
390 [% MACRO jsinclude BLOCK %]
391 [% INCLUDE 'calendar.inc' %]
392 [% INCLUDE 'datatables.inc' %]
393 [% Asset.js("js/tools-menu.js") | $raw %]
395 var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
397 /* Creates all the structures to deal with all different kinds of holidays */
398 var week_days = new Array();
399 var holidays = new Array();
400 var holidates = new Array();
401 var exception_holidays = new Array();
402 var day_month_holidays = new Array();
403 var hola= "[% code | html %]";
404 [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
405 week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
407 [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
408 holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
409 holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
411 [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
412 exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
414 [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
415 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 %]"};
418 function holidayOperation(formObject, opType) {
419 var op = document.getElementsByName('operation');
420 op[0].value = opType;
424 // This function shows the "Show Holiday" panel //
425 function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
426 $("#newHoliday").slideUp("fast");
427 $("#showHoliday").slideDown("fast");
428 $('#showDaynameOutput').html(dayName);
429 $('#showDayname').val(dayName);
430 $('#showBranchNameOutput').html($("#branch :selected").text());
431 $('#showBranchName').val($("#branch").val());
432 $('#showDayOutput').html(day);
433 $('#showDay').val(day);
434 $('#showMonthOutput').html(month);
435 $('#showMonth').val(month);
436 $('#showYearOutput').html(year);
437 $('#showYear').val(year);
438 $('#showDescription').val(description);
439 $('#showWeekday:first').val(weekDay);
440 $('#showTitle').val(title);
441 $('#showHolidayType').val(holidayType);
443 if (holidayType == 'exception') {
444 $("#showOperationDelLabel").html(_("Delete this exception."));
445 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
446 } else if(holidayType == 'weekday') {
447 $("#showOperationDelLabel").html(_("Delete this holiday."));
448 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
449 } else if(holidayType == 'daymonth') {
450 $("#showOperationDelLabel").html(_("Delete this holiday."));
451 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
453 $("#showOperationDelLabel").html(_("Delete this holiday."));
454 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
457 if (exceptionPossibility == 1) {
458 $(".exceptionPossibility").parent().show();
460 $(".exceptionPossibility").parent().hide();
464 // This function shows the "Add Holiday" panel //
465 function newHoliday (dayName, day, month, year, weekDay) {
466 $("#showHoliday").slideUp("fast");
467 $("#newHoliday").slideDown("fast");
468 $("#newDaynameOutput").html(dayName);
469 $("#newDayname").val(dayName);
470 $("#newBranchNameOutput").html($('#branch :selected').text());
471 $("#newBranchName").val($('#branch').val());
472 $("#newDayOutput").html(day);
473 $("#newDay").val(day);
474 $("#newMonthOutput").html(month);
475 $("#newMonth").val(month);
476 $("#newYearOutput").html(year);
477 $("#newYear").val(year);
478 $("#newWeekday:first").val(weekDay);
481 function hidePanel(aPanelName) {
482 $("#"+aPanelName).slideUp("fast");
485 function changeBranch () {
486 var branch = $("#branch option:selected").val();
487 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
491 * Build settings to be passed to the formatDay function for each day in the calendar
492 * @param {object} dayElem - HTML node passed from Flatpickr
495 function dateStatusHandler( dayElem ) {
496 var day = dayElem.dateObj.getDate();
497 var month = dayElem.dateObj.getMonth() + 1;
498 var year = dayElem.dateObj.getFullYear();
499 var weekDay = dayElem.dateObj.getDay();
500 var dayMonth = month + '/' + day;
501 var dateString = year + '/' + month + '/' + day;
502 if (exception_holidays[dateString] != null) {
503 formatDay( [ "exception", _("Exception: %s").format(exception_holidays[dateString].title)], dayElem );
504 } else if ( week_days[weekDay] != null ){
505 formatDay( [ "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)], dayElem );
506 } else if ( day_month_holidays[dayMonth] != null ) {
507 formatDay( [ "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)], dayElem );
508 } else if (holidays[dateString] != null) {
509 formatDay( [ "holiday", _("Single holiday: %s").format(holidays[dateString].title)], dayElem );
511 formatDay( [ "normalday", _("Normal day")], dayElem );
516 * Adds style and title attribute to a day on the calendar
517 * @param {object} settings - span class attribute ([0]) and title attribute ([1])
518 * @param {node} dayElem - HTML node passed from Flatpickr
521 function formatDay( settings, dayElem ){
522 $(dayElem).attr("title", settings[1]).addClass( settings[0]);
526 * Triggers an action based on a click on a calendar day: If a holiday exists on
527 * that day it loads an edit form. If there is no existing holiday one can be created
528 * @param {object} calendar - a Date object corresponding to the clicked day
531 function dateChanged( calendar ) {
532 var day = calendar.getDate();
533 var month = calendar.getMonth() + 1;
534 var year = calendar.getFullYear();
535 var weekDay = calendar.getDay();
536 var dayName = weekdays[weekDay];
537 var dayMonth = month + '/' + day;
538 var dateString = year + '/' + month + '/' + day;
539 if (holidays[dateString] != null) {
540 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title, holidays[dateString].description, 'ymd');
541 } else if (exception_holidays[dateString] != null) {
542 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
543 } else if (week_days[weekDay] != null) {
544 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title, week_days[weekDay].description, 'weekday');
545 } else if (day_month_holidays[dayMonth] != null) {
546 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
548 newHoliday(dayName, day, month, year, weekDay);
552 /* Custom table search configuration: If a table row
553 has an "expired" class, hide it UNLESS the
554 show_expired checkbox is checked */
555 $.fn.dataTable.ext.search.push(
556 function( settings, searchData, index, rowData, counter ) {
557 var table = settings.nTable.id;
558 var row = $(settings.aoData[index].nTr);
559 if( row.hasClass("date_past") && !$("#show_past_" + table ).prop("checked") ){
567 // Create current date variable
568 var date = new Date();
569 var datestring = date.toISOString().substring(0, 10);
571 $(document).ready(function() {
574 $("#branch").change(function(){
577 $("#holidayweeklyrepeatable>tbody>tr").each(function(){
578 var first_td = $(this).find('td').first();
579 first_td.html(weekdays[first_td.html()]);
581 $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
585 var tables = $("#holidayexceptions, #holidaysyearlyrepeatable, #holidaysunique").DataTable($.extend(true, {}, dataTablesDefaults, {
588 "createdRow": function( row, data, dataIndex ) {
589 var holiday = $(row).data("date");
590 if( holiday < datestring ){
591 $(row).addClass("date_past");
596 $(".show_past").on("change", function(){
600 $("a.helptext").click(function(){
601 $(this).parent().find(".hint").toggle(); return false;
604 var dateofrange = $("#dateofrange").flatpickr();
606 var datecancelrange = $("#datecancelrange").flatpickr();
608 $("#dateofrange").each(function () { this.value = "" });
609 $("#datecancelrange").each(function () { this.value = "" });
611 var maincalendar = $("#calendar-anchor").flatpickr({
616 onDayCreate: function( dObj, dStr, fp, dayElem ){
617 /* for each day on the calendar, get the
618 correct status information for the date */
619 dateStatusHandler( dayElem );
621 onChange: function( selectedDates, dateStr, instance ){
622 var fromdate = selectedDates[0];
623 var enddate = dateofrange.selectedDates[0];
625 dateChanged( fromdate );
627 dateofrange.set( 'defaultDate', fromdate );
628 dateofrange.set( 'minDate', fromdate );
630 if ( enddate != undefined ) {
631 if ( enddate < fromdate ) {
632 dateofrange.set("defaultDate", fromdate);
633 dateofrange.setDate(fromdate);
638 defaultDate: new Date("[% keydate | html %]")
641 $(".hidePanel").on("click",function(){
642 if( $(this).hasClass("showHoliday") ){
643 hidePanel("showHoliday");
645 hidePanel("newHoliday");
652 [% INCLUDE 'intranet-bottom.inc' %]