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