Bug 34478: ILL OPAC: create -> add_form
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-illrequests.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE KohaDates %]
4 [% USE AuthorisedValues %]
5 [% USE Branches %]
6 [% USE AdditionalContents %]
7 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
8 [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Your interlibrary loan requests &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% BLOCK cssinclude %][% END %]
13 </head>
14 [% INCLUDE 'bodytag.inc' bodyid='opac-illrequests' bodyclass='scrollto' %]
15 [% BLOCK messages %]
16     [% IF message == "1" %]
17         <div class="alert alert-success" role="alert">Request updated</div>
18     [% ELSIF message == "2" %]
19         <div class="alert alert-success" role="alert">Request placed</div>
20     [% END %]
21 [% END %]
22 [% INCLUDE 'masthead.inc' %]
23 <div class="main">
24     [% WRAPPER breadcrumbs %]
25         [% IF ( logged_in_user ) %]
26             [% WRAPPER breadcrumb_item %]
27                 <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
28             [% END %]
29         [% END %]
30
31         [% IF op != 'list' %]
32             [% WRAPPER breadcrumb_item %]
33                 <a href="/cgi-bin/koha/opac-illrequests.pl">Interlibrary loan requests</a>
34             [% END %]
35             [% IF op == 'cud-create' %]
36                 [% WRAPPER breadcrumb_item bc_active= 1 %]
37                     <span>New interlibrary loan request</span>
38                 [% END %]
39             [% ELSIF op == 'view' %]
40                 [% WRAPPER breadcrumb_item bc_active= 1 %]
41                     <span>View interlibrary loan request</span>
42                 [% END %]
43             [% ELSIF op == 'typedisclaimer' %]
44                 [% WRAPPER breadcrumb_item bc_active= 1 %]
45                     <span>Ill request disclaimer</span>
46                 [% END %]
47             [% END %]
48         [% ELSE %]
49             [% WRAPPER breadcrumb_item bc_active= 1 %]
50                 <a href="#" aria-current="page">Interlibrary loan requests</a>
51             [% END %]
52         [% END %]
53     [% END #/ WRAPPER breadcrumbs %]
54
55     <div class="container-fluid">
56         <div class="row">
57             [% IF ( OpacNav||loggedinusername ) && !print %]
58                 <div class="col-lg-2">
59                     <div id="navigation">
60                         [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
61                     </div>
62                 </div>
63             [% END %]
64
65             [% IF ( OpacNav||loggedinusername ) %]
66                 <div class="col-lg-10 order-first order-md-first order-lg-2">
67             [% ELSE %]
68                 <div class="col order-first order-md-first order-lg-2">
69             [% END %]
70
71                 [% IF !backends_available %]
72                     <div class="alert alert-warning">ILL module configuration problem. Contact your administrator.</div>
73                 [% ELSE %]
74                     <div id="illrequests" class="maincontent">
75                         [% IF op == 'cud-create' %]
76                             <h1>New interlibrary loan request</h1>
77                             [% IF stage == 'copyrightclearance' %]
78                                 [% INCLUDE messages %]
79                                 <div>
80                                     <p>
81                                         [% Koha.Preference('ILLModuleCopyrightClearance') | $raw %]
82                                     </p>
83                                     [% USE link_url = url('/cgi-bin/koha/opac-illrequests.pl', whole.value.other) %]
84                                     <a href="[% link_url _ '&amp;stage=copyrightclearance' | $raw %]"
85                                     class="btn btn-sm btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Yes</a>
86                                     <a href="/cgi-bin/koha/opac-illrequests.pl"
87                                     class="btn btn-sm btn-danger"><i class="fa fa-times" aria-hidden="true"></i> No</a>
88                                 </div>
89                             [% ELSE %]
90                                 [% INCLUDE messages %]
91                                 [% IF backends %]
92                                     <form method="get" id="illrequestcreate-form" novalidate="novalidate">
93                                         <legend class="sr-only">Backends</legend>
94                                         <fieldset class="rows">
95                                             <label for="backend">Provider:</label>
96                                             <select name="backend">
97                                                 [% FOREACH backend IN backends %]
98                                                     <option value="[% backend | html %]">[% backend | html %]</option>
99                                                 [% END %]
100                                             </select>
101                                         </fieldset>
102                                         <fieldset class="action">
103                                             <input type="hidden" name="op" value="add_form" />
104                                             <input type="submit" class="btn btn-sm btn-primary" value="Next" />
105                                         </fieldset>
106                                     </form>
107                                 [% ELSE %]
108                                     [% PROCESS $whole.opac_template %]
109                                 [% END %]
110                             [% END # /IF stage == 'copyrightclearance' %]
111                         [% ELSIF op == 'list' %]
112                             <h1>Interlibrary loan requests</h1>
113                             [% INCLUDE messages %]
114
115                             [% IF can_place_ill_in_opac %]
116                                 <div id="illrequests-create-button" class="dropdown btn-group">
117                                     [% IF backends.size > 1 %]
118                                         <button class="btn btn-primary dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
119                                             <i class="fa fa-plus" aria-hidden="true"></i> Create a new request <span class="caret"></span>
120                                         </button>
121                                         <div id="backend-dropdown-options" class="dropdown-menu nojs" aria-labelledby="ill-backend-dropdown">
122                                             [% FOREACH backend IN backends %]
123                                                 <a class="dropdown-item" href="/cgi-bin/koha/opac-illrequests.pl?op=add_form&amp;backend=[% backend | uri %]">[% backend | html %]</a>
124                                             [% END %]
125                                         </div>
126                                     [% ELSE %]
127                                         <a id="ill-new" class="btn btn-primary" href="/cgi-bin/koha/opac-illrequests.pl?op=add_form&amp;backend=[% backends.0 | html %]">
128                                             <i class="fa fa-plus" aria-hidden="true"></i> Create a new request
129                                         </a>
130                                     [% END %]
131                                 </div>
132                             [% END %]
133
134                             <table id="illrequestlist" class="table table-bordered table-striped">
135                                 <caption class="sr-only">Requests</caption>
136                                 <thead>
137                                     <tr>
138                                         <th>Request ID</th>
139                                         <th>Author</th>
140                                         <th>Title</th>
141                                         <th>Requested from</th>
142                                         <th>Request type</th>
143                                         <th>Status</th>
144                                         <th>Request placed</th>
145                                         <th>Last updated</th>
146                                         <th></th>
147                                     </tr>
148                                 </thead>
149                                 <tbody>
150                                     [% FOREACH request IN requests %]
151                                         [% status = request.status | html %]
152                                         [% type = request.get_type %]
153                                         <tr>
154                                             <td>[% request.id | html %]</td>
155                                             <td>
156                                                 [% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %]
157                                             </td>
158                                             <td>
159                                                 [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %]
160                                             </td>
161                                             <td>[% request.backend | html %]</td>
162                                             <td>
163                                                 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
164                                             </td>
165                                             <td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td>
166                                             <td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td>
167                                             <td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td>
168                                             <td>
169                                                 <a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm pull-right">View</a>
170                                             </td>
171                                         </tr>
172                                     [% END %]
173                                 </tbody>
174                             </table>
175                         [% ELSIF op == 'view' %]
176                             <h1>View interlibrary loan request</h1>
177                             [% INCLUDE messages %]
178                             [% status = request.status %]
179                             <form method="post" action="?op=update" id="illrequestupdate-form" novalidate="novalidate">
180                                 [% INCLUDE 'csrf-token.inc' %]
181                                 <fieldset class="rows">
182                                     <legend id="library_legend">Details from library</legend>
183                                     <ol>
184                                         [% type = request.get_type %]
185                                         <li>
186                                             <label for="request_id">Request ID:</label>
187                                             [% request.id | html %]
188                                         </li>
189                                         <li>
190                                             <label for="backend">Requested from:</label>
191                                             [% request.backend | html %]
192                                         </li>
193                                         [% IF request.biblio_id %]
194                                             <li>
195                                                 <label for="biblio">Requested item:</label>
196                                                 <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% request.biblio_id | uri %]">View the requested item</a>
197                                             </li>
198                                         [% END %]
199                                         <li>
200                                             <label for="branchcode">Collection library:</label>
201                                             [% Branches.GetName(request.branchcode) | html %]
202                                         </li>
203                                         <li>
204                                             <label for="status">Status:</label>
205                                             [% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]
206                                         </li>
207                                         <li>
208                                             <label for="medium">Request type:</label>
209                                             [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
210                                         </li>
211                                         <li>
212                                             <label for="placed">Request placed:</label>
213                                             [% request.placed | $KohaDates %]
214                                         </li>
215                                         <li>
216                                             <label for="updated">Last updated:</label>
217                                             [% request.updated | $KohaDates %]
218                                         </li>
219                                         <li>
220                                             <label for="notesopac">Notes:</label>
221                                             [% IF !request.completed %]
222                                                 <textarea name="notesopac" rows="5" cols="50">[% request.notesopac | html %]</textarea>
223                                             [% ELSE %]
224                                                 [% request.notesopac | html %]
225                                             [% END %]
226                                         </li>
227                                     </ol>
228                                 </fieldset>
229                                 <div id="ill-supplier-metadata" class="rows">
230                                     <legend id="backend_legend">Details from [% request.backend | html %]</legend>
231                                     [% FOREACH meta IN request.metadata %]
232                                         <div class="requestattr-[% meta.key | replace(' ', '_') | html %]">
233                                             <span class="label">[% meta.key | html %]:</span>
234                                             <span class="value">[% IF meta.value %][% meta.value | html %][% ELSE %]N/A[% END %]</span>
235                                         </div>
236                                     [% END %]
237                                 </div>
238                             [% IF can_place_ill_in_opac %]
239                                 <fieldset class="action illrequest-actions">
240                                     <input type="hidden" name="illrequest_id" value="[% request.illrequest_id | html %]" />
241                                     <input type="hidden" name="op" value="update" />
242                                     [% IF !request.completed %]
243                                         [% IF request.status == "NEW" %]
244                                             <a class="cancel-illrequest btn btn-danger" href="/cgi-bin/koha/opac-illrequests.pl?op=cancreq&amp;illrequest_id=[% request.illrequest_id | html %]">Request cancellation</a>
245                                         [% END %]
246                                         <input type="submit" class="update-illrequest btn btn-primary" value="Submit modifications" />
247                                     [% END %]
248                                     <span class="cancel"><a href="/cgi-bin/koha/opac-illrequests.pl">Cancel</a></span>
249                                 </fieldset>
250                             [% END %]
251                             </form>
252                         [% ELSIF op == 'availability' %]
253                             <h1>Interlibrary loan item availability</h1>
254                             <div id="results">
255                                 <form method="POST" action="/cgi-bin/koha/opac-illrequests.pl">
256                                     [% INCLUDE 'csrf-token.inc' %]
257                                     <legend><h2>Displaying availability results</h2></legend>
258                                     [% FOREACH key IN whole.keys %]
259                                         [% value = whole.$key %]
260                                         [% IF key != 'custom_key' && key != 'custom_value' %]
261                                         <input type="hidden" name="[% key | html %]" value="[% value | html %]">
262                                         [% END %]
263                                     [% END %]
264                                     [% custom_keys = whole.custom_key.split('\0') %]
265                                     [% custom_values = whole.custom_value.split('\0') %]
266                                     [% i = 0 %]
267                                     [% FOREACH custom_key IN custom_keys %]
268                                         <input type="hidden" name="custom_key" value="[% custom_key | html %]">
269                                         <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
270                                     [% i = i + 1 %]
271                                     [% END %]
272                                     <input type="hidden" name="checked_availability" value="1">
273                                     <div id="continue-request-row" class="alert">
274                                         If you can't find what you are looking for, you can
275                                         <button class="button" class="btn btn-primary" type="submit">continue creating your request</button> or
276                                         <a href="/cgi-bin/koha/opac-illrequests.pl">cancel your request</a>
277                                     </div>
278                                 </form>
279                                 [% FOR service IN services %]
280                                     <h3 class="ill_availability_sourcename">[% service.name | html %]</h3>
281                                     [% INCLUDE 'ill-availability-table.inc' service=service %]
282                                 [% END %]
283                             </div> <!-- /#illrequestupdate-form -->
284                         [% ELSIF op == 'typedisclaimer' %]
285                             <h1>ILL request disclaimer</h1>
286                             <div id="results" class="page-section">
287                                 [% INCLUDE messages %]
288                                 <form method="post" id="typedisclaimer-form">
289                                     [% INCLUDE 'csrf-token.inc' %]
290                                     <fieldset class="rows">
291                                         [% disclaimer.text | $raw %]
292                                         [% SET disc_av_category_code = AuthorisedValues.GetAuthValueDropbox(disclaimer.av_cat) %]
293                                         [% IF disc_av_category_code.count %]
294                                         <br>
295                                             <select name="type_disclaimer_value">
296                                                 [% FOR av_option IN disc_av_category_code %]
297                                                     <option value="[% av_option.lib_opac | html %]">[% av_option.lib_opac | html %]</option>
298                                                 [% END %]
299                                             </select>
300                                         [% END %]
301                                     </fieldset>
302                                     <fieldset class="action">
303                                         [% FOREACH key IN whole.keys %]
304                                             [% value = whole.$key %]
305                                             [% IF key != 'custom_key' && key != 'custom_value' %]
306                                             <input type="hidden" name="[% key | html %]" value="[% value | html %]">
307                                             [% END %]
308                                         [% END %]
309                                         [% custom_keys = whole.custom_key.split('\0') %]
310                                         [% custom_values = whole.custom_value.split('\0') %]
311                                         [% i = 0 %]
312                                         [% FOREACH custom_key IN custom_keys %]
313                                             <input type="hidden" name="custom_key" value="[% custom_key | html %]">
314                                             <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
315                                         [% i = i + 1 %]
316                                         [% END %]
317                                         <input type="hidden" name="type_disclaimer_submitted" value="1">
318                                         <input type="submit" class="btn btn-primary" value="Submit" />
319                                         <a class="action" href="/cgi-bin/koha/opac-illrequests.pl">Cancel</a>
320                                     </fieldset>
321                                 </form>
322                             </div>
323                         [% END # / IF op == 'cud-create' %]
324                     </div> <!-- / #illrequests -->
325                 [% END # /IF !backends_available %]
326             </div> <!-- / .col-lg-10/12 -->
327         </div> <!-- / .row -->
328     </div> <!-- / .container-fluid -->
329 </div> <!-- / .main -->
330
331 [% INCLUDE 'opac-bottom.inc' %]
332
333 [% BLOCK jsinclude %]
334     [% INCLUDE 'datatables.inc' %]
335     <script>
336         $("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
337             "columnDefs": [
338                 { "targets": [ -1 ], "sortable": false, "searchable": false }
339             ],
340             "order": [[ 3, "desc" ]],
341             "deferRender": true
342         }));
343         $("#backend-dropdown-options").removeClass("nojs");
344         [% IF services_json.length > 0 %]
345             var services = [% services_json | $raw %];
346         [% ELSE %]
347             var services = [];
348         [% END %]
349         [% IF metadata.length > 0 %]
350             var metadata = "[% metadata | $raw %]";
351         [% END %]
352     </script>
353     [% IF op == 'availability' %]
354         [% Asset.js("js/ill-availability.js") | $raw %]
355         <script>
356             $(document).ready(function() {
357                 window.doSearch();
358             });
359         </script>
360     [% END %]
361     [% TRY %]
362         [% PROCESS backend_jsinclude %]
363     [% CATCH %]
364     [% END %]
365 [% END %]