Bug 20469: Add item status to staff article request form
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / article-requests.tt
1 [% USE KohaDates %]
2 [% USE ItemTypes %]
3 [% USE Branches %]
4 [% USE AuthorisedValues %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Circulation &rsaquo; Article requests</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <style> p { margin-top: 0; } [id^="article-menu-"] { display: none; } [id^="article-menu-"]:before { content: "|"; }</style>
10 </head>
11
12 [% BLOCK actions %]
13     <div id="[% menuid | html %]" class="btn-group dropup">
14         <a class="btn btn-default btn-xs dropdown-toggle ar-actions" role="button" data-toggle="dropdown" href="#">
15             Actions <b class="caret"></b>
16         </a>
17
18         <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
19             <li>
20                 <a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;">
21                     <i class="fa fa-cog"></i>
22                     Process request
23                 </a>
24
25                 <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
26                     <i class="fa fa-check-circle"></i>
27                     Complete request
28                 </a>
29
30                 <a class="ar-cancel-request" href="#" onclick="HandleMulti( Cancel, [% id_arg | html %], $(this) ); return false;">
31                     <i class="fa fa-minus-circle"></i>
32                     Cancel request
33                 </a>
34
35                 [% IF id_arg %][%# TODO: Does not work with multi-select %]
36                 <a class="ar-print-request" href="#" onclick="HandleMulti( PrintSlip, [% id_arg | html %], $(this) ); return false;">
37                     <i class="fa fa-print"></i>
38                     Print slip
39                 </a>
40                 [% END %]
41             </li>
42         </ul>
43     </div>
44 [% END %]
45 [% BLOCK item_status %]
46     [% IF myitem.onloan %]<span>Checked out</span>
47     [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span>
48     [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span>
49     [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
50     [% END %]
51 [% END %]
52
53 <body id="circ_article-requests" class="circ">
54     [% INCLUDE 'header.inc' %]
55     [% INCLUDE 'cat-search.inc' %]
56
57     <div id="breadcrumbs">
58         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
59         &rsaquo;
60         <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
61         &rsaquo;
62         <a href="/cgi-bin/koha/circ/article-requests.pl">Article requests</a>
63     </div>
64
65     <div class="main container-fluid">
66         <div class="row">
67             <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
68
69                 <h1>Article requests</h1>
70
71                 <form id="ar-branchcode-form" method="post">
72                     <select name="branchcode" id="branchcode">
73                         <option value="">All libraries</option>
74                         [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
75                             [% IF b.branchcode == branchcode %]
76                                 <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
77                             [% ELSE %]
78                                 <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
79                             [% END %]
80                         [% END %]
81                     </select>
82                     <button type="submit" class="btn btn-default btn-xs">
83                         <i class="fa fa-refresh"></i> Update
84                     </button>
85                 </form>
86
87                 <div id="article-request-tabs" class="toptabs">
88                     <ul>
89                         <li>
90                             <a href="#article-requests-pending">
91                                 Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
92                             </a>
93                         </li>
94
95                         <li>
96                             <a href="#article-requests-processing">
97                                 Processing (<span id="ar_processing_count">[% article_requests_processing.count | html %]</span>)
98                             </a>
99                         </li>
100                     </ul>
101
102                     <div id="article-requests-pending">
103                         <div class="article-requests-pending_table_controls">
104                             <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
105                             [% PROCESS actions menuid='article-menu-pending' id_arg=0 pull_right='' aria_menu='table_controls' %]
106                         </div>
107
108                         <table id="article-requests-pending-table">
109                             <thead>
110                                 <tr>
111                                     <th/>
112                                     <th class="ar-title">Title</th>
113                                     <th class="ar-request">Requested article</th>
114                                     <th class="ar-collection">Collection</th>
115                                     <th class="ar-itemtype">Item type</th>
116                                     <th class="ar-callnumber">Call number</th>
117                                     <th class="ar-status">Status</th>
118                                     <th class="ar-copynumber">Copy number</th>
119                                     <th class="ar-enumchron">Enumeration</th>
120                                     <th class="ar-barcode">Barcode</th>
121                                     <th class="ar-patron">Patron</th>
122                                     <th class="ar-date">Date</th>
123                                     <th class="ar-actions">Actions</th>
124                                 </tr>
125                             </thead>
126
127                              <tbody>
128                                 <tr class="ar-pending-none">
129                                     <td colspan="12">
130                                         There are no pending article requests at this time.
131                                     </td>
132                                 </tr>
133
134                                 [% FOREACH ar IN article_requests_pending %]
135                                     <tr class="ar-row ar-pending">
136                                         <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
137                                         <td class="ar-title">
138                                             <p>
139                                                 <a href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
140                                                     [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
141                                                 </a>
142                                             </p>
143
144                                             <p>
145                                                 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
146                                                 <div class="ar-author">[% ar.biblio.author | html %]</div>
147                                                 <div class="ar-pubdata">
148                                                     [% ar.biblio.biblioitem.publishercode | html %]
149
150                                                     [% IF ar.biblio.biblioitem.publicationyear %]
151                                                         [% ar.biblio.biblioitem.publicationyear | html %]
152                                                     [% ELSIF ar.biblio.copyrightdate %]
153                                                         [% ar.biblio.copyrightdate | html %]
154                                                     [% END %]
155
156                                                     [% IF ar.biblio.biblioitem.pages %]
157                                                         : [% ar.biblio.biblioitem.pages | html %]
158                                                     [% END %]
159
160                                                     [% r.biblio.biblioitem.size | html %]
161
162                                                     [% IF ar.biblio.biblioitem.isbn %]
163                                                         ISBN: [% ar.biblio.biblioitem.isbn | html %]
164                                                     [% END %]
165                                                 </div>
166                                             </p>
167                                         </td>
168                                         <td class="ar-request">
169                                             [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
170                                             [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
171                                             [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
172                                             [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
173                                             [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
174                                             [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
175                                             [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
176                                             [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
177                                         </td>
178                                         <td class="ar-collection">[% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) | html %]</td>
179                                         <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
180                                         <td class="ar-callnumber">
181                                             [% IF ar.item.location %]
182                                                 <em>[% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) | html %]</em>
183                                             [% END %]
184
185                                             [% ar.item.itemcallnumber | html %]
186                                         </td>
187                                         <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
188                                         <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
189                                         <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
190                                         <td class="ar-barcode">[% ar.item.barcode | html %]</td>
191                                         <td class="ar-patron">
192                                             <p>
193                                                 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
194                                                     [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
195                                                 </a>
196                                             </p>
197
198                                             <p>[% ar.borrower.phone | html %]</p>
199                                         </td>
200                                         <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
201                                         <td class="ar-actions">
202                                             [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
203                                         </td>
204                                     </tr>
205                                 [% END %]
206                             </tbody>
207                         </table>
208                     </div>
209
210                     <div id="article-requests-processing">
211                         <div class="article-requests-processing_table_controls">
212                             <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
213                             [% PROCESS actions menuid='article-menu-processing' id_arg=0 pull_right='' aria_menu='table_controls' %]
214                         </div>
215                         <table id="article-requests-processing-table">
216                             <thead>
217                                 <tr>
218                                     <th/>
219                                     <th class="ar-title">Title</th>
220                                     <th class="ar-request">Requested article</th>
221                                     <th class="ar-collection">Collection</th>
222                                     <th class="ar-itemtype">Item type</th>
223                                     <th class="ar-callnumber">Call number</th>
224                                     <th class="ar-status">Status</th>
225                                     <th class="ar-copynumber">Copy number</th>
226                                     <th class="ar-enumchron">Enumeration</th>
227                                     <th class="ar-barcode">Barcode</th>
228                                     <th class="ar-patron">Patron</th>
229                                     <th class="ar-date">Date</th>
230                                     <th class="ar-actions">Actions</th>
231                                 </tr>
232                             </thead>
233
234                              <tbody>
235                                 <tr class="ar-processing-none">
236                                     <td colspan="12">
237                                         There are no article requests in processing at this time.
238                                     </td>
239                                 </tr>
240
241                                 [% FOREACH ar IN article_requests_processing %]
242                                     <tr class="ar-row ar-processing">
243                                         <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
244                                         <td class="ar-title">
245                                             <p>
246                                                 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% ar.biblionumber | uri %]">
247                                                     [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
248                                                 </a>
249                                             </p>
250
251                                             <p>
252                                                 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
253                                                 <div class="ar-author">[% ar.biblio.author | html %]</div>
254                                                 <div class="ar-pubdata">
255                                                     [% ar.biblio.biblioitem.publishercode | html %]
256
257                                                     [% IF ar.biblio.biblioitem.publicationyear %]
258                                                         [% ar.biblio.biblioitem.publicationyear | html %]
259                                                     [% ELSIF ar.biblio.copyrightdate %]
260                                                         [% ar.biblio.copyrightdate | html %]
261                                                     [% END %]
262
263                                                     [% IF ar.biblio.biblioitem.pages %]
264                                                         : [% ar.biblio.biblioitem.pages | html %]
265                                                     [% END %]
266
267                                                     [% r.biblio.biblioitem.size | html %]
268
269                                                     [% IF ar.biblio.biblioitem.isbn %]
270                                                         ISBN: [% ar.biblio.biblioitem.isbn | html %]
271                                                     [% END %]
272                                                 </div>
273                                             </p>
274                                         </td>
275                                         <td class="ar-request">
276                                             [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
277                                             [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
278                                             [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
279                                             [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
280                                             [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
281                                             [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
282                                             [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
283                                             [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
284                                         </td>
285                                         <td class="ar-collection">[% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) | html %]</td>
286                                         <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
287                                         <td class="ar-callnumber">
288                                             [% IF ar.item.location %]
289                                                 <em>[% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) | html %]</em>
290                                             [% END %]
291
292                                             [% ar.item.itemcallnumber | html %]
293                                         </td>
294                                         <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
295                                         <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
296                                         <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
297                                         <td class="ar-barcode">[% ar.item.barcode | html %]</td>
298                                         <td class="ar-patron">
299                                             <p>
300                                                 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
301                                                     [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
302                                                 </a>
303                                             </p>
304
305                                             <p>[% ar.borrower.phone | html %]</p>
306                                         </td>
307                                         <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
308                                         <td class="ar-actions">
309                                             [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
310                                         </td>
311                                     </tr>
312                                 [% END %]
313                             </tbody>
314                         </table>
315                     </div>
316                     <br/>
317                 </div>
318             </div>
319         </div>
320     </div>
321
322 [% MACRO jsinclude BLOCK %]
323     <script>
324         var active_table = "#article-requests-pending";
325         var last_cancel_reason;
326         $(document).ready(function() {
327             $('#article-request-tabs').tabs({
328                 activate: function( activate_event, activate_ui ) {
329                     active_table = activate_ui.newPanel.selector;
330                     activateBatchActions( active_table );
331                 },
332                 create: function( create_event, create_ui ){
333                     active_table = create_ui.panel.selector;
334                 },
335             });
336
337             activateBatchActions( active_table );
338
339             [% IF article_requests_pending.count %]
340                 $(".ar-pending-none").hide();
341             [% END %]
342
343             [% IF article_requests_processing.count %]
344                 $(".ar-processing-none").hide();
345             [% END %]
346
347             $( "input:checkbox", active_table ).on("change", function(){
348                 activateBatchActions( active_table );
349             });
350
351             $(".SelectAll").on("click", function(e) {
352                 e.preventDefault();
353                 $( active_table + " input[type='checkbox']").prop('checked', true);
354                 activateBatchActions( active_table );
355             });
356             $(".ClearAll").on("click", function(e) {
357                 e.preventDefault();
358                 $( active_table + " input[type='checkbox']").prop('checked', false);
359                 activateBatchActions( active_table );
360             });
361             $("a.ar-actions").on('click', function(e) {
362                 // Hide menu option ?
363                 if( $('#article-requests-processing-table').is(":visible") )
364                     $('a.ar-process-request').hide();
365                 else $('a.ar-process-request').show();
366             });
367         });
368
369         function activateBatchActions( active_table ){
370             // Check to see whether batch menu should be shown based on state of checkboxes
371             if ( $( "input:checkbox", active_table ).length > 0 ) {
372                 // There are rows with checkboxes
373                 $( "[class$='_table_controls']", active_table ).show();
374                 if ( $( "input:checkbox:checked", active_table ).length > 0 ) {
375                     $( "[id^='article-menu-']", active_table ).css("display","inline-block");
376                 } else {
377                     $( "[id^='article-menu-']", active_table ).hide();
378                 }
379             } else {
380                 // All rows have been removed
381                 $("[class$='_table_controls']", active_table ).hide();
382             }
383         }
384
385         function HandleMulti( fnHandler, id, a ) {
386             last_cancel_reason = undefined;
387             if( id !== 0 ) { fnHandler( id, a ); return; }
388             $( active_table + " input[type='checkbox']:checked").each(function() {
389                 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
390             });
391         }
392
393         function PrintSlip(id, a) {
394             var link = 'article-request-slip.pl?id='+id;
395             window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
396         }
397
398         function Cancel( id, a ) {
399             // last_cancel_reason: undefined means 'prompt for new reason'
400             // a null value indicates that prompt was cancelled
401             if( last_cancel_reason === undefined ) last_cancel_reason = prompt(_("Please specify the reason for cancelling selected item(s):"));
402             if ( last_cancel_reason === null ) {
403                 return;
404             }
405
406             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
407             $.ajax({
408                 type: "POST",
409                 url: '/cgi-bin/koha/svc/article_request',
410                 data: {
411                     action: 'cancel',
412                     id: id,
413                     notes: last_cancel_reason
414                 },
415                 success: function( data ) {
416                     a.closest('tr').remove();
417                     UpdateTabCounts();
418                     activateBatchActions( active_table );
419                 },
420                 dataType: 'json'
421             });
422         }
423
424         function Process( id, a ) {
425             var table_row = a.closest('tr').clone();
426             table_row.find('.ar-process-request').remove();
427             table_row.find('input[type="checkbox"]').prop('checked', false);
428
429             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
430             $.ajax({
431                 type: "POST",
432                 url: '/cgi-bin/koha/svc/article_request',
433                 data: {
434                     action: 'process',
435                     id: id,
436                 },
437                 success: function( data ) {
438                     a.closest('tr').remove();
439                     $("#article-requests-processing-table").append( table_row );
440                     $("#article-requests-processing-table .ar-processing-none").hide();
441                     UpdateTabCounts();
442                     activateBatchActions( active_table );
443                 },
444                 dataType: 'json'
445             });
446         }
447
448         function Complete( id, a ) {
449             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
450             $.ajax({
451                 type: "POST",
452                 url: '/cgi-bin/koha/svc/article_request',
453                 data: {
454                     action: 'complete',
455                     id: id,
456                 },
457                 success: function( data ) {
458                     a.closest('tr').remove();
459                     UpdateTabCounts();
460                     activateBatchActions( active_table );
461                 },
462                 dataType: 'json'
463             });
464         }
465
466         function UpdateTabCounts() {
467             var pending_count = $('#article-requests-pending-table tbody tr.ar-row').length;
468             $("#ar_pending_count").html( pending_count );
469             if ( pending_count == 0 ) $(".ar-pending-none").show();
470
471             var processing_count = $('#article-requests-processing-table tbody tr.ar-row').length;
472             $("#ar_processing_count").html( processing_count );
473             if ( processing_count == 0 ) $(".ar-processing-none").show();
474         }
475     </script>
476 [% END %]
477
478 [% INCLUDE 'intranet-bottom.inc' %]