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