Bug 3268: Adds the ability to edit the description of a holiday.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / holidays.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Tools &rsaquo; Calendar</title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
5 <script language="JavaScript" type="text/javascript">
6 //<![CDATA[
7         // Captura el evento onmousemove para cualquier navegador
8         if (document.layers) { // Netscape
9                 document.captureEvents(Event.MOUSEMOVE);
10             document.onmousemove = captureMousePosition;
11         } else if (document.all) { // Internet Explorer
12             document.onmousemove = captureMousePosition;
13         } else if (document.getElementById) { // Netcsape 6
14             document.onmousemove = captureMousePosition;
15         }
16
17         var mouseXMax = 0;
18         var mouseYMax = 0;
19         var mouseX = 0;
20         var mouseY = 0;
21
22         function captureMousePosition(e) {
23             if (document.layers) {
24                     mouseX = e.pageX;
25                         mouseY = e.pageY;
26                 mouseXMax = window.innerWidth + window.pageXOffset;
27                     mouseYMax = window.innerHeight + window.pageYOffset;
28             } else if (document.all) {
29                     mouseX = window.event.x + document.body.scrollLeft;
30                 mouseY = window.event.y + document.body.scrollTop;
31                 mouseXMax = document.body.clientWidth + document.body.scrollLeft;
32                 mouseYMax = document.body.clientHeight + document.body.scrollTop;
33             } else if (document.getElementById) {
34                 mouseX = e.pageX;
35                     mouseY = e.pageY;
36                 mouseXMax = window.innerWidth + window.pageXOffset;
37                 mouseYMax = window.innerHeight + window.pageYOffset;
38             }
39         } 
40
41         function holidayOperation(formObject, opType) {
42                 var op = document.getElementsByName('operation');
43                 op[0].value = opType;
44                 formObject.submit();
45         }
46
47         // This function shows the "Show Holiday" panel //
48         function showHoliday (exceptionPosibility, dayName, day, month, year, weekDay, title, description, holidayType) {
49                 $("#newHoliday").slideUp("fast");
50                 $("#showHoliday").slideDown("fast");
51                 document.getElementById('showDayname').value = dayName;
52                 document.getElementById('showBranchName').value = document.getElementById('branch').value;
53                 document.getElementById('showDay').value = day;
54                 document.getElementById('showMonth').value = month;
55                 document.getElementById('showYear').value = year;
56                 document.getElementById('showDescription').value = description;
57                 document.getElementsByName('showWeekday')[0].value = weekDay;
58                 document.getElementById('showTitle').value = title;
59                 document.getElementById('showHolidayType').value = holidayType;
60
61                 if (holidayType == 'exception') {
62                         document.getElementById('showOperationDelLabel').innerHTML = 'Delete this exception.';
63                 } else {
64                         document.getElementById('showOperationDelLabel').innerHTML = 'Delete this holiday.';
65                 }
66                 
67                 if (exceptionPosibility == 1) {
68                         document.getElementById('exceptionPosibility').style.display = 'inline';
69                 } else {
70                         document.getElementById('exceptionPosibility').style.display = 'none';
71                 }
72         }
73
74         // This function shows the "Add Holiday" panel //
75         function newHoliday (dayName, day, month, year, weekDay) {
76                 $("#showHoliday").slideUp("fast");
77                 $("#newHoliday").slideDown("fast");
78                 $("#newDayname").val(dayName);
79                 $("#newBranchName").val($('#branch').val());
80                 $("#newDay").val(day);
81                 $("#newMonth").val(month);
82                 $("#newYear").val(year);
83                 $("#newWeekday")[0].val(weekDay);
84         }
85
86         function hidePanel(aPanelName) {
87                 $("#"+aPanelName).slideUp("fast");
88         }
89
90         function changeBranch () {
91                 var branch = $("#branch option:selected").val();
92                 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + "<!-- TMPL_VAR NAME='calendardate' -->";
93         }
94
95         function additionalInformation (anExplanation) {
96                 var panel = document.getElementById('information');
97                 var paragraph = document.getElementById('explanation');
98                 panel.style.display = 'inline'
99                 panel.style.top = mouseY;
100                 panel.style.left = mouseX;
101                 var info = document.createTextNode(anExplanation);
102                 if (paragraph.hasChildNodes()) {
103                         paragraph.removeChild(paragraph.lastChild);
104                 }
105                 paragraph.appendChild(info);
106         }
107
108         function Help() {
109                 newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
110         }
111         $(document).ready(function() {
112                 $("#branch").change(function(){
113                         changeBranch();
114                 });
115                 $("#holidayexceptions").tablesorter({
116                   sortList: [[0,0]], widgets: ['zebra']
117                 });
118                 $("#holidayweeklyrepeatable").tablesorter({
119                   sortList: [[0,0]], widgets: ['zebra']
120                 });
121                 $("#holidaysyearlyrepeatable").tablesorter({
122                   sortList: [[0,0]], widgets: ['zebra']
123                 });
124                 $("#holidaysunique").tablesorter({
125                   sortList: [[0,0]], widgets: ['zebra']
126                 });
127         });
128 //]]>
129 </script>
130 <style type="text/css">
131 .normalday { background-color :  #EDEDED; color :  Black; border : 1px solid #000000; }
132 .exception { background-color :  #EDEDED; color :  Black; border : 1px solid #000000; }
133 .holiday {  background-color :  red; color :  Black;  border : 1px solid #000000; }
134 .repeatableday {  background-color :  yellow; color :  Black;  border : 1px solid #000000; }
135 .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; }
136 .panel { z-index : 1; width : 500px; display : none; border : 1px solid #000000; padding : 3px; /* position: absolute; */ background-color: #CCCCCC; }
137 div.dmy { display:inline; }
138 .blacklabel, div.dmy input { background-color:#FFFFFF; color:Black; font-size:10px; }
139 h1 select { width: 20em; }
140 </style>
141 </head>
142 <body>
143 <!-- TMPL_INCLUDE NAME="header.inc" -->
144 <!-- TMPL_INCLUDE NAME="cat-search.inc" -->
145
146 <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; Calendar</div>
147
148 <div id="doc3" class="yui-t2">
149    
150    <div id="bd">
151         <div id="yui-main">
152         <div class="yui-b">
153
154
155
156
157 <!-- *************************************************************************************** -->
158 <!-- ******                     START OF INFORMATION PANEL                            ****** -->
159 <!-- *************************************************************************************** -->
160
161 <div class="information" style="position:absolute" id="information" onclick=" hidePanel('information')">
162         <table>
163                 <tr>
164                         <td>
165                                 <p id="explanation" style="display:inline;align:justify"></p>
166                         </td>
167                 </tr>
168         </table>
169 </div>
170
171 <!-- ************************************************************************************** -->
172 <!-- ******                      END OF INFORMATION PANEL                            ****** -->
173 <!-- ************************************************************************************** -->
174
175 <h1>Define the holidays for :</h1>
176         <label for="branch">Select a library :</label>
177             <select id="branch" name="branch">
178                 <!-- TMPL_LOOP NAME="branchloop" -->
179                     <!-- TMPL_IF NAME="selected" -->
180                         <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
181                     <!-- TMPL_ELSE -->
182                         <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
183                     <!-- /TMPL_IF -->
184                 <!-- /TMPL_LOOP -->
185             </select>
186         <ul>
187                 <li>Search in the calendar the day you want to set as holiday.</li>
188                 <li>Complete the information in the right area.</li>
189                 <li>Once you finish the steps above, click Save.</li>
190         </ul>
191         <p>
192                 <span class="normalday">Working day</span>
193                 <span class="holiday">Unique holiday</span>
194                 <span class="repeatableday">Repeatable holiday</span>
195                 <span class="exception">Holiday exception</span>
196         </p>
197         
198         <!-- ******************************** FLAT PANELS ******************************************* -->
199         <!-- *****           Makes all the flat panel to deal with holidays                     ***** -->
200         <!-- **************************************************************************************** -->
201
202         <!-- ********************** Panel for showing already loaded holidays *********************** -->
203         <div class="panel" id="showHoliday">
204                 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
205                         <input type="hidden" id="showHolidayType" name="showHolidayType" value="" />
206                         <h2>Edit this holiday</h2>
207                         <p>
208                                 <label for="showBranchName">Library</label>
209                                 <input type="text" size="20" id="showBranchName" name="showBranchName" readonly="readonly" class="blacklabel" />
210                         </p>
211                         <p>
212                                 <label for="showDayname">Day name</label>
213                                 <input type="text" size="20" id="showDayname" name="showDayname" readonly="readonly" class="blacklabel" />
214                                 <input type="hidden" name="showWeekday" />
215                         </p>
216                         <div class="dmy">
217                                 <label for="showDay">Day</label> <input type="text" size="2" id="showDay" name="showDay" readonly="readonly" />
218                                 <label for="showMonth">Month</label> <input type="text" size="2" id="showMonth" name="showMonth" readonly="readonly" />
219                                 <label for="showYear">Year</label> <input type="text" size="4" id="showYear" name="showYear" readonly="readonly" />             
220                         </div>
221                     <!-- showTitle is necessary for exception radio button to work properly --> 
222                     <input type="hidden" id="showTitle" name="showTitle" value="" />
223                     <p><label for="showDescription">Description:</label>
224                                 <br />
225                                 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>    
226                         </p>
227                         <div id="exceptionPosibility" style="position:static">
228                                 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception to this holiday.</label>
229                                 <a href="#" onclick=" additionalInformation('You can make an exception for this holiday rule. This means that you will be able to say for a repeatable holiday, that there is one of those days that is going to be an exception.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a><br />
230                         </div>
231                         <input type="radio" name="showOperation" id="showOperationDel" value="delete" /> <label for="showOperationDel" id="showOperationDelLabel">Delete this holiday</label>
232                         <a href="#" onclick=" additionalInformation('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.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a><br />
233                         <input type="radio" name="showOperation" id="showOperationEdit" value="edit" checked="checked" /> <label for="showOperationEdit">Edit this holiday</label>
234                         <a href="#" onclick=" additionalInformation('This will save changes to the holiday\'s description. If the description for a repeatable holiday is modified, it affects all of the dates that the holiday is repeated.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
235                         <p>
236                                 <input type="submit" name="submit" value="Save" />
237                                 <input type="button" name="cancel2" value="Cancel" onclick=" hidePanel('showHoliday');hidePanel('information')" />
238                         </p>
239                 </form>
240         </div>
241
242         <!-- ***************************** Panel to deal with new holidays **********************  -->
243         <div class="panel" id="newHoliday">
244                 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
245                                 <input type="hidden" name="branchCodes" id="branchCodes" value="<!-- TMPL_VAR NAME="branchcodes" -->" /> 
246                         <h2>Add new holiday</h2>
247                         <p>
248                                 <label for="newBranchName">Library</label>
249                                 <input type="text" size="20" id="newBranchName" name="newBranchName" readonly="readonly" class="blacklabel" />
250                         </p>
251                         <p>
252                                 <label for="newDayname">Day name</label>
253                                 <input type="text" size="20" id="newDayname" name="newDayname" readonly="readonly" class="blacklabel" />
254                                 <input type="hidden" name="newWeekday" />
255                         </p>
256                         <div class="dmy">
257                                 <label for="newDay">Day</label> <input type="text" size="2" id="newDay" name="newDay" readonly="readonly" />
258                                 <label for="newMonth">Month</label> <input type="text" size="2" id="newMonth" name="newMonth"  readonly="readonly" />
259                                 <label for="newYear">Year</label> <input type="text" size="4" id="newYear" name="newYear" readonly="readonly" />
260                         </div>
261                         <p><label for="newDescription">Description:</label>
262                                 <br />
263                                 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
264                         </p>
265                                 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
266                                 <label for="newOperationOnce">Holiday only on this day</label>.
267                                 <a href="#" onclick=" additionalInformation('Make a single holiday. For example, selecting August 1st, 2012 will make it holiday, but will not affect August 1st in other years.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
268                                 <br />
269                                 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
270                                 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
271                                 <a href="#" onclick=" additionalInformation('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.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
272                                 <br />
273                                 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
274                                 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
275                                 <a href="#" onclick=" additionalInformation('This will take this day and month as a reference to make it 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.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
276                                 <p>
277                                 <input type="checkbox" name="allBranches" id="allBranches" />
278                                 <label for="allBranches">Copy to all locations</label>.
279                                 <a href="#" onclick=" additionalInformation('If checked, this holiday will be copied to all locations. If the holiday already exists for a location, no change is made.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
280                                 </p><p>
281                                         <input type="submit" name="submit" value="Save" />
282                                         <input type="button" name="cancel2" value="Cancel" onclick=" hidePanel('newHoliday');hidePanel('information')" />
283                                 </p>
284                 </form>
285         </div>
286
287         <!-- *************************************************************************************** -->
288         <!-- ******                          END OF FLAT PANELS                               ****** -->
289         <!-- *************************************************************************************** -->
290
291 <!-- ************************************************************************************** -->
292 <!-- ******                              MAIN SCREEN CODE                            ****** -->
293 <!-- ************************************************************************************** -->
294 <h2>Calendar information</h2>
295 <div id="calendar-container">
296 <script type="text/javascript">
297         /* Creates all the structures to deal with all diferents kinds of holidays */
298         var week_days = new Array();
299         var holidays = new Array();
300         var exception_holidays = new Array();
301         var day_month_holidays = new Array();
302         var hola= "<!-- TMPL_VAR NAME="code" -->";
303         <!-- TMPL_LOOP NAME="WEEK_DAYS_LOOP" -->
304         week_days["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
305         <!-- /TMPL_LOOP -->
306         <!-- TMPL_LOOP NAME="HOLIDAYS_LOOP" -->
307         holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
308         <!-- /TMPL_LOOP -->
309         <!-- TMPL_LOOP NAME="EXCEPTION_HOLIDAYS_LOOP" -->
310         exception_holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
311         <!-- /TMPL_LOOP -->
312         <!-- TMPL_LOOP NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
313         day_month_holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
314         <!-- /TMPL_LOOP -->
315
316         /* This function gives css clases to each kind of day */
317         function dateStatusHandler(date) {
318                 var day = date.getDate();
319                 var month = date.getMonth() + 1;
320                 var year = date.getFullYear();
321                 var weekDay = date.getDay();
322                 var dayMonth = month + '/' + day;
323                 var dateString = year + '/' + month + '/' + day;
324                 if (exception_holidays[dateString] != null) {
325                         return 'exception';
326                 } else if ((week_days[weekDay] != null) || (day_month_holidays[dayMonth] != null)) {
327                         return 'repeatableday';
328                 } else if (holidays[dateString] != null) {
329                         return 'holiday';
330                 } else {
331                         return 'normalday';
332                 }
333         }
334
335         /* This function is in charge of showing the correct panel considering the kind of holiday */
336         function dateChanged(calendar) {
337                 var day = calendar.date.getDate();
338                 var month = calendar.date.getMonth() + 1;
339                 var year = calendar.date.getFullYear();
340                 var weekDay = calendar.date.getDay();
341                 var dayName = calendar.date.print('%A');
342                 var dayMonth = month + '/' + day;
343                 var dateString = year + '/' + month + '/' + day;
344                 if (calendar.dateClicked) {
345                         if (holidays[dateString] != null) {
346                                 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,  holidays[dateString].description, 'ymd');
347                         } else if (exception_holidays[dateString] != null) {
348                                 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description, 'exception');
349                         } else if (week_days[weekDay] != null) {
350                                 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,    week_days[weekDay].description, 'weekday');
351                         } else if (day_month_holidays[dayMonth] != null) {
352                                 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description, 'daymonth');
353                         } else {
354                                 newHoliday(dayName, day, month, year, weekDay);
355                         }
356                 }
357         };
358         Calendar.setup(
359                 {
360                         flat : "calendar-container",
361                         flatCallback : dateChanged,
362                         date: "<!-- TMPL_VAR NAME='keydate' -->",
363                         dateStatusFunc : dateStatusHandler
364                 }
365         );
366 </script>
367
368 <div id="holiday-list">
369 <!-- Exceptions First -->
370 <!--   this will probably always have the least amount of data -->
371 <!-- TMPL_IF NAME="EXCEPTION_HOLIDAYS_LOOP" -->
372 <h3>Exceptions</h3>
373   <table id="holidayexceptions">
374 <thead><tr>
375   <th class="exception">Date</th>
376   <th class="exception">Title</th>
377   <th class="exception">Description</th>
378 </tr>
379 </thead>
380 <tbody>
381   <!-- TMPL_LOOP NAME="EXCEPTION_HOLIDAYS_LOOP" -->
382   <tr>
383   <td><!-- TMPL_VAR NAME="DATE" --></td>
384   <td><!-- TMPL_VAR NAME="TITLE" --></td>
385   <td><!-- TMPL_VAR NAME="DESCRIPTION" --></td> 
386   </tr>
387   <!-- /TMPL_LOOP --> 
388 </tbody>
389 </table>
390 <!-- /TMPL_IF -->
391
392 <!--TMPL_IF NAME="WEEK_DAYS_LOOP" -->
393 <h3>Weekly - Repeatable Holidays</h3>
394 <table id="holidayweeklyrepeatable">
395 <thead>
396 <tr>
397   <th class="repeatableday">Day of Week</th>
398   <th class="repeatableday">Title</th>
399   <th class="repeatableday">Description</th>
400 </tr>
401 </thead>
402 <tbody>
403   <!-- TMPL_LOOP NAME="WEEK_DAYS_LOOP" -->
404   <tr>
405   <td>
406 <script type="text/javascript">
407   document.write(weekdays[ <!-- TMPL_VAR NAME="KEY" -->]);
408 </script>
409   </td> 
410   <td><!-- TMPL_VAR NAME="TITLE" --></td> 
411   <td><!-- TMPL_VAR NAME="DESCRIPTION" --></td> 
412   </tr>
413   <!-- /TMPL_LOOP --> 
414 </tbody>
415 </table>
416 <!-- /TMPL_IF -->
417
418 <!-- TMPL_IF NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
419 <h3>Yearly - Repeatable Holidays</h3>
420 <table id="holidaysyearlyrepeatable">
421 <thead>
422 <tr>
423   <!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
424   <th class="repeatableday">Day/Month</th>
425   <!-- TMPL_ELSE -->
426   <th class="repeatableday">Month/Day</th>
427   <!-- /TMPL_IF -->
428   <th class="repeatableday">Title</th>
429   <th class="repeatableday">Description</th>
430 </tr>
431 </thead>
432 <tbody>
433   <!-- TMPL_LOOP NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
434   <tr>
435   <td><!-- TMPL_VAR NAME="DATE" --></td>
436   <td><!-- TMPL_VAR NAME="TITLE" --></td> 
437   <td><!-- TMPL_VAR NAME="DESCRIPTION" --></td> 
438   </tr>
439   <!-- /TMPL_LOOP --> 
440 </tbody>
441 </table>
442 <!-- /TMPL_IF -->
443
444 <!-- TMPL_IF NAME="HOLIDAYS_LOOP" -->
445 <h3>Unique Holidays</h3>
446 <table id="holidaysunique">
447 <thead>
448 <tr>
449   <th class="holiday">Date</th>
450   <th class="holiday">Title</th>
451   <th class="holiday">Description</th>
452 </tr>
453 </thead>
454 <tbody>
455     <!-- TMPL_LOOP NAME="HOLIDAYS_LOOP" -->
456 <tr>
457   <td><!-- TMPL_VAR NAME="DATE" --></td>
458   <td><!-- TMPL_VAR NAME="TITLE" --></td>
459   <td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
460 </tr>
461   <!-- /TMPL_LOOP --> 
462 </tbody>
463 </table>
464 <!-- /TMPL_IF -->
465 </div>
466 </div>
467 </div>
468 </div>
469 <div class="yui-b noprint">
470 <!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
471 </div>
472 </div>
473 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->