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