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