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