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