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>
51 <a class="ar-print-request" href="#" onclick="HandleMulti( PrintSlip, [% id_arg | html %], $(this) ); return false;">
52 <i class="fa fa-print"></i>
56 <a class="ar-print-request" href="#" onclick="PrintMultipleSlip(); return false;">
57 <i class="fa fa-print"></i>
67 [% BLOCK item_status %]
68 [% IF myitem.onloan %]<span>Checked out</span>
69 [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span>
70 [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span>
71 [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
74 [% BLOCK urls_modal %]
75 <div id="myModal" class="modal fade modal-lg" role="dialog">
76 <div class="modal-dialog">
77 <div class="modal-content">
78 <div class="modal-header">
79 <h4 class="modal-title">Edit URL(s)</h4>
81 <div class="modal-body">
82 <textarea id="urls" style="width:100%;"></textarea>
84 <div class="modal-footer">
85 <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
91 [% BLOCK cancel_modal %]
92 <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
93 <div class="modal-dialog" role="document">
94 <div class="modal-content">
95 <div class="modal-header">
96 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
97 <h3>Confirm deletion</h3>
100 <div class="modal-body">
101 <p>Are you sure you want to cancel this article request?</p>
103 <fieldset class="action">
104 [% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
105 [% IF ar_cancellation %]
106 <label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
107 <select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
108 <option value="" selected>Other reasons</option>
109 [% FOREACH reason IN ar_cancellation %]
110 <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
115 <fieldset class="action">
116 <div class="hint col-sm-offset-4">Enter reason</div>
117 <input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
121 <div class="modal-footer">
122 <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
123 <a href="#" data-dismiss="modal">Cancel</a>
130 <body id="circ_article-requests" class="circ">
131 [% INCLUDE 'header.inc' %]
132 [% INCLUDE 'cat-search.inc' %]
135 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
138 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
141 <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
144 <a href="#" aria-current="page">Article requests</a>
149 <div class="main container-fluid starthidden">
151 <div class="col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
153 <h1>Article requests</h1>
154 [% PROCESS urls_modal %]
156 <form id="ar-branchcode-form" method="post">
157 <select name="branchcode" id="branchcode">
158 <option value="">All libraries</option>
159 [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
160 [% IF b.branchcode == branchcode %]
161 <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
163 <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
167 <button type="submit" class="btn btn-default btn-xs">
168 <i class="fa fa-refresh"></i> Update
172 <div id="article-request-tabs" class="toptabs">
175 <a href="#article-requests-requested">
176 New (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
181 <a href="#article-requests-pending">
182 Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
187 <a href="#article-requests-processing">
188 Processing (<span id="ar_processing_count">[% article_requests_processing.count | html %]</span>)
193 <div id="article-requests-requested">
194 <div class="article-requests-requested_table_controls">
195 <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>
196 [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
199 <table id="article-requests-requested-table">
203 <th class="ar-title">Title</th>
204 <th class="ar-request">Requested article</th>
205 <th class="ar-collection">Collection</th>
206 <th class="ar-itemtype">Item type</th>
207 <th class="ar-callnumber">Call number</th>
208 <th class="ar-status">Status</th>
209 <th class="ar-copynumber">Copy number</th>
210 <th class="ar-enumchron">Enumeration</th>
211 <th class="ar-barcode">Barcode</th>
212 <th class="ar-format">Format</th>
213 <th class="ar-urls">URLs</th>
214 <th class="ar-patron">Patron</th>
215 <th class="ar-date">Date</th>
216 <th class="ar-actions noExport">Actions</th>
221 [% FOREACH ar IN article_requests_requested %]
222 <tr class="ar-row ar-requested">
223 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
224 <td class="ar-title">
226 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
227 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
232 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
233 <div class="ar-author">[% ar.biblio.author | html %]</div>
234 <div class="ar-pubdata">
235 [% ar.biblio.biblioitem.publishercode | html %]
237 [% IF ar.biblio.biblioitem.publicationyear %]
238 [% ar.biblio.biblioitem.publicationyear | html %]
239 [% ELSIF ar.biblio.copyrightdate %]
240 [% ar.biblio.copyrightdate | html %]
243 [% IF ar.biblio.biblioitem.pages %]
244 : [% ar.biblio.biblioitem.pages | html %]
247 [% r.biblio.biblioitem.size | html %]
249 [% IF ar.biblio.biblioitem.isbn %]
250 ISBN: [% ar.biblio.biblioitem.isbn | html %]
255 <td class="ar-request">
256 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
257 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
258 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
259 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
260 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
261 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
262 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
263 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
264 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
266 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
267 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
268 <td class="ar-callnumber">
269 [% IF ar.item.location %]
270 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
273 [% ar.item.itemcallnumber | html %]
275 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
276 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
277 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
278 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
279 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
280 <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>
281 <td class="ar-patron">
283 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
284 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
288 <p>[% ar.borrower.phone | html %]</p>
290 <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
291 <td class="ar-actions">
292 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
300 <div id="article-requests-pending">
301 <div class="article-requests-pending_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 menuid='article-menu-pending' id_arg=0 pull_right='' aria_menu='table_controls' %]
306 <table id="article-requests-pending-table">
310 <th class="ar-title">Title</th>
311 <th class="ar-request">Requested article</th>
312 <th class="ar-collection">Collection</th>
313 <th class="ar-itemtype">Item type</th>
314 <th class="ar-callnumber">Call number</th>
315 <th class="ar-status">Status</th>
316 <th class="ar-copynumber">Copy number</th>
317 <th class="ar-enumchron">Enumeration</th>
318 <th class="ar-barcode">Barcode</th>
319 <th class="ar-format">Format</th>
320 <th class="ar-urls">URLs</th>
321 <th class="ar-patron">Patron</th>
322 <th class="ar-date">Date</th>
323 <th class="ar-actions noExport">Actions</th>
328 [% FOREACH ar IN article_requests_pending %]
329 <tr class="ar-row ar-pending">
330 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
331 <td class="ar-title">
333 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
334 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
339 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
340 <div class="ar-author">[% ar.biblio.author | html %]</div>
341 <div class="ar-pubdata">
342 [% ar.biblio.biblioitem.publishercode | html %]
344 [% IF ar.biblio.biblioitem.publicationyear %]
345 [% ar.biblio.biblioitem.publicationyear | html %]
346 [% ELSIF ar.biblio.copyrightdate %]
347 [% ar.biblio.copyrightdate | html %]
350 [% IF ar.biblio.biblioitem.pages %]
351 : [% ar.biblio.biblioitem.pages | html %]
354 [% r.biblio.biblioitem.size | html %]
356 [% IF ar.biblio.biblioitem.isbn %]
357 ISBN: [% ar.biblio.biblioitem.isbn | html %]
362 <td class="ar-request">
363 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
364 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
365 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
366 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
367 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
368 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
369 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
370 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
371 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
373 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
374 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
375 <td class="ar-callnumber">
376 [% IF ar.item.location %]
377 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
380 [% ar.item.itemcallnumber | html %]
382 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
383 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
384 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
385 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
386 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
387 <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>
388 <td class="ar-patron">
390 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
391 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
395 <p>[% ar.borrower.phone | html %]</p>
397 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
398 <td class="ar-actions">
399 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
407 <div id="article-requests-processing">
408 <div class="article-requests-processing_table_controls">
409 <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>
410 [% PROCESS actions menuid='article-menu-processing' id_arg=0 pull_right='' aria_menu='table_controls' %]
412 <table id="article-requests-processing-table">
416 <th class="ar-title">Title</th>
417 <th class="ar-request">Requested article</th>
418 <th class="ar-collection">Collection</th>
419 <th class="ar-itemtype">Item type</th>
420 <th class="ar-callnumber">Call number</th>
421 <th class="ar-status">Status</th>
422 <th class="ar-copynumber">Copy number</th>
423 <th class="ar-enumchron">Enumeration</th>
424 <th class="ar-barcode">Barcode</th>
425 <th class="ar-format">Format</th>
426 <th class="ar-urls">URLs</th>
427 <th class="ar-patron">Patron</th>
428 <th class="ar-date">Date</th>
429 <th class="ar-actions noExport">Actions</th>
434 [% FOREACH ar IN article_requests_processing %]
435 <tr class="ar-row ar-processing">
436 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
437 <td class="ar-title">
439 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio link = 1%]
443 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
444 <div class="ar-author">[% ar.biblio.author | html %]</div>
445 <div class="ar-pubdata">
446 [% ar.biblio.biblioitem.publishercode | html %]
448 [% IF ar.biblio.biblioitem.publicationyear %]
449 [% ar.biblio.biblioitem.publicationyear | html %]
450 [% ELSIF ar.biblio.copyrightdate %]
451 [% ar.biblio.copyrightdate | html %]
454 [% IF ar.biblio.biblioitem.pages %]
455 : [% ar.biblio.biblioitem.pages | html %]
458 [% r.biblio.biblioitem.size | html %]
460 [% IF ar.biblio.biblioitem.isbn %]
461 ISBN: [% ar.biblio.biblioitem.isbn | html %]
466 <td class="ar-request">
467 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
468 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
469 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
470 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
471 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
472 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
473 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
474 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
475 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
477 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
478 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
479 <td class="ar-callnumber">
480 [% IF ar.item.location %]
481 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
484 [% ar.item.itemcallnumber | html %]
486 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
487 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
488 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
489 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
490 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
491 <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>
492 <td class="ar-patron">
494 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
495 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
499 <p>[% ar.borrower.phone | html %]</p>
501 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
502 <td class="ar-actions">
503 [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
515 [% PROCESS cancel_modal %]
517 [% MACRO jsinclude BLOCK %]
518 [% INCLUDE 'datatables.inc' %]
520 var active_tab = "#article-requests-requested";
521 var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
522 $(document).ready(function() {
523 $('#article-request-tabs').tabs({
524 activate: function( activate_event, activate_ui ) {
525 active_tab = activate_ui.newPanel.selector;
526 if( active_tab == '#article-requests-requested' )
527 active_datatable = requested_datatable;
528 else if( active_tab == '#article-requests-pending' )
529 active_datatable = pending_datatable;
530 else active_datatable = processing_datatable;
531 activateBatchActions( active_tab );
536 $( "input:checkbox, #article-request-tabs" ).on("change", function(){
537 activateBatchActions( active_tab );
540 $(".SelectAll").on("click", function(e) {
542 $( active_tab + " input[type='checkbox']").prop('checked', true);
543 activateBatchActions( active_tab );
545 $(".ClearAll").on("click", function(e) {
547 $( active_tab + " input[type='checkbox']").prop('checked', false);
548 activateBatchActions( active_tab );
550 $("a.ar-actions").on('click', function(e) {
551 // Hide menu option ?
552 if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
553 $('a.ar-process-request').show();
554 else $('a.ar-process-request').hide();
556 if( $('#article-requests-requested-table').is(":visible") )
557 $('a.ar-set-pending-request').show();
558 else $('a.ar-set-pending-request').hide();
561 $('#myModal').on("shown.bs.modal", function () {
562 $('#myModal textarea').focus();
564 $('#myModal').on("hidden.bs.modal", function () {
565 // Set focus back to dropdown
566 var id = $('#myModal textarea').attr('ar_id');
567 var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
568 if( link.length > 0 ) link[0].focus();
570 $( '#myModal button' ).on("click", function () {
571 SaveURLs( $('#myModal textarea').val() );
574 requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
576 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
580 pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
582 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
585 processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
587 { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
590 active_datatable = requested_datatable;
591 activateBatchActions( active_tab );
592 $(".starthidden").show();
595 function activateBatchActions( active_tab ){
596 // Check to see whether batch menu should be shown based on state of checkboxes
597 if ( $( "input:checkbox", active_tab ).length > 0 ) {
598 // There are rows with checkboxes
599 $( "[class$='_table_controls']", active_tab ).show();
600 if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
601 $( "[id^='article-menu-']", active_tab ).css("display","inline-block");
603 $( "[id^='article-menu-']", active_tab ).hide();
606 // All rows have been removed
607 $("[class$='_table_controls']", active_tab ).hide();
611 function HandleMulti( fnHandler, id, a ) {
612 last_cancel_reason = undefined;
613 if( id !== 0 ) { fnHandler( id, a ); return; }
614 $( active_tab + " input[type='checkbox']:checked").each(function() {
615 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
619 function PrintSlip(id, a) {
620 var link = 'article-request-slip.pl?id='+id;
621 window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
624 $('#modal-cancellation-reason').on('change', function(e) {
625 let reason = $(this).val();
626 $('#modal-notes').attr('disabled', !!reason);
629 // Confirm cancellation of article requests
632 $("#cancelModalConfirmBtn").on("click",function(e) {
633 let reason = $("#modal-cancellation-reason").val();
634 let notes = $("#modal-notes").val();
635 let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
637 HandleMulti(function(id, a) {
638 var table_row = a.closest('tr');
639 table_row.find('.ar-process-request').remove();
640 table_row.find('input[type="checkbox"]').prop('checked', false);
643 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
647 url: '/api/v1/article_requests/'+id+query,
648 success: function( data ) {
649 active_datatable.row( a.closest('tr') ).remove().draw();
651 activateBatchActions( active_tab );
654 }, cancel_id, cancel_a)
657 function PrintMultipleSlip() {
659 $( active_tab + " input[type='checkbox']:checked").each(function() {
660 ids.push($(this).attr('reqid'));
662 var link = 'article-request-slip.pl?multi=1&id='+ids.join(',');
663 window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
667 function Cancel( id, a ) {
671 $('#cancelModal').modal();
674 function SetPending( id, a ) {
675 var table_row = a.closest('tr');
676 table_row.find('.ar-set-pending-request').remove();
677 table_row.find('input[type="checkbox"]').prop('checked', false);
678 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
681 url: '/cgi-bin/koha/svc/article_request',
686 success: function( data ) {
687 $("img.spinner").remove();
688 requested_datatable.row( table_row ).remove().draw();
689 pending_datatable.row.add( table_row ).draw();
691 activateBatchActions( active_tab );
697 function Process( id, a ) {
698 var table_row = a.closest('tr');
699 var table = a.closest('table');
700 var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
701 table_row.find('.ar-process-request').remove();
702 table_row.find('input[type="checkbox"]').prop('checked', false);
704 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
707 url: '/cgi-bin/koha/svc/article_request',
712 success: function( data ) {
713 $("img.spinner").remove();
714 orig_datatable.row( table_row ).remove().draw();
715 processing_datatable.row.add( table_row ).draw();
717 activateBatchActions( active_tab );
723 function Complete( id, a ) {
724 // if it is a scan, check if urls field is filled
725 var urlspan = $('span#url_'+id);
726 if( urlspan.length>0 && urlspan.text() === '' ) {
727 alert( _("Please fill URL before completing request.") );
730 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
733 url: '/cgi-bin/koha/svc/article_request',
738 success: function( data ) {
739 active_datatable.row( a.closest('tr') ).remove().draw();
741 activateBatchActions( active_tab );
747 function UpdateTabCounts() {
748 $("#ar_requested_count").html( requested_datatable.rows().count() );
749 $("#ar_pending_count").html( pending_datatable.rows().count() );
750 $("#ar_processing_count").html( processing_datatable.rows().count() );
753 function EditURLs(id) {
754 var urls = $('span#url_'+ id).text();
755 $('#myModal textarea').val(urls);
756 $('#myModal textarea').attr('ar_id', id);
757 $('#myModal').modal('show');
760 function SaveURLs(newurl) {
761 var id = $('#myModal textarea').attr('ar_id');
762 $('span#url_'+ id).text(newurl);
764 $('span#url_yesno_'+id).text(_("Yes"));
766 $('span#url_yesno_'+id).text(_("No"));
770 url: '/cgi-bin/koha/svc/article_request',
771 data: { action: 'update_urls', id: id, urls: newurl },
773 error: function() { alert('Error: Saving URL failed!'); },
774 success: function(data) { if(!data.success) alert('Saving URL failed!'); },
780 [% INCLUDE 'intranet-bottom.inc' %]