Bug 33590: Fix DOM id name for tabs after WRAPPER code added to article-requests.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / request-article.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Context %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE ItemTypes %]
8 [% USE AuthorisedValues %]
9 [% USE Price %]
10 [% SET footerjs = 1 %]
11 [% SET article_requests_view = 1 %]
12 [% SET biblionumber = biblio.biblionumber %]
13 [% INCLUDE 'doc-head-open.inc' %]
14 [% SET libraries = Branches.all %]
15 [% SET categories = Categories.all.unblessed %]
16 [% SET columns = ['name', 'address', 'cardnumber', 'dateofbirth', 'category', 'branch', 'phone'] %]
17 [% PROCESS "patron-search.inc" %]
18 <title>Request article &rsaquo; Circulation &rsaquo; Koha</title>
19 [% INCLUDE 'doc-head-close.inc' %]
20 </head>
21
22 [% BLOCK cancel_modal %]
23     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
24         <div class="modal-dialog" role="document">
25             <div class="modal-content">
26                 <div class="modal-header">
27                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
28                     <h3>Confirm deletion</h3>
29                 </div>
30
31                 <div class="modal-body">
32                     <p>Are you sure you want to cancel this article request?</p>
33
34                     <fieldset class="action">
35                         [% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
36                         [% IF ar_cancellation.count %]
37                             <label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
38                             <select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
39                                 <option value="" selected>Other reasons</option>
40                                 [% FOREACH reason IN ar_cancellation %]
41                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
42                                 [% END %]
43                             </select>
44                         [% END %]
45                     </fieldset>
46                     <fieldset class="action">
47                         <div class="hint col-sm-offset-4">Enter reason</div>
48                         <input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
49                     </fieldset>
50                 </div>
51
52                 <div class="modal-footer">
53                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
54                     <a href="#" data-dismiss="modal">Cancel</a>
55                 </div>
56             </div>
57         </div>
58     </div>
59 [% END %]
60
61 <body id="circ_request-article" class="circ">
62     [% WRAPPER 'header.inc' %]
63     [% INCLUDE 'circ-search.inc' %]
64 [% END %]
65
66 [% WRAPPER 'sub-header.inc' %]
67     [% WRAPPER breadcrumbs %]
68         [% IF blocking_error %]
69             [% WRAPPER breadcrumb_item bc_active= 1 %]
70                 <span>Catalog</span>
71             [% END %]
72         [% ELSE %]
73             [% WRAPPER breadcrumb_item %]
74                 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
75             [% END %]
76             [% WRAPPER breadcrumb_item %]
77                 [% INCLUDE 'biblio-title.inc' link = 1 %]
78             [% END %]
79             [% WRAPPER breadcrumb_item bc_active= 1 %]
80                 <span>Request article</span>
81             [% END %]
82         [% END %]
83     [% END #/ WRAPPER breadcrumbs %]
84 [% END #/ WRAPPER sub-header.inc %]
85
86 [% INCLUDE 'blocking_errors.inc' %]
87 <div class="main container-fluid">
88     <div class="row">
89         <div class="col-sm-10 col-sm-push-2">
90             <main>
91
92                     <h1>Request article from [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
93                     [% IF error_message %]
94                         <div class="dialog alert">
95                         [% SWITCH error_message %]
96                             [% CASE 'article_request_limit_reached'       %]<p>Patron reached daily limit.</p>
97                             [% CASE 'article_request_unhandled_exception' %]<p>An error has occurred. Check the logs.</p>
98                         [% END %]
99                         </div>
100                     [% END %]
101                     [% UNLESS patron %]
102                         <fieldset class="brief">
103                             <label>Search patrons</label>
104                             [% PROCESS patron_search_filters_simple %]
105                             [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
106                         </fieldset>
107                     [% ELSE %]
108                         [% IF biblio.can_article_request( patron ) %]
109                             [% IF article_request_fee > 0 %]
110                                 <div class="dialog alert">
111                                     Patron will be charged with <strong>[% article_request_fee | $Price %]</strong> for every request
112                                 </div>
113                             [% END %]
114                             <form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
115                                 <input type="hidden" name="action" value="create" />
116                                 <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
117                                 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id | html %]" />
118
119                                 <fieldset class="rows">
120                                     <legend>Place article request from [% biblio.title | html %] for [% patron.firstname | html %] [% patron.surname | html %] ( [% patron.cardnumber | html %] )</legend>
121                                     <ol>
122                                         <li>
123                                             <label for="title">Title:</label>
124                                             <input type="text" name="title" id="title" size="50"/>
125                                         </li>
126
127                                         <li>
128                                             <label for="author">Author:</label>
129                                             <input type="text" name="author" id="author" size="50"/>
130                                         </li>
131
132                                         <li>
133                                             <label for="volume">Volume:</label>
134                                             <input type="text" name="volume" id="volume" size="50"/>
135                                         </li>
136
137                                         <li>
138                                             <label for="issue">Issue:</label>
139                                             <input type="text" name="issue" id="issue" size="50"/>
140                                         </li>
141
142                                         <li>
143                                             <label for="date">Date:</label>
144                                             <input type="text" name="date" id="date" size="50"/>
145                                         </li>
146
147                                         <li>
148                                             <label for="toc_request">Table of contents:</label>
149                                             <input type="checkbox" name="toc_request" value="1"/>
150                                         </li>
151
152                                         <li>
153                                             <label for="pages">Pages:</label>
154                                             <input type="text" name="pages" id="pages" size="50"/>
155                                         </li>
156
157                                         <li>
158                                             <label for="chapters">Chapters:</label>
159                                             <input type="text" name="chapters" id="chapters" size="50"/>
160                                         </li>
161
162                                         <li>
163                                             <label for="patron_notes">Patron notes:</label>
164                                             <input type="text" name="patron_notes" id="patron_notes" size="50"/>
165                                         </li>
166
167                                         <li>
168                                             <label for="format">Format:</label>
169                                             <select name="format" id="format">
170                                                 <option value="PHOTOCOPY">Photocopy</option>
171                                                 <option value="SCAN">Digital scan</option>
172                                             </select>
173                                         </li>
174
175                                         <li>
176                                             <label for="branchcode">Pickup library:</label>
177                                             <select name="branchcode" id="branchcode">
178                                                 [% FOREACH b IN Branches.all %]
179                                                     [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
180                                                         <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
181                                                     [% ELSE %]
182                                                         <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
183                                                     [% END %]
184                                                 [% END %]
185                                             </select>
186                                         </li>
187                                     </ol>
188                                 </fieldset>
189
190                                 [% SET article_request_type = biblio.article_request_type( patron ) %]
191                                 [% IF article_request_type != 'bib_only' %]
192                                     <div class="page-section">
193                                         <table id="current-requests-table" class="ar-table table table-bordered table-striped">
194                                             <caption>Select item:</caption>
195                                             <thead>
196                                                 <tr>
197                                                     <th>&nbsp;</th>
198                                                     <th>Item type</th>
199                                                     <th>Barcode</th>
200                                                     <th>Home library</th>
201                                                     <th>Call number</th>
202                                                     <th>Enumeration</th>
203                                                 </tr>
204                                             </thead>
205
206                                             <tbody>
207                                                 [% FOREACH item IN biblio.items %]
208                                                     [% IF item.can_article_request( patron ) %]
209                                                         <tr>
210                                                             <td>
211                                                                 [% IF article_request_type == 'item_only' && !checked %]
212                                                                     [% SET checked = 1 %]
213                                                                     <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
214                                                                 [% ELSE %]
215                                                                     <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
216                                                                 [% END %]
217                                                             </td>
218                                                             <td>
219                                                                 [% ItemTypes.GetDescription( item.itype ) | html %]
220                                                             </td>
221                                                             <td>
222                                                                 [% item.barcode | html %]
223                                                             </td>
224                                                             <td>
225                                                                 [% Branches.GetName( item.homebranch ) | html %]
226                                                             </td>
227                                                             <td>
228                                                                 [% item.itemcallnumber | html %]
229                                                             </td>
230                                                             <td>
231                                                                 [% item.enumchron | html %]
232                                                             </td>
233                                                         </tr>
234                                                     [% END %]
235                                                 [% END %]
236
237                                                 [% IF article_request_type != 'item_only' %]
238                                                     <tr>
239                                                         <td>
240                                                             <input type="radio" name="itemnumber" value="" checked="checked"/>
241                                                         </td>
242                                                         <td colspan="5">
243                                                             Any item
244                                                         </td>
245                                                     </tr>
246                                                 [% END %]
247                                             </tbody>
248                                         </table>
249                                     </div><!-- /.page-section -->
250                                 [% END %]
251
252                                 <p>
253                                     <input type="submit" class="btn btn-default" value="Place request" />
254                                 </p>
255                             </form>
256                         [% ELSE %]
257                             No article requests can be made for this record.
258                         [% END %]
259
260                     [% END %]
261
262                     [% SET biblio_current_article_requests = Context.Scalar( Context.Scalar( biblio, 'article_requests' ), 'filter_by_current' ) %]
263                     [% IF biblio_current_article_requests.count > 0 && !patron %]
264                         <fieldset class="rows left" id="current-article-requests-fieldset">
265                             <legend>Current article requests</legend>
266
267                             <table id="current-article-requests-table">
268                                 <tr>
269                                     <th>Placed on</th>
270                                     <th>Patron</th>
271                                     <th>Title</th>
272                                     <th>Author</th>
273                                     <th>Volume</th>
274                                     <th>Issue</th>
275                                     <th>Date</th>
276                                     <th>TOC</th>
277                                     <th>Pages</th>
278                                     <th>Chapters</th>
279                                     <th>Patron notes</th>
280                                     <th>Format</th>
281                                     <th>Item</th>
282                                     <th>Status</th>
283                                     <th>Pickup library</th>
284                                     <th>&nbsp;</th>
285                                 </tr>
286
287                                 [% FOREACH ar IN biblio_current_article_requests %]
288                                     <tr>
289                                         <td>[% ar.created_on | $KohaDates %]</td>
290                                         <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber | uri %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
291                                         <td>[% ar.title | html %]</td>
292                                         <td>[% ar.author | html %]</td>
293                                         <td>[% ar.volume | html %]</td>
294                                         <td>[% ar.issue | html %]</td>
295                                         <td>[% ar.date | html %]</td>
296                                         <td>[% IF ar.toc_request %]Yes[% END %]</td>
297                                         <td>[% ar.pages | html %]</td>
298                                         <td>[% ar.chapters | html %]</td>
299                                         <td>[% ar.patron_notes | html %]</td>
300                                         <td>[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
301                                         <td>
302                                             [% IF ar.item %]
303                                                 <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber | uri %]&biblionumber=[% ar.biblionumber | uri %]">[% ar.item.barcode | html %]</a>
304                                             [% END %]
305                                         </td>
306                                         <td>
307                                             [% IF ar.status == 'PENDING' %]
308                                                 <span>Pending</span>
309                                             [% ELSIF ar.status == 'PROCESSING' %]
310                                                 <span>Processing</span>
311                                             [% ELSIF ar.status == 'REQUESTED' %]
312                                                 <span>New</span>
313                                             [% ELSIF ar.status == 'COMPLETED' %]
314                                                 <span>Completed</span>
315                                             [% ELSIF ar.status == 'CANCELED' %]
316                                                 <span>Canceled</span>
317                                             [% END %]
318                                         </td>
319                                         <td>
320                                             <i id="update-processing-[% ar.id | html %]" class="fa fa-cog fa-spin hidden"></i>
321                                             <select name="branchcode" id="branchcode-[% ar.id | html %]" class="ar-update-branchcode">
322                                                 [% FOREACH b IN Branches.all %]
323                                                     [% IF b.branchcode == ar.branchcode %]
324                                                         <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
325                                                     [% ELSE %]
326                                                         <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
327                                                     [% END %]
328                                                 [% END %]
329                                             </select>
330                                         </td>
331                                         <td>
332                                             <a title="Cancel article request" href="#" id="cancel-[% ar.id | html %]" class="ar-cancel-request">
333                                                 <i id="cancel-processing-spinner-[% ar.id | html %]" class="fa fa-cog fa-spin hide"></i>
334                                                 <i id="cancel-processing-[% ar.id | html %]" class="fa fa-times fa-lg" style="color:red"></i>
335                                             </a>
336                                         </td>
337                                     </tr>
338                                 [% END %]
339                             </table>
340                         </fieldset>
341                         [% PROCESS cancel_modal %]
342                     [% END %]
343
344             </main>
345         </div> <!-- /.col-sm-10.col-sm-push-2 -->
346
347         <div class="col-sm-2 col-sm-pull-10">
348             <aside>
349                 [% INCLUDE 'biblio-view-menu.inc' %]
350             </aside>
351         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
352      </div> <!-- /.row -->
353
354 [% MACRO jsinclude BLOCK %]
355     [% INCLUDE 'datatables.inc' %]
356
357     <script>
358         $('#current-article-requests').ready(function() {
359             $(".hide").hide();
360         });
361
362         $(document).ready(function() {
363
364             $( ".ar-update-branchcode" ).on('focus', function(){
365                 previous_branchcode = this.value;
366             }).on('change', function(){
367                 var branchcode = this.value;
368                 var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
369
370                 if ( c ) {
371                     var id = this.id.split("branchcode-")[1];
372                     $("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
373
374                     $.ajax({
375                         type: "POST",
376                         url: '/cgi-bin/koha/svc/article_request',
377                         data: {
378                             action: 'update_branchcode',
379                             id: id,
380                             branchcode: branchcode,
381                         },
382                         success: function( data ) {
383                             $("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
384                         },
385                         dataType: 'json'
386                     });
387
388                 } else {
389                     this.value = previous_branchcode;
390                 }
391             });
392
393             $('#modal-cancellation-reason').on('change', function(e) {
394                 let reason = $(this).val();
395                 $('#modal-notes').attr('disabled', !!reason);
396             })
397
398             let cancel_a;
399             $("#cancelModalConfirmBtn").on("click",function(e) {
400                 var id = cancel_a.attr('id').split("cancel-")[1];
401                 $("#cancel-processing-" + id ).hide('slow');
402                 $("#cancel-processing-spinner-" + id ).show('slow');
403
404                 let reason = $("#modal-cancellation-reason").val();
405                 let notes = $("#modal-notes").val();
406                 let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
407
408                 $.ajax({
409                     type: "DELETE",
410                     url: '/api/v1/article_requests/'+id+query,
411                     success: function( data ) {
412                         cancel_a.parents('tr').hide('slow');
413                     }
414                 });
415             });
416
417
418             $(".ar-cancel-request").on("click", function(){
419                 cancel_a = $(this);
420                 $('#cancelModal').modal();
421             });
422
423             // Initialize format(s)
424             var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | $raw %]";
425             if( !supported_formats.match(/PHOTOCOPY/) )
426                 $('#format option[value="PHOTOCOPY"]').remove();
427             if( !supported_formats.match(/SCAN/) )
428                 $('#format option[value="SCAN"]').remove();
429
430             if( $('#format option').length > 1 ) {
431             // Select first listed format
432                 var first_format = supported_formats.split('|')[0].replace(/^\s*|\s*$/g, '');
433                 $('#format option[value="'+first_format+'"]').attr('selected', true);
434             }
435         });
436     </script>
437
438     [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %]
439
440 [% END %]
441
442 [% INCLUDE 'intranet-bottom.inc' %]