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