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