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