Merge remote-tracking branch 'kc/new/enh/bug_6540' into kcmaster
[koha.git] / koha-tmpl / opac-tmpl / prog / en / modules / opac-reserve.tt
1 [% INCLUDE 'doc-head-open.inc' %][% LibraryNameTitle or "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 <style type="text/css">td ul { padding : 0; } td li { white-space: nowrap; font-size: 90%; list-style-type:none; padding : .3em 0; }</style>
156 </head>
157
158 <body id="opac-holds">
159   <div id="doc3" class="yui-t7">
160     [% INCLUDE 'masthead.inc' %]
161     <div id="bd">
162           <div id="yui-g">
163         <div id="holds" class="container">
164         [% IF ( message ) %]
165             [% IF ( GNA ) %]
166               <div id="gna" class="dialog alert">
167                 <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>
168               <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>
169               </div>
170             [% END %]
171             [% IF ( lost ) %]
172               <div id="lost" class="dialog alert">
173                 <p><strong>Sorry</strong>, you cannot place holds because your library card has been marked as lost or stolen.</p>
174                 <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>
175               </div>
176             [% END %]
177             [% IF ( debarred ) %]
178               <div id="debarred" class="dialog alert">
179                 <p><strong>Sorry</strong>, you cannot place holds because your account has been frozen.</p>
180                 <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>
181               </div>
182             [% END %]
183             [% IF ( too_much_oweing ) %]
184               <div id="too_much_oweing" class="dialog alert">
185                 Sorry, you cannot place holds because you owe [% too_much_oweing %].
186               </div>
187             [% END %]
188             [% IF ( too_many_reserves ) %]
189               <div id="too_many_reserves" class="dialog alert">Sorry, you cannot place more than [% too_many_reserves %] holds.
190               </div>
191             [% END %]
192             [% IF ( bad_biblionumber ) %]
193               <div id="bad_biblionumber" class="dialog alert">ERROR: No biblio record found for biblionumber [% bad_biblionumber %].</div>
194             [% END %]
195             [% IF ( no_items_selected ) %]
196               <div id="no_items_selected" class="dialog alert">
197                 You must select at least one item.
198               </div>
199             [% END %]
200             [% IF ( no_branch_selected ) %]
201               <div id="no_branch_selected" class="dialog alert">
202                 You must select a library for pickup.
203               </div>
204             [% END %]
205             [% IF ( no_biblionumber ) %]
206               <div id="no_biblionumber" class="dialog alert">ERROR: No biblionumber received.</div>
207             [% END %]
208             [% IF ( bad_data ) %]
209               <div id="bad_data" class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
210             [% END %]
211           [% ELSE %]
212             [% IF ( none_available ) %]
213                 <div id="none_available" class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
214                 </div>
215               [% END %]
216           [% END %]<!-- NAME="message" -->
217
218       [% UNLESS ( message ) %][% UNLESS ( none_available ) %]<h3>Confirm holds for:
219                       [% FOREACH USER_INF IN USER_INFO %]
220                         [% USER_INF.firstname %] [% USER_INF.surname %] ([% USER_INF.cardnumber %])
221                       [% END %]
222                     </h3>[% END %]
223
224             <form action="/cgi-bin/koha/opac-reserve.pl" method="post">
225             <input type="hidden" name="place_reserve" value="1"/>
226
227             <!-- These values are set dynamically by js -->
228             <input type="hidden" name="biblionumbers" id="biblionumbers"/>
229             <input type="hidden" name="selecteditems" id="selections"/>
230             <div id="bigloop">
231               <table id="bibitemloop">
232                 [% UNLESS ( none_available ) %]<tr>
233                   <th>Hold</th>
234                   <th>Title</th>
235                   [% UNLESS ( item_level_itypes ) %]
236                     <th>Item Type</th>
237                   [% END %]
238                   [% IF ( showpriority ) %]
239                   <th>Priority</th>
240                   [% END %]
241                   [% IF ( reserve_in_future ) %]
242                   <th>Hold Starts on Date</th>
243                   [% END %]
244                   <th>Hold Not Needed After</th>
245                   [% IF ( OPACItemHolds ) %]
246                     <th id="place_on_hdr" style="display:none">Place On</th>
247                   [% END %]
248                   [% UNLESS ( singleBranchMode ) %]
249                     [% IF ( choose_branch ) %]
250                         <th>Pickup Location</th>
251                     [% END %]
252                   [% END %]
253                 </tr>[% ELSE %]<tr><th colspan="5">Title</th></tr>[% END %]
254
255                 [% FOREACH bibitemloo IN bibitemloop %]
256                   <tr>
257                       [% IF ( bibitemloo.holdable ) %]
258                                           <td>
259                       <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
260                       <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
261                         <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
262                         <span class="confirm_nonjs">
263                           <input type="radio" class="confirmbox checkitem [% bibitemloo.checkitem_bib %]"
264                                  name="[% bibitemloo.checkitem_bib %]" checked="checked"
265                                  id="[% bibitemloo.checkitem_bib %]"
266                                  value="any" />
267                           <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
268                         </span>
269                                         </td>
270                       [% ELSE %]
271                                           [% UNLESS ( none_available ) %]<td>&nbsp;</td>[% END %]
272                       [% END %]
273                     [% IF ( bibitemloo.holdable ) %]<td>[% ELSE %]<td colspan="5">[% END %]
274                       <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>
275                       [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
276
277                       [% UNLESS ( bibitemloo.holdable ) %]
278
279                         [% IF ( bibitemloo.already_reserved ) %]
280                           <div class="bibmessage">You have already requested this title.</div>
281                         [% ELSE %]
282                           [% UNLESS ( bibitemloo.bib_available ) %]
283                             <div class="bibmessage">No available items.</div>
284                           [% ELSE %]
285                             <div class="bibmessage">This title cannot be requested.</div>
286                           [% END %]
287                         [% END %]
288
289
290                         [% END %]
291
292                     </td>
293                     [% IF ( bibitemloo.holdable ) %][% UNLESS ( item_level_itypes ) %]
294                                           <td>
295                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
296                                 [% bibitemloo.description %]
297                                           </td>
298                                         [% END %][% END %]
299                     [% IF ( bibitemloo.holdable ) %]
300                     [% IF ( showpriority ) %]
301                     <td>
302                     [% bibitemloo.rank %] out of [% bibitemloo.reservecount %]
303                     </td>[% END %][% END %]
304                     [% IF ( reserve_in_future ) %]
305                     [% IF ( bibitemloo.holdable ) %]<td>
306               <input name="reserve_date_[% bibitemloo.biblionumber %]" id="reserve_date_[% bibitemloo.biblionumber %]" size="10">
307               <script language="JavaScript" type="text/javascript">
308               //<![CDATA[
309               $("#reserve_date_[% bibitemloo.biblionumber %]").attr( 'readonly', 'readonly' );
310
311               var cal_img = document.createElement('img');
312               cal_img.src = "[% themelang %]/lib/calendar/cal.gif";
313               cal_img.alt = "Show Calendar";
314               cal_img.border = "0";
315               cal_img.id = "CalendarReserveDate[% bibitemloo.biblionumber %]";
316               cal_img.style.cursor = "pointer";
317               document.getElementById("reserve_date_[% bibitemloo.biblionumber %]").parentNode.appendChild( cal_img );
318
319               function validate[% bibitemloo.biblionumber %](date) {
320                   var today = new Date();
321                         if ( (date > today) ||
322                                 ( date.getDate() == today.getDate() &&
323                                   date.getMonth() == today.getMonth() &&
324                                   date.getFullYear() == today.getFullYear() ) ) {
325                             return false;
326                         } else {
327                             return true;
328                         }
329               };
330               Calendar.setup(
331               {
332                 inputField : "reserve_date_[% bibitemloo.biblionumber %]",
333                 ifFormat : "[% DHTMLcalendar_dateformat %]",
334                 button : "CalendarReserveDate[% bibitemloo.biblionumber %]",
335                 disableFunc : validate[% bibitemloo.biblionumber %],
336                 dateStatusFunc : validate[% bibitemloo.biblionumber %]
337               }
338               );
339               //]]>
340               </script>
341       <p style="margin:.3em 2em;">
342       <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('reserve_date_[% bibitemloo.biblionumber %]').value='';return false;">Clear Date</a></p>
343                 </td>[% END %]
344
345                     [% END %]
346         [% IF ( bibitemloo.holdable ) %]<td>
347         <input name="expiration_date_[% bibitemloo.biblionumber %]" id="expiration_date_[% bibitemloo.biblionumber %]" size="10" readonly="readonly" />
348         <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="CalendarExpirationDate_[% bibitemloo.biblionumber %]" style="cursor: pointer;" />
349         <script language="JavaScript" type="text/javascript">
350       //<![CDATA[
351       function validate1(date) {
352         var today = new Date();
353         if ( (date > today) ||
354                       ( date.getDate() == today.getDate() &&
355                         date.getMonth() == today.getMonth() &&
356                         date.getFullYear() == today.getFullYear() ) ) {
357           return false;
358         } else {
359           return true;
360         }
361       };
362       Calendar.setup(
363         {
364           inputField : "expiration_date_[% bibitemloo.biblionumber %]",
365           ifFormat : "[% DHTMLcalendar_dateformat %]",
366           button : "CalendarExpirationDate_[% bibitemloo.biblionumber %]",
367           disableFunc : validate1,
368           dateStatusFunc : validate1
369         }
370       );
371       //]]>
372         </script>
373       <p style="margin:.3em 2em;">
374       <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('expiration_date_[% bibitemloo.biblionumber %]').value='';return false;">Clear Date</a></p>
375     </td>[% END %]
376
377                     [% IF ( bibitemloo.holdable ) %]
378                     <!-- HOLD ABLE -->
379                     [% IF ( OPACItemHolds ) %]
380                     <!-- ITEM HOLDS -->
381                                           <td class="place_on_type" style="display:none">
382                                             <ul>
383                                                 <li>
384                                                   [% UNLESS ( bibitemloo.holdable ) %]
385                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
386                                                            id="reqany_[% bibitemloo.biblionumber %]"
387                                                            class="selectany"
388                                                            value="Any"
389                                                            disabled="disabled"
390                                                     />
391                                                   [% ELSE %]
392                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
393                                                            id="reqany_[% bibitemloo.biblionumber %]"
394                                                            class="selectany"
395                                                            value="Any"
396                                                            checked="checked"
397                                                     />
398                                                   [% END %]
399                                                   <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
400                                                 </li>
401                                                 <li>
402                                                   [% UNLESS ( bibitemloo.holdable ) %]
403                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
404                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
405                                                            class="selectspecific"
406                                                            disabled="disabled"
407                                                            value="Specific"
408                                                     />
409                                                   [% ELSE %]
410                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
411                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
412                                                            class="selectspecific"
413                                                            value="Specific"
414                                                     />
415                                                   [% END %]
416                                                   <label for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
417                                                 </li>
418                                             </ul>
419                                           </td>
420                                         [% END %][% END %]
421
422                     [% UNLESS ( singleBranchMode ) %]
423                         [% IF ( bibitemloo.holdable ) %]
424                             [% IF ( choose_branch ) %]
425                                            <td>
426                                               <select name="branch" id="branch_[% bibitemloo.biblionumber %]"
427                                                 [% UNLESS ( bibitemloo.holdable ) %]disabled="disabled"[% END %] >
428                                                 [% FOREACH branchChoicesLoo IN bibitemloo.branchChoicesLoop %]
429                                                   [% IF ( branchChoicesLoo.selected ) %]
430                                                     <option value="[% branchChoicesLoo.value %]" selected="selected">[% branchChoicesLoo.branchname %]</option>
431                                                   [% ELSE %]
432                                                     <option value="[% branchChoicesLoo.value %]">[% branchChoicesLoo.branchname %]</option>
433                                                   [% END %]
434                                                 [% END %]
435                                               </select>
436                                            </td>
437                             [% END %]
438                         [% END %]
439                     [% END %]
440                   </tr>
441
442                   [% IF ( OPACItemHolds ) %]
443                   [% IF ( bibitemloo.holdable ) %]
444                     <tr class="copiesrow" id="copiesrow_[% bibitemloo.biblionumber %]">
445                       <td>&nbsp;</td>
446                       <td colspan="[% itemtable_colspan %]">
447                         <table>
448                           <caption>Select a specific copy:</caption>
449                           <tr>
450                             <th>Copy</th>
451                             [% IF ( item_level_itypes ) %]
452                               <th>Item Type</th>
453                             [% END %]
454                             <th>Barcode</th>
455                             [% UNLESS ( singleBranchMode ) %]
456                               <th>Home Library</th>
457                               <th>Last Location</th>
458                             [% END %]
459                             <th>Call Number</th>
460                             [% IF ( bibitemloo.itemdata_enumchron ) %]
461                               <th>Vol Info</th>
462                             [% END %]
463                             <th>Information</th>
464                           </tr>
465
466                           [% FOREACH itemLoo IN bibitemloo.itemLoop %]
467                             <tr class="[% itemLoo.backgroundcolor %]">
468                               <td>
469                                 [% IF ( itemLoo.available ) %]
470                                   <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]"
471                                          value="[% itemLoo.itemnumber %]" />
472                                 [% ELSE %]
473                                   <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]" />
474                                   <img src="/opac-tmpl/[% theme %]/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
475                                 [% END %] [% IF ( itemLoo.copynumber ) %][% itemLoo.copynumber %][% END %]
476                               </td>
477                               [% IF ( item_level_itypes ) %]
478                                 <td>
479                                   [% UNLESS ( noItemTypeImages ) %]
480                                   [% IF ( itemLoo.imageurl ) %]<img src="[% itemLoo.imageurl %]" alt="" />[% END %]
481                                   [% END %]
482                                                                 [% itemLoo.description %]
483                                 </td>
484                               [% END %]
485                               <td>[% itemLoo.barcode %]</td>
486                               [% UNLESS ( singleBranchMode ) %]
487                                 <td>[% itemLoo.homeBranchName %]</td>
488                                 <td>[% itemLoo.holdingBranchName %]</td>
489                               [% END %]
490                               <td>[% itemLoo.callNumber %]</td>
491                               [% IF ( itemLoo.itemdata_enumchron ) %]<!-- test -->
492                                 <td>[% itemLoo.enumchron %]</td>
493                               [% END %]
494                               <td>
495                                 [% IF ( itemLoo.date_due ) %]
496                                   <span class="checkedout">Due [% itemLoo.date_due %]</span>
497                                 [% ELSIF ( itemLoo.transfertwhen ) %]
498                                   <span class="intransit">In transit from [% itemLoo.transfertfrom %],
499                                     to [% itemLoo.transfertto %], since [% itemLoo.transfertwhen %]</span>
500                                 [% END %]
501                                 [% IF ( itemLoo.message ) %]
502                                   <span class="lost">Unavailable (lost or missing)</span>
503                                 [% END %]
504                                 [% IF ( itemLoo.notforloan ) %]
505                                   <span class="notforloan">Not for loan ([% itemLoo.notforloanvalue %])</span>
506                                 [% END %]
507                                 [% IF ( itemLoo.reservedate ) %]
508                                   <span class="waiting">[% IF ( itemLoo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %] for patron
509                                     [% IF ( itemLoo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemLoo.ExpectedAtLibrary %]
510                                     since
511                                     [% IF ( itemLoo.waitingdate ) %][% itemLoo.waitingdate %][% ELSE %][% IF ( itemLoo.reservedate ) %][% itemLoo.reservedate %][% END %][% END %].
512                                   </span>
513                                 [% ELSE %]
514                                   <span class="notonhold">Not on hold</span>
515                                 [% END %]&nbsp;
516                               </td>
517                             </tr>
518                           [% END %]
519                         </table>
520                       </td>
521                     </tr>
522                   [% END %]<!-- bib_available -->
523                   [% END %]<!-- OPACItemHolds -->
524                 [% END %]
525               </table><!-- bibitemloop -->
526               [% END %] <!-- if message -->
527             </div><!-- bigloop -->
528
529             [% UNLESS ( message ) %]
530             [% UNLESS ( none_available ) %]
531             <input type="submit" value="Place Hold" class="placehold" />
532             [% END %]
533             [% END %]
534
535             </form>
536
537         </div><!-- holds -->
538       </div><!-- yui-g -->
539     </div><!-- bd    -->
540   </div><!-- doc3  -->
541
542 <div><!-- The following include seems to have an extra "/div" in it... -->
543 [% INCLUDE 'opac-bottom.inc' %]