4 [% USE AuthorisedValues %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Article requests › Circulation › 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>
15 <div id="[% menuid | html %]" class="btn-group dropup">
17 <a class="btn btn-default btn-xs dropdown-toggle ar-actions" role="button" data-toggle="dropdown" href="#">
18 Actions <b class="caret"></b>
21 <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
23 <a class="ar-set-pending-request" href="#" onclick="HandleMulti( SetPending, [% id_arg | html %], $(this) ); return false;">
24 <i class="fa fa-bars"></i>
25 Set request as pending
28 <a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;">
29 <i class="fa fa-cog"></i>
33 [% IF id_arg && format=='SCAN' %]
34 <a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg | html %], $(this) ); return false;">
35 <i class="fa fa-edit"></i>
40 <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
41 <i class="fa fa-check-circle"></i>
45 <a class="ar-cancel-request" href="#" onclick="Cancel( [% id_arg | html %], $(this) ); return false;">
46 <i class="fa fa-minus-circle"></i>
50 [% IF id_arg %][%# TODO: Does not work with multi-select %]
51 <a class="ar-print-request" href="#" onclick="HandleMulti( PrintSlip, [% id_arg | html %], $(this) ); return false;">
52 <i class="fa fa-print"></i>
61 [% BLOCK item_status %]
62 [% IF myitem.onloan %]<span>Checked out</span>
63 [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span>
64 [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span>
65 [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
68 [% BLOCK urls_modal %]
69 <div id="myModal" class="modal fade modal-lg" role="dialog">
70 <div class="modal-dialog">
71 <div class="modal-content">
72 <div class="modal-header">
73 <h4 class="modal-title">Edit URL(s)</h4>
75 <div class="modal-body">
76 <textarea id="urls" style="width:100%;"></textarea>
78 <div class="modal-footer">
79 <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
85 [% BLOCK cancel_modal %]
86 <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
87 <div class="modal-dialog" role="document">
88 <div class="modal-content">
89 <div class="modal-header">
90 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
91 <h3>Confirm deletion</h3>
94 <div class="modal-body">
95 <p>Are you sure you want to cancel this article request?</p>
97 <fieldset class="action">
98 [% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
99 [% IF ar_cancellation %]
100 <label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
101 <select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
102 <option value="" selected>Other reasons</option>
103 [% FOREACH reason IN ar_cancellation %]
104 <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
109 <fieldset class="action">
110 <div class="hint col-sm-offset-4">Enter reason</div>
111 <input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
115 <div class="modal-footer">
116 <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
117 <a href="#" data-dismiss="modal">Cancel</a>
124 <body id="circ_article-requests" class="circ">
125 [% INCLUDE 'header.inc' %]
126 [% INCLUDE 'cat-search.inc' %]
129 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
132 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
135 <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
138 <a href="#" aria-current="page">Article requests</a>
143 <div class="main container-fluid starthidden">
145 <div class="col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
147 <h1>Article requests</h1>
148 [% PROCESS urls_modal %]
150 <form id="ar-branchcode-form" method="post">
151 <select name="branchcode" id="branchcode">
152 <option value="">All libraries</option>
153 [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
154 [% IF b.branchcode == branchcode %]
155 <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
157 <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
161 <button type="submit" class="btn btn-default btn-xs">
162 <i class="fa fa-refresh"></i> Update
166 <div id="article-request-tabs" class="toptabs">
169 <a href="#article-requests-requested">
170 New (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
175 <a href="#article-requests-pending">
176 Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
181 <a href="#article-requests-processing">
182 Processing (<span id="ar_processing_count">[% article_requests_processing.count | html %]</span>)
187 <div id="article-requests-requested">
188 <div class="article-requests-requested_table_controls">
189 <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>
190 [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
193 <table id="article-requests-requested-table">
197 <th class="ar-title">Title</th>
198 <th class="ar-request">Requested article</th>
199 <th class="ar-collection">Collection</th>
200 <th class="ar-itemtype">Item type</th>
201 <th class="ar-callnumber">Call number</th>
202 <th class="ar-status">Status</th>
203 <th class="ar-copynumber">Copy number</th>
204 <th class="ar-enumchron">Enumeration</th>
205 <th class="ar-barcode">Barcode</th>
206 <th class="ar-format">Format</th>
207 <th class="ar-urls">URLs</th>
208 <th class="ar-patron">Patron</th>
209 <th class="ar-date">Date</th>
210 <th class="ar-actions noExport">Actions</th>
215 [% FOREACH ar IN article_requests_requested %]
216 <tr class="ar-row ar-requested">
217 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
218 <td class="ar-title">
220 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
221 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
226 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
227 <div class="ar-author">[% ar.biblio.author | html %]</div>
228 <div class="ar-pubdata">
229 [% ar.biblio.biblioitem.publishercode | html %]
231 [% IF ar.biblio.biblioitem.publicationyear %]
232 [% ar.biblio.biblioitem.publicationyear | html %]
233 [% ELSIF ar.biblio.copyrightdate %]
234 [% ar.biblio.copyrightdate | html %]
237 [% IF ar.biblio.biblioitem.pages %]
238 : [% ar.biblio.biblioitem.pages | html %]
241 [% r.biblio.biblioitem.size | html %]
243 [% IF ar.biblio.biblioitem.isbn %]
244 ISBN: [% ar.biblio.biblioitem.isbn | html %]
249 <td class="ar-request">
250 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
251 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
252 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
253 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
254 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
255 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
256 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
257 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
259 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
260 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
261 <td class="ar-callnumber">
262 [% IF ar.item.location %]
263 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
266 [% ar.item.itemcallnumber | html %]
268 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
269 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
270 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
271 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
272 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
273 <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
274 <td class="ar-patron">
276 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
277 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
281 <p>[% ar.borrower.phone | html %]</p>
283 <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
284 <td class="ar-actions">
285 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
293 <div id="article-requests-pending">
294 <div class="article-requests-pending_table_controls">
295 <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>
296 [% PROCESS actions menuid='article-menu-pending' id_arg=0 pull_right='' aria_menu='table_controls' %]
299 <table id="article-requests-pending-table">
303 <th class="ar-title">Title</th>
304 <th class="ar-request">Requested article</th>
305 <th class="ar-collection">Collection</th>
306 <th class="ar-itemtype">Item type</th>
307 <th class="ar-callnumber">Call number</th>
308 <th class="ar-status">Status</th>
309 <th class="ar-copynumber">Copy number</th>
310 <th class="ar-enumchron">Enumeration</th>
311 <th class="ar-barcode">Barcode</th>
312 <th class="ar-format">Format</th>
313 <th class="ar-urls">URLs</th>
314 <th class="ar-patron">Patron</th>
315 <th class="ar-date">Date</th>
316 <th class="ar-actions noExport">Actions</th>
321 [% FOREACH ar IN article_requests_pending %]
322 <tr class="ar-row ar-pending">
323 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
324 <td class="ar-title">
326 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
327 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
332 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
333 <div class="ar-author">[% ar.biblio.author | html %]</div>
334 <div class="ar-pubdata">
335 [% ar.biblio.biblioitem.publishercode | html %]
337 [% IF ar.biblio.biblioitem.publicationyear %]
338 [% ar.biblio.biblioitem.publicationyear | html %]
339 [% ELSIF ar.biblio.copyrightdate %]
340 [% ar.biblio.copyrightdate | html %]
343 [% IF ar.biblio.biblioitem.pages %]
344 : [% ar.biblio.biblioitem.pages | html %]
347 [% r.biblio.biblioitem.size | html %]
349 [% IF ar.biblio.biblioitem.isbn %]
350 ISBN: [% ar.biblio.biblioitem.isbn | html %]
355 <td class="ar-request">
356 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
357 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
358 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
359 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
360 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
361 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
362 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
363 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
365 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
366 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
367 <td class="ar-callnumber">
368 [% IF ar.item.location %]
369 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
372 [% ar.item.itemcallnumber | html %]
374 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
375 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
376 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
377 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
378 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
379 <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
380 <td class="ar-patron">
382 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
383 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
387 <p>[% ar.borrower.phone | html %]</p>
389 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
390 <td class="ar-actions">
391 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
399 <div id="article-requests-processing">
400 <div class="article-requests-processing_table_controls">
401 <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>
402 [% PROCESS actions menuid='article-menu-processing' id_arg=0 pull_right='' aria_menu='table_controls' %]
404 <table id="article-requests-processing-table">
408 <th class="ar-title">Title</th>
409 <th class="ar-request">Requested article</th>
410 <th class="ar-collection">Collection</th>
411 <th class="ar-itemtype">Item type</th>
412 <th class="ar-callnumber">Call number</th>
413 <th class="ar-status">Status</th>
414 <th class="ar-copynumber">Copy number</th>
415 <th class="ar-enumchron">Enumeration</th>
416 <th class="ar-barcode">Barcode</th>
417 <th class="ar-format">Format</th>
418 <th class="ar-urls">URLs</th>
419 <th class="ar-patron">Patron</th>
420 <th class="ar-date">Date</th>
421 <th class="ar-actions noExport">Actions</th>
426 [% FOREACH ar IN article_requests_processing %]
427 <tr class="ar-row ar-processing">
428 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
429 <td class="ar-title">
431 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio link = 1%]
435 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
436 <div class="ar-author">[% ar.biblio.author | html %]</div>
437 <div class="ar-pubdata">
438 [% ar.biblio.biblioitem.publishercode | html %]
440 [% IF ar.biblio.biblioitem.publicationyear %]
441 [% ar.biblio.biblioitem.publicationyear | html %]
442 [% ELSIF ar.biblio.copyrightdate %]
443 [% ar.biblio.copyrightdate | html %]
446 [% IF ar.biblio.biblioitem.pages %]
447 : [% ar.biblio.biblioitem.pages | html %]
450 [% r.biblio.biblioitem.size | html %]
452 [% IF ar.biblio.biblioitem.isbn %]
453 ISBN: [% ar.biblio.biblioitem.isbn | html %]
458 <td class="ar-request">
459 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
460 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
461 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
462 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
463 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
464 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
465 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
466 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
468 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
469 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
470 <td class="ar-callnumber">
471 [% IF ar.item.location %]
472 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
475 [% ar.item.itemcallnumber | html %]
477 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
478 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
479 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
480 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
481 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
482 <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
483 <td class="ar-patron">
485 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
486 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
490 <p>[% ar.borrower.phone | html %]</p>
492 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
493 <td class="ar-actions">
494 [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
506 [% PROCESS cancel_modal %]
508 [% MACRO jsinclude BLOCK %]
509 [% INCLUDE 'datatables.inc' %]
511 var active_tab = "#article-requests-requested";
512 var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
513 $(document).ready(function() {
514 $('#article-request-tabs').tabs({
515 activate: function( activate_event, activate_ui ) {
516 active_tab = activate_ui.newPanel.selector;
517 if( active_tab == '#article-requests-requested' )
518 active_datatable = requested_datatable;
519 else if( active_tab == '#article-requests-pending' )
520 active_datatable = pending_datatable;
521 else active_datatable = processing_datatable;
522 activateBatchActions( active_tab );
527 $( "input:checkbox, #article-request-tabs" ).on("change", function(){
528 activateBatchActions( active_tab );
531 $(".SelectAll").on("click", function(e) {
533 $( active_tab + " input[type='checkbox']").prop('checked', true);
534 activateBatchActions( active_tab );
536 $(".ClearAll").on("click", function(e) {
538 $( active_tab + " input[type='checkbox']").prop('checked', false);
539 activateBatchActions( active_tab );
541 $("a.ar-actions").on('click', function(e) {
542 // Hide menu option ?
543 if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
544 $('a.ar-process-request').show();
545 else $('a.ar-process-request').hide();
547 if( $('#article-requests-requested-table').is(":visible") )
548 $('a.ar-set-pending-request').show();
549 else $('a.ar-set-pending-request').hide();
552 $('#myModal').on("shown.bs.modal", function () {
553 $('#myModal textarea').focus();
555 $('#myModal').on("hidden.bs.modal", function () {
556 // Set focus back to dropdown
557 var id = $('#myModal textarea').attr('ar_id');
558 var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
559 if( link.length > 0 ) link[0].focus();
561 $( '#myModal button' ).on("click", function () {
562 SaveURLs( $('#myModal textarea').val() );
565 requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
567 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
571 pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
573 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
576 processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
578 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
581 active_datatable = requested_datatable;
582 activateBatchActions( active_tab );
583 $(".starthidden").show();
586 function activateBatchActions( active_tab ){
587 // Check to see whether batch menu should be shown based on state of checkboxes
588 if ( $( "input:checkbox", active_tab ).length > 0 ) {
589 // There are rows with checkboxes
590 $( "[class$='_table_controls']", active_tab ).show();
591 if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
592 $( "[id^='article-menu-']", active_tab ).css("display","inline-block");
594 $( "[id^='article-menu-']", active_tab ).hide();
597 // All rows have been removed
598 $("[class$='_table_controls']", active_tab ).hide();
602 function HandleMulti( fnHandler, id, a ) {
603 last_cancel_reason = undefined;
604 if( id !== 0 ) { fnHandler( id, a ); return; }
605 $( active_tab + " input[type='checkbox']:checked").each(function() {
606 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
610 function PrintSlip(id, a) {
611 var link = 'article-request-slip.pl?id='+id;
612 window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
615 $('#modal-cancellation-reason').on('change', function(e) {
616 let reason = $(this).val();
617 $('#modal-notes').attr('disabled', !!reason);
620 // Confirm cancellation of article requests
623 $("#cancelModalConfirmBtn").on("click",function(e) {
624 let reason = $("#modal-cancellation-reason").val();
625 let notes = $("#modal-notes").val();
626 let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
628 HandleMulti(function(id, a) {
629 var table_row = a.closest('tr');
630 table_row.find('.ar-process-request').remove();
631 table_row.find('input[type="checkbox"]').prop('checked', false);
634 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
638 url: '/api/v1/article_requests/'+id+query,
639 success: function( data ) {
640 active_datatable.row( a.closest('tr') ).remove().draw();
642 activateBatchActions( active_tab );
645 }, cancel_id, cancel_a)
648 function Cancel( id, a ) {
652 $('#cancelModal').modal();
655 function SetPending( id, a ) {
656 var table_row = a.closest('tr');
657 table_row.find('.ar-set-pending-request').remove();
658 table_row.find('input[type="checkbox"]').prop('checked', false);
659 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
662 url: '/cgi-bin/koha/svc/article_request',
667 success: function( data ) {
668 $("img.spinner").remove();
669 requested_datatable.row( table_row ).remove().draw();
670 pending_datatable.row.add( table_row ).draw();
672 activateBatchActions( active_tab );
678 function Process( id, a ) {
679 var table_row = a.closest('tr');
680 var table = a.closest('table');
681 var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
682 table_row.find('.ar-process-request').remove();
683 table_row.find('input[type="checkbox"]').prop('checked', false);
685 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
688 url: '/cgi-bin/koha/svc/article_request',
693 success: function( data ) {
694 $("img.spinner").remove();
695 orig_datatable.row( table_row ).remove().draw();
696 processing_datatable.row.add( table_row ).draw();
698 activateBatchActions( active_tab );
704 function Complete( id, a ) {
705 // if it is a scan, check if urls field is filled
706 var urlspan = $('span#url_'+id);
707 if( urlspan.length>0 && urlspan.text() === '' ) {
708 alert( _("Please fill URL before completing request.") );
711 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
714 url: '/cgi-bin/koha/svc/article_request',
719 success: function( data ) {
720 active_datatable.row( a.closest('tr') ).remove().draw();
722 activateBatchActions( active_tab );
728 function UpdateTabCounts() {
729 $("#ar_requested_count").html( requested_datatable.rows().count() );
730 $("#ar_pending_count").html( pending_datatable.rows().count() );
731 $("#ar_processing_count").html( processing_datatable.rows().count() );
734 function EditURLs(id) {
735 var urls = $('span#url_'+ id).text();
736 $('#myModal textarea').val(urls);
737 $('#myModal textarea').attr('ar_id', id);
738 $('#myModal').modal('show');
741 function SaveURLs(newurl) {
742 var id = $('#myModal textarea').attr('ar_id');
743 $('span#url_'+ id).text(newurl);
745 $('span#url_yesno_'+id).text(_("Yes"));
747 $('span#url_yesno_'+id).text(_("No"));
751 url: '/cgi-bin/koha/svc/article_request',
752 data: { action: 'update_urls', id: id, urls: newurl },
754 error: function() { alert('Error: Saving URL failed!'); },
755 success: function(data) { if(!data.success) alert('Saving URL failed!'); },
761 [% INCLUDE 'intranet-bottom.inc' %]