Bug 28273: Add form validation for pickup locations
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% USE JSON.Escape %]
5 [% USE Koha %]
6 [% USE KohaDates %]
7 [% USE Branches %]
8 [% USE Categories %]
9 [% USE ItemTypes %]
10 [% USE AuthorisedValues %]
11 [% USE Price %]
12 [% USE TablesSettings %]
13 [% SET footerjs = 1 %]
14 [% INCLUDE 'doc-head-open.inc' %]
15 [% UNLESS ( multi_hold ) %]
16     <title>Place a hold on [% INCLUDE 'biblio-title-head.inc' %] &rsaquo; Holds &rsaquo; Circulation &rsaquo; Koha</title>
17 [% ELSE %]
18     <title>Confirm holds &rsaquo; Holds &rsaquo; Circulation &rsaquo; Koha</title>
19 [% END %]
20 [% INCLUDE 'doc-head-close.inc' %]
21 </head>
22
23 <body id="circ_request" class="catalog">
24
25 [% INCLUDE 'header.inc' %]
26 [% INCLUDE 'circ-search.inc' %]
27
28 [% UNLESS ( multi_hold ) %]
29     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
30         <ol>
31             <li>
32                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
33             </li>
34             <li>
35                 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
36             </li>
37             <li>
38                 [% INCLUDE 'biblio-title.inc' link =1 %]
39             </li>
40             <li>
41                 <a href="#" aria-current="page">
42                     Place a hold
43                 </a>
44             </li>
45         </ol>
46     </nav>
47 [% ELSE %]
48     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
49         <ol>
50             <li>
51                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
52             </li>
53             <li>
54                 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
55             </li>
56             <li>
57                 <a href="#" aria-current="page">
58                     Confirm holds
59                 </a>
60             </li>
61         </ol>
62     </nav>
63 [% END # UNLESS multi_hold %]
64
65 <div class="main container-fluid">
66     <div class="row">
67         [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
68             <div class="col-md-10 col-md-offset-1">
69         [% ELSE %]
70             <div class="col-sm-10 col-sm-push-2">
71         [% END %]
72
73         <main>
74
75             [% IF ( noitems ) %]
76                 <div class="dialog alert">
77                 [%IF (multi_hold) %]
78                     <strong>Cannot place hold:</strong> one or more records without items attached.
79                 [% ELSE %]
80                     <strong>Cannot place hold:</strong> this record has no items attached.
81                 [% END %]
82                 </div>
83             [% END %]
84
85             [% IF ( messagetransfert ) %]
86                 <div class="dialog message">
87                     <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
88                     <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
89                     </p>
90                     <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
91                         <input type="submit" class="button" />
92                     </form>
93                 </div>
94             [% END %]
95
96             [% UNLESS ( multi_hold ) %]
97                 <h1>Place a hold on [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
98             [% ELSE %]
99                 <h1>Confirm holds</h1>
100             [% END %]
101
102             [% UNLESS club OR patron OR patron.borrowernumber OR noitems %]
103                 [% IF ( messageborrower ) %]
104                     <div class="dialog alert">
105                         <h3>Patron not found</h3>
106                         <p>No patron with this name, please, try another</p>
107                     </div>
108                 [% END %]
109
110                 [% IF ( messageclub ) %]
111                     <div class="dialog alert">
112                         <h3>Club not found</h3>
113                         <p>No club with this name, please, try another</p>
114                     </div>
115                 [% END %]
116                 <fieldset class="brief">
117                     [% IF clubcount %]
118                         <label>Search patrons or clubs</label>
119                     [% ELSE %]
120                         <label>Search patrons</label>
121                     [% END %]
122                     <div id="circ_holds_select" class="toptabs">
123                         <ul>
124                             <li><a href="#holds_patronsearch_pane">Patrons</a></li>
125                             [% IF clubcount %]
126                                 <li><a href="#holds_clubsearch_pane">Clubs</a></li>
127                             [% END %]
128                         </ul>
129                         <div id="holds_patronsearch_pane">
130                             <form id="holds_patronsearch" action="request.pl?biblionumbers=[% biblionumbers | html %]" method="post">
131                                 <div class="hint">Enter patron card number or partial name:</div>
132                                 <input type="text" size="40" id="patron" class="focus" name="findborrower" autocomplete="off" />
133                                 <input type="submit" value="Search" />
134                                 [% IF multi_hold %]
135                                     <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
136                                 [% ELSE %]
137                                     <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
138                                 [% END %]
139
140                             </form> <!-- /#holds_patronsearch -->
141                             [% IF borrowers %]
142                                 [% INCLUDE 'circ-patron-search-results.inc' destination = "holds" %]
143                             [% END %]
144                         </div>
145                         [% IF clubcount %]
146                             <div id="holds_clubsearch_pane">
147                                 <form id="holds_clubsearch" action="request.pl?biblionumber=[% biblionumber | html %]" method="post">
148                                     <div class="hint">Enter club ID or partial name:</div>
149                                     <input type="text" size="40" id="club" class="focus" name="findclub" autocomplete="off" />
150                                     <input type="submit" value="Search" />
151                                     [% IF multi_hold %]
152                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
153                                     [% ELSE %]
154                                         <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
155                                     [% END %]
156
157                                 </form> <!-- /#holds_patronsearch -->
158                                 [% IF clubs %]
159                                     [% INCLUDE 'clubs-table.inc' destination = "holds" %]
160                                 [% END %]
161                             </div>
162                         [% END %]
163                     </div>
164                 </fieldset>
165             [% ELSIF club %]
166                 <div class="dialog alert hide clubalert">
167                 </div>
168                 <fieldset class="rows">
169                     <legend>Hold details</legend>
170                     <form action="/api/v1/clubs/[% club.id | html %]/holds" method="post" name="form" id="club-request-form">
171
172                         [% IF ( multi_hold ) %]
173                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
174                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
175                             <input type="hidden" name="request" value="any"/>
176                             [% FOREACH biblioloo IN biblioloop %]
177                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
178                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
179                             [% END %]
180                         [% ELSE %]
181                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
182                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
183                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
184                         [% END # /IF multi_hold %]
185                         <ol>
186                             <li>
187                                 <span class="label">Club: </span> [% club.name | html %]
188                             </li>
189                             <li>
190                                 <span class="label">Description: </span> [% club.description | html %]
191                             </li>
192                             <li>
193                                 <label for="pickup">Pickup at:</label>
194                                 <select name="pickup" id="pickup">
195                                     [% PROCESS options_for_libraries libraries => Branches.all({ selected => club.branchcode, search_params => { pickup_location => 1 } }) %]
196                                 </select>
197                             </li>
198                             <li>
199                                 <label for="default_patron_home">Pickup at patron's home library when possible:</label>
200                                 <input type="checkbox" id="default_patron_home" name="default_patron_home"/>
201                             </li>
202                         </ol>
203                         <h2 style="padding: 0 1em;">Members</h2>
204                         <ol>
205                             [% FOREACH member IN members %]
206                                 [% SET patron = member.patron %]
207                                 <li style="padding: 0.5em 1em;">
208                                     <div><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a></div>
209                                     [% IF member.exceeded_maxreserves %]
210                                         <div>
211                                             <i class="fa fa-error"></i>
212                                             <strong>Too many holds: </strong> Patron can only place a maximum of [% maxreserves | html %] total holds.
213                                         </div>
214                                     [% END %]
215                                     [% IF ( member.expiry ) %]
216                                         <div>
217                                             <i class="fa fa-warning"></i>
218                                             <strong>Account has expired</strong>
219                                         </div>
220                                     [% END %]
221                                     [% IF patron.is_debarred %]
222                                         <div>
223                                             <i class="fa fa-warning"></i>
224                                             <strong>Patron has restrictions</strong>
225                                         </div>
226                                     [% END %]
227                                     [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
228                                         <div>
229                                             <i class="fa fa-warning"></i>
230                                             <strong>Patron has outstanding fines: [% member.amount_outstanding | $Price %]</strong>
231                                         </div>
232                                     [% END %]
233
234                                     [% IF ( member.diffbranch ) %]
235                                         <div>
236                                             <i class="fa fa-warning"></i>
237                                             <strong>Pickup library is different.</strong> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )
238                                         </div>
239                                     [% END %]
240                                 </li>
241                             [% END %]
242                         </ol>
243                         [% UNLESS ( multi_hold ) %]
244                             <fieldset class="action">
245                                 <input type="submit" value="Place hold" />
246                             </fieldset>
247                         [% ELSE %]
248                             <table id="requesttitles">
249                                 <tr>
250                                     <th>&nbsp;</th>
251                                     <th>Title</th>
252                                     [% UNLESS ( item_level_itypes ) %]
253                                         <th>Item type</th>
254                                     [% END %]
255                                     <th>Priority</th>
256                                     <th>Information</th>
257                                 </tr>
258                                 [% FOREACH biblioloo IN biblioloop %]
259                                     [% IF ( biblioloo.warn ) %]
260                                         <tr class="onissue">
261                                     [% ELSE %]
262                                         <tr>
263                                     [% END %]
264                                         <td>
265                                             [% UNLESS ( biblioloo.warn ) %]
266                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
267                                                 </td>
268                                             [% END %]
269                                         <td>
270                                             <ul>
271                                                 <li>
272                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
273                                                 </li>
274                                                 [% IF ( biblioloo.publicationyear ) %]
275                                                     <li>
276                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
277                                                     </li>
278                                                 [% END %]
279                                             </ul>
280                                             [% IF ( biblioloo.warn ) %]
281                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
282                                             [% END %]
283                                         </td>
284                                         [% UNLESS ( item_level_itypes ) %]
285                                             <td>
286                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
287                                             </td>
288                                         [% END %]
289                                         <td>[% biblioloo.rank | html %]</td>
290                                         <td>
291                                             [% IF ( biblioloo.checked_previously ) %]
292                                                 <span>Patron has previously checked out this title</span><br/>
293                                             [% END %]
294                                             [% IF ( biblioloo.alreadyres ) %]
295                                                 <ul>
296                                             [% ELSE %]
297                                                 [% IF ( biblioloo.none_avail ) %]
298                                                     <ul>
299                                                 [% END %]
300                                             [% END %]
301
302                                             [% IF ( biblioloo.alreadyres ) %]
303                                                 <li>
304                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
305                                                     <strong>already has a hold</strong> on this item
306                                                 </li>
307                                             [% END %]
308                                             [% IF ( biblioloo.none_avail ) %]
309                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
310                                             [% END %]
311
312                                             [% IF ( biblioloo.alreadyres ) %]
313                                                 </ul>
314                                             [% ELSE %]
315                                                 [% IF ( biblioloo.none_avail ) %]
316                                                     </ul>
317                                                 [% END %]
318                                             [% END %]
319                                         </td>
320                                     </tr>
321                                 [% END # /FOREACH biblioloo %]
322                             </table> <!-- /#requesttitles -->
323                         [% END %]
324                     </form>
325                 </fieldset>
326             [% ELSIF NOT noitems # /UNLESS patron %]
327
328                 [% IF ( checked_previously && !multi_hold ) %]
329                     <div class="dialog alert">
330                         <ul>
331                             <li>Patron has previously checked out this title</li>
332                         </ul>
333                     </div>
334                 [% END %]
335
336                 [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
337                     <div class="dialog alert">
338
339                         [% UNLESS ( multi_hold ) %]
340                             <h3>Cannot place hold</h3>
341                             <ul>
342                                 [% IF ( no_reserves_allowed ) %]
343                                     <li><strong>No holds allowed: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> cannot place a hold on any of these items.</li>
344                                 [% ELSIF ( exceeded_maxreserves ) %]
345                                     <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% maxreserves | html %] total holds.</li>
346                                 [% ELSIF ( exceeded_holds_per_record ) %]
347                                     <li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
348                                 [% ELSIF ( alreadypossession ) %]
349                                     <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>is already in possession</strong> of one item.</li>
350                                 [% ELSIF ( alreadyreserved ) %]
351                                     <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>already has a hold</strong> on this item.</li>
352                                 [% ELSIF ( ageRestricted ) %]
353                                     <li><strong>Age restricted</strong></li>
354                                 [% ELSIF ( none_available ) %]
355                                     <li> <strong>No items are available</strong> to be placed on hold.</li>
356                                 [% ELSIF ( maxreserves ) %]
357                                     <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> has too many holds.</li>
358                                 [% END # /IF exceeded_maxreserves %]
359                             </ul>
360                         [% ELSE # UNLESS multi_hold %]
361                             <h3>Cannot place hold on some items</h3>
362                             [% IF (no_reserves_allowed ) %]
363                                 <li><strong>No holds allowed: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> cannot place holds on some of these title's items.</li>
364                             [% ELSIF ( exceeded_maxreserves ) %]
365                                 <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can place [% new_reserves_allowed | html %] of the requested [% new_reserves_count | html %] holds for a maximum of [% maxreserves | html %] total holds.</li>
366                             [% ELSIF ( exceeded_holds_per_record ) %]
367                                 [% FOREACH biblioloo IN biblioloop %]
368                                     [% IF (biblioloo.tooManyHoldsForThisRecord) %]
369                                         <li><strong>Too many holds for <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]"> [% biblioloo.title | html %]</a>: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
370                                     [% END %]
371                                 [% END %]
372                             [% END # /IF exceeded_maxreserves %]
373                         [% END # /UNLESS multi_hold %]
374                     </div>
375                 [% END # /IF ( exceeded_maxreserves || ... %]
376
377                 [% IF ( expiry || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
378                     <div class="dialog message">
379                         <ul>
380                             [% IF ( expiry ) %]
381                                 <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Account has expired</strong></li>
382                             [% END %]
383
384                             [% IF patron.is_debarred %]
385                                 <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]#reldebarments">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has restrictions</strong></li>
386                             [% END %]
387
388                             [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
389                                 <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has outstanding fines: [% amount_outstanding | $Price %]</strong></li>
390                             [% END %]
391
392                             [% IF ( diffbranch ) %]
393                                 <li> <strong>Pickup library is different. </strong>Patron: <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )</li>
394                             [% END %]
395                         </ul> <!-- /.dialog.message -->
396                     </div>
397                 [% END # /IF expiry || diffbranch ... %]
398
399                 [% IF ( messageborrower ) %]
400                     <div class="dialog alert">
401                         <h3>Patron not found:</h3>
402                         <p>Name or barcode not found. Please try an other </p>
403                     </div>
404                 [% END %]
405
406                 <div class="dialog alert hide holdalert">
407                 </div>
408
409                 <fieldset class="rows">
410                     <legend>Hold details</legend>
411                     <form action="placerequest.pl" method="post" name="form" id="hold-request-form">
412
413                         <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
414                         <input type="hidden" name="type" value="str8" />
415
416                         [% IF ( multi_hold ) %]
417                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
418                             <input type="hidden" name="multi_holds" id="multi_holds" value="1" />
419                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
420                             <input type="hidden" name="request" value="any"/>
421                             [% FOREACH biblioloo IN biblioloop %]
422                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
423                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
424                             [% END %]
425                         [% ELSE %]
426                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
427                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
428                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
429                         [% END # /IF multi_hold %]
430
431                         <ol>
432                             <li>
433                                 <span class="label">Patron:</span>
434                                 [% IF ( patron.borrowernumber ) %]
435                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a>
436                                 [% ELSE %]
437                                     Not defined yet
438                                 [% END %]
439                             </li>
440
441                             [% UNLESS ( multi_hold ) %]
442                                 <li>
443                                     <span class="label">Estimated priority:</span>
444                                     <strong>[% fixedRank | html %]</strong>
445                                 </li>
446                             [% END %]
447
448                             <li>
449                                 <label for="holdnotes">Notes:</label>
450                                 <textarea id="holdnotes" name="notes" cols="30" rows="1"></textarea>
451                             </li>
452                             <li>
453                                 <label for="pickup">Pickup at:</label>
454                             [% UNLESS ( multi_hold ) %]
455                                 <select name="pickup" id="pickup" data-biblio-id="[% biblio.biblionumber | html %]" data-patron-id="[% patron.borrowernumber | html %]">
456                                     [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => biblionumber, patron => patron }, selected => pickup }) %]
457                             [% ELSE %]
458                                 <select name="pickup" id="pickup_multi" data-patron-id="[% patron.borrowernumber | html %]">
459                                     <option value="" selected="selected"></option>
460                                 [% FOREACH pickup_location IN multi_pickup_locations %]
461                                     <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option>
462                                 [% END %]
463                             [% END %]
464                                 </select>
465                             </li>
466
467                             [% UNLESS ( multi_hold ) %]
468                                 [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
469                                     <li>
470                                         <label for="itemtype">Request specific item type:</label>
471                                         <select name="itemtype" id="itemtype">
472                                             <option value="">Any item type</option>
473                                             [%- FOREACH itemtype IN available_itemtypes %]
474                                                 <option value="[% itemtype | html %]">[% ItemTypes.GetDescription( itemtype ) | html %]</option>
475                                             [%- END %]
476                                         </select>
477                                     </li>
478                                 [% END %]
479                             [% END # /UNLESS multi_hold %]
480
481                             [% IF ( reserve_in_future ) %]
482                                 <li>
483                                     <label for="from">Hold starts on date:</label>
484                                     <input name="reserve_date" id="from" size="10" class="datepickerfrom" type="text" >
485                                     <input type="hidden" class="datepickerfrom_hidden" />
486                                     <a href="#" id="clear-date-from" class="clear-date">Clear date</a>
487                                 </li>
488                             [% END %]
489
490                             <li>
491                                 <label for="to">Hold expires on date:</label>
492                                 <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
493                                 <input type="hidden" class="datepickerto_hidden" />
494                                 <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
495                             </li>
496
497                             [% UNLESS ( multi_hold ) %]
498                                 <li>
499                                     <label for="requestany">Hold next available item </label>
500                                     [% IF force_hold_level == 'item' %]
501                                         <input type="checkbox" id="requestany" name="request" disabled="true" />
502                                     [% ELSIF force_hold_level == 'record' %]
503                                         <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/>
504                                         <input type="hidden" name="request" value="Any"/>
505                                     [% ELSE %]
506                                         <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
507                                     [% END %]
508                                     <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
509                                     <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
510                                 </li>
511
512                                 [% IF remaining_holds_for_record > 1 %]
513                                     <li>
514                                         <label for="holds_to_place_count">Holds to place (count)</label>
515                                         <input type="text" inputmode="numeric" pattern="[0-9]*" id="holds_to_place_count" name="holds_to_place_count" maxlength="[% remaining_holds_for_record | html %]" value="1" />
516                                     </li>
517                                 [% ELSE %]
518                                     <input type="hidden" name="holds_to_place_count" value="1" />
519                                 [% END %]
520                             [% END # /UNLESS multi_hold %]
521
522                             <li id="non_priority_list_item">
523                                 <label for="non_priority">Non priority hold:</label>
524                                 <input name="non_priority" id="non_priority" type="checkbox" />
525                                 <span class="hint">A non priority hold doesn't prevent a current checkout from renewing</span>
526                             </li>
527                         </ol>
528
529                         [% UNLESS ( multi_hold ) %]
530                             <fieldset class="action">
531                                 [% IF ( patron.borrowernumber ) %]
532                                     [% IF ( override_required ) %]
533                                         <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
534                                     [% ELSIF ( none_available ) %]
535                                         <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
536                                     [% ELSE %]
537                                         <button type="submit" class="btn btn-default">Place hold</button>
538                                     [% END %]
539                                 [% END %]
540                             </fieldset>
541
542                             [% FOREACH bibitemloo IN bibitemloop %]
543                                 <ol>
544                                     [% UNLESS ( item_level_itypes ) %]
545                                         <li>
546                                             <span class="label">Item type:</span>
547                                             [% bibitemloo.description | html %]
548                                         </li>
549                                     [% END %]
550
551                                     [% IF ( bibitemloo.publicationyear ) %]
552                                         <li>
553                                             <span class="label">Publication year:</span>
554                                             [% bibitemloo.publicationyear | html %]
555                                         </li>
556                                     [% END %]
557                                 </ol>
558
559                                 <h2 style="padding: 0 1em;">
560                                     Place a hold on a specific item
561                                     [% IF bibitemloo.force_hold_level == 'item' %]
562                                          <span class="error"><em>(Required)</em></span>
563                                     [% END %]
564                                 </h2>
565
566                                 <table id="requestspecific">
567                                     <thead>
568                                         <tr>
569                                             <th>Hold</th>
570                                             [% IF ( item_level_itypes ) %]
571                                                 <th>Item type</th>
572                                             [% END %]
573                                             <th>Barcode</th>
574                                             <th>Home library</th>
575                                             <th>Last location</th>
576                                             [% IF itemdata_ccode %]
577                                                 <th>Collection</th>
578                                             [% END %]
579                                             <th>Call number</th>
580                                             <th>Copy number</th>
581                                             [% IF itemdata_enumchron %]
582                                                 <th>Vol no.</th>
583                                             [% END %]
584                                             <th>Information</th>
585                                             <th>Allowed pickup locations</th>
586                                         </tr>
587                                     </thead>
588                                     <tbody>
589                                         [% SET selected = 0 %]
590                                         [% FOREACH itemloo IN bibitemloo.itemloop %]
591                                             [% UNLESS ( itemloo.hide ) %]
592                                                 <tr class="[% itemloo.backgroundcolor | html %]">
593                                                     <td>
594                                                         [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
595                                                             <span class="error">
596                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
597                                                                 Hold must be record level
598                                                             </span>
599                                                         [% ELSIF ( itemloo.available ) %]
600                                                             <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
601                                                         [% ELSIF ( itemloo.override ) %]
602                                                             <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
603                                                             <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
604                                                         [% ELSE %]
605                                                             <span class="error">
606                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
607                                                                 [% IF itemloo.not_holdable %]
608                                                                     [% IF itemloo.not_holdable == 'damaged' %]
609                                                                         Item damaged
610                                                                     [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
611                                                                         Age restricted
612                                                                     [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
613                                                                         Exceeded max holds per record
614                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
615                                                                         Daily hold limit reached for patron
616                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
617                                                                         Too many holds
618                                                                     [% ELSIF itemloo.not_holdable == 'notReservable' %]
619                                                                         Not holdable
620                                                                     [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
621                                                                         Patron is from different library
622                                                                     [% ELSIF itemloo.not_holdable == 'branchNotInHoldGroup' %]
623                                                                         Cannot place hold from patron's library
624                                                                     [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
625                                                                         Patron already has hold for this item
626                                                                     [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
627                                                                         Cannot be transferred to pickup library
628                                                                     [% ELSIF itemloo.not_holdable == 'pickupNotInHoldGroup' %]
629                                                                         Only pickup locations within the same hold group are allowed
630                                                                     [% ELSIF itemloo.not_holdable == 'noReservesAllowed' %]
631                                                                         No reserves are allowed on this item
632                                                                     [% ELSE %]
633                                                                         [% itemloo.not_holdable | html %]
634                                                                     [% END %]
635                                                                 [% END %]
636                                                             </span>
637                                                         [% END # /IF itemloo.force_hold_level %]
638                                                     </td>
639                                                     [% IF ( item_level_itypes ) %]
640                                                         <td>
641                                                             [% UNLESS ( noItemTypeImages ) %]
642                                                                 [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
643                                                             [% END %]
644                                                             [% itemloo.itypename | html %]
645                                                         </td>
646                                                     [% END %]
647                                                     <td>
648                                                         [% itemloo.barcode | html %]
649                                                     </td>
650                                                     <td>
651                                                         [% Branches.GetName( itemloo.homebranch ) | html %]
652                                                     </td>
653                                                     <td>
654                                                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
655                                                     </td>
656                                                     [% IF itemdata_ccode %]
657                                                         <td>
658                                                             [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => itemloo.ccode ) | html %][% END %]
659                                                         </td>
660                                                     [% END %]
661                                                     <td>
662                                                         [% itemloo.itemcallnumber | html %]
663                                                     </td>
664                                                     <td>
665                                                         [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
666                                                     </td>
667                                                     [% IF itemdata_enumchron %]
668                                                         <td>
669                                                             [% itemloo.enumchron | html %]
670                                                         </td>
671                                                     [% END %]
672                                                     [% IF ( itemloo.onloan ) %]
673                                                         <td data-order="[% itemloo.date_due | html %]">
674                                                             <span class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
675                                                     [% ELSE %]
676                                                         <td>
677                                                             [% IF ( itemloo.transfertwhen ) %]
678                                                                 In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
679                                                                 to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
680                                                             [% END %]
681                                                     [% END %]
682
683                                                         [% IF ( itemloo.reservedate ) %]
684                                                             [% IF ( itemloo.nocancel ) %]
685                                                                     Can't be cancelled when item is in transit
686                                                             [% ELSE %]
687                                                                 [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
688                                                                 [% IF ( itemloo.canreservefromotherbranches ) %]
689                                                                     for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>
690                                                                 [% END %]
691                                                                 [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %]
692                                                                 [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %] since
693                                                                 [% IF ( itemloo.waitingdate ) %]
694                                                                     [% itemloo.waitingdate | $KohaDates %]
695                                                                 [% ELSE %]
696                                                                     [% IF ( itemloo.reservedate ) %]
697                                                                         [% itemloo.reservedate | html %]
698                                                                     [% END %]
699                                                                 [% END %].
700                                                                 <a class="info cancel-hold" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber | html %]&amp;CancelBorrowerNumber=[% itemloo.ReservedFor.borrowernumber | html %]&amp;CancelItemnumber=[% itemloo.itemnumber | html %]">Cancel hold</a>
701                                                             [% END # /IF itemloo.nocancel %]
702                                                         [% ELSE %]
703                                                             Not on hold
704                                                         [% END # /IF itemloo.reservedate %]
705
706                                                         [% IF itemloo.item_level_holds == "N" %]
707                                                             <br/>Item level hold not allowed from OPAC
708                                                         [% ELSIF itemloo.item_level_holds == "F" %]
709                                                             <br/>Item level hold forced from OPAC
710                                                         [% END %]
711
712                                                         [% IF ( itemloo.itemlost ) %]
713                                                            <span class="lost">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => itemloo.itemlost ) | html %]</span>
714                                                         [% END %]
715
716                                                         [% IF ( itemloo.damaged ) %]
717                                                             <span class="dmg">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => itemloo.damaged ) | html %]</span>
718                                                         [% END %]
719
720                                                         [% IF ( itemloo.withdrawn ) %]
721                                                            <span class="wdn">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => itemloo.withdrawn ) | html %]</span>
722                                                         [% END %]
723
724                                                         [% IF ( itemloo.notforloan ) %]
725                                                            <span class="nfl">Not for loan ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => itemloo.notforloan ) | html %])</span>
726                                                         [% END %]
727                                                     </td>
728                                                     <td>
729                                                     [% IF itemloo.any_pickup_location %]
730                                                         Any library
731                                                     [% ELSE %]
732                                                         [% itemloo.pickup_locations | html %]
733                                                     [% END %]
734                                                     </td>
735                                                 </tr>
736                                             [% END # / UNLESS itemloo.hide %]
737                                         [% END # /FOREACH itemloo %]
738                                     </tbody>
739                                 </table> <!-- /#requestspecific -->
740
741                                 [% IF ( bibitemloo.hiddencount ) %]
742                                     <form>
743                                         <p class="hiddencount">
744                                             <a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a>
745                                         </p>
746                                     </form>
747                                 [% END # /IF bibitemloo.hiddencount %]
748                             [% END # /FOREACH bibitemloo %]
749
750                         [% ELSE # /UNLESS multi_hold %]
751
752                             <table id="requesttitles">
753                                 <tr>
754                                     <th>&nbsp;</th>
755                                     <th>Title</th>
756                                     [% UNLESS ( item_level_itypes ) %]
757                                         <th>Item type</th>
758                                     [% END %]
759                                     <th>Priority</th>
760                                     <th>Information</th>
761                                     <th>Pickup location</th>
762                                 </tr>
763                                 [% FOREACH biblioloo IN biblioloop %]
764                                     [% IF ( biblioloo.warn ) %]
765                                         <tr class="onissue">
766                                     [% ELSE %]
767                                         <tr>
768                                     [% END %]
769                                         <td>
770                                             [% UNLESS ( biblioloo.warn ) %]
771                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
772                                                 </td>
773                                             [% END %]
774                                         <td>
775                                             <ul>
776                                                 <li>
777                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
778                                                 </li>
779                                                 [% IF ( biblioloo.publicationyear ) %]
780                                                     <li>
781                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
782                                                     </li>
783                                                 [% END %]
784                                             </ul>
785                                             [% IF ( biblioloo.warn ) %]
786                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
787                                             [% END %]
788                                         </td>
789                                         [% UNLESS ( item_level_itypes ) %]
790                                             <td>
791                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
792                                             </td>
793                                         [% END %]
794                                         <td>[% biblioloo.rank | html %]</td>
795                                         <td>
796                                             [% IF ( biblioloo.checked_previously ) %]
797                                                 <span>Patron has previously checked out this title</span><br/>
798                                             [% END %]
799                                             [% IF ( biblioloo.alreadyres ) %]
800                                                 <ul>
801                                             [% ELSE %]
802                                                 [% IF ( biblioloo.none_avail ) %]
803                                                     <ul>
804                                                 [% END %]
805                                             [% END %]
806
807                                             [% IF ( biblioloo.alreadyres ) %]
808                                                 <li>
809                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
810                                                     <strong>already has a hold</strong> on this item
811                                                 </li>
812                                             [% END %]
813                                             [% IF ( biblioloo.none_avail ) %]
814                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
815                                             [% END %]
816
817                                             [% IF ( biblioloo.alreadyres ) %]
818                                                 </ul>
819                                             [% ELSE %]
820                                                 [% IF ( biblioloo.none_avail ) %]
821                                                     </ul>
822                                                 [% END %]
823                                             [% END %]
824                                         </td>
825                                         <td>
826                                             <select name="pickup_[% biblioloo.biblionumber | html %]"
827                                                     class="multi_pickup_select"
828                                                     data-biblio-id="[% biblioloo.biblionumber | html %]"
829                                                     data-patron-id="[% patron.borrowernumber | html %]"
830                                                     data-pickup-locations='[% biblioloo.pickup_locations_codes.json | $raw %]'>
831                                                 <option value=""></option>
832                                             [% FOREACH pickup_location IN biblioloo.pickup_locations %]
833                                                 <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option>
834                                             [% END %]
835                                             </select>
836                                         </td>
837                                     </tr>
838                                 [% END # /FOREACH biblioloo %]
839                             </table> <!-- /#requesttitles -->
840
841                         [% END # /UNLESS multi_hold %]
842
843                         <fieldset class="action">
844                             [% IF ( patron AND patron.borrowernumber ) %]
845                                 [% IF ( override_required ) %]
846                                     <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
847                                 [% ELSIF ( none_available ) %]
848                                     <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
849                                 [% ELSE %]
850                                     [% IF ( multi_hold ) %]
851                                         <button type="submit" class="btn btn-default" id="multi_hold_submit">Place hold</button>
852                                     [% ELSE %]
853                                         <button type="submit" class="btn btn-default">Place hold</button>
854                                     [% END %]
855                                 [% END %]
856                             [% END # /IF patron %]
857                         </fieldset> <!-- /.action -->
858                     </form> <!-- /#hold-request-form -->
859                 </fieldset> <!-- /.rows -->
860             [% END %]
861
862             [% UNLESS ( patron ) %]
863                 [% IF ( reserveloop ) %]
864                     <form id="existing_holds" name="T[% time | html %]" action="modrequest.pl" method="post" style="display:block">
865                         [% IF ( multi_hold ) %]
866                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
867                         [% END %]
868
869                         <h2>Existing holds</h2>
870                         <div id="toolbar" class="btn-toolbar">
871                             <input type="submit" name="submit" value="Update hold(s)" />
872                         <fieldset id="cancellation-reason-fieldset" class="action">
873                             [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
874                             [% IF hold_cancellation %]
875                                 <label for="cancellation-reason">Cancellation reason: </label>
876                                 <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
877                                     <option value="">No reason given</option>
878                                     [% FOREACH reason IN hold_cancellation %]
879                                         <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
880                                     [% END %]
881                                 </select>
882                             [% END %]
883                         </fieldset>
884                         </div>
885
886                         [% FOREACH biblioloo IN biblioloop %]
887                             [% IF ( biblioloo.reserveloop ) %]
888                                 [% IF ( multi_hold ) %]
889                                     <h3>
890                                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
891                                             [% biblioloo.title | html %]
892                                         </a>
893                                     </h3>
894                                 [% END %]
895
896                                 [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
897                                     [% SET branchcodes = [] %]
898
899                                     [% FOREACH h IN biblioloo.reserveloop %]
900                                         [% branchcodes.push( h.branchcode ) %]
901                                     [% END %]
902                                     [% branchcodes = branchcodes.unique %]
903
904                                     [% FOREACH b IN branchcodes.sort %]
905                                         [% SET holds_by_branch = [] %]
906                                         [% FOREACH h IN biblioloo.reserveloop %]
907                                             [% IF h.branchcode == b %]
908                                                 [% holds_by_branch.push( h ) %]
909                                             [% END %]
910                                         [% END %]
911                                         <fieldset>
912                                             <legend>[% Branches.GetName( b ) | html %]</legend>
913                                             [% INCLUDE holds_table.inc holds=holds_by_branch %]
914                                         </fieldset>
915                                     [% END # /FOREACh b %]
916                                 [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
917                                     [% SET itemtypes = [] %]
918
919                                     [% FOREACH h IN biblioloo.reserveloop %]
920                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
921                                         [% itemtypes.push( hold_itemtype ) %]
922                                     [% END %]
923                                     [% itemtypes = itemtypes.unique %]
924
925                                     [% FOREACH i IN itemtypes.sort %]
926                                         [% SET holds_by_itemtype = [] %]
927                                         [% FOREACH h IN biblioloo.reserveloop %]
928                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
929                                             [% IF hold_itemtype == i %]
930                                                 [% holds_by_itemtype.push( h ) %]
931                                             [% END %]
932                                         [% END %]
933
934                                         <fieldset>
935                                             [% IF i %]
936                                                 <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
937                                             [% ELSE %]
938                                                 <legend>Any item type</legend>
939                                             [% END %]
940                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
941                                         </fieldset>
942                                     [% END # /FOREACH i %]
943                                 [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
944                                     [% SET branchcodes = [] %]
945
946                                     [% FOREACH h IN biblioloo.reserveloop %]
947                                         [% branchcodes.push( h.branchcode ) %]
948                                     [% END %]
949                                     [% branchcodes = branchcodes.unique %]
950
951                                     [% FOREACH b IN branchcodes.sort %]
952                                         <fieldset>
953                                             <legend>[% Branches.GetName( b ) | html %]</legend>
954                                             [% SET holds_by_branch = [] %]
955                                             [% FOREACH h IN biblioloo.reserveloop %]
956                                                 [% IF h.branchcode == b %]
957                                                     [% holds_by_branch.push( h ) %]
958                                                 [% END %]
959                                             [% END %]
960
961                                             [% SET itemtypes = [] %]
962                                             [% FOREACH h IN holds_by_branch %]
963                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
964                                                 [% itemtypes.push( hold_itemtype ) %]
965                                             [% END %]
966                                             [% itemtypes = itemtypes.unique %]
967
968                                             [% FOREACH i IN itemtypes.sort %]
969                                                 [% IF i %]
970                                                     <h3>[% ItemTypes.GetDescription( i ) | html %]</h3>
971                                                 [% ELSE %]
972                                                     <h3>Any item type</h3>
973                                                 [% END %]
974
975                                                 [% SET holds_by_itemtype = [] %]
976                                                 [% FOREACH h IN holds_by_branch %]
977                                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
978                                                     [% IF hold_itemtype == i %]
979                                                         [% holds_by_itemtype.push( h ) %]
980                                                     [% END %]
981                                                 [% END %]
982                                                 [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
983                                             [% END %]
984                                         </fieldset>
985                                     [% END # /FOREACH b %]
986                                 [% ELSE %]
987                                     [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
988                                 [% END # /IF HoldsSplitQueue %]
989
990                             [% END # /IF biblioloo.reserveloop %]
991                         [% END # FOREACH biblioloo %]
992                         </fieldset> <!-- /.rows -->
993                     </form> <!-- /name=TTime -->
994                 [% END # IF reserveloop %]
995             [% END # UNLESS patron %]
996
997         </main>
998
999         [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
1000             </div> <!-- /.col-md-10.col-md-offset-1 -->
1001         [% ELSE %]
1002             </div> <!-- /.col-sm-10.col-sm-push-2 -->
1003                 <div class="col-sm-2 col-sm-pull-10">
1004                     <aside>
1005                         [% INCLUDE 'biblio-view-menu.inc' %]
1006                     </aside>
1007                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1008         [% END %]
1009     </div> <!-- /.row -->
1010
1011     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
1012         <div class="modal-dialog" role="document">
1013             <div class="modal-content">
1014                 <div class="modal-header">
1015                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1016                     <h3>Confirm deletion</h3>
1017                 </div>
1018
1019                 <div class="modal-body">
1020                     <p>Are you sure you want to cancel this hold?</p>
1021
1022                     <fieldset class="action">
1023                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
1024                         [% IF hold_cancellation %]
1025                             <label for="cancellation-reason">Cancellation reason: </label>
1026                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
1027                                 <option value="">No reason given</option>
1028                                 [% FOREACH reason IN hold_cancellation %]
1029                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
1030                                 [% END %]
1031                             </select>
1032                         [% END %]
1033                     </fieldset>
1034                 </div>
1035
1036                 <div class="modal-footer">
1037                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
1038                     <a href="#" data-dismiss="modal">Cancel</a>
1039                 </div>
1040             </div>
1041         </div>
1042     </div>
1043
1044 [% MACRO jsinclude BLOCK %]
1045     [% INCLUDE 'datatables.inc' %]
1046     [% INCLUDE 'calendar.inc' %]
1047     [% INCLUDE 'columns_settings.inc' %]
1048     [% Asset.js("lib/hc-sticky.js") | $raw %]
1049     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
1050     [% INCLUDE 'select2.inc' %]
1051     <script>
1052         var Sticky;
1053         var biblionumber = "[% biblionumber | $raw %]";
1054         var borrowernumber = "[% patron.borrowernumber | $raw %]";
1055         var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]";
1056         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
1057         [% itemloo.itemnumber | html %]: {
1058             homebranch: "[% To.json( Branches.GetName( itemloo.homebranch ) ) | $raw %]",
1059             holdallowed: "[% itemloo.holdallowed | html %]"
1060             },
1061             [% END %][% END %][% END %]
1062         };
1063         var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
1064         var ERROR_MAP = {
1065             damaged: _("Item damaged"),
1066             ageRestricted: _("Age restricted"),
1067             tooManyHoldsForThisRecord: _("Exceeded max holds per record"),
1068             tooManyReservesToday: _("Daily hold limit reached for patron"),
1069             tooManyReserves: _("Too many holds"),
1070             notReservable: _("Not holdable"),
1071             noReservesAllowed: _("No reserves allowed"),
1072             cannotReserveFromOtherBranches: _("Patron is from different library"),
1073             itemAlreadyOnHold: _("Patron already has hold for this item"),
1074             cannotBeTransferred: _("Cannot be transferred to pickup library"),
1075             pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1076         }
1077         columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1078         $.fn.select2.defaults.set("width", "100%" );
1079         $.fn.select2.defaults.set("dropdownAutoWidth", true );
1080
1081         $(document).ready(function() {
1082             $('#cancellation-reason-fieldset').hide();
1083             $('.rank-request').on('change', function() {
1084                 if ( $(".rank-request option:selected[value='del']").length ) {
1085                     $('#cancellation-reason-fieldset').show();
1086                 } else {
1087                     $('#cancellation-reason-fieldset').hide();
1088                 }
1089             });
1090
1091             [% SET active = clubs ? 1 : 0 %]
1092             $('#circ_holds_select').tabs({
1093                 active: [% active | $raw %],
1094                 activate: function(){
1095                     $(this).find("input.focus").focus();
1096                 },
1097                 create: function(){
1098                     $(this).find("input.focus").focus();
1099                 }
1100             });
1101             function ToggleHoldsToPlace() {
1102                 if ( $("#requestany").prop('checked') ) {
1103                     $("#holds_to_place_count").prop('disabled', false);
1104                 } else {
1105                     $("#holds_to_place_count").prop('disabled', true);
1106                 }
1107             }
1108             ToggleHoldsToPlace();
1109             $("#requestany").on('change', function(){
1110                 ToggleHoldsToPlace();
1111             });
1112
1113             [% IF Koha.Preference('UseBranchTransferLimits') %]
1114                 $("#pickup").on('change', function(){
1115                     var pickup = $("#pickup").val();
1116                     var url = "?pickup=" + pickup;
1117                     url += "&borrowernumber=" + borrowernumber;
1118                     url += "&biblionumber=" + biblionumber;
1119                     window.location.replace(url);
1120                 });
1121             [% END %]
1122
1123             [% IF AutoResumeSuspendedHolds %]
1124                 $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
1125             [% END %]
1126
1127             $(".datepickerto").datepicker("option", "altField", ".datepickerto_hidden");
1128             $(".datepickerto").datepicker("option", "altFormat", "yy-mm-dd");
1129
1130             $(".datepickerfrom").datepicker("option", "altField", ".datepickerfrom_hidden");
1131             $(".datepickerfrom").datepicker("option", "altFormat", "yy-mm-dd");
1132
1133             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1134                 'bPaginate': false,
1135                 "sDom": '<"top pager"ilf>t',
1136             }));
1137
1138             //Override fieldset styling for dataTables search box
1139             $("div.top.pager").css("margin-left","1em");
1140             $(".dataTables_filter label").css({
1141                 "width":"auto",
1142                 "margin-right":"0em"
1143             });
1144
1145             $("#club-request-form").on("submit", function() {
1146                 let $t = $(this);
1147                 $('.clubalert, .holdalert').addClass('hide');
1148                 let biblionumbers = [biblionumber];
1149                 let biblionumbers_text;
1150                 const data = {
1151                     pickup_library_id: $('select[name="pickup"]').val()
1152                 };
1153                 if($('input[name="checkitem"]:checked').length)
1154                     data.item_id = $('input[name="checkitem"]:checked').val();
1155                 if($('input[name="borrowernumber"]').length)
1156                     data.patron_id = $('input[name="borrowernumber"]').val();
1157                 if($('textarea[name="notes"]').length)
1158                     data.notes = $('textarea[name="notes"]').val()||null;
1159                 if($('.datepickerto_hidden').length)
1160                     data.expiration_date = $('.datepickerto_hidden').val()||null;
1161                 if($('.datepickerfrom_hidden').length)
1162                     data.hold_date = $('.datepickerfrom_hidden').val()||null;
1163                 if($('input[name="itemtype"]').length) {
1164                     data.item_type = $('input[name="itemtype"]').val()||null;
1165                 }
1166                 if($('input[name="default_patron_home"]:checked').length) {
1167                     data.default_patron_home = 1;
1168                 }
1169                 if($('input[name="biblionumbers"]').length) {
1170                     biblionumbers_text = $('input[name="biblionumbers"]').val();
1171                     biblionumbers = biblionumbers_text.replace(/\/$/, '').split('/')
1172                 }
1173
1174                 const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1175                 biblionumbers.forEach(function(biblionumber) {
1176                     data.biblio_id = biblionumber;
1177                     let options = {
1178                         url: $t.attr('action'),
1179                         method: $t.attr('method').toUpperCase(),
1180                         contentType: 'application/json',
1181                         data: JSON.stringify(data)
1182                     };
1183                     for(let i = 0; i < count; i++) {
1184                         $.ajax(options)
1185                         .then(function(result) {
1186                             let url = 'request.pl?biblionumber='+biblionumber;
1187                             if(biblionumbers_text) {
1188                                 url = 'request.pl?biblionumbers='+biblionumbers_text;
1189                             }
1190                             document.location = url;
1191                         })
1192                         .fail(function(err) {
1193                             var message = err.responseJSON.error;
1194                             var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1195                             if(match && ERROR_MAP[match[1]]) {
1196                                 message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1197                             }
1198                             $('.clubalert, .holdalert').removeClass('hide').html(message);
1199                         });
1200                     }
1201                 });
1202
1203                 return false;
1204             });
1205
1206             [% UNLESS ( multi_hold ) %]
1207                 $("#hold-request-form").on("submit", function(){
1208                     return check();
1209                 });
1210             [% ELSE %]
1211                 $("#hold-request-form").on("submit", function(){
1212                     return checkMultiHold();
1213                 });
1214             [% END %]
1215
1216             function display_pickup_location (state) {
1217                 var $text;
1218                 if ( state.needs_override === true ) {
1219                     $text = $(
1220                         '<span>' + state.text + '</span> <span style="float:right;" title="' +
1221                         _("This pickup location is not allowed according to circulation rules") +
1222                         '"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>'
1223                     );
1224                 }
1225                 else {
1226                     $text = $('<span>'+state.text+'</span>');
1227                 }
1228
1229                 return $text;
1230             };
1231
1232             $(".pickup_location_dropdown").each( function () {
1233                 var this_dropdown = $(this);
1234                 var hold_id = $(this).data('hold_id');
1235
1236                 this_dropdown.select2({
1237                     allowClear: false,
1238                     ajax: {
1239                         url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations',
1240                         delay: 300, // wait 300 milliseconds before triggering the request
1241                         dataType: 'json',
1242                         data: function (params) {
1243                             var search_term = (params.term === undefined) ? '' : params.term;
1244                             var query = {
1245                                 "q": JSON.stringify({"name":{"-like":search_term+'%'}}),
1246                                 "_order_by": "name"
1247                             };
1248                             return query;
1249                         },
1250                         processResults: function (data) {
1251                             var results = [];
1252                             data.forEach( function ( pickup_location ) {
1253                                 results.push(
1254                                     {
1255                                         "id": pickup_location.library_id.escapeHtml(),
1256                                         "text": pickup_location.name.escapeHtml(),
1257                                         "needs_override": pickup_location.needs_override
1258                                     }
1259                                 );
1260                             });
1261                             return { "results": results };
1262                         }
1263                     },
1264                     templateResult: display_pickup_location
1265                 });
1266             });
1267
1268             $("#pickup_multi").select2({
1269                 width: '30%',
1270                 allowClear: true
1271             });
1272
1273             $('.multi_pickup_select').select2({
1274                 width: '100%',
1275                 allowClear: true
1276             });
1277
1278             $("#pickup_multi").on("change", function() {
1279                 var selection = $(this).val();
1280                 if ( selection != '' ) {
1281                     $(".multi_pickup_select").each(function() {
1282                         var valid_pickup_locations = $(this).data('pickup-locations');
1283                         if ( valid_pickup_locations.includes(selection) ) {
1284                             $(this).val(selection);
1285                             $(this).trigger("change");
1286                         }
1287                     });
1288                 }
1289             });
1290
1291             $("#pickup").each( function () {
1292                 var this_dropdown = $(this);
1293                 var patron_id = $(this).data('patron-id');
1294                 var biblio_id = $(this).data('biblio-id');
1295
1296                 this_dropdown.select2({
1297                     width: 'style',
1298                     allowClear: false,
1299                     ajax: {
1300                         url: '/api/v1/biblios/' + encodeURIComponent(biblio_id) + '/pickup_locations',
1301                         delay: 300, // wait 300 milliseconds before triggering the request
1302                         dataType: 'json',
1303                         data: function (params) {
1304                             var search_term = (params.term === undefined) ? '' : params.term;
1305                             var query = {
1306                                 "q": JSON.stringify({"name":{"-like":search_term+'%'}}),
1307                                 "_order_by": "name",
1308                                 "patron_id": patron_id
1309                             };
1310                             return query;
1311                         },
1312                         processResults: function (data) {
1313                             var results = [];
1314                             data.forEach( function ( pickup_location ) {
1315                                 results.push(
1316                                     {
1317                                         "id": pickup_location.library_id.escapeHtml(),
1318                                         "text": pickup_location.name.escapeHtml(),
1319                                         "needs_override": pickup_location.needs_override
1320                                     }
1321                                 );
1322                             });
1323                             return { "results": results };
1324                         }
1325                     },
1326                     templateResult: display_pickup_location
1327                 });
1328             });
1329         });
1330
1331         function check() {
1332             var msg = "";
1333             var count_reserv = 0;
1334
1335             // check if we have checkitem form
1336             if (document.form.checkitem){
1337                 for (i=0;i<document.form.checkitem.length;i++){
1338                     if (document.form.checkitem[i].checked == true) {
1339                         count_reserv++ ;
1340                     }
1341                 }
1342                 // for only one item, check the checkitem without consider the loop checkitem
1343                 if (i==0){
1344                     if (document.form.checkitem.checked == true) {
1345                         count_reserv++;
1346                     }
1347                 }
1348             }
1349
1350             if (document.form.requestany.checked == true){
1351                 count_reserv++ ;
1352             }
1353
1354             if (count_reserv == "0"){
1355                 msg += (_("- Please select an item to place a hold") + "\n");
1356             }
1357
1358             if (msg == "") {
1359                 $('#hold-request-form').preventDoubleFormSubmit();
1360                 return(true);
1361             } else {
1362                 alert(msg);
1363                 return(false);
1364             }
1365         }
1366
1367         function checkMultiHold() {
1368
1369             var biblionumbers = "";
1370             var selected_bibs = $(".multi_hold_item_checkbox:checked");
1371             if ( selected_bibs.length > 0 ) {
1372                 // there are biblios selected in the form!
1373                 // verify they have a pickup location selected
1374
1375                 var pickup_not_set = 0;
1376                 selected_bibs.each(function() {
1377                     if ( $(this).closest('tr').find(".multi_pickup_select").val() === "" ) {
1378                         pickup_not_set++;
1379                     }
1380                     else {
1381                         var bibnum = $(this).attr("title");
1382                         biblionumbers += bibnum + "/";
1383                     }
1384                 });
1385                 if ( pickup_not_set > 0 ) {
1386                     alert( _("Please make sure all selected titles have a pickup location set" + "\n") );
1387                     return false;
1388                 }
1389             }
1390             else {
1391                 alert( _("Please select at least one title" + "\n") );
1392                 return false;
1393             }
1394
1395             var badSpans = $(".not_holdable");
1396             var badBibs = "";
1397             $(badSpans).each(function() {
1398                 var bibnum = $(this).attr("title");
1399                 badBibs += bibnum + "/";
1400             });
1401
1402             $("#multi_hold_bibs").val(biblionumbers);
1403             $("#bad_bibs").val(badBibs);
1404
1405             $('#hold-request-form').preventDoubleFormSubmit();
1406
1407             return true;
1408         }
1409
1410          $(document).ready(function() {
1411             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1412                 var itemnumber = this.value;
1413                 var msg = '';
1414
1415                 switch (override_items[itemnumber].holdallowed) {
1416                     case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1417                     case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1418                 }
1419
1420                 msg += "\n\n" + _("Place hold on this item?");
1421
1422                 return confirm(msg);
1423             });
1424             $("button.warning").click(function() {
1425                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1426             });
1427             $("#requestany").click(function() {
1428                 if(this.checked){
1429                     $("input[name=checkitem]").each(function() {
1430                         $(this).prop("checked", false);
1431                     });
1432                 }
1433             });
1434             $("input[name=checkitem]").click(function() {
1435                 onechecked = 0;
1436                 $("input[name=checkitem]").each(function() {
1437                     if(this.checked){
1438                         onechecked = 1;
1439                     }
1440                 });
1441                 if(onechecked == 1){
1442                     $("#requestany").prop("checked", false);
1443                     $("#holds_to_place_count").prop('disabled', true);
1444                 } else {
1445                     $("#requestany").prop("checked",true);
1446                     $("#holds_to_place_count").prop('disabled', false);
1447                 }
1448             });
1449             var prev_rank_request;
1450             $("select[name=rank-request]").on("focus", function() {
1451                 prev_rank_request = $(this).val();
1452                 var row = $(this).parents("tr:first");
1453             }).change(function() {
1454                 var row = $(this).parents("tr:first");
1455                 var value = parseInt($(this).val());
1456                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
1457                 if( !isNaN(value) ) {  //If moved to 'del'
1458                     var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds)
1459                     if (prev_rank_request > value) {
1460                         row.insertBefore(after);
1461                     } else {
1462                         row.insertAfter(after);
1463                     }
1464                 }
1465
1466                 var next_priority = 1;
1467                 $("select[name=rank-request]").each(function () {
1468                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
1469                     $(this).val(next_priority);
1470                     next_priority++;
1471                 });
1472             });
1473
1474             $(".clear-date").on("click",function(e){
1475                 e.preventDefault();
1476                 var fieldID = this.id.replace("clear-date-","");
1477                 $("#" + fieldID).val("");
1478             });
1479
1480             // Confirm cancellation of hold
1481             let cancel_link;
1482             $(".cancel-hold").on("click",function(e) {
1483                 e.preventDefault;
1484                 cancel_link = $(this);
1485                 $('#cancelModal').modal();
1486                 return false;
1487             });
1488             $("#cancelModalConfirmBtn").on("click",function(e) {
1489                 let borrowernumber = cancel_link.data('borrowernumber');
1490                 let biblionumber = cancel_link.data('biblionumber');
1491                 let reserve_id = cancel_link.data('id');
1492                 let reason = $("#modal-cancellation-reason").val();
1493                 let link = `request.pl?action=cancel&amp;borrowernumber=${ borrowernumber }&amp;biblionumber=${ biblionumber }&amp;reserve_id=${ reserve_id }`;
1494                 if ( reason ) {
1495                     link += "&amp;cancellation-reason=" + reason
1496                 }
1497                 window.location.href = link;
1498                 return false;
1499             });
1500
1501             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
1502                 [% IF ( PatronAutoComplete ) %]
1503                 $( "#patron" ).autocomplete({
1504                     source: "/cgi-bin/koha/circ/ysearch.pl",
1505                     minLength: 3,
1506                     select: function( event, ui ) {
1507                         $( "#patron" ).val( ui.item.cardnumber );
1508                         $( "#holds_patronsearch" ).submit();
1509                         return false;
1510                     }
1511                 })
1512                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
1513                     return $( "<li></li>" )
1514                     .data( "ui-autocomplete-item", item )
1515                     .append(
1516                         "<a>"
1517                             + ( item.surname ? item.surname.escapeHtml() : "" )
1518                             + ", "
1519                             + ( item.firstname ? item.firstname.escapeHtml() : "" )
1520                             + " (" + ( item.cardnumber ? item.cardnumber.escapeHtml() : "" ) + ")"
1521                             + " "
1522                             + "<small>"
1523                                 + ( item.address ? item.address.escapeHtml() : "" )
1524                                 + " "
1525                                 + ( item.city ? item.city.escapeHtml() : "" )
1526                                 + " "
1527                                 + ( item.zipcode ? item.zipcode.escapeHtml() : "" )
1528                                 + " "
1529                                 + ( item.country ? item.country.escapeHtml() : "" )
1530                             + "</small>"
1531                         + "</a>" )
1532                     .appendTo( ul );
1533                 };
1534                 [% END %]
1535             [% END %]
1536             Sticky = $("#toolbar");
1537             Sticky.hcSticky({
1538                 stickTo: "#existing_holds",
1539                 stickyClass: "floating"
1540             });
1541         });
1542     </script>
1543 [% END %]
1544
1545 [% INCLUDE 'intranet-bottom.inc' %]