Bug 22818: Add generation and sending of notices
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / ill / ill-requests.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% USE Koha %]
5 [% USE KohaDates %]
6 [% SET footerjs = 1 %]
7 [% USE AuthorisedValues %]
8 [% USE TablesSettings %]
9 [% USE Price %]
10
11 [% INCLUDE 'doc-head-open.inc' %]
12 <title>Koha &rsaquo; ILL requests</title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 </head>
15
16 <body id="illrequests" class="ill">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'cat-search.inc' %]
19
20 <div id="breadcrumbs">
21     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
22     <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
23     [% IF query_type == 'create' %]
24          &rsaquo; New request
25     [% ELSIF query_type == 'status' %]
26          &rsaquo; Status
27     [% END %]
28 </div>
29
30 <div class="main container-fluid">
31     <div class="row">
32
33         [% IF query_type == 'illlist' %]
34             <div class="col-sm-2">
35                 <aside>
36                     <form method="get" id="illfilter_form">
37                         <fieldset class="brief">
38                             <h3>Filters</h3>
39                             <ol>
40                                 <li>
41                                     <label for="illfilter_status">Status:</label>
42                                     <select name="illfilter_status" id="illfilter_status">
43                                         <option value=""></option>
44                                     </select>
45                                 </li>
46                                 <li>
47                                     <label for="illfilter_dateplaced_start">Date placed between:</label>
48                                     <input type="text" name="illfilter_dateplaced_start" id="illfilter_dateplaced_start" class="datepicker" />
49                                 </li>
50                                 <li>
51                                     <label for="illfilter_dateplaced_end">and:</label>
52                                     <input type="text" name="illfilter_dateplaced_end" id="illfilter_dateplaced_end" class="datepicker" />
53                                 </li>
54                                 <li>
55                                     <label for="illfilter_datemodified_start">Updated between:</label>
56                                     <input type="text" name="illfilter_datemodified_start" id="illfilter_datemodified_start" class="datepicker" />
57                                 </li>
58                                 <li>
59                                     <label for="illfilter_datemodified_end">and:</label>
60                                     <input type="text" name="illfilter_datemodified_end" id="illfilter_datemodified_end" class="datepicker" />
61                                 </li>
62                                 <li>
63                                     <label for="illfilter_branchname">Library:</label>
64                                     <select name="illfilter_branchname" id="illfilter_branchname">
65                                         <option value=""></option>
66                                     </select>
67                                 </li>
68                                 <li>
69                                     <label for="illfilter_patron">Patron:</label>
70                                     <input type="text" name="illfilter_patron" id="illfilter_patron" />
71                                 </li>
72                             </ol>
73                             <fieldset class="action">
74                                 <input type="submit" value="Search" />
75                                 <input type="button" value="Clear" id="clear_search" />
76                             </fieldset>
77                         </fieldset>
78                     </form> <!-- /#illfilter_form -->
79                 </aside>
80             </div> <!-- /.col-sm-2 -->
81             <div class="col-sm-10">
82                 <main>
83         [% ELSE %]
84             <div class="col-sm-10 col-sm-offset-2">
85                 <main>
86         [% END %]
87             <div id="interlibraryloans">
88         [% IF !backends_available || !has_branch %]
89             <div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div>
90         [% ELSE %]
91                 [% INCLUDE 'ill-toolbar.inc' %]
92
93                 [% IF whole.error %]
94                     <h1>Error performing operation</h1>
95                     <!-- Dispatch on Status -->
96                     <p>We encountered an error:</p>
97                     <p>
98                       <pre>[% whole.message | html %] ([% whole.status | html %])</pre>
99                     </p>
100                 [% END %]
101
102                 [% IF whole.success %]
103                     <p>[% whole.success | html %]</p>
104                 [% END %]
105
106                 [% IF query_type == 'create' %]
107                     <h1>New ILL request</h1>
108                     [% PROCESS $whole.template %]
109
110                 [% ELSIF query_type == 'confirm' %]
111                     <h1>Confirm ILL request</h1>
112                     [% PROCESS $whole.template %]
113
114                 [% ELSIF query_type == 'cancel' and !whole.error %]
115                     <h1>Cancel a confirmed request</h1>
116                     [% PROCESS $whole.template %]
117
118                 [% ELSIF query_type == 'check_out' and !whole.error %]
119                     [% IF !whole.stage || whole.stage == 'form' %]
120                         <h1 id="ill-issue-title">Issue requested item to [% INCLUDE 'patron-title.inc' patron = request.patron %]</h1>
121                         [% IF !request.biblio_id || request.biblio_id.length == 0 %]
122                         <div class="alert">This item cannot be issued as it has no biblio record associated with it</div>
123                         [% END %]
124                         [% IF whole.value.errors.itemcount %]
125                         <div class="alert">The bibliographic record for this request has multiple items, it should only have one. Please fix this then try again.</div>
126                         [% END %]
127                         [% IF whole.value.errors.item_creation %]
128                         <div class="alert">An unknown error occurred while trying to add an item</div>
129                         [% END %]
130                         [% IF whole.value.errors.item_check_out %]
131                         <div class="alert">An unknown error occurred while trying to check out the item</div>
132                         [% END %]
133                         [% IF whole.value.check_out_errors %]
134                             [% IF whole.value.check_out_errors.error.STATS %]
135                             <div class="alert">
136                                 Local use recorded
137                             </div>
138                             [% ELSE %]
139                             <div class="alert">
140                                 There was a problem checking this item out, please check for problems with the <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% whole.value.patron.borrowernumber | uri %]">patron's account</a>
141                             </div>
142                             [% END %]
143                         [% END %]
144                         [% IF request.biblio_id && request.biblio_id.length > 0  && !whole.value.check_out_errors.error.STATS %]
145                             <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
146                                 <fieldset class="rows">
147                                     <legend>Check out details</legend>
148                                     [% items = whole.value.biblio.items.unblessed %]
149                                     [% IF items.size == 1 %]
150                                         <p>The bibliographic record for this request already has an item attached to it, you are about to check it out</p>
151                                     [% ELSE %]
152                                         <p>A bibliographic record for this request exists, but no item. You are about to create an item and check it out</p>
153                                     [% END %]
154                                     <ol>
155                                         <li class="ill_checkout_inhouse">
156                                             <label for="inhouse" class="ill_checkout_inhouse_label">Statistical patron:</label>
157                                             <select id="ill_checkout_inhouse_select" name="inhouse" class="ill_checkout_inhouse_select">
158                                                 <option value=""></option>
159                                                 [% FOREACH stat IN whole.value.statistical %]
160                                                     [% IF stat.borrowernumber == params.inhouse %]
161                                                         <option value="[% stat.cardnumber | html %]" selected>[% INCLUDE 'patron-title.inc' patron = stat %]</option>
162                                                     [% ELSE %]
163                                                         <option value="[% stat.cardnumber | html %]">[% INCLUDE 'patron-title.inc' patron = stat %]</option>
164                                                     [% END %]
165                                                 [% END %]
166                                             </select>
167                                             [% IF whole.value.errors.inhouse %]
168                                             <span class="required">You must choose a valid patron</span>
169                                             [% END %]
170                                             <div class="hint">If you do not wish to check out the item to [% INCLUDE 'patron-title.inc' patron = request.patron %] and would rather issue it to an in-house statistical patron, choose the patron here</div>
171                                         </li>
172                                         <li class="ill_checkout_item_type">
173                                             <label for="item_type" class="ill_checkout_item_type_label required">Item type:</label>
174                                             [% IF items.size != 1 %]
175                                                 <select id="ill_checkout_item_type_select" name="item_type" required>
176                                                     [% FOREACH type IN whole.value.itemtypes %]
177                                                         [% IF type.itemtype == params.item_type %]
178                                                         <option value="[% type.itemtype | html %]" selected>
179                                                         [% ELSE %]
180                                                         <option value="[% type.itemtype | html %]">
181                                                         [% END %]
182                                                             [% type.description | html %]
183                                                         </option>
184                                                     [% END %]
185                                                 </select>
186                                             [% ELSE %]
187                                                 [% FOREACH type IN whole.value.itemtypes %]
188                                                     [% IF type.itemtype == items.0.itype %]
189                                                         [% type.description | html %]
190                                                     [% END %]
191                                                 [% END %]
192                                             [% END %]
193                                             [% IF whole.value.errors.item_type %]
194                                             <span class="required">You must choose an item type</span>
195                                             [% END %]
196                                         </li>
197                                         [% IF items.size == 1 %]
198                                             <li>
199                                                 <label for="barcode" class="ill_checkout_barcode_label">Item barcode:</label>
200                                                 [% items.0.barcode | html %]
201                                             </li>
202                                         [% END %]
203                                         <li class="ill_checkout_branchcode">
204                                             <label for="branchcode" class="ill_checkout_branchcode_label required">Library:</label>
205                                             [% branchcode = items.size == 1 ? items.0.homebranch : params.branchcode ? params.branchcode : request.branchcode %]
206                                             [% IF items.size != 1 %]
207                                                 <select name="branchcode" id="ill_checkout_branchcode_select" required>
208                                                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
209                                                 </select>
210                                             [% ELSE %]
211                                                 [% FOREACH branch IN whole.value.libraries.unblessed %]
212                                                     [% IF branch.branchcode == branchcode %]
213                                                         [% branch.branchname | html %]
214                                                     [% END %]
215                                                 [% END %]
216                                             [% END %]
217                                             [% IF whole.value.errors.branchcode %]
218                                             <span class="required">You must choose a branch</span>
219                                             [% END %]
220                                         </li>
221                                         <li class="ill_checkout_due_date">
222                                             <label for="duedate" class="ill_checkout_duedate_label">Due date:</label>
223                                             <input name="duedate" id="ill_checkout_duedate_input" type="text" value="[% params.duedate | html %]"> [% INCLUDE 'date-format.inc' %]
224                                             <div class="hint">If you do not specify a due date, it will be set according to circulation rules</p>
225                                         </li>
226                                     </ol>
227                                 </fieldset>
228                                 <fieldset class="action">
229                                     <input type="hidden" value="check_out" name="method">
230                                     <input type="hidden" value="form" name="stage">
231                                     [% IF items.size == 1 %]
232                                         <input name="branchcode" type="hidden" value="[% branchcode | html %]">
233                                         <input name="item_type" type="hidden" value="[% items.0.itype | html %]">
234                                     [% END %]
235                                     <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
236                                     <input type="submit" value="Submit">
237                                     <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&amp;illrequest_id=[% request.id | html %]">Cancel</a>
238                                 </fieldset>
239                             </form>
240                         [% END %]
241                         [% IF whole.value.check_out_errors.error.STATS %]
242                             <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&amp;illrequest_id=[% request.id | html %]">Return to request</a>
243                         [% END %]
244                     [% ELSIF whole.stage == 'done_check_out' %]
245                         <h1>Item checked out</h1>
246                         <fieldset class="rows">
247                             <legend>Check out details</legend>
248                             <ol>
249                                 <li>
250                                     <label>Checked out to:</label>
251                                     [% INCLUDE 'patron-title.inc' patron = whole.value.patron %]
252                                 </li>
253                                 <li>
254                                     <label>Due date:</label>
255                                     [% whole.value.check_out.date_due | $KohaDates with_hours => 1 %]
256                                 </li>
257                             </ol>
258                         </fieldset>
259                         <fieldset class="action">
260                             <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&amp;illrequest_id=[% request.id | html %]">Return to request</a>
261                         </fieldset>
262                     [% END %]
263
264                 [% ELSIF query_type == 'generic_confirm' %]
265                     <h1>Place request with partner libraries</h1>
266                   [% IF error %]
267                     [% IF error == 'no_target_email' %]
268                         <div class="alert">
269                             No target email addresses found. Either select at least
270                             one partner or check your ILL partner library records.
271                         </div>
272                     [% ELSIF error == 'no_library_email' %]
273                         <div class="alert">
274                             Your library has no usable email address. Please set it.
275                         </div>
276                     [% ELSIF error == 'unkown_error' %]
277                         <div class="alert">
278                             Unknown error processing your request. Contact your administrator.
279                         </div>
280                     [% END %]
281                   [% END %]
282                     <!-- Start of GENERIC_EMAIL case -->
283                     [% IF whole.value.partners %]
284                        [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %]
285                         <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
286                             <fieldset class="rows">
287                                 <legend>Interlibrary loan request details</legend>
288                                 <ol>
289                                     <li>
290                                         <label for="partner_filter">Filter partner libraries:</label>
291                                         <input type="text" id="partner_filter" />
292                                     </li>
293                                     <li>
294                                         <label for="partners" class="required">Select partner libraries:</label>
295                                         <select size="5" multiple="true" id="partners" name="partners" required="required">
296                                             [% FOREACH partner IN whole.value.partners %]
297                                                 [% IF partner.email && partner.email.length > 0 %]
298                                                     <option data-partner-id="[% partner.id | html %]" value=[% partner.email | html %]>
299                                                         [% partner.branchcode _ " - " _ partner.surname %]
300                                                     </option>
301                                                 [% END %]
302                                             [% END %]
303                                         </select>
304                                         [% IF Koha.Preference('ILLCheckAvailability') %]
305                                             <div id="generic_confirm_search_count">Partners available for searching: <span id="generic_confirm_enabled">none</span></div>
306                                             <div id="generic_confirm_search">
307                                                 <button type="button">Search selected partners</button>
308                                             </div>
309                                         [% END %]
310                                     </li>
311                                     <li>
312                                         <label for="subject" class="required">Subject line:</label>
313                                         <input type="text" name="subject" id="subject" type="text" value="[% whole.value.draft.subject | html %]" required="required" />
314                                     </li>
315                                     <li>
316                                         <label for="body" class="required">Email text:</label>
317                                         <textarea name="body" id="body" rows="20" cols="80" required="required">[% whole.value.draft.body | html %]</textarea>
318                                     </li>
319                                 </ol>
320                                 <input type="hidden" value="generic_confirm" name="method">
321                                 <input type="hidden" value="draft" name="stage">
322                                 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
323                             </fieldset>
324                             <fieldset class="action">
325                                 <input type="submit" class="btn btn-default" value="Send email"/>
326                                 <span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span>
327                             </fieldset>
328                         </form>
329                         [% IF Koha.Preference('ILLCheckAvailability') %]
330                             <div id="partnerSearch" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="partnerSearchLabel" aria-hidden="true">
331                                 <div class="modal-dialog">
332                                     <div class="modal-content">
333                                         <div class="modal-header">
334                                             <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
335                                             <h3 id="partnerSearchLabel"> Search partners</h3>
336                                         </div>
337                                         <div class="modal-body">
338                                             [% FOR service IN services %]
339                                                 <h4 class="ill_availability_sourcename">[% service.name | html %]</h4>
340                                                 [% INCLUDE 'ill-availability-table.inc' service=service %]
341                                             [% END %]
342                                             <span id="service_id_restrict" data-service_id_restrict_plugin="ILL availability - z39.50" data-service_id_restrict_ids=""></span>
343                                         </div>
344                                         <div class="modal-footer">
345                                             <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
346                                         </div>
347                                     </div>
348                                 </div>
349                             </div>
350                         [% END %]
351
352                     [% ELSE %]
353                         <fieldset class="rows">
354                             <legend>Interlibrary loan request details</legend>
355                             <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
356                             <p>Be sure to provide email addresses for these patrons.</p>
357                             <p><span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span></p>
358                         </fieldset>
359                     [% END %]
360                 <!-- generic_confirm ends here -->
361
362                 [% ELSIF query_type == 'edit_action' %]
363                     <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
364                         <fieldset class="rows">
365                             <legend>Request details</legend>
366                             <ol>
367                                 [% type = request.get_type %]
368                                 <li class="borrowernumber">
369                                     <label for="borrowernumber">Patron ID:</label>
370                                     [% request.borrowernumber | html %]
371                                 </li>
372                                 <li class="biblio_id">
373                                     <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label>
374                                     <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]">
375                                 </li>
376                                 <li class="branchcode">
377                                     <label for="library" class="branchcode">Library:</label>
378                                     <select name="branchcode" id="library">
379                                         [% PROCESS options_for_libraries libraries => Branches.all( selected => request.branchcode ) %]
380                                     </select>
381                                 </li>
382                                 <li class="status">
383                                     <label class="status">Status:</label>
384                                     [% stat = request.status %]
385                                     [% current_alias = request.status_alias %]
386                                     <select id="status_alias" name="status_alias">
387                                         [% IF !current_alias %]
388                                         <option value="" selected>
389                                         [% ELSE %]
390                                         <option value="">
391                                         [% END %]
392                                             [% request.capabilities.$stat.name | html %]
393                                         </option>
394                                         [% FOREACH alias IN AuthorisedValues.Get('ILLSTATUS') %]
395                                             [% IF alias.authorised_value == current_alias %]
396                                             <option value="[% alias.authorised_value | html %]" selected>
397                                             [% ELSE %]
398                                             <option value="[% alias.authorised_value | html %]">
399                                             [% END %]
400                                                 [% alias.lib | html %]
401                                             </option>
402                                         [% END %]
403                                     </select>
404                                 </li>
405                                 <li class="updated">
406                                     <label class="updated">Last updated:</label>
407                                     [% request.updated | $KohaDates  with_hours => 1 %]
408                                 </li>
409                                 <li class="medium">
410                                     <label class="medium">Request type:</label>
411                                     [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
412                                 </li>
413                                 <li class="cost">
414                                     <label class="cost">Cost:</label>
415                                     [% IF request.cost %][% request.cost | $Price %][% ELSE %]<span>N/A</span>[% END %]
416                                 </li>
417                                 <li class="price_paid">
418                                     <label class="price_paid">Price paid:</label>
419                                     <input name="price_paid" id="price_paid" type="text" value="[% request.price_paid | html %]">
420                                 </li>
421                                 <li class="req_id">
422                                     <label class="req_id">Request number:</label>
423                                     [% request.id_prefix _ request.illrequest_id | html %]
424                                 </li>
425                                 <li class="notesstaff">
426                                     <label for="notesstaff" class="notesstaff">Staff notes:</label>
427                                     <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff | html %]</textarea>
428                                 </li>
429                                 <li class="notesopac">
430                                     <label for="notesopac" class="notesopac">Opac notes:</label>
431                                     <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac | html %]</textarea>
432                                 </li>
433                             </ol>
434                         </fieldset>
435                         <fieldset class="action">
436                             <input type="hidden" value="edit_action" name="method">
437                             <input type="hidden" value="form" name="stage">
438                             <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
439                             <input type="hidden" value="[% request.borrowernumber | html %]" name="borrowernumber">
440                             <input type="submit" value="Submit">
441                             <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&amp;illrequest_id=[% request.id | html %]">Cancel</a>
442                         </fieldset>
443                     </form>
444
445                 [% ELSIF query_type == 'delete_confirm' %]
446
447                     <div class="dialog alert">
448                         <h3>Are you sure you wish to delete this request?</h3>
449                         <form action="/cgi-bin/koha/ill/ill-requests.pl" method="post">
450                             <input type="hidden" name="method" value="delete" />
451                             <input type="hidden" name="confirmed" value="1" />
452                             <input type="hidden" name="illrequest_id" value="[% request.id | html %]" />
453                             <button type="submit" class="btn btn-default approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
454                         </form>
455                         <a class="btn btn-default deny" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&amp;illrequest_id=[% request.id | html %]"><i class="fa fa-fw fa-remove"></i>No, do not delete</a>
456                     </div>
457
458                 [% ELSIF query_type == 'illview' %]
459                     [% req_status = request.status %]
460
461                     [% IF error %]
462                       [% IF error == 'migrate_target' %]
463                           <div class="alert">
464                               The backend you tried to migrate to does not yet support migrations, please try again with an alternative target.
465                           </div>
466                       [% END %]
467                     [% END %]
468
469                     [% IF tran_success %]
470                         [% succ_methods = [] %]
471                         [% IF tran_success.match('email') %]
472                             [% succ_methods.push('email') %]
473                         [% END %]
474                         [% IF tran_success.match('sms') %]
475                             [% succ_methods.push('SMS') %]
476                         [% END %]
477                         <div class="alert">
478                             The requested notice was queued for delivery by [% succ_methods.join(', ') | html %]
479                         </div>
480                     [% END %]
481                     [% IF tran_fail %]
482                         [% fail_methods = [] %]
483                         [% IF tran_fail.match('email') %]
484                             [% fail_methods.push('email') %]
485                         [% END %]
486                         [% IF tran_fail.match('sms') %]
487                             [% fail_methods.push('SMS') %]
488                         [% END %]
489                         <div class="alert">
490                             The requested notice was NOT queued for delivery by [% fail_methods.join(', ') | html %]
491                         </div>
492                     [% END %]
493
494                     <h1>Manage ILL request</h1>
495                     <div id="request-toolbar" class="btn-toolbar">
496                         <a title="Edit request" id="ill-toolbar-btn-edit-action" class="btn btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=edit_action&amp;illrequest_id=[% request.illrequest_id | html %]">
497                         <span class="fa fa-pencil"></span>
498                         Edit request
499                         </a>
500                         [% FOREACH action IN request.available_actions %]
501                             [% needs_prefs = action.needs_prefs.size ? action.needs_prefs : [] %]
502                             [% needs_perms = action.needs_perms.size ? action.needs_perms : [] %]
503                             [% needs_all = action.needs_all.size ? action.needs_all : [] %]
504                             [% has_prefs_count = 0 %]
505                             [% has_perms_count = 0 %]
506                             [% has_all_count = 0 %]
507                             [% FOREACH pref IN needs_prefs %]
508                                 [% IF Koha.Preference(pref) %]
509                                     [% has_prefs_count = has_prefs_count + 1 %]
510                                 [% END %]
511                             [% END %]
512                             [% FOREACH perm IN needs_perms %]
513                                 [% perm_name = 'CAN_' _ perm %]
514                                 [% IF ($perm_name) %]
515                                     [% has_perms_count = has_perms_count + 1 %]
516                                 [% END %]
517                             [% END %]
518                             [% FOREACH func IN needs_all %]
519                                 [% IF func(request) %]
520                                     [% has_all_count = has_all_count + 1 %]
521                                 [% END %]
522                             [% END %]
523                             [% NEXT IF has_prefs_count < needs_prefs.size || has_perms_count < needs_perms.size || has_all_count < needs_all.size %]
524                             [% IF action.method == 'migrate' %]
525                                 [% IF backends.size > 2 %]
526                                     <div class="dropdown btn-group">
527                                         <button class="btn btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
528                                             <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
529                                         </button>
530                                         <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
531                                             [% FOREACH backend IN backends %]
532                                                 [% IF backend != request.backend %]
533                                                     <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]&amp;backend=[% backend | uri %]">[% backend | html %]</a></li>
534                                                 [% END %]
535                                             [% END %]
536                                         </ul>
537                                     </div>
538                                 [% ELSIF backends.size == 2 %]
539                                     [% FOREACH backend IN backends %]
540                                         [% IF backend != request.backend %]
541                                             <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]&amp;backend=[% backend | uri %]">
542                                             <span class="fa [% action.ui_method_icon | html %]"></span>
543                                             [% action.ui_method_name | html %]
544                                             </a>
545                                         [% END %]
546                                     [% END %]
547                                 [% END %]
548                             [% ELSIF action.method != 0 %]
549                                 <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]">
550                                 <span class="fa [% action.ui_method_icon | html %]"></span>
551                                 [% action.ui_method_name | html %]
552                                 </a>
553                             [% END %]
554                         [% END %]
555                         <div class="dropdown btn-group">
556                             <button class="btn btn-default dropdown-toggle" type="button" id="ill-notice-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
557                                 <i class="fa fa-envelope"></i> Send notice to patron <span class="caret"></span>
558                             </button>
559                             <ul class="dropdown-menu" aria-labelledby="ill-notice-dropdown">
560                                 [% FOREACH notice IN notices %]
561                                     <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=send_notice&amp;illrequest_id=[% request.illrequest_id | uri %]&amp;notice_code=[% notice.code | uri %]">[% notice.name | html %]</a></li>
562                                 [% END %]
563                             </ul>
564                         </div>
565                         <a title="Display supplier metadata" id="ill-request-display-metadata" class="btn btn-default pull-right" href="#">
566                             <span class="fa fa-eye"></span>
567                             Display supplier metadata
568                         </a>
569                         <a title="ILL request log" id="ill-request-display-log" class="btn btn-default pull-right" href="#">
570                             <span class="fa fa-calendar"></span>
571                             ILL request log
572                         </a>
573                     </div>
574                     <div class="ill-view-panel panel panel-default">
575                         <div class="panel-heading">
576                             <h3>Request details</h3>
577                         </div>
578                         <div class="panel-body">
579                             <h4>Details from library</h4>
580                             <div class="rows">
581                                 <ol>
582                                     <li class="orderid">
583                                         <span class="label orderid">Order ID:</span>
584                                         [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
585                                     </li>
586                                     <li class="borrowernumber">
587                                         <span class="label borrowernumber">Patron:</span>
588                                         [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
589                                         <a href="[% borrowerlink | url %]" title="View borrower details">
590                                         [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
591                                         </a>
592                                     </li>
593
594                                     <li class="biblio_id">
595                                         <span class="label biblio_id">Bibliographic record ID:</span>
596                                         [% IF request.biblio_id %]
597                                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
598                                         [% ELSE %]
599                                             <span>N/A</span>
600                                         [% END %]
601                                     </li>
602                                     <li class="branchcode">
603                                         <span class="label branchcode">Library:</span>
604                                         [% Branches.GetName(request.branchcode) | html %]
605                                     </li>
606                                     <li class="status">
607                                         <span class="label status">Status:</span>
608                                         [% IF request.statusalias %]
609                                             [% request.statusalias.lib | html %]
610                                         [% ELSE %]
611                                             [% request.capabilities.$req_status.name | html%]
612                                             [% IF request.requested_partners.length > 0 %]
613                                                 ([% request.requested_partners | html %])
614                                             [% END %]
615                                         [% END %]
616                                     </li>
617                                     <li class="updated">
618                                         <span class="label updated">Last updated:</span>
619                                         [% request.updated | $KohaDates  with_hours => 1 %]
620                                     </li>
621                                     <li class="medium">
622                                         <span class="label medium">Request type:</span>
623                                         [% type = request.get_type %]
624                                         [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
625                                     </li>
626                                     <li class="cost">
627                                         <span class="label cost">Cost:</span>
628                                         [% IF request.cost %][% request.cost | $Price %][% ELSE %]<span>N/A</span>[% END %]
629                                     </li>
630                                     <li class="price_paid">
631                                         <span class="label price_paid">Price paid:</span>
632                                         [% IF request.price_paid %][% request.price_paid | $Price %][% ELSE %]<span>N/A</span>[% END %]
633                                     </li>
634                                     <li class="req_id">
635                                         <span class="label req_id">Request number:</span>
636                                         [% request.id_prefix _ request.illrequest_id | html %]
637                                     </li>
638                                     <li class="notesstaff">
639                                         <span class="label notes_staff">Staff notes:</span>
640                                         <p>[% request.notesstaff | html %]</p>
641                                     </li>
642                                     <li class="notesopac">
643                                         <span class="label notes_opac">Notes:</span>
644                                         <p>[% request.notesopac | html %]</p>
645                                     </li>
646                                 </ol>
647                             </div>
648                             <div class="rows">
649                                 <h4>Details from supplier ([% request.backend | html %])</h4>
650                                 <ol>
651                                     [% FOREACH meta IN request.metadata %]
652                                         <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
653                                             <span class="label">[% meta.key | html %]:</span>
654                                             [% meta.value | html %]
655                                         </li>
656                                     [% END %]
657                                 </ol>
658                             </div>
659                         </div>
660                     </div>
661
662                     <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
663                         <div class="modal-dialog">
664                             <div class="modal-content">
665                                 <div class="modal-header">
666                                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
667                                     <h3 id="dataPreviewLabel"> Supplier metadata</h3>
668                                 </div>
669                                 <div class="modal-body">
670                                     <div id="requestattributes">
671                                         [% FOREACH attr IN request.illrequestattributes %]
672                                         <div class="requestattr-[% attr.type | html %]">
673                                             <span class="label">[% attr.type | html %]:</span>
674                                             [% attr.value | html %]
675                                         </div>
676                                             [% END %]
677                                     </div>
678                                 </div>
679                                 <div class="modal-footer">
680                                     <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
681                                 </div>
682                             </div>
683                         </div>
684                     </div>
685
686                     <div id="requestLog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
687                         <div class="modal-dialog">
688                             <div class="modal-content">
689                                 <div class="modal-header">
690                                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
691                                     <h3 id="requestLogLabel"> Request log</h3>
692                                 </div>
693                                 <div class="modal-body">
694                                 [% IF request.logs.size > 0 %]
695                                     [% FOREACH log IN request.logs %]
696                                         [% tpl = log.template %]
697                                         [% INCLUDE $tpl log=log %]
698                                     [% END %]
699                                 [% ELSE %]
700                                     There are no recorded logs for this request
701                                 [% END %]
702                                 </div>
703                                 <div class="modal-footer">
704                                     <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
705                                 </div>
706                             </div>
707                         </div>
708                     </div>
709
710                     <div class="ill-view-panel panel panel-default">
711                         <div class="panel-heading">
712                             <h3>[% request.illcomments.count | html %] comments</h3>
713                         </div>
714                         <div class="panel-body">
715                             [% IF request.illcomments.count && request.illcomments.count > 0 %]
716                                 [% FOREACH comment IN request.illcomments %]
717                                     <div class="rows comment_[% comment.patron.categorycode | html %]">
718                                     <h5>Comment by:
719                                     <a href="[% borrowerlink | url %]" title="View borrower details">
720                                     [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
721                                     [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
722                                     <p>[% comment.comment | html %]</p>
723                                     </div>
724                                 [% END %]
725                             [% END %]
726                                 <div class="rows">
727                                     <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
728                                     <div id="addcomment" class="content_hidden">
729                                         <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
730                                             <input type="hidden" value="save_comment" name="method">
731                                             <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
732                                             <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
733                                             <fieldset class="rows">
734                                                 <ol>
735                                                     <li>
736                                                         <label class="required" for="comment">Comment: </label>
737                                                         <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
738                                                         <span class="required">Required</span>
739                                                     </li>
740                                                 </ol>
741                                             </fieldset>
742                                             <fieldset class="action">
743                                                 <input type="submit" value="Submit">
744                                             </fieldset>
745                                         </form>
746                                     </div>
747                                 </div>
748                         </div>
749                     </div>
750
751                 [% ELSIF query_type == 'illlist' %]
752                     <!-- illlist -->
753                     <h1>View ILL requests</h1>
754                     <div id="results">
755                         <h3>Details for all requests</h3>
756                         [% INCLUDE 'ill-list-table.inc' %]
757
758                     </div> <!-- /#results -->
759                 [% ELSIF query_type == 'availability' %]
760                     <!-- availability -->
761                     <h1>Availability</h1>
762                     <div id="results">
763                         <h3>Displaying availability results</h3>
764                         <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
765                             [% FOREACH key IN whole.keys %]
766                                 [% value = whole.$key %]
767                                 [% IF key != 'method' && key != 'custom_key' && key != 'custom_value' %]
768                                 <input type="hidden" name="[% key | html %]" value="[% value | html %]">
769                                 [% END %]
770                             [% END %]
771                             [% custom_keys = whole.custom_key.split('\0') %]
772                             [% custom_values = whole.custom_value.split('\0') %]
773                             [% i = 0 %]
774                             [% FOREACH custom_key IN custom_keys %]
775                                 <input type="hidden" name="custom_key" value="[% custom_key | html %]">
776                                 <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
777                             [% i = i + 1 %]
778                             [% END %]
779                             <input type="hidden" name="method" value="create">
780                             <input type="hidden" name="stage" value="form">
781                             <input type="hidden" name="checked_availability" value="1">
782                             <div id="continue-request-row" class="alert">
783                                 If you can't find what you are looking for, you can
784                                 <button class="button" type="submit">continue creating your request</button> or
785                                 <a href="/cgi-bin/koha/ill/ill-requests.pl">cancel your request</a>
786                             </div>
787                         </form>
788                         [% FOR service IN services %]
789                             <h4 class="ill_availability_sourcename">[% service.name | html %]</h4>
790                             [% INCLUDE 'ill-availability-table.inc' service=service %]
791                         [% END %]
792                     </div>
793                 [% ELSE %]
794                 <!-- Custom Backend Action -->
795                 [% PROCESS $whole.template %]
796
797                 [% END %]
798         [% END %]
799                 </div> <!-- /#interlibraryloans -->
800             </main>
801         </div> <!-- /.col-sm-10 -->
802     </div> <!-- /.row -->
803
804
805 [% MACRO jsinclude BLOCK %]
806     [% INCLUDE 'datatables.inc' %]
807     [% INCLUDE 'columns_settings.inc' %]
808     [% INCLUDE 'calendar.inc' %]
809     [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %]
810     <script>
811         var prefilters = '[% prefilters | $raw %]';
812         // Set column settings
813         var columns_settings = [% TablesSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %];
814         $("#ill_checkout_duedate_input").datetimepicker({
815             hour: 23,
816             minute: 59
817         }).on("change", function(e, value) {
818             if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
819         });
820         [% IF services_json.length > 0 %]
821         var services = [% services_json | $raw %];
822         [% ELSE %]
823         var services = [];
824         [% END %]
825         [% IF metadata.length > 0 %]
826         var metadata = "[% metadata | $raw %]";
827         [% END %]
828     </script>
829     <script>
830         $('#ill_checkout_inhouse_select').on('change', function() {
831             if ($(this).val().length > 0) {
832                 $('.ill_checkout_due_date').hide();
833             } else {
834                 $('.ill_checkout_due_date').show();
835             }
836         });
837     </script>
838     [% INCLUDE 'ill-list-table-strings.inc' %]
839     [% Asset.js("js/ill-list-table.js") | $raw %]
840     [% IF (query_type == 'availability' || query_type == 'generic_confirm') && Koha.Preference('ILLCheckAvailability') %]
841         [% Asset.js("js/ill-availability.js") | $raw %]
842     [% END %]
843     [% IF query_type == 'availability' && Koha.Preference('ILLCheckAvailability') %]
844         <script>
845             $(document).ready(function() {
846                 window.doSearch();
847             });
848         </script>
849     [% END %]
850     [% IF query_type == 'generic_confirm' && Koha.Preference('ILLCheckAvailability') %]
851         [% Asset.js("js/ill-availability-partner.js") | $raw %]
852     [% END %]
853 [% END %]
854
855 [% TRY %]
856 [% PROCESS backend_jsinclude %]
857 [% CATCH %]
858 [% END %]
859
860 [% INCLUDE 'intranet-bottom.inc' %]