Bug 6857: display a charge warning alert for reserves
[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               [% IF (RESERVE_CHARGE) %]
224               <div class="dialog alert">
225                 There is a charge of [% RESERVE_CHARGE %] for placing this reserve
226               </div>
227               [% END %]
228
229             <form action="/cgi-bin/koha/opac-reserve.pl" method="post">
230             <input type="hidden" name="place_reserve" value="1"/>
231
232             <!-- These values are set dynamically by js -->
233             <input type="hidden" name="biblionumbers" id="biblionumbers"/>
234             <input type="hidden" name="selecteditems" id="selections"/>
235             <div id="bigloop">
236               <table id="bibitemloop">
237                 [% UNLESS ( none_available ) %]<tr>
238                   <th>Hold</th>
239                   <th>Title</th>
240                   [% UNLESS ( item_level_itypes ) %]
241                     <th>Item Type</th>
242                   [% END %]
243                   [% IF ( showpriority ) %]
244                   <th>Priority</th>
245                   [% END %]
246                   [% IF ( reserve_in_future ) %]
247                   <th>Hold Starts on Date</th>
248                   [% END %]
249                   <th>Hold Not Needed After</th>
250                   [% IF ( OPACItemHolds ) %]
251                     <th id="place_on_hdr" style="display:none">Place On</th>
252                   [% END %]
253                   [% UNLESS ( singleBranchMode ) %]
254                     [% IF ( choose_branch ) %]
255                         <th>Pickup Location</th>
256                     [% END %]
257                   [% END %]
258                 </tr>[% ELSE %]<tr><th colspan="5">Title</th></tr>[% END %]
259
260                 [% FOREACH bibitemloo IN bibitemloop %]
261                   <tr>
262                       [% IF ( bibitemloo.holdable ) %]
263                                           <td>
264                       <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
265                       <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
266                         <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
267                         <span class="confirm_nonjs">
268                           <input type="radio" class="confirmbox checkitem [% bibitemloo.checkitem_bib %]"
269                                  name="[% bibitemloo.checkitem_bib %]" checked="checked"
270                                  id="[% bibitemloo.checkitem_bib %]"
271                                  value="any" />
272                           <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
273                         </span>
274                                         </td>
275                       [% ELSE %]
276                                           [% UNLESS ( none_available ) %]<td>&nbsp;</td>[% END %]
277                       [% END %]
278                     [% IF ( bibitemloo.holdable ) %]<td>[% ELSE %]<td colspan="5">[% END %]
279                       <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>
280                       [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
281
282                       [% UNLESS ( bibitemloo.holdable ) %]
283
284                         [% IF ( bibitemloo.already_reserved ) %]
285                           <div class="bibmessage">You have already requested this title.</div>
286                         [% ELSE %]
287                           [% UNLESS ( bibitemloo.bib_available ) %]
288                             <div class="bibmessage">No available items.</div>
289                           [% ELSE %]
290                             <div class="bibmessage">This title cannot be requested.</div>
291                           [% END %]
292                         [% END %]
293
294
295                         [% END %]
296
297                     </td>
298                     [% IF ( bibitemloo.holdable ) %][% UNLESS ( item_level_itypes ) %]
299                                           <td>
300                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
301                                 [% bibitemloo.description %]
302                                           </td>
303                                         [% END %][% END %]
304                     [% IF ( bibitemloo.holdable ) %]
305                     [% IF ( showpriority ) %]
306                     <td>
307                     [% bibitemloo.rank %] out of [% bibitemloo.reservecount %]
308                     </td>[% END %][% END %]
309                     [% IF ( reserve_in_future ) %]
310                     [% IF ( bibitemloo.holdable ) %]<td>
311               <input name="reserve_date_[% bibitemloo.biblionumber %]" id="reserve_date_[% bibitemloo.biblionumber %]" size="10">
312               <script language="JavaScript" type="text/javascript">
313               //<![CDATA[
314               $("#reserve_date_[% bibitemloo.biblionumber %]").attr( 'readonly', 'readonly' );
315
316               var cal_img = document.createElement('img');
317               cal_img.src = "[% themelang %]/lib/calendar/cal.gif";
318               cal_img.alt = "Show Calendar";
319               cal_img.border = "0";
320               cal_img.id = "CalendarReserveDate[% bibitemloo.biblionumber %]";
321               cal_img.style.cursor = "pointer";
322               document.getElementById("reserve_date_[% bibitemloo.biblionumber %]").parentNode.appendChild( cal_img );
323
324               function validate[% bibitemloo.biblionumber %](date) {
325                   var today = new Date();
326                         if ( (date > today) ||
327                                 ( date.getDate() == today.getDate() &&
328                                   date.getMonth() == today.getMonth() &&
329                                   date.getFullYear() == today.getFullYear() ) ) {
330                             return false;
331                         } else {
332                             return true;
333                         }
334               };
335               Calendar.setup(
336               {
337                 inputField : "reserve_date_[% bibitemloo.biblionumber %]",
338                 ifFormat : "[% DHTMLcalendar_dateformat %]",
339                 button : "CalendarReserveDate[% bibitemloo.biblionumber %]",
340                 disableFunc : validate[% bibitemloo.biblionumber %],
341                 dateStatusFunc : validate[% bibitemloo.biblionumber %]
342               }
343               );
344               //]]>
345               </script>
346       <p style="margin:.3em 2em;">
347       <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('reserve_date_[% bibitemloo.biblionumber %]').value='';return false;">Clear Date</a></p>
348                 </td>[% END %]
349
350                     [% END %]
351         [% IF ( bibitemloo.holdable ) %]<td>
352         <input name="expiration_date_[% bibitemloo.biblionumber %]" id="expiration_date_[% bibitemloo.biblionumber %]" size="10" readonly="readonly" />
353         <img src="[% themelang %]/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="CalendarExpirationDate_[% bibitemloo.biblionumber %]" style="cursor: pointer;" />
354         <script language="JavaScript" type="text/javascript">
355       //<![CDATA[
356       function validate1(date) {
357         var today = new Date();
358         if ( (date > today) ||
359                       ( date.getDate() == today.getDate() &&
360                         date.getMonth() == today.getMonth() &&
361                         date.getFullYear() == today.getFullYear() ) ) {
362           return false;
363         } else {
364           return true;
365         }
366       };
367       Calendar.setup(
368         {
369           inputField : "expiration_date_[% bibitemloo.biblionumber %]",
370           ifFormat : "[% DHTMLcalendar_dateformat %]",
371           button : "CalendarExpirationDate_[% bibitemloo.biblionumber %]",
372           disableFunc : validate1,
373           dateStatusFunc : validate1
374         }
375       );
376       //]]>
377         </script>
378       <p style="margin:.3em 2em;">
379       <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('expiration_date_[% bibitemloo.biblionumber %]').value='';return false;">Clear Date</a></p>
380     </td>[% END %]
381
382                     [% IF ( bibitemloo.holdable ) %]
383                     <!-- HOLD ABLE -->
384                     [% IF ( OPACItemHolds ) %]
385                     <!-- ITEM HOLDS -->
386                                           <td class="place_on_type" style="display:none">
387                                             <ul>
388                                                 <li>
389                                                   [% UNLESS ( bibitemloo.holdable ) %]
390                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
391                                                            id="reqany_[% bibitemloo.biblionumber %]"
392                                                            class="selectany"
393                                                            value="Any"
394                                                            disabled="disabled"
395                                                     />
396                                                   [% ELSE %]
397                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
398                                                            id="reqany_[% bibitemloo.biblionumber %]"
399                                                            class="selectany"
400                                                            value="Any"
401                                                            checked="checked"
402                                                     />
403                                                   [% END %]
404                                                   <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
405                                                 </li>
406                                                 <li>
407                                                   [% UNLESS ( bibitemloo.holdable ) %]
408                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
409                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
410                                                            class="selectspecific"
411                                                            disabled="disabled"
412                                                            value="Specific"
413                                                     />
414                                                   [% ELSE %]
415                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
416                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
417                                                            class="selectspecific"
418                                                            value="Specific"
419                                                     />
420                                                   [% END %]
421                                                   <label for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
422                                                 </li>
423                                             </ul>
424                                           </td>
425                                         [% END %][% END %]
426
427                     [% UNLESS ( singleBranchMode ) %]
428                         [% IF ( bibitemloo.holdable ) %]
429                             [% IF ( choose_branch ) %]
430                                            <td>
431                                               <select name="branch" id="branch_[% bibitemloo.biblionumber %]"
432                                                 [% UNLESS ( bibitemloo.holdable ) %]disabled="disabled"[% END %] >
433                                                 [% FOREACH branchChoicesLoo IN bibitemloo.branchChoicesLoop %]
434                                                   [% IF ( branchChoicesLoo.selected ) %]
435                                                     <option value="[% branchChoicesLoo.value %]" selected="selected">[% branchChoicesLoo.branchname %]</option>
436                                                   [% ELSE %]
437                                                     <option value="[% branchChoicesLoo.value %]">[% branchChoicesLoo.branchname %]</option>
438                                                   [% END %]
439                                                 [% END %]
440                                               </select>
441                                            </td>
442                             [% END %]
443                         [% END %]
444                     [% END %]
445                   </tr>
446
447                   [% IF ( OPACItemHolds ) %]
448                   [% IF ( bibitemloo.holdable ) %]
449                     <tr class="copiesrow" id="copiesrow_[% bibitemloo.biblionumber %]">
450                       <td>&nbsp;</td>
451                       <td colspan="[% itemtable_colspan %]">
452                         <table>
453                           <caption>Select a specific copy:</caption>
454                           <tr>
455                             <th>Copy</th>
456                             [% IF ( item_level_itypes ) %]
457                               <th>Item Type</th>
458                             [% END %]
459                             <th>Barcode</th>
460                             [% UNLESS ( singleBranchMode ) %]
461                               <th>Home Library</th>
462                               <th>Last Location</th>
463                             [% END %]
464                             <th>Call Number</th>
465                             [% IF ( bibitemloo.itemdata_enumchron ) %]
466                               <th>Vol Info</th>
467                             [% END %]
468                             <th>Information</th>
469                           </tr>
470
471                           [% FOREACH itemLoo IN bibitemloo.itemLoop %]
472                             <tr class="[% itemLoo.backgroundcolor %]">
473                               <td>
474                                 [% IF ( itemLoo.available ) %]
475                                   <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]"
476                                          value="[% itemLoo.itemnumber %]" />
477                                 [% ELSE %]
478                                   <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]" />
479                                   <img src="/opac-tmpl/[% theme %]/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
480                                 [% END %] [% IF ( itemLoo.copynumber ) %][% itemLoo.copynumber %][% END %]
481                               </td>
482                               [% IF ( item_level_itypes ) %]
483                                 <td>
484                                   [% UNLESS ( noItemTypeImages ) %]
485                                   [% IF ( itemLoo.imageurl ) %]<img src="[% itemLoo.imageurl %]" alt="" />[% END %]
486                                   [% END %]
487                                                                 [% itemLoo.description %]
488                                 </td>
489                               [% END %]
490                               <td>[% itemLoo.barcode %]</td>
491                               [% UNLESS ( singleBranchMode ) %]
492                                 <td>[% itemLoo.homeBranchName %]</td>
493                                 <td>[% itemLoo.holdingBranchName %]</td>
494                               [% END %]
495                               <td>[% itemLoo.callNumber %]</td>
496                               [% IF ( itemLoo.itemdata_enumchron ) %]<!-- test -->
497                                 <td>[% itemLoo.enumchron %]</td>
498                               [% END %]
499                               <td>
500                                 [% IF ( itemLoo.date_due ) %]
501                                   <span class="checkedout">Due [% itemLoo.date_due %]</span>
502                                 [% ELSIF ( itemLoo.transfertwhen ) %]
503                                   <span class="intransit">In transit from [% itemLoo.transfertfrom %],
504                                     to [% itemLoo.transfertto %], since [% itemLoo.transfertwhen %]</span>
505                                 [% END %]
506                                 [% IF ( itemLoo.message ) %]
507                                   <span class="lost">Unavailable (lost or missing)</span>
508                                 [% END %]
509                                 [% IF ( itemLoo.notforloan ) %]
510                                   <span class="notforloan">Not for loan ([% itemLoo.notforloanvalue %])</span>
511                                 [% END %]
512                                 [% IF ( itemLoo.reservedate ) %]
513                                   <span class="waiting">[% IF ( itemLoo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %] for patron
514                                     [% IF ( itemLoo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemLoo.ExpectedAtLibrary %]
515                                     since
516                                     [% IF ( itemLoo.waitingdate ) %][% itemLoo.waitingdate %][% ELSE %][% IF ( itemLoo.reservedate ) %][% itemLoo.reservedate %][% END %][% END %].
517                                   </span>
518                                 [% ELSE %]
519                                   <span class="notonhold">Not on hold</span>
520                                 [% END %]&nbsp;
521                               </td>
522                             </tr>
523                           [% END %]
524                         </table>
525                       </td>
526                     </tr>
527                   [% END %]<!-- bib_available -->
528                   [% END %]<!-- OPACItemHolds -->
529                 [% END %]
530               </table><!-- bibitemloop -->
531               [% END %] <!-- if message -->
532             </div><!-- bigloop -->
533
534             [% UNLESS ( message ) %]
535             [% UNLESS ( none_available ) %]
536             <input type="submit" value="Place Hold" class="placehold" />
537             [% END %]
538             [% END %]
539
540             </form>
541
542         </div><!-- holds -->
543       </div><!-- yui-g -->
544     </div><!-- bd    -->
545   </div><!-- doc3  -->
546
547 <div><!-- The following include seems to have an extra "/div" in it... -->
548 [% INCLUDE 'opac-bottom.inc' %]