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