Bug 28044: Increase specificity of calendar tables CSS
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / holidays.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Tools &rsaquo; [% Branches.GetName( branch ) | html %] calendar</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("css/calendar.css") | $raw %]
9 </head>
10 <body id="tools_holidays" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
13
14 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
15     <ol>
16         <li>
17             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
18         </li>
19         <li>
20             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
21         </li>
22         <li>
23             <a href="#" aria-current="page">
24                 [% Branches.GetName( branch ) | html %] calendar
25             </a>
26         </li>
27     </ol>
28 </nav>
29
30 <div class="main container-fluid">
31     <div class="row">
32         <div class="col-sm-10 col-sm-push-2">
33             <main>
34
35     <h2>[% Branches.GetName( branch ) | html %] calendar</h2>
36
37     <div class="row">
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 ) %]
42             </select>
43     
44     <!-- ******************************** FLAT PANELS ******************************************* -->
45     <!-- *****           Makes all the flat panel to deal with holidays                     ***** -->
46     <!-- **************************************************************************************** -->
47
48     <!-- ********************** Panel for showing already loaded holidays *********************** -->
49     <div class="panel" id="showHoliday">
50          <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
51              <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
52             <fieldset class="brief">
53             <h3>Edit this holiday</h3>
54             <span id="holtype"></span>
55             <ol>
56             <li>
57                 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
58                 <input type="hidden" id="showBranchName" name="showBranchName" />
59             </li>
60             <li>
61                 <strong>From date:</strong>
62                 <span id="showDaynameOutput"></span>, 
63                 
64                                 [% IF ( dateformat == "us" ) %]<span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>[% ELSIF ( dateformat == "metric") %]<span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>[% ELSIF ( dateformat == "dmydot") %]<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>[% END %]
65
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" />
71             </li>
72             <li class="dateinsert">
73                 <strong>To date: </strong>
74                 <input type="text" id="datecancelrange" name="datecancelrange" size="20" value="[% datecancelrange | html %]" class="datepicker"/>
75             </li>
76             <li><label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" /></li>
77             <!-- showTitle is necessary for exception radio button to work properly -->
78             <li>
79                 <label for="showDescription">Description:</label>
80                 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>
81             </li>
82             <li class="radio"><div class="exceptionPossibility" style="position:static">
83                 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
84                 <a href="#" class="helptext">[?]</a>
85                 <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>
86             </div></li>
87             <li class="radio"><div class="exceptionPossibility" style="position:static">
88                 <input type="radio" name="showOperation" id="showOperationExcRange" value="exceptionrange" />
89                 <label for="showOperationExcRange">Generate exceptions on a range of dates.</label>
90                 <a href="#" class="helptext">[?]</a>
91                 <div class="hint">You can make an exception on a range of dates repeated yearly.</div>
92             </div></li>
93             <li class="radio"><input type="radio" name="showOperation" id="showOperationDel" value="delete" /> <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
94                 <a href="#" class="helptext">[?]</a>
95                 <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></li>
96             <li class="radio"><input type="radio" name="showOperation" id="showOperationDelRange" value="deleterange" /> <label for="showOperationDelRange" id="showOperationDelLabelRange">Delete the single holidays on a range</label>.
97                 <a href="#" class="helptext">[?]</a>
98                 <div class="hint">This will delete the single holidays rules only. The repeatable holidays and exceptions will not be deleted.</div>
99             </li>
100             <li class="radio"><input type="radio" name="showOperation" id="showOperationDelRangeRepeat" value="deleterangerepeat" /> <label for="showOperationDelRangeRepeat" id="showOperationDelLabelRangeRepeat">Delete the repeated holidays on a range</label>.
101                 <a href="#" class="helptext">[?]</a>
102                 <div class="hint">This will delete the repeated holidays rules only. The repeatable holidays will be deleted but not the exceptions.</div>
103             </li>
104             <li class="radio"><input type="radio" name="showOperation" id="showOperationDelRangeRepeatExcept" value="deleterangerepeatexcept" /> <label for="showOperationDelRangeRepeatExcept" id="showOperationDelLabelRangeRepeatExcept">Delete the exceptions on a range</label>.
105                 <a href="#" class="helptext">[?]</a>
106                 <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>
107             </li>
108             <li class="radio"><input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
109                 <a href="#" class="helptext">[?]</a>
110                 <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>
111             <li class="checkbox">
112                 <input type="checkbox" name="allBranches" id="allBranches" />
113                 <label for="allBranches">Copy changes to all libraries</label>.
114                 <a href="#" class="helptext">[?]</a>
115                 <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>
116             </li>
117             </ol>
118             <fieldset class="action">
119                 <input type="submit" name="submit" value="Save" />
120                 <a href="#" class="cancel hidePanel showHoliday">Cancel</a>
121             </fieldset>
122             </fieldset>
123         </form>
124     </div>
125
126     <!-- ***************************** Panel to deal with new holidays **********************  -->
127     <div class="panel" id="newHoliday">
128          <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
129             <fieldset class="brief">
130             <h3>Add new holiday</h3>
131             <ol>
132             <li>
133                 <strong>Library:</strong>
134                 <span id="newBranchNameOutput"></span>
135                 <input type="hidden" id="newBranchName" name="newBranchName" />
136             </li>
137             <li>
138                 <strong>From date:</strong>
139                 <span id="newDaynameOutput"></span>, 
140
141                          [% IF ( dateformat == "us" ) %]<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>[% ELSIF ( dateformat == "metric" ) %]<span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>[% ELSIF ( dateformat == "dmydot" ) %]<span id="newDayOutput"></span>.<span id="newMonthOutput"></span>.<span id="newYearOutput"></span>[% ELSE %]<span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>[% END %]
142
143                 <input type="hidden" id="newDayname" name="showDayname" />
144                 <input type="hidden" id="newWeekday" name="newWeekday" />
145                 <input type="hidden" id="newDay" name="newDay" />
146                 <input type="hidden" id="newMonth" name="newMonth" />
147                 <input type="hidden" id="newYear" name="newYear" />
148             </li>
149             <li class="dateinsert">
150                 <strong>To date: </strong>
151                 <input type="text" id="dateofrange" name="dateofrange" size="20" value="[% dateofrange | html %]" class="datepicker" />
152             </li>
153             <li><label for="title">Title: </label><input type="text" name="newTitle" id="title" size="35" /></li>
154             <li><label for="newDescription">Description:</label>
155                 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
156             </li>
157             <li class="radio"><input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
158             <label for="newOperationOnce">Holiday only on this day</label>.
159             <a href="#" class="helptext">[?]</a>
160             <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>
161             </li>
162             <li class="radio"><input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
163                             <label for="newOperationDay">Holiday repeated every same day of the week</label>.
164                             <a href="#" class="helptext">[?]</a>
165                             <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>
166                             </li>
167             <li class="radio"><input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
168                             <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
169                             <a href="#" class="helptext">[?]</a>
170                             <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>
171                             </li>
172             <li class="radio"><input type="radio" name="newOperation" id="newOperationField" value="holidayrange" />
173                             <label for="newOperationField">Holidays on a range</label>.
174                             <a href="#" class="helptext">[?]</a>
175                             <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>
176                             </li>
177             <li class="radio"><input type="radio" name="newOperation" id="newOperationFieldyear" value="holidayrangerepeat" />
178                             <label for="newOperationFieldyear">Holidays repeated yearly on a range</label>.
179                             <a href="#" class="helptext">[?]</a>
180                             <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>
181                             </li>
182                 <li class="checkbox">
183                 <input type="checkbox" name="allBranches" id="allBranches" />
184                 <label for="allBranches">Copy to all libraries</label>.
185                 <a href="#" class="helptext">[?]</a>
186                 <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>
187                 </li></ol>
188                 <fieldset class="action">
189                     <input type="submit" name="submit" value="Save" />
190                     <a href="#" class="cancel hidePanel newHoliday">Cancel</a>
191                 </fieldset>
192                 </fieldset>
193          </form>
194     </div>
195
196     <!-- *************************************************************************************** -->
197     <!-- ******                          END OF FLAT PANELS                               ****** -->
198     <!-- *************************************************************************************** -->
199
200 <!-- ************************************************************************************** -->
201 <!-- ******                              MAIN SCREEN CODE                            ****** -->
202 <!-- ************************************************************************************** -->
203 <h3>Calendar information</h3>
204 <div id="jcalendar-container"></div>
205
206 <div style="margin-top: 2em;">
207 <form action="copy-holidays.pl" method="post">
208     <input type="hidden" name="from_branchcode" value="[% branch | html %]" />
209   <label for="branchcode">Copy holidays to:</label>
210   <select id="branchcode" name="branchcode">
211     <option value=""></option>
212     [% FOREACH l IN Branches.all() %]
213     <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
214     [% END %]
215   </select>
216     <input type="submit" value="Copy" />
217 </form>
218 </div>
219
220 </div>
221 <div class="col-sm-6">
222 <div class="help">
223 <h4>Hints</h4>
224     <ul>
225         <li>Search in the calendar the day you want to set as holiday.</li>
226         <li>Click the date to add or edit a holiday.</li>
227         <li>Enter a title and description for the holiday.</li>
228         <li>Specify how the holiday should repeat.</li>
229         <li>Click Save to finish.</li>
230     </ul>
231 <h4>Key</h4>
232     <p>
233         <span class="key normalday">Working day</span>
234         <span class="key holiday">Unique holiday</span>
235         <span class="key repeatableweekly">Holiday repeating weekly</span>
236         <span class="key repeatableyearly">Holiday repeating yearly</span>
237         <span class="key exception">Holiday exception</span>
238     </p>
239 </div>
240 <div id="holiday-list">
241 <!-- Exceptions First -->
242 <!--   this will probably always have the least amount of data -->
243 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
244 <h3>Exceptions</h3>
245   <table id="holidayexceptions">
246 <thead><tr>
247   <th class="exception">Date</th>
248   <th class="exception">Title</th>
249   <th class="exception">Description</th>
250 </tr>
251 </thead>
252 <tbody>
253   [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
254   <tr>
255   <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&amp;calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE | uri %]"><span title="[% EXCEPTION_HOLIDAYS_LOO.DATE_SORT | html %]">[% EXCEPTION_HOLIDAYS_LOO.DATE | html %]</span></a></td>
256   <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE | html %]</td>
257   <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
258   </tr>
259   [% END %] 
260 </tbody>
261 </table>
262 [% END %]
263
264 [% IF ( WEEK_DAYS_LOOP ) %]
265 <h3>Weekly - Repeatable holidays</h3>
266 <table id="holidayweeklyrepeatable">
267 <thead>
268 <tr>
269   <th class="repeatableweekly">Day of week</th>
270   <th class="repeatableweekly">Title</th>
271   <th class="repeatableweekly">Description</th>
272 </tr>
273 </thead>
274 <tbody>
275   [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
276   <tr>
277   <td>[% WEEK_DAYS_LOO.KEY | html %]</td>
278   </td> 
279   <td>[% WEEK_DAYS_LOO.TITLE | html %]</td>
280   <td>[% WEEK_DAYS_LOO.DESCRIPTION | html %]</td>
281   </tr>
282   [% END %] 
283 </tbody>
284 </table>
285 [% END %]
286
287 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
288 <h3>Yearly - Repeatable holidays</h3>
289 <table id="holidaysyearlyrepeatable">
290 <thead>
291 <tr>
292   [% IF ( dateformat == "metric" ) %]
293   <th class="repeatableyearly">Day/month</th>
294   [% ELSE %]
295   <th class="repeatableyearly">Month/day</th>
296   [% END %]
297   <th class="repeatableyearly">Title</th>
298   <th class="repeatableyearly">Description</th>
299 </tr>
300 </thead>
301 <tbody>
302   [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
303   <tr>
304   <td><span title="[% DAY_MONTH_HOLIDAYS_LOO.DATE_SORT | html %]">[% DAY_MONTH_HOLIDAYS_LOO.DATE | html %]</span></td>
305   <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE | html %]</td>
306   <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION | html %]</td>
307   </tr>
308   [% END %] 
309 </tbody>
310 </table>
311 [% END %]
312
313 [% IF ( HOLIDAYS_LOOP ) %]
314 <h3>Unique holidays</h3>
315 <table id="holidaysunique">
316 <thead>
317 <tr>
318   <th class="holiday">Date</th>
319   <th class="holiday">Title</th>
320   <th class="holiday">Description</th>
321 </tr>
322 </thead>
323 <tbody>
324     [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
325 <tr>
326   <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% branch | uri %]&amp;calendardate=[% HOLIDAYS_LOO.DATE | uri %]"><span title="[% HOLIDAYS_LOO.DATE_SORT | html %]">[% HOLIDAYS_LOO.DATE | html %]</span></a></td>
327   <td>[% HOLIDAYS_LOO.TITLE | html %]</td>
328   <td>[% HOLIDAYS_LOO.DESCRIPTION.replace('\\\r\\\n', '<br />') | html %]</td>
329 </tr>
330   [% END %] 
331 </tbody>
332 </table>
333 [% END %]
334 </div>
335 </div>
336 </div>
337
338             </main>
339         </div> <!-- /.col-sm-10.col-sm-push-2 -->
340
341         <div class="col-sm-2 col-sm-pull-10">
342             <aside>
343                 [% INCLUDE 'tools-menu.inc' %]
344             </aside>
345         </div> <!-- .col-sm-2.col-sm-pull-10 -->
346      </div> <!-- /.row -->
347
348 [% MACRO jsinclude BLOCK %]
349     [% INCLUDE 'calendar.inc' %]
350     [% INCLUDE 'datatables.inc' %]
351     [% Asset.js("js/tools-menu.js") | $raw %]
352     <script>
353         var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
354
355         /* Creates all the structures to deal with all different kinds of holidays */
356         var week_days = new Array();
357         var holidays = new Array();
358         var holidates = new Array();
359         var exception_holidays = new Array();
360         var day_month_holidays = new Array();
361         var hola= "[% code | html %]";
362         [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
363         week_days["[% WEEK_DAYS_LOO.KEY | html %]"] = {title:"[% WEEK_DAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
364         [% END %]
365         [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
366         holidates.push("[% HOLIDAYS_LOO.KEY | html %]");
367         holidays["[% HOLIDAYS_LOO.KEY | html %]"] = {title:"[% HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
368         [% END %]
369         [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
370         exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY | html %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE | replace('"','\"') | html %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION | replace('"','\"') | html %]"};
371         [% END %]
372         [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
373         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 %]"};
374         [% END %]
375
376         function holidayOperation(formObject, opType) {
377             var op = document.getElementsByName('operation');
378             op[0].value = opType;
379             formObject.submit();
380         }
381
382         // This function shows the "Show Holiday" panel //
383         function showHoliday (exceptionPossibility, dayName, day, month, year, weekDay, title, description, holidayType) {
384             $("#newHoliday").slideUp("fast");
385             $("#showHoliday").slideDown("fast");
386             $('#showDaynameOutput').html(dayName);
387             $('#showDayname').val(dayName);
388             $('#showBranchNameOutput').html($("#branch :selected").text());
389             $('#showBranchName').val($("#branch").val());
390             $('#showDayOutput').html(day);
391             $('#showDay').val(day);
392             $('#showMonthOutput').html(month);
393             $('#showMonth').val(month);
394             $('#showYearOutput').html(year);
395             $('#showYear').val(year);
396             $('#showDescription').val(description);
397             $('#showWeekday:first').val(weekDay);
398             $('#showTitle').val(title);
399             $('#showHolidayType').val(holidayType);
400
401             if (holidayType == 'exception') {
402                 $("#showOperationDelLabel").html(_("Delete this exception."));
403                 $("#holtype").attr("class","key exception").html(_("Holiday exception"));
404             } else if(holidayType == 'weekday') {
405                 $("#showOperationDelLabel").html(_("Delete this holiday."));
406                 $("#holtype").attr("class","key repeatableweekly").html(_("Holiday repeating weekly"));
407             } else if(holidayType == 'daymonth') {
408                 $("#showOperationDelLabel").html(_("Delete this holiday."));
409                 $("#holtype").attr("class","key repeatableyearly").html(_("Holiday repeating yearly"));
410             } else {
411                 $("#showOperationDelLabel").html(_("Delete this holiday."));
412                 $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
413             }
414
415             if (exceptionPossibility == 1) {
416                 $(".exceptionPossibility").parent().show();
417             } else {
418                 $(".exceptionPossibility").parent().hide();
419             }
420         }
421
422         // This function shows the "Add Holiday" panel //
423         function newHoliday (dayName, day, month, year, weekDay) {
424             $("#showHoliday").slideUp("fast");
425             $("#newHoliday").slideDown("fast");
426             $("#newDaynameOutput").html(dayName);
427             $("#newDayname").val(dayName);
428             $("#newBranchNameOutput").html($('#branch :selected').text());
429             $("#newBranchName").val($('#branch').val());
430             $("#newDayOutput").html(day);
431             $("#newDay").val(day);
432             $("#newMonthOutput").html(month);
433             $("#newMonth").val(month);
434             $("#newYearOutput").html(year);
435             $("#newYear").val(year);
436             $("#newWeekday:first").val(weekDay);
437         }
438
439         function hidePanel(aPanelName) {
440             $("#"+aPanelName).slideUp("fast");
441         }
442
443         function changeBranch () {
444             var branch = $("#branch option:selected").val();
445             location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate | html %]";
446         }
447
448         function Help() {
449             newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
450         }
451
452         /* This function gives css clases to each kind of day */
453         function dateStatusHandler(date) {
454             date = new Date(date);
455             var day = date.getDate();
456             var month = date.getMonth() + 1;
457             var year = date.getFullYear();
458             var weekDay = date.getDay();
459             var dayMonth = month + '/' + day;
460             var dateString = year + '/' + month + '/' + day;
461             if (exception_holidays[dateString] != null) {
462                 return [true, "exception", _("Exception: %s").format(exception_holidays[dateString].title)];
463             } else if ( week_days[weekDay] != null ){
464                 return [true, "repeatableweekly", _("Weekly holiday: %s").format(week_days[weekDay].title)];
465             } else if ( day_month_holidays[dayMonth] != null ) {
466                 return [true, "repeatableyearly", _("Yearly holiday: %s").format(day_month_holidays[dayMonth].title)];
467             } else if (holidays[dateString] != null) {
468                 return [true, "holiday", _("Single holiday: %s").format(holidays[dateString].title)];
469             } else {
470                 return [true, "normalday", _("Normal day")];
471             }
472         }
473
474         /* This function is in charge of showing the correct panel considering the kind of holiday */
475         function dateChanged(calendar) {
476             calendar = new Date(calendar);
477             var day = calendar.getDate();
478             var month = calendar.getMonth() + 1;
479             var year = calendar.getFullYear();
480             var weekDay = calendar.getDay();
481             var dayName = weekdays[weekDay];
482             var dayMonth = month + '/' + day;
483             var dateString = year + '/' + month + '/' + day;
484                 if (holidays[dateString] != null) {
485                     showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,     holidays[dateString].description, 'ymd');
486                 } else if (exception_holidays[dateString] != null) {
487                     showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
488                 } else if (week_days[weekDay] != null) {
489                     showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,     week_days[weekDay].description, 'weekday');
490                 } else if (day_month_holidays[dayMonth] != null) {
491                     showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
492                 } else {
493                     newHoliday(dayName, day, month, year, weekDay);
494                 }
495         };
496
497         $(document).ready(function() {
498
499             $(".hint").hide();
500             $("#branch").change(function(){
501                 changeBranch();
502             });
503             $("#holidayweeklyrepeatable>tbody>tr").each(function(){
504                 var first_td = $(this).find('td').first();
505                 first_td.html(weekdays[first_td.html()]);
506             });
507             $("#holidayweeklyrepeatable").dataTable($.extend(true, {}, dataTablesDefaults, {
508                 "sDom": 't',
509                 "bPaginate": false
510             }));
511             $("#holidayexceptions,#holidaysyearlyrepeatable,#holidaysunique").dataTable($.extend(true, {}, dataTablesDefaults, {
512                 "sDom": 't',
513                 "aoColumns": [
514                     { "sType": "title-string" },null,null
515                 ],
516                 "bPaginate": false
517             }));
518             $("a.helptext").click(function(){
519                 $(this).parent().find(".hint").toggle(); return false;
520             });
521             $("#dateofrange").datepicker({
522                 beforeShow: function() {
523                     var startdate = $("#jcalendar-container").datepicker("getDate");
524                     if (startdate !== null) {
525                         var sd = new Date(startdate);
526                         var ed = new Date($(this).datepicker("getDate"));
527                         if (ed < sd) {
528                             $(this).datepicker("setDate", startdate);
529                             $(this).datepicker("option", "defaultDate", startdate);
530                         }
531                     }
532                 }
533             });
534             $("#datecancelrange").datepicker();
535             $("#dateofrange").each(function () { this.value = "" });
536             $("#datecancelrange").each(function () { this.value = "" });
537             $("#jcalendar-container").datepicker({
538                 beforeShowDay: function(thedate) {
539                     var day = thedate.getDate();
540                     var month = thedate.getMonth() + 1;
541                     var year = thedate.getFullYear();
542                     var dateString = year + '/' + month + '/' + day;
543                     return dateStatusHandler(dateString);
544                 },
545                 onSelect: function(dateText, inst) {
546                     dateChanged($(this).datepicker("getDate"));
547                     var enddate = $("#dateofrange").datepicker("getDate");
548                     $("#dateofrange").datepicker("option", "defaultDate", $(this).datepicker("getDate"));
549                     $("#dateofrange").datepicker( "option", "minDate", $(this).datepicker("getDate")); //ensure end date can't be before start date
550                     if (enddate !== null) {
551                         var ed = new Date(enddate);
552                         var sd = new Date($(this).datepicker("getDate"));
553                         if (ed < sd) {
554                             $("#dateofrange").datepicker("setDate", $(this).datepicker("getDate"));
555                             $("#dateofrange").datepicker("option", "defaultDate", enddate);
556                         }
557                     }
558                 },
559                 defaultDate: new Date("[% keydate | html %]")
560             });
561             $(".hidePanel").on("click",function(){
562                 if( $(this).hasClass("showHoliday") ){
563                     hidePanel("showHoliday");
564                 } else {
565                     hidePanel("newHoliday");
566                 }
567             })
568         });
569     </script>
570 [% END %]
571
572 [% INCLUDE 'intranet-bottom.inc' %]