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