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