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