Merge branch 'new/enh/bug_5917' into kcmaster
[koha.git] / koha-tmpl / opac-tmpl / prog / en / modules / opac-reserve.tt
1 [% INCLUDE 'doc-head-open.inc' %][% DEFAULT LibraryNameTitle="Koha Online" %] Catalog ›  Placing hold [% title |html %] for [% FOREACH USER_INF IN USER_INFO %][% USER_INF.firstname %] [% USER_INF.surname %][% END %]
2 [% INCLUDE 'doc-head-close.inc' %]
3 [% INCLUDE 'calendar.inc' %]
4 <script type="text/javascript">
5 // <![CDATA[
6  var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
7
8  function prefixOf (s, tok) {
9      var index = s.indexOf(tok);
10      return s.substring(0, index);
11  }
12  function suffixOf (s, tok) {
13      var index = s.indexOf(tok);
14      return s.substring(index + 1);
15  }
16
17  $(document).ready(function() {
18     var copiesRowId = null;
19     var wasSpecific = false;
20     var lastCopiesRowId = null;
21         $(".checkitem").parent().click(function(e){
22                 if(e.target.tagName.toLowerCase() == 'td'){
23            $(this).find("input.checkitem").each( function() {
24                $(this).attr('checked', !$(this).attr('checked'));
25                         });
26                 }
27         });
28     // Hides all 'specific copy' table rows on load.
29     $(".copiesrow").hide();
30
31     $("#place_on_hdr").show();
32     $(".place_on_type").show();
33
34     // Replace non-JS single-selection with multi-selection capability.
35     $(".reserve_mode").val("multi");
36     $(".confirm_nonjs").remove();
37     $(".confirmjs_hold").each(function(){
38         var bib = $(this).attr("title");
39         var html = "<input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
40         html += "value=\"" + bib + "\"/>";
41         $(this).html(html);
42     });
43     $(".confirmjs_nohold").each(function(){
44         var bib = $(this).attr("title");
45         var html = "<input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
46         html += "value=\"" + bib + "\"/>";
47         $(this).html(html);
48     });
49
50     // Make sure a specific item was selected where specified
51     // before moving on to a new item.
52     function changeSelection (newCopiesRowId, isSpecific) {
53         if (copiesRowId && ((copiesRowId != newCopiesRowId) || (wasSpecific != isSpecific))) {
54             var biblioNum = suffixOf(copiesRowId, "_");
55
56             // If the 'specific copy' radio button was checked
57               if (wasSpecific && (copiesRowId != newCopiesRowId)) {
58                 // Find the selected copy
59                 var item = $(".checkitem_" + biblioNum + ":checked");
60                 if ($(item).size() == 0) {
61                     alert(MSG_NO_COPY_SELECTED);
62                     return false;
63                 }
64             }
65         }
66         copiesRowId = newCopiesRowId;
67         wasSpecific = isSpecific;
68         return true;
69     }
70
71     // When 'specific copy' radio button is clicked
72     $(".selectspecific").click(function() {
73
74         // Make sure all other specific copy table rows are hidden
75         biblioNum = suffixOf($(this).attr("id"), "_");
76         newCopiesRowId = "#copiesrow_" + biblioNum;
77
78         if (!changeSelection(newCopiesRowId, true)) {
79             return false;
80         }
81         $(".copiesrow:not(" + newCopiesRowId + ")").hide();
82
83         // Show the specific copy table for this radio button.
84         $(newCopiesRowId).show();
85     });
86
87
88     // When 'first available' radion button is clicked
89     $(".selectany").click(function() {
90         // Make sure all other specific copy table rows are hidden
91         biblioNum = suffixOf($(this).attr("id"), "_");
92         newCopiesRowId = "#copiesrow_" + biblioNum;
93
94         if (!changeSelection(newCopiesRowId, false)) {
95             return false;
96         }
97
98         // Hide the copies table row
99         $(".copiesrow").hide();
100     });
101
102     // When 'Place Hold' button is clicked
103     $(".placehold").click(function(){
104         var biblionumbers = "";
105         var selections = "";
106
107         if ($(".confirmjs:checked").size() == 0) {
108             alert(MSG_NO_RECORD_SELECTED);
109             return false;
110         }
111
112         // Find the items with the 'Hold' box checked
113         var badBib = null;
114         $(".confirmjs:checked").each(function() {
115             var biblioNum = $(this).val();
116             biblionumbers += biblioNum + "/";
117             selections += biblioNum + "/";
118
119             // If the 'specific copy' radio button is checked
120             if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
121                 // Find the selected copy
122                 var item = $(".checkitem_" + biblioNum + ":checked");
123                 if ($(item).size() == 0) {
124                     badBib = biblioNum;
125                     return false;
126                 } else {
127                   selections += $(item).val();
128                 }
129             }
130             selections += "/";
131
132             // Add the pickup location
133             var branchSel = $("#branch_" + biblioNum);
134             if (branchSel.size() > 0) {
135                 selections += $(branchSel).val();
136             }
137             selections += "/";
138             return true;
139         });
140
141         if (badBib) {
142             alert(MSG_NO_COPY_SELECTED);
143             return false;
144         }
145
146         $("#selections").val(selections);
147         $("#biblionumbers").val(biblionumbers);
148
149         return true;
150     });
151
152  });
153 // ]]>
154 </script>
155 </head>
156
157 <body id="opac-holds">
158   <div id="doc3" class="yui-t7">
159     [% INCLUDE 'masthead.inc' %]
160     <div id="bd">
161           <div id="yui-g">
162         <div id="holds" class="container">
163         [% IF ( message ) %]
164             [% IF ( GNA ) %]
165               <div id="gna" class="dialog alert">
166                 <p><strong>Sorry</strong>, you cannot place holds because the library doesn't have up-to-date <a href="/cgi-bin/koha/opac-userupdate.pl">contact information</a> on file.</p>
167               <p>Please contact your librarian, or use the <a href="/cgi-bin/koha/opac-userupdate.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)</p>
168               </div>
169             [% END %]
170             [% IF ( lost ) %]
171               <div id="lost" class="dialog alert">
172                 <p><strong>Sorry</strong>, you cannot place holds because your library card has been marked as lost or stolen.</p>
173                 <p>If this is an error, please take your card to the circulation desk at your local library and the error will be corrected.</p>
174               </div>
175             [% END %]
176             [% IF ( debarred ) %]
177               <div id="debarred" class="dialog alert">
178                 <p><strong>Sorry</strong>, you cannot place holds because your account has been frozen.</p>
179                 <p>Usually the reason for freezing an account is old overdues or damage fees.   If <a href="/cgi-bin/koha/opac-user.pl">your account page</a> shows your account to be clear, please consult a librarian.</p>
180               </div>
181             [% END %]
182             [% IF ( too_much_oweing ) %]
183               <div class="dialog alert">
184                 Sorry, you cannot place holds because you owe [% too_much_oweing %].
185               </div>
186             [% END %]
187             [% IF ( too_many_reserves ) %]
188               <div class="dialog alert">Sorry, you cannot place more than [% too_many_reserves %] holds.
189               </div>
190             [% END %]
191             [% IF ( bad_biblionumber ) %]
192               <div class="dialog alert">ERROR: No biblio record found for biblionumber [% bad_biblionumber %].</div>
193             [% END %]
194             [% IF ( no_items_selected ) %]
195               <div class="dialog alert">
196                 You must select at least one item.
197               </div>
198             [% END %]
199             [% IF ( no_branch_selected ) %]
200               <div class="dialog alert">
201                 You must select a library for pickup.
202               </div>
203             [% END %]
204             [% IF ( no_biblionumber ) %]
205               <div class="dialog alert">ERROR: No biblionumber received.</div>
206             [% END %]
207             [% IF ( bad_data ) %]
208               <div class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
209             [% END %]
210           [% ELSE %]
211             [% IF ( none_available ) %]
212                 <div class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
213                 </div>
214               [% END %]
215           [% END %]<!-- NAME="message" -->
216
217       [% UNLESS ( message ) %][% UNLESS ( none_available ) %]<h3>Confirm holds for:
218                       [% FOREACH USER_INF IN USER_INFO %]
219                         [% USER_INF.firstname %] [% USER_INF.surname %] ([% USER_INF.cardnumber %])
220                       [% END %]
221                     </h3>[% END %]
222
223             <form action="/cgi-bin/koha/opac-reserve.pl" method="post">
224             <input type="hidden" name="place_reserve" value="1"/>
225
226             <!-- These values are set dynamically by js -->
227             <input type="hidden" name="biblionumbers" id="biblionumbers"/>
228             <input type="hidden" name="selecteditems" id="selections"/>
229             <div id="bigloop">
230               <table id="bibitemloop">
231                 [% UNLESS ( none_available ) %]<tr>
232                   <th>Hold</th>
233                   <th>Title</th>
234                   [% UNLESS ( item_level_itypes ) %]
235                     <th>Item Type</th>
236                   [% END %]
237                   [% IF ( showpriority ) %]
238                   <th>Priority</th>
239                   [% END %]
240                   [% IF ( reserve_in_future ) %]
241                   <th>Hold Starts on Date</th>
242                   [% END %]
243                   <th>Hold Not Needed After</th>
244                   [% IF ( OPACItemHolds ) %]
245                     <th id="place_on_hdr" style="display:none">Place On</th>
246                   [% END %]
247                   [% UNLESS ( singleBranchMode ) %]
248                     [% IF ( choose_branch ) %]
249                         <th>Pickup Location</th>
250                     [% END %]
251                   [% END %]
252                 </tr>[% ELSE %]<tr><th colspan="5">Title</th></tr>[% END %]
253
254                 [% FOREACH bibitemloo IN bibitemloop %]
255                   <tr>
256                       [% IF ( bibitemloo.holdable ) %]
257                                           <td>
258                       <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
259                       <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
260                         <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
261                         <span class="confirm_nonjs">
262                           <input type="radio" class="confirmbox checkitem [% bibitemloo.checkitem_bib %]"
263                                  name="[% bibitemloo.checkitem_bib %]" checked="checked"
264                                  id="[% bibitemloo.checkitem_bib %]"
265                                  value="any" />
266                           <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
267                         </span>
268                                         </td>
269                       [% ELSE %]
270                                           [% UNLESS ( none_available ) %]<td>&nbsp;</td>[% END %]
271                       [% END %]
272                     [% IF ( bibitemloo.holdable ) %]<td>[% ELSE %]<td colspan="5">[% END %]
273                       <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
274                       [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
275
276                       [% UNLESS ( bibitemloo.holdable ) %]
277
278                         [% IF ( bibitemloo.already_reserved ) %]
279                           <div class="bibmessage">You have already requested this title.</div>
280                         [% ELSE %]
281                           [% UNLESS ( bibitemloo.bib_available ) %]
282                             <div class="bibmessage">No available items.</div>
283                           [% ELSE %]
284                             <div class="bibmessage">This title cannot be requested.</div>
285                           [% END %]
286                         [% END %]
287
288
289                         [% END %]
290
291                     </td>
292                     [% IF ( bibitemloo.holdable ) %][% UNLESS ( item_level_itypes ) %]
293                                           <td>
294                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
295                                 [% bibitemloo.description %]
296                                           </td>
297                                         [% END %][% END %]
298                     [% IF ( bibitemloo.holdable ) %]
299                     [% IF ( showpriority ) %]
300                     <td>
301                     [% bibitemloo.rank %] out of [% bibitemloo.reservecount %]
302                     </td>[% END %][% END %]
303                     [% IF ( reserve_in_future ) %]
304                     [% IF ( bibitemloo.holdable ) %]<td>
305               <input name="reserve_date_[% bibitemloo.biblionumber %]" id="reserve_date_[% bibitemloo.biblionumber %]" size="10">
306               <script language="JavaScript" type="text/javascript">
307               //<![CDATA[
308               $("#reserve_date_[% bibitemloo.biblionumber %]").attr( 'readonly', 'readonly' );
309
310               var cal_img = document.createElement('img');
311               cal_img.src = "[% themelang %]/lib/calendar/cal.gif";
312               cal_img.alt = "Show Calendar";
313               cal_img.border = "0";
314               cal_img.id = "CalendarReserveDate[% bibitemloo.biblionumber %]";
315               cal_img.style.cursor = "pointer";
316               document.getElementById("reserve_date_[% bibitemloo.biblionumber %]").parentNode.appendChild( cal_img );
317
318               function validate[% bibitemloo.biblionumber %](date) {
319                   var today = new Date();
320                         if ( (date > today) ||
321                                 ( date.getDate() == today.getDate() &&
322                                   date.getMonth() == today.getMonth() &&
323                                   date.getFullYear() == today.getFullYear() ) ) {
324                             return false;
325                         } else {
326                             return true;
327                         }
328               };
329               Calendar.setup(
330               {
331                 inputField : "reserve_date_[% bibitemloo.biblionumber %]",
332                 ifFormat : "[% bibitemloo.DHTMLcalendar_dateformat %]",
333                 button : "CalendarReserveDate[% bibitemloo.biblionumber %]",
334                 disableFunc : validate[% bibitemloo.biblionumber %],
335                 dateStatusFunc : validate[% bibitemloo.biblionumber %]
336               }
337               );
338               //]]>
339               </script>
340                 </td>[% END %]
341
342                     [% END %]
343         [% IF ( bibitemloo.holdable ) %]<td>
344         <input name="expiration_date_[% bibitemloo.biblionumber %]" id="expiration_date_[% bibitemloo.biblionumber %]" size="10" readonly="readonly" />
345         <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="CalendarExpirationDate_[% bibitemloo.biblionumber %]" style="cursor: pointer;" />
346         <script language="JavaScript" type="text/javascript">
347       //<![CDATA[
348       function validate1(date) {
349         var today = new Date();
350         if ( (date > today) ||
351                       ( date.getDate() == today.getDate() &&
352                         date.getMonth() == today.getMonth() &&
353                         date.getFullYear() == today.getFullYear() ) ) {
354           return false;
355         } else {
356           return true;
357         }
358       };
359       Calendar.setup(
360         {
361           inputField : "expiration_date_[% bibitemloo.biblionumber %]",
362           ifFormat : "[% bibitemloo.DHTMLcalendar_dateformat %]",
363           button : "CalendarExpirationDate_[% bibitemloo.biblionumber %]",
364           disableFunc : validate1,
365           dateStatusFunc : validate1
366         }
367       );
368       //]]>
369         </script>
370       <p style="margin:.3em 2em;">
371       <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('expiration_date_[% bibitemloo.biblionumber %]').value='';return false;">Clear Date</a></p>
372     </td>[% END %]
373
374                     [% IF ( bibitemloo.holdable ) %][% IF ( OPACItemHolds ) %]
375                                           <td class="place_on_type" style="display:none">
376                                             <table>
377                                               <tr>
378                                                 <td>
379                                                   [% UNLESS ( bibitemloo.holdable ) %]
380                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
381                                                            id="reqany_[% bibitemloo.biblionumber %]"
382                                                            class="selectany"
383                                                            value="Any"
384                                                            disabled="disabled"
385                                                     />
386                                                   [% ELSE %]
387                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
388                                                            id="reqany_[% bibitemloo.biblionumber %]"
389                                                            class="selectany"
390                                                            value="Any"
391                                                            checked="checked"
392                                                     />
393                                                   [% END %]
394                                                   <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
395                                                 </td>
396                                               </tr>
397                                               <tr>
398                                                 <td>
399                                                   [% UNLESS ( bibitemloo.holdable ) %]
400                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
401                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
402                                                            class="selectspecific"
403                                                            disabled="disabled"
404                                                            value="Specific"
405                                                     />
406                                                   [% ELSE %]
407                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
408                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
409                                                            class="selectspecific"
410                                                            value="Specific"
411                                                     />
412                                                   [% END %]
413                                                   <label for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
414                                                 </td>
415                                               </tr>
416                                             </table>
417                                           </td>
418                                         [% END %][% END %]
419
420                     [% UNLESS ( singleBranchMode ) %]
421                         [% IF ( bibitemloo.holdable ) %]
422                             [% IF ( choose_branch ) %]
423                                            <td>
424                                               <select name="branch" id="branch_[% bibitemloo.biblionumber %]"
425                                                 [% UNLESS ( bibitemloo.holdable ) %]disabled="disabled"[% END %] >
426                                                 [% FOREACH branchChoicesLoo IN bibitemloo.branchChoicesLoop %]
427                                                   [% IF ( branchChoicesLoo.selected ) %]
428                                                     <option value="[% branchChoicesLoo.value %]" selected="selected">[% branchChoicesLoo.branchname %]</option>
429                                                   [% ELSE %]
430                                                     <option value="[% branchChoicesLoo.value %]">[% branchChoicesLoo.branchname %]</option>
431                                                   [% END %]
432                                                 [% END %]
433                                               </select>
434                                            </td>
435                             [% END %]
436                         [% END %]
437                     [% END %]
438                   </tr>
439
440                   [% IF ( OPACItemHolds ) %]
441                   [% IF ( bibitemloo.holdable ) %]
442                     <tr class="copiesrow" id="copiesrow_[% bibitemloo.biblionumber %]">
443                       <td colspan="1">
444                       </td>
445                       <td colspan="[% bibitemloo.itemtable_colspan %]">
446                         <table>
447                           <caption>Select a specific copy:</caption>
448                           <tr>
449                             <th>Copy</th>
450                             [% IF ( item_level_itypes ) %]
451                               <th>Item Type</th>
452                             [% END %]
453                             <th>Barcode</th>
454                             [% UNLESS ( bibitemloo.singleBranchMode ) %]
455                               <th>Home Library</th>
456                               <th>Last Location</th>
457                             [% END %]
458                             <th>Call Number</th>
459                             [% IF ( bibitemloo.itemdata_enumchron ) %]
460                               <th>Vol Info</th>
461                             [% END %]
462                             <th>Information</th>
463                           </tr>
464
465                           [% FOREACH itemLoo IN bibitemloo.itemLoop %]
466                             <tr class="[% itemLoo.backgroundcolor %]">
467                               <td>
468                                 [% IF ( itemLoo.available ) %]
469                                   <input type="radio" class="checkitem checkitem_[% itemLoo.biblionumber %]" name="checkitem_[% itemLoo.biblionumber %]"
470                                          value="[% itemLoo.itemnumber %]" />
471                                 [% ELSE %]
472                                   <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]" />
473                                   <img src="/opac-tmpl/[% itemLoo.theme %]/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
474                                 [% END %] [% IF ( itemLoo.copynumber ) %][% itemLoo.copynumber %][% END %]
475                               </td>
476                               [% IF ( item_level_itypes ) %]
477                                 <td>
478                                   [% UNLESS ( noItemTypeImages ) %]
479                                   [% IF ( itemLoo.imageurl ) %]<img src="[% itemLoo.imageurl %]" alt="" />[% END %]
480                                   [% END %]
481                                                                 [% itemLoo.description %]
482                                 </td>
483                               [% END %]
484                               <td>[% itemLoo.barcode %]</td>
485                               [% UNLESS ( singleBranchMode ) %]
486                                 <td>[% itemLoo.homeBranchName %]</td>
487                                 <td>[% itemLoo.holdingBranchName %]</td>
488                               [% END %]
489                               <td>[% itemLoo.callNumber %]</td>
490                               [% IF ( itemLoo.itemdata_enumchron ) %]<!-- test -->
491                                 <td>[% itemLoo.enumchron %]</td>
492                               [% END %]
493                               <td>
494                                 [% IF ( itemLoo.date_due ) %]
495                                   <span class="checkedout">Due [% itemLoo.date_due %]</span>
496                                 [% ELSIF ( itemLoo.transfertwhen ) %]
497                                   <span class="intransit">In transit from [% itemLoo.transfertfrom %],
498                                     to [% itemLoo.transfertto %], since [% itemLoo.transfertwhen %]</span>
499                                 [% END %]
500                                 [% IF ( itemLoo.message ) %]
501                                   <span class="lost">Unavailable (lost or missing)</span>
502                                 [% END %]
503                                 [% IF ( itemLoo.notforloan ) %]
504                                   <span class="notforloan">Not for loan ([% itemLoo.notforloanvalue %])</span>
505                                 [% END %]
506                                 [% IF ( itemLoo.reservedate ) %]
507                                   <span class="waiting">[% IF ( itemLoo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %] for patron
508                                     [% IF ( itemLoo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemLoo.ExpectedAtLibrary %]
509                                     since
510                                     [% IF ( itemLoo.waitingdate ) %][% itemLoo.waitingdate %][% ELSE %][% IF ( itemLoo.reservedate ) %][% itemLoo.reservedate %][% END %][% END %].
511                                   </span>
512                                 [% ELSE %]
513                                   <span class="notonhold">Not on hold</span>
514                                 [% END %]&nbsp;
515                               </td>
516                             </tr>
517                           [% END %]
518                         </table>
519                       </td>
520                     </tr>
521                   [% END %]<!-- bib_available -->
522                   [% END %]<!-- OPACItemHolds -->
523                 [% END %]
524               </table><!-- bibitemloop -->
525               [% END %] <!-- if message -->
526             </div><!-- bigloop -->
527
528             [% UNLESS ( message ) %]
529             [% UNLESS ( none_available ) %]
530             <input type="submit" value="Place Hold" class="placehold" />
531             [% END %]
532             [% END %]
533
534             </form>
535
536         </div><!-- holds -->
537       </div><!-- yui-g -->
538     </div><!-- bd    -->
539   </div><!-- doc3  -->
540
541 <div><!-- The following include seems to have an extra "/div" in it... -->
542 [% INCLUDE 'opac-bottom.inc' %]