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