Merge remote branch 'kc/new/enh/bug_5917' into kcmaster
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / holidays.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Tools &rsaquo; [% branchname %] Calendar</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 [% INCLUDE 'calendar.inc' %]
5 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
6 <script language="JavaScript" type="text/javascript">
7 //<![CDATA[
8
9         var weekdays = new Array(_("Sundays"),_("Mondays"),_("Tuesdays"),_("Wednesdays"),_("Thursdays"),_("Fridays"),_("Saturdays"));
10
11         function holidayOperation(formObject, opType) {
12                 var op = document.getElementsByName('operation');
13                 op[0].value = opType;
14                 formObject.submit();
15         }
16
17         // This function shows the "Show Holiday" panel //
18         function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, holidayType) {
19                 $("#newHoliday").slideUp("fast");
20                 $("#showHoliday").slideDown("fast");
21                 $('#showDaynameOutput').html(dayName);
22                 $('#showDayname').val(dayName);
23                 $('#showBranchNameOutput').html($("#branch :selected").text());
24                 $('#showBranchName').val($("#branch").val());
25                 $('#showDayOutput').html(day);
26                 $('#showDay').val(day);
27                 $('#showMonthOutput').html(month);
28                 $('#showMonth').val(month);
29                 $('#showYearOutput').html(year);
30                 $('#showYear').val(year);
31                 $('#showDescription').val(description);
32                 $('#showWeekday:first').val(weekDay);
33                 $('#showTitle').val(title);
34                 $('#showHolidayType').val(holidayType);
35
36                 if (holidayType == 'exception') {
37                         $("#showOperationDelLabel").html(_('Delete this exception.'));
38                         $("#holtype").attr("class","key exception").html(_("Holiday exception"));
39                 } else if(holidayType == 'weekday') {
40                         $("#showOperationDelLabel").html(_('Delete this holiday.'));
41                         $("#holtype").attr("class","key repeatableday").html(_("Repeatable holiday"));
42                 } else {
43                         $("#showOperationDelLabel").html(_('Delete this holiday.'));
44                         $("#holtype").attr("class","key holiday").html(_("Unique holiday"));
45                 }
46                 
47                 if (exceptionPosibility == 1) {
48                         $("#exceptionPosibility").parent().show();
49                 } else {
50                         $("#exceptionPosibility").parent().hide();
51                 }
52         }
53
54         // This function shows the "Add Holiday" panel //
55         function newHoliday (dayName, day, month, year, weekDay) {
56                 $("#showHoliday").slideUp("fast");
57                 $("#newHoliday").slideDown("fast");
58                 $("#newDaynameOutput").html(dayName);
59                 $("#newDayname").val(dayName);
60                 $("#newBranchNameOutput").html($('#branch :selected').text());
61                 $("#newBranchName").val($('#branch').val());
62                 $("#newDayOutput").html(day);
63                 $("#newDay").val(day);
64                 $("#newMonthOutput").html(month);
65                 $("#newMonth").val(month);
66                 $("#newYearOutput").html(year);
67                 $("#newYear").val(year);
68                 $("#newWeekday:first").val(weekDay);
69         }
70
71         function hidePanel(aPanelName) {
72                 $("#"+aPanelName).slideUp("fast");
73         }
74
75         function changeBranch () {
76                 var branch = $("#branch option:selected").val();
77                 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "[% calendardate %]";
78         }
79
80         function Help() {
81                 newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
82         }
83         $(document).ready(function() {
84                 $(".hint").hide();
85                 $("#branch").change(function(){
86                         changeBranch();
87                 });
88                 $("#holidayexceptions").tablesorter({
89                   sortList: [[0,0]], widgets: ['zebra']
90                 });
91                 $("#holidayweeklyrepeatable").tablesorter({
92                   sortList: [[0,0]], widgets: ['zebra']
93                 });
94                 $("#holidaysyearlyrepeatable").tablesorter({
95                   sortList: [[0,0]], widgets: ['zebra']
96                 });
97                 $("#holidaysunique").tablesorter({
98                   sortList: [[0,0]], widgets: ['zebra']
99                 });
100                 $("a.helptext").click(function(){
101                         $(this).parent().find(".hint").toggle(); return false;
102                 });
103         });
104 //]]>
105 </script>
106 <style type="text/css"> .key { padding : 3px; white-space:nowrap; line-height:230%; }
107 .normalday { background-color :  #EDEDED; color :  Black; border : 1px solid #BCBCBC; }
108 .exception { background-color :  #b3d4ff; color :  Black; border : 1px solid #BCBCBC; }
109 .holiday {  background-color :  #ffaeae; color :  Black;  border : 1px solid #BCBCBC; }
110 .repeatableday {  background-color :  #FFFF99; color :  Black;  border : 1px solid #BCBCBC; }
111 .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; }
112 .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; }
113 #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; }
114 </style>
115 </head>
116 <body>
117 [% INCLUDE 'header.inc' %]
118 [% INCLUDE 'cat-search.inc' %]
119
120 <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; [% branchname %] Calendar</div>
121
122 <div id="doc3" class="yui-t1">
123    
124    <div id="bd">
125         <div id="yui-main">
126         <div class="yui-b">
127         <h2>[% branchname %] Calendar</h2>
128         <div class="yui-g">
129         <div class="yui-u first">
130         <label for="branch">Define the holidays for:</label>
131             <select id="branch" name="branch">
132                 [% FOREACH branchloo IN branchloop %]
133                     [% IF ( branchloo.selected ) %]
134                         <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
135                     [% ELSE %]
136                         <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
137                     [% END %]
138                 [% END %]
139             </select>
140         
141         <!-- ******************************** FLAT PANELS ******************************************* -->
142         <!-- *****           Makes all the flat panel to deal with holidays                     ***** -->
143         <!-- **************************************************************************************** -->
144
145         <!-- ********************** Panel for showing already loaded holidays *********************** -->
146         <div class="panel" id="showHoliday">
147                 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
148                         <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
149                         <fieldset class="brief">
150                         <h3>Edit this holiday</h3>
151                         <span id="holtype"></span>
152                         <ol>
153                         <li>
154                                 <strong>Library:</strong> <span id="showBranchNameOutput"></span>
155                                 <input type="hidden" id="showBranchName" name="showBranchName" />
156                         </li>
157                         <li>
158                                 <strong>Date:</strong>
159                                 <span id="showDaynameOutput"></span>, 
160                                 
161                                 [% 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>[% ELSE %]<span id="showYearOutput"></span>/<span id="showMonthOutput"></span>/<span id="showDayOutput"></span>[% END %]
162
163                                 <input type="hidden" id="showDayname" name="showDayname" />
164                                 <input type="hidden" id="showWeekday" name="showWeekday" />
165                                 <input type="hidden" id="showDay" name="showDay" />
166                                 <input type="hidden" id="showMonth" name="showMonth" />
167                                 <input type="hidden" id="showYear" name="showYear" />
168                         </li>
169                         <li><label for="showTitle">Title: </label><input type="text" name="showTitle" id="showTitle" size="35" /></li>
170                     <!-- showTitle is necessary for exception radio button to work properly --> 
171                                 <label for="showDescription">Description:</label>
172                                 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>    
173                     </li>
174                         <li class="radio"><div id="exceptionPosibility" style="position:static">
175                                 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception for this repeated holiday.</label>
176                                 <a href="#" class="helptext">[?]</a>
177                                 <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>
178                         </div></li>
179                         <li class="radio"><input type="radio" name="showOperation" id="showOperationDel" value="delete" /> <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
180                                 <a href="#" class="helptext">[?]</a>
181                                 <div class="hint">This will delete this holiday rule. If it is a repeatable holiday, this option checks for posible exceptions. If an exception exists, this option will remove the exception and set the date to a regular holiday.</div></li>
182                         <li class="radio"><input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
183                                                 <a href="#" class="helptext">[?]</a>
184                                                 <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>
185
186                         </ol>
187                         <fieldset class="action">
188                                 <input type="submit" name="submit" value="Save" />
189                                 <a href="#" class="cancel" name="cancel2" onclick=" hidePanel('showHoliday');">Cancel</a>
190                         </fieldset>
191                         </fieldset>
192                 </form>
193         </div>
194
195         <!-- ***************************** Panel to deal with new holidays **********************  -->
196         <div class="panel" id="newHoliday">
197                 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
198                                 <input type="hidden" name="branchCodes" id="branchCodes" value="[% branchcodes %]" /> 
199                         <fieldset class="brief">
200                         <h3>Add new holiday</h3>
201                         <ol>
202                         <li>
203                                 <strong>Library:</strong>
204                                 <span id="newBranchNameOutput"></span>
205                                 <input type="hidden" id="newBranchName" name="newBranchName" />
206                         </li>
207                         <li>
208                                 <strong>Date:</strong>
209                                 <span id="newDaynameOutput"></span>, 
210
211                                 [% 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>[% ELSE %]<span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>[% END %]
212
213                                 <input type="hidden" id="newDayname" name="showDayname" />
214                                 <input type="hidden" id="newWeekday" name="newWeekday" />
215                                 <input type="hidden" id="newDay" name="newDay" />
216                                 <input type="hidden" id="newMonth" name="newMonth" />
217                                 <input type="hidden" id="newYear" name="newYear" />
218                         </li>
219                         <li><label for="title">Title: </label><input type="text" name="newTitle" id="title" size="35" /></li>
220                         <li><label for="newDescription">Description:</label>
221                                 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
222                         </li>
223                         <li class="radio"><input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
224                         <label for="newOperationOnce">Holiday only on this day</label>.
225                         <a href="#" class="helptext">[?]</a>
226                         <div class="hint">Make a single holiday. For example, selecting August 1st, 2012 will make it a holiday, but will not affect August 1st in other years.</div>
227                         </li>
228                         <li class="radio"><input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
229                                                         <label for="newOperationDay">Holiday repeated every same day of the week</label>.
230                                                         <a href="#" class="helptext">[?]</a>
231                                                         <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>
232                                                         </li>
233                         <li class="radio"><input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
234                                                         <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
235                                                         <a href="#" class="helptext">[?]</a>
236                                                         <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 1st will make August 1st a holiday every year.</div>
237                                                         </li>
238                                 <li class="radio">
239                                 <input type="checkbox" name="allBranches" id="allBranches" />
240                                 <label for="allBranches">Copy to all libraries</label>.
241                                 <a href="#" class="helptext">[?]</a>
242                                 <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>
243                                 </li></ol>
244                                 <fieldset class="action">
245                                         <input type="submit" name="submit" value="Save" />
246                                         <a href="#" class="cancel" name="cancel2" onclick=" hidePanel('newHoliday');">Cancel</a>
247                                 </fieldset>
248                                 </fieldset>
249                 </form>
250         </div>
251
252         <!-- *************************************************************************************** -->
253         <!-- ******                          END OF FLAT PANELS                               ****** -->
254         <!-- *************************************************************************************** -->
255
256 <!-- ************************************************************************************** -->
257 <!-- ******                              MAIN SCREEN CODE                            ****** -->
258 <!-- ************************************************************************************** -->
259 <h3>Calendar information</h3>
260 <div id="calendar-container">
261 <script type="text/javascript">
262         /* Creates all the structures to deal with all diferents kinds of holidays */
263         var week_days = new Array();
264         var holidays = new Array();
265         var exception_holidays = new Array();
266         var day_month_holidays = new Array();
267         var hola= "[% code %]";
268         [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
269         week_days["[% WEEK_DAYS_LOO.KEY %]"] = {title:"[% WEEK_DAYS_LOO.TITLE %]", description:"[% WEEK_DAYS_LOO.DESCRIPTION %]"};
270         [% END %]
271         [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
272         holidays["[% HOLIDAYS_LOO.KEY %]"] = {title:"[% HOLIDAYS_LOO.TITLE %]", description:"[% HOLIDAYS_LOO.DESCRIPTION %]"};
273         [% END %]
274         [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
275         exception_holidays["[% EXCEPTION_HOLIDAYS_LOO.KEY %]"] = {title:"[% EXCEPTION_HOLIDAYS_LOO.TITLE %]", description:"[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION %]"};
276         [% END %]
277         [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
278         day_month_holidays["[% DAY_MONTH_HOLIDAYS_LOO.KEY %]"] = {title:"[% DAY_MONTH_HOLIDAYS_LOO.TITLE %]", description:"[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION %]"};
279         [% END %]
280
281         /* This function gives css clases to each kind of day */
282         function dateStatusHandler(date) {
283                 var day = date.getDate();
284                 var month = date.getMonth() + 1;
285                 var year = date.getFullYear();
286                 var weekDay = date.getDay();
287                 var dayMonth = month + '/' + day;
288                 var dateString = year + '/' + month + '/' + day;
289                 if (exception_holidays[dateString] != null) {
290                         return 'exception';
291                 } else if ((week_days[weekDay] != null) || (day_month_holidays[dayMonth] != null)) {
292                         return 'repeatableday';
293                 } else if (holidays[dateString] != null) {
294                         return 'holiday';
295                 } else {
296                         return 'normalday';
297                 }
298         }
299
300         /* This function is in charge of showing the correct panel considering the kind of holiday */
301         function dateChanged(calendar) {
302                 var day = calendar.date.getDate();
303                 var month = calendar.date.getMonth() + 1;
304                 var year = calendar.date.getFullYear();
305                 var weekDay = calendar.date.getDay();
306                 var dayName = calendar.date.print('%A');
307                 var dayMonth = month + '/' + day;
308                 var dateString = year + '/' + month + '/' + day;
309                 if (calendar.dateClicked) {
310                         if (holidays[dateString] != null) {
311                                 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,  holidays[dateString].description, 'ymd');
312                         } else if (exception_holidays[dateString] != null) {
313                                 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
314                         } else if (week_days[weekDay] != null) {
315                                 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,    week_days[weekDay].description, 'weekday');
316                         } else if (day_month_holidays[dayMonth] != null) {
317                                 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
318                         } else {
319                                 newHoliday(dayName, day, month, year, weekDay);
320                         }
321                 }
322         };
323         Calendar.setup(
324                 {
325                         flat : "calendar-container",
326                         flatCallback : dateChanged,
327                         date: "[% keydate %]",
328                         dateStatusFunc : dateStatusHandler
329                 }
330         );
331 </script>
332
333
334 </div>
335 </div>
336 <div class="yui-u">
337 <div class="help">
338 <h4>Hints</h4>
339         <ul>
340                 <li>Search in the calendar the day you want to set as holiday.</li>
341                 <li>Click the date to add or edit a holiday.</li>
342                 <li>Enter a title and description for the holdiay.</li>
343                 <li>Specify how the holiday should repeat.</li>
344                 <li>Click Save to finish.</li>
345         </ul>
346 <h4>Key</h4>
347         <p>
348                 <span class="key normalday">Working day</span>
349                 <span class="key holiday">Unique holiday</span>
350                 <span class="key repeatableday">Repeatable holiday</span>
351                 <span class="key exception">Holiday exception</span>
352         </p>
353 </div>
354 <div id="holiday-list">
355 <!-- Exceptions First -->
356 <!--   this will probably always have the least amount of data -->
357 [% IF ( EXCEPTION_HOLIDAYS_LOOP ) %]
358 <h3>Exceptions</h3>
359   <table id="holidayexceptions">
360 <thead><tr>
361   <th class="exception">Date</th>
362   <th class="exception">Title</th>
363   <th class="exception">Description</th>
364 </tr>
365 </thead>
366 <tbody>
367   [% FOREACH EXCEPTION_HOLIDAYS_LOO IN EXCEPTION_HOLIDAYS_LOOP %]
368   <tr>
369   <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% EXCEPTION_HOLIDAYS_LOO.branch %]&amp;calendardate=[% EXCEPTION_HOLIDAYS_LOO.DATE %]">[% EXCEPTION_HOLIDAYS_LOO.DATE %]</a></td>
370   <td>[% EXCEPTION_HOLIDAYS_LOO.TITLE %]</td>
371   <td>[% EXCEPTION_HOLIDAYS_LOO.DESCRIPTION %]</td> 
372   </tr>
373   [% END %] 
374 </tbody>
375 </table>
376 [% END %]
377
378 [% IF ( WEEK_DAYS_LOOP ) %]
379 <h3>Weekly - Repeatable Holidays</h3>
380 <table id="holidayweeklyrepeatable">
381 <thead>
382 <tr>
383   <th class="repeatableday">Day of Week</th>
384   <th class="repeatableday">Title</th>
385   <th class="repeatableday">Description</th>
386 </tr>
387 </thead>
388 <tbody>
389   [% FOREACH WEEK_DAYS_LOO IN WEEK_DAYS_LOOP %]
390   <tr>
391   <td>
392 <script type="text/javascript">
393   document.write(weekdays[ [% WEEK_DAYS_LOO.KEY %]]);
394 </script>
395   </td> 
396   <td>[% WEEK_DAYS_LOO.TITLE %]</td> 
397   <td>[% WEEK_DAYS_LOO.DESCRIPTION %]</td> 
398   </tr>
399   [% END %] 
400 </tbody>
401 </table>
402 [% END %]
403
404 [% IF ( DAY_MONTH_HOLIDAYS_LOOP ) %]
405 <h3>Yearly - Repeatable Holidays</h3>
406 <table id="holidaysyearlyrepeatable">
407 <thead>
408 <tr>
409   [% IF ( dateformat == 'metric' ) %]
410   <th class="repeatableday">Day/Month</th>
411   [% ELSE %]
412   <th class="repeatableday">Month/Day</th>
413   [% END %]
414   <th class="repeatableday">Title</th>
415   <th class="repeatableday">Description</th>
416 </tr>
417 </thead>
418 <tbody>
419   [% FOREACH DAY_MONTH_HOLIDAYS_LOO IN DAY_MONTH_HOLIDAYS_LOOP %]
420   <tr>
421   <td>[% DAY_MONTH_HOLIDAYS_LOO.DATE %]</td>
422   <td>[% DAY_MONTH_HOLIDAYS_LOO.TITLE %]</td> 
423   <td>[% DAY_MONTH_HOLIDAYS_LOO.DESCRIPTION %]</td> 
424   </tr>
425   [% END %] 
426 </tbody>
427 </table>
428 [% END %]
429
430 [% IF ( HOLIDAYS_LOOP ) %]
431 <h3>Unique Holidays</h3>
432 <table id="holidaysunique">
433 <thead>
434 <tr>
435   <th class="holiday">Date</th>
436   <th class="holiday">Title</th>
437   <th class="holiday">Description</th>
438 </tr>
439 </thead>
440 <tbody>
441     [% FOREACH HOLIDAYS_LOO IN HOLIDAYS_LOOP %]
442 <tr>
443   <td><a href="/cgi-bin/koha/tools/holidays.pl?branch=[% HOLIDAYS_LOO.branch %]&amp;calendardate=[% HOLIDAYS_LOO.DATE %]">[% HOLIDAYS_LOO.DATE %]</a></td>
444   <td>[% HOLIDAYS_LOO.TITLE %]</td>
445   <td>[% HOLIDAYS_LOO.DESCRIPTION %]</td>
446 </tr>
447   [% END %] 
448 </tbody>
449 </table>
450 [% END %]
451 </div>
452 </div>
453 </div>
454 </div>
455 </div>
456
457 <div class="yui-b noprint">
458 [% INCLUDE 'tools-menu.inc' %]
459 </div>
460 </div>
461 [% INCLUDE 'intranet-bottom.inc' %]