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