Beginning work on Calendar compatibility fixes
[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; Holidays</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) {
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                 
60                 if (exceptionPosibility == 1) {
61                         document.getElementById('exceptionPosibility').style.display = 'inline';
62                 } else {
63                         document.getElementById('exceptionPosibility').style.display = 'none';
64                 }
65         }
66
67         // This function shows the "Add Holiday" panel //
68         function newHoliday (dayName, day, month, year, weekDay) {
69                 $("#showHoliday").slideUp("fast");
70                 $("#newHoliday").slideDown("fast");
71                 $("#newDayname").val(dayName);
72                 $("#newBranchName").val($('#branch').val());
73                 $("#newDay").val(day);
74                 $("#newMonth").val(month);
75                 $("#newYear").val(year);
76                 $("#newWeekday")[0].val(weekDay);
77         }
78
79         function hidePanel(aPanelName) {
80                 $("#"+aPanelName).slideUp("fast");
81         }
82
83         function changeBranch () {
84                 var branch = $("#branch option:selected").val();
85                 location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch;
86         }
87
88         function additionalInformation (anExplanation) {
89                 var panel = document.getElementById('information');
90                 var paragraph = document.getElementById('explanation');
91                 panel.style.display = 'inline'
92                 panel.style.top = mouseY;
93                 panel.style.left = mouseX;
94                 var info = document.createTextNode(anExplanation);
95                 if (paragraph.hasChildNodes()) {
96                         paragraph.removeChild(paragraph.lastChild);
97                 }
98                 paragraph.appendChild(info);
99         }
100
101         function Help() {
102                 newin=window.open("/cgi-bin/koha/help.pl","Koha Help",'width=600,height=600,toolbar=false,scrollbars=yes');
103         }
104         $(document).ready(function() {
105                 $("#branch").change(function(){
106                         changeBranch();
107                 });
108         });
109 //]]>
110 </script>
111
112 <style type="text/css">
113 .normalday { 
114         background-color :  #EDEDED;
115         color :  Black; 
116         border : 1px solid #000000;
117 }
118
119 .exception {
120         background-color :  #EDEDED;
121         color :  Black;                 
122         border : 1px solid #000000;
123 }
124
125 .holiday { 
126         background-color :  red;
127         color :  Black; 
128         border : 1px solid #000000;
129 }
130
131 .repeatableday { 
132         background-color :  yellow;
133         color :  Black; 
134         border : 1px solid #000000;
135 }
136
137 .information {
138         z-index : 1;
139         background-color :  #DCD2F1;
140         width : 300px;
141         display : none;
142         border : 1px solid #000000;
143         color :  #000000;
144         font-size :  8pt;
145         font-weight :  bold;
146     background-color :  #FFD700;
147         cursor :  pointer;
148         padding : 2px;
149 }
150
151 .panel {
152         z-index : 1;
153         width : 500px;
154         display : none;
155         border : 1px solid #000000;
156         padding : 3px;
157         /* position: absolute; */
158         background-color: #CCCCCC;
159 }
160
161 div.dmy {
162         display:inline;
163 }
164
165 .blacklabel, div.dmy input {
166         background-color:#FFFFFF;
167         color:Black;
168         font-size:10px;
169 }
170
171 </style>
172 </head>
173 <body>
174 <!-- TMPL_INCLUDE NAME="header.inc" -->
175 <!-- TMPL_INCLUDE NAME="cat-search.inc" -->
176
177 <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; Holidays</div>
178
179 <div id="doc3" class="yui-t2">
180    
181    <div id="bd">
182         <div id="yui-main">
183         <div class="yui-b">
184
185
186
187
188 <!-- *************************************************************************************** -->
189 <!-- ******                     START OF INFORMATION PANEL                            ****** -->
190 <!-- *************************************************************************************** -->
191
192 <div class="information" style="position:absolute" id="information" onclick=" hidePanel('information')">
193         <table>
194                 <tr>
195                         <td>
196                                 <p id="explanation" style="display:inline;align:justify"></p>
197                         </td>
198                 </tr>
199         </table>
200 </div>
201
202 <!-- ************************************************************************************** -->
203 <!-- ******                      END OF INFORMATION PANEL                            ****** -->
204 <!-- ************************************************************************************** -->
205
206 <h1>Define the holidays for branch <!-- TMPL_VAR name="BRANCHES" --></h1>
207         <ul>
208                 <li>Search in the calendar the day you want to set as holiday.</li>
209                 <li>Complete the information in the right area.</li>
210                 <li>Once you finish the steps above, click Save.</li>
211         </ul>
212         <p>
213                 <span class="normalday">Working day</span>
214                 <span class="holiday">Unique holiday</span>
215                 <span class="repeatableday">Repeatable holiday</span>
216                 <span class="exception">Holiday exception</span>
217         </p>
218         
219         <!-- ******************************** FLAT PANELS ******************************************* -->
220         <!-- *****           Makes all the flat panel to deal with holidays                     ***** -->
221         <!-- **************************************************************************************** -->
222
223         <!-- ********************** Panel for showing already loaded holidays *********************** -->
224         <div class="panel" id="showHoliday">
225                 <form action="/cgi-bin/koha/tools/exceptionHolidays.pl" method="post">
226                         <h2>Edit this holiday</h2>
227                         <p>
228                                 <label for="showBranchName">Library</label>
229                                 <input type="text" size="20" id="showBranchName" name="showBranchName" readonly="readonly" class="blacklabel" />
230                         </p>
231                         <p>
232                                 <label for="showDayname">Day name</label>
233                                 <input type="text" size="20" id="showDayname" name="showDayname" readonly="readonly" class="blacklabel" />
234                                 <input type="hidden" name="showWeekday" />
235                         </p>
236                         <div class="dmy">
237                                 <label for="showDay">Day</label> <input type="text" size="2" id="showDay" name="showDay" readonly="readonly" />
238                                 <label for="showMonth">Month</label> <input type="text" size="2" id="showMonth" name="showMonth" readonly="readonly" />
239                                 <label for="showYear">Year</label> <input type="text" size="4" id="showYear" name="showYear" readonly="readonly" />             
240                         </div>
241                     <p><label for="showDescription">Description:</label>
242                                 <br />
243                                 <textarea rows="2" cols="40" id="showDescription" name="showDescription"></textarea>    
244                         </p>
245                         <div id="exceptionPosibility" style="position:static">
246                                 <input type="radio" name="showOperation" id="showOperationExc" value="exception" /> <label for="showOperationExc">Generate an exception to this holiday.</label>
247                                 <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>
248                         </div>
249                         <input type="radio" name="showOperation" id="showOperationDel" value="delete" checked="checked" /> <label for="showOperationDel">Delete this holiday</label>.
250                         <a href="#" onclick=" additionalInformation('This will delete this holiday rule. In case it is a repeatable holiday, this option checks for posible exceptions. In case those exists, this option take care of set this exceptions to regular holidays.')"><img src="<!-- TMPL_VAR NAME="themelang" -->/../img/more.gif" border="0" alt="More information" /></a>
251                         <p>
252                                 <input type="submit" name="submit" value="Save" />
253                                 <input type="button" name="cancel2" value="Cancel" onclick=" hidePanel('showHoliday');hidePanel('information')" />
254                         </p>
255                 </form>
256         </div>
257
258         <!-- ***************************** Panel to deal with new holidays **********************  -->
259         <div class="panel" id="newHoliday">
260                 <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
261                         <h2>Add new holiday</h2>
262                         <p>
263                                 <label for="newBranchName">Library</label>
264                                 <input type="text" size="20" id="newBranchName" name="newBranchName" readonly="readonly" class="blacklabel" />
265                         </p>
266                         <p>
267                                 <label for="newDayname">Day name</label>
268                                 <input type="text" size="20" id="newDayname" name="newDayname" readonly="readonly" class="blacklabel" />
269                                 <input type="hidden" name="newWeekday" />
270                         </p>
271                         <div class="dmy">
272                                 <label for="newDay">Day</label> <input type="text" size="2" id="newDay" name="newDay" readonly="readonly" />
273                                 <label for="newMonth">Month</label> <input type="text" size="2" id="newMonth" name="newMonth"  readonly="readonly" />
274                                 <label for="newYear">Year</label> <input type="text" size="4" id="newYear" name="newYear" readonly="readonly" />
275                         </div>
276                         <p><label for="newDescription">Description:</label>
277                                 <br />
278                                 <textarea rows="2" cols="40" id="newDescription" name="newDescription"></textarea>
279                         </p>
280                                 <input type="radio" name="newOperation" id="newOperationOnce" value="holiday" checked="checked" />
281                                 <label for="newOperationOnce">Holiday only on this day</label>.
282                                 <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>
283                                 <br />
284                                 <input type="radio" name="newOperation" id="newOperationDay" value="weekday" />
285                                 <label for="newOperationDay">Holiday repeated every same day of the week</label>.
286                                 <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>
287                                 <br />
288                                 <input type="radio" name="newOperation" id="newOperationYear" value="repeatable" />
289                                 <label for="newOperationYear">Holiday repeated yearly on the same date</label>.
290                                 <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>
291                                 <p>
292                                         <input type="submit" name="submit" value="Save" />
293                                         <input type="button" name="cancel2" value="Cancel" onclick=" hidePanel('newHoliday');hidePanel('information')" />
294                                 </p>
295                 </form>
296         </div>
297
298         <!-- *************************************************************************************** -->
299         <!-- ******                          END OF FLAT PANELS                               ****** -->
300         <!-- *************************************************************************************** -->
301
302 <!-- ************************************************************************************** -->
303 <!-- ******                              MAIN SCREEN CODE                            ****** -->
304 <!-- ************************************************************************************** -->
305 <h2>Calendar information</h2>
306 <div id="calendar-container">
307 <script type="text/javascript">
308         /* Creates all the structures to deal with all diferents kinds of holidays */
309         var week_days = new Array();
310         var holidays = new Array();
311         var exception_holidays = new Array();
312         var day_month_holidays = new Array();
313         var hola= "<!-- TMPL_VAR NAME="code" -->";
314         <!-- TMPL_LOOP NAME="WEEK_DAYS_LOOP" -->
315         week_days["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
316         <!-- /TMPL_LOOP -->
317         <!-- TMPL_LOOP NAME="HOLIDAYS_LOOP" -->
318         holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
319         <!-- /TMPL_LOOP -->
320         <!-- TMPL_LOOP NAME="EXCEPTION_HOLIDAYS_LOOP" -->
321         exception_holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
322         <!-- /TMPL_LOOP -->
323         <!-- TMPL_LOOP NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
324         day_month_holidays["<!-- TMPL_VAR NAME="KEY" -->"] = {title:"<!-- TMPL_VAR NAME="TITLE" -->", description:"<!-- TMPL_VAR NAME="DESCRIPTION" -->"};
325         <!-- /TMPL_LOOP -->
326
327         /* This function gives css clases to each kind of day */
328         function dateStatusHandler(date) {
329                 var day = date.getDate();
330                 var month = date.getMonth() + 1;
331                 var year = date.getFullYear();
332                 var weekDay = date.getDay();
333                 var dayMonth = month + '/' + day;
334                 var dateString = year + '/' + month + '/' + day;
335                 if (exception_holidays[dateString] != null) {
336                         return 'exception';
337                 } else if ((week_days[weekDay] != null) || (day_month_holidays[dayMonth] != null)) {
338                         return 'repeatableday';
339                 } else if (holidays[dateString] != null) {
340                         return 'holiday';
341                 } else {
342                         return 'normalday';
343                 }
344         }
345
346         /* This function is in charge of showing the correct panel considering the kind of holiday */
347         function dateChanged(calendar) {
348                 var day = calendar.date.getDate();
349                 var month = calendar.date.getMonth() + 1;
350                 var year = calendar.date.getFullYear();
351                 var weekDay = calendar.date.getDay();
352                 var dayName = calendar.date.print('%A');
353                 var dayMonth = month + '/' + day;
354                 var dateString = year + '/' + month + '/' + day;
355                 if (calendar.dateClicked) {
356                         if (holidays[dateString] != null) {
357                                 showHoliday(0, dayName, day, month, year, weekDay, holidays[dateString].title,  holidays[dateString].description);
358                         } else if (exception_holidays[dateString] != null) {
359                                 showHoliday(0, dayName, day, month, year, weekDay, exception_holidays[dateString].title, exception_holidays[dateString].description);
360                         } else if (week_days[weekDay] != null) {
361                                 showHoliday(1, dayName, day, month, year, weekDay, week_days[weekDay].title,    week_days[weekDay].description);
362                         } else if (day_month_holidays[dayMonth] != null) {
363                                 showHoliday(1, dayName, day, month, year, weekDay, day_month_holidays[dayMonth].title, day_month_holidays[dayMonth].description);
364                         } else {
365                                 newHoliday(dayName, day, month, year, weekDay);
366                         }
367                 }
368         };
369         Calendar.setup(
370                 {
371                         flat : "calendar-container",
372                         flatCallback : dateChanged,
373                         dateStatusFunc : dateStatusHandler
374                 }
375         );
376 </script>
377 </div>
378 </div>
379 </div>
380 <div class="yui-b noprint">
381 <!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
382 </div>
383 </div>
384 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->