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