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