5 [% USE AuthorisedValues %]
8 [% PROCESS 'i18n.inc' %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>[% FILTER collapse %]
12 [% t("Article requests") | html %] ›
13 [% t("Circulation") | html %] ›
14 [% t("Koha") | html %]
16 [% INCLUDE 'doc-head-close.inc' %]
17 <style>p { margin-top: 0; } [id^="article-menu-"] { display: none; } [id^="article-menu-"]:before { content: "|"; } .starthidden { display:none; }</style>
21 <div id="[% menuid | html %]" class="btn-group dropup">
23 <a class="btn btn-default btn-xs dropdown-toggle ar-actions" role="button" data-toggle="dropdown" href="#">
24 Actions <b class="caret"></b>
27 <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
29 <a class="ar-set-pending-request" data-ar-id="[% id_arg | uri %]" href="#">
30 <i class="fa fa-bars"></i>
31 Set request as pending
34 <a class="ar-process-request" data-ar-id="[% id_arg | uri %]" href="#">
35 <i class="fa fa-cog"></i>
39 [% IF id_arg && format=='SCAN' %]
40 <a class="ar-edit-urls" href="#" data-ar-id="[% id_arg | uri %]" href="#">
41 <i class="fa-solid fa-pencil" aria-hidden="true"></i>
46 <a class="ar-complete-request" href="#" data-ar-id="[% id_arg | uri %]" href="#">
47 <i class="fa fa-check-circle"></i>
51 <a class="ar-cancel-request" href="#" data-ar-id="[% id_arg | uri %]" href="#">
52 <i class="fa fa-minus-circle"></i>
57 <a class="ar-print-request" href="#" data-ar-id="[% id_arg | uri %]" href="#">
58 <i class="fa fa-print"></i>
62 <a class="ar-print-multiple-requests" href="#">
63 <i class="fa fa-print"></i>
73 [% BLOCK item_status %]
74 [% IF myitem.onloan %]<span>Checked out</span>
75 [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span>
76 [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span>
77 [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
80 [% BLOCK urls_modal %]
81 <div id="myModal" class="modal fade modal-lg" role="dialog">
82 <div class="modal-dialog">
83 <div class="modal-content">
84 <div class="modal-header">
85 <h4 class="modal-title">Edit URL(s)</h4>
87 <div class="modal-body">
88 <textarea id="urls" style="width:100%;"></textarea>
90 <div class="modal-footer">
91 <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
97 [% BLOCK cancel_modal %]
98 <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
99 <div class="modal-dialog" role="document">
100 <div class="modal-content">
101 <div class="modal-header">
102 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
103 <h3>Confirm deletion</h3>
106 <div class="modal-body">
107 <p>Are you sure you want to cancel this article request?</p>
109 <fieldset class="action">
110 [% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
111 [% IF ar_cancellation.count %]
112 <label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
113 <select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
114 <option value="" selected>Other reasons</option>
115 [% FOREACH reason IN ar_cancellation %]
116 <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
121 <fieldset class="action">
122 <div class="hint col-sm-offset-4">Enter reason</div>
123 <input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
127 <div class="modal-footer">
128 <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
129 <a href="#" data-dismiss="modal">Cancel</a>
136 <body id="circ_article-requests" class="circ">
137 [% WRAPPER 'header.inc' %]
138 [% INCLUDE 'cat-search.inc' %]
141 [% WRAPPER 'sub-header.inc' %]
142 [% WRAPPER breadcrumbs %]
143 [% WRAPPER breadcrumb_item %]
144 <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
146 [% WRAPPER breadcrumb_item bc_active= 1 %]
147 <span>Article requests</span>
149 [% END #/ WRAPPER breadcrumbs %]
150 [% END #/ WRAPPER sub-header.inc %]
152 <div class="main container-fluid starthidden">
155 [% INCLUDE 'messages.inc' %]
156 [% IF Koha.Preference('CircSidebar') %]
157 <div class="col-sm-10 col-sm-push-2">
159 <div class="col-md-12 col-lg-10 col-lg-offset-1">
162 <h1>Article requests</h1>
163 [% PROCESS urls_modal %]
165 <form id="ar-branchcode-form" method="get">
166 <select name="branchcode" id="branchcode">
167 <option value="">All libraries</option>
168 [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
169 [% IF b.branchcode == branchcode %]
170 <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
172 <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
176 <button type="submit" class="btn btn-default btn-xs">
177 <i class="fa-solid fa-rotate"></i> Update
181 [% WRAPPER tabs id= "article-request-tabs" %]
182 [% WRAPPER tabs_nav %]
183 [% WRAPPER tab_item tabname= "article-requests-requested" bt_active= 1 %]
184 <span>New</span> (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
186 [% WRAPPER tab_item tabname= "article-requests-pending" %]
187 <span>Pending</span> (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
189 [% WRAPPER tab_item tabname= "article-requests-processing" %]
190 <span>Processing</span> (<span id="ar_processing_count">[% article_requests_processing.count | html %]</span>)
192 [% END # /WRAPPER tabs_nav %]
194 [% WRAPPER tab_panels %]
195 [% WRAPPER tab_panel tabname="article-requests-requested" bt_active= 1 %]
196 <div class="article-requests-requested_table_controls">
197 <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-times"></i> Clear all</a>
198 [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
201 <table id="article-requests-requested-table">
205 <th class="ar-title">Title</th>
206 <th class="ar-request">Requested article</th>
207 <th class="ar-collection">Collection</th>
208 <th class="ar-itemtype">Item type</th>
209 <th class="ar-callnumber">Call number</th>
210 <th class="ar-status">Status</th>
211 <th class="ar-copynumber">Copy number</th>
212 <th class="ar-enumchron">Enumeration</th>
213 <th class="ar-barcode">Barcode</th>
214 <th class="ar-format">Format</th>
215 <th class="ar-urls">URLs</th>
216 <th class="ar-patron">Patron</th>
217 <th class="ar-date">Date</th>
218 <th class="ar-actions noExport">Actions</th>
223 [% FOREACH ar IN article_requests_requested %]
224 <tr class="ar-row ar-requested">
225 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
226 <td class="ar-title">
228 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
229 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
234 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
235 <div class="ar-author">[% ar.biblio.author | html %]</div>
236 <div class="ar-pubdata">
237 [% ar.biblio.biblioitem.publishercode | html %]
239 [% IF ar.biblio.biblioitem.publicationyear %]
240 [% ar.biblio.biblioitem.publicationyear | html %]
241 [% ELSIF ar.biblio.copyrightdate %]
242 [% ar.biblio.copyrightdate | html %]
245 [% IF ar.biblio.biblioitem.pages %]
246 : [% ar.biblio.biblioitem.pages | html %]
249 [% r.biblio.biblioitem.size | html %]
251 [% IF ar.biblio.biblioitem.isbn %]
252 <span>ISBN: [% ar.biblio.biblioitem.isbn | html %]</span>
257 <td class="ar-request">
258 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
259 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
260 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
261 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
262 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
263 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
264 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
265 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
266 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
268 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
269 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
270 <td class="ar-callnumber">
271 [% IF ar.item.location %]
272 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
275 [% ar.item.itemcallnumber | html %]
277 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
278 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
279 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
280 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
281 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
282 <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>
283 <td class="ar-patron">
285 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
286 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
290 <p>[% ar.borrower.phone | html %]</p>
292 <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
293 <td class="ar-actions">
294 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
300 [% END # /tab_panel#article-requests-requested %]
302 [% WRAPPER tab_panel tabname="article-requests-pending" %]
303 <div class="article-requests-pending_table_controls">
304 <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-times"></i> Clear all</a>
305 [% PROCESS actions menuid='article-menu-pending' id_arg=0 pull_right='' aria_menu='table_controls' %]
308 <table id="article-requests-pending-table">
312 <th class="ar-title">Title</th>
313 <th class="ar-request">Requested article</th>
314 <th class="ar-collection">Collection</th>
315 <th class="ar-itemtype">Item type</th>
316 <th class="ar-callnumber">Call number</th>
317 <th class="ar-status">Status</th>
318 <th class="ar-copynumber">Copy number</th>
319 <th class="ar-enumchron">Enumeration</th>
320 <th class="ar-barcode">Barcode</th>
321 <th class="ar-format">Format</th>
322 <th class="ar-urls">URLs</th>
323 <th class="ar-patron">Patron</th>
324 <th class="ar-date">Date</th>
325 <th class="ar-actions noExport">Actions</th>
330 [% FOREACH ar IN article_requests_pending %]
331 <tr class="ar-row ar-pending">
332 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
333 <td class="ar-title">
335 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
336 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
341 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
342 <div class="ar-author">[% ar.biblio.author | html %]</div>
343 <div class="ar-pubdata">
344 [% ar.biblio.biblioitem.publishercode | html %]
346 [% IF ar.biblio.biblioitem.publicationyear %]
347 [% ar.biblio.biblioitem.publicationyear | html %]
348 [% ELSIF ar.biblio.copyrightdate %]
349 [% ar.biblio.copyrightdate | html %]
352 [% IF ar.biblio.biblioitem.pages %]
353 : [% ar.biblio.biblioitem.pages | html %]
356 [% r.biblio.biblioitem.size | html %]
358 [% IF ar.biblio.biblioitem.isbn %]
359 <span>ISBN: [% ar.biblio.biblioitem.isbn | html %]</span>
364 <td class="ar-request">
365 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
366 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
367 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
368 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
369 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
370 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
371 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
372 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
373 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
375 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
376 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
377 <td class="ar-callnumber">
378 [% IF ar.item.location %]
379 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
382 [% ar.item.itemcallnumber | html %]
384 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
385 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
386 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
387 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
388 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
389 <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>
390 <td class="ar-patron">
392 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
393 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
397 <p>[% ar.borrower.phone | html %]</p>
399 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
400 <td class="ar-actions">
401 [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
407 [% END # /tab_panel#article-requests-pending %]
409 [% WRAPPER tab_panel tabname="article-requests-processing" %]
410 <div class="article-requests-processing_table_controls">
411 <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-times"></i> Clear all</a>
412 [% PROCESS actions menuid='article-menu-processing' id_arg=0 pull_right='' aria_menu='table_controls' %]
414 <table id="article-requests-processing-table">
418 <th class="ar-title">Title</th>
419 <th class="ar-request">Requested article</th>
420 <th class="ar-collection">Collection</th>
421 <th class="ar-itemtype">Item type</th>
422 <th class="ar-callnumber">Call number</th>
423 <th class="ar-status">Status</th>
424 <th class="ar-copynumber">Copy number</th>
425 <th class="ar-enumchron">Enumeration</th>
426 <th class="ar-barcode">Barcode</th>
427 <th class="ar-format">Format</th>
428 <th class="ar-urls">URLs</th>
429 <th class="ar-patron">Patron</th>
430 <th class="ar-date">Date</th>
431 <th class="ar-actions noExport">Actions</th>
436 [% FOREACH ar IN article_requests_processing %]
437 <tr class="ar-row ar-processing">
438 <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
439 <td class="ar-title">
441 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio link = 1%]
445 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
446 <div class="ar-author">[% ar.biblio.author | html %]</div>
447 <div class="ar-pubdata">
448 [% ar.biblio.biblioitem.publishercode | html %]
450 [% IF ar.biblio.biblioitem.publicationyear %]
451 [% ar.biblio.biblioitem.publicationyear | html %]
452 [% ELSIF ar.biblio.copyrightdate %]
453 [% ar.biblio.copyrightdate | html %]
456 [% IF ar.biblio.biblioitem.pages %]
457 : [% ar.biblio.biblioitem.pages | html %]
460 [% r.biblio.biblioitem.size | html %]
462 [% IF ar.biblio.biblioitem.isbn %]
463 <span>ISBN: [% ar.biblio.biblioitem.isbn | html %]</span>
468 <td class="ar-request">
469 [% IF ar.toc_request %] <p><strong>Include TOC</strong> </p> [% END %]
470 [% IF ar.title %] <p><strong>Title:</strong> [% ar.title | html %] </p> [% END %]
471 [% IF ar.author %] <p><strong>Author:</strong> [% ar.author | html %] </p> [% END %]
472 [% IF ar.volume %] <p><strong>Volume:</strong> [% ar.volume | html %] </p> [% END %]
473 [% IF ar.issue %] <p><strong>Issue:</strong> [% ar.issue | html %] </p> [% END %]
474 [% IF ar.date %] <p><strong>Date:</strong> [% ar.date | html %] </p> [% END %]
475 [% IF ar.pages %] <p><strong>Pages:</strong> [% ar.pages | html %] </p> [% END %]
476 [% IF ar.chapters %] <p><strong>Chapters:</strong> [% ar.chapters | html %] </p> [% END %]
477 [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
479 <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
480 <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
481 <td class="ar-callnumber">
482 [% IF ar.item.location %]
483 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
486 [% ar.item.itemcallnumber | html %]
488 <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
489 <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
490 <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
491 <td class="ar-barcode">[% ar.item.barcode | html %]</td>
492 <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
493 <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>
494 <td class="ar-patron">
496 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
497 [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
501 <p>[% ar.borrower.phone | html %]</p>
503 <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
504 <td class="ar-actions">
505 [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
511 [% END # /tab_panel#article-requests-processing %]
512 [% END # /WRAPPER tab_panels %]
513 [% END # /WRAPPER tabs %]
516 [% IF Koha.Preference('CircSidebar') %]
517 <div class="col-sm-2 col-sm-pull-10">
519 [% INCLUDE 'circ-nav.inc' %]
525 [% PROCESS cancel_modal %]
527 [% MACRO jsinclude BLOCK %]
528 [% INCLUDE 'datatables.inc' %]
530 var active_tab = "#article-requests-requested_panel";
531 var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
532 $(document).ready(function() {
534 $("#article-request-tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
535 active_tab = e.target.hash;
536 if( active_tab == "#article-requests-requested_panel" ){
537 active_datatable = requested_datatable;
538 } else if( active_tab == "#article-requests-pending_panel" ){
539 active_datatable = pending_datatable;
541 active_datatable = processing_datatable;
543 activateBatchActions( active_tab );
546 $( "input:checkbox, #article-request-tabs" ).on("change", function(){
547 activateBatchActions( active_tab );
550 $(".SelectAll").on("click", function(e) {
552 $( active_tab + " input[type='checkbox']").prop('checked', true);
553 activateBatchActions( active_tab );
555 $(".ClearAll").on("click", function(e) {
557 $( active_tab + " input[type='checkbox']").prop('checked', false);
558 activateBatchActions( active_tab );
560 $("a.ar-actions").on('click', function(e) {
561 // Hide menu option ?
562 if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
563 $('a.ar-process-request').show();
564 else $('a.ar-process-request').hide();
566 if( $('#article-requests-requested-table').is(":visible") )
567 $('a.ar-set-pending-request').show();
568 else $('a.ar-set-pending-request').hide();
571 $('#myModal').on("shown.bs.modal", function () {
572 $('#myModal textarea').focus();
574 $('#myModal').on("hidden.bs.modal", function () {
575 // Set focus back to dropdown
576 var id = $('#myModal textarea').attr('ar_id');
577 var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
578 if( link.length > 0 ) link[0].focus();
581 requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
583 { "targets": [0, -1], "orderable": false, "searchable": false },
587 pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
589 { "targets": [0, -1], "orderable": false, "searchable": false },
592 processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
594 { "targets": [0, -1], "orderable": false, "searchable": false },
597 active_datatable = requested_datatable;
598 activateBatchActions( active_tab );
599 $(".starthidden").show();
602 function activateBatchActions( active_tab ){
603 // Check to see whether batch menu should be shown based on state of checkboxes
604 if ( $( "input:checkbox", active_tab ).length > 0 ) {
605 // There are rows with checkboxes
606 $( "[class$='_table_controls']", active_tab ).show();
607 if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
608 $( "[id^='article-menu-']", active_tab ).css("display","inline-block");
610 $( "[id^='article-menu-']", active_tab ).hide();
613 // All rows have been removed
614 $("[class$='_table_controls']", active_tab ).hide();
618 function HandleMulti( fnHandler, id, a ) {
619 last_cancel_reason = undefined;
620 if( id !== 0 ) { fnHandler( id, a ); return; }
621 $( active_tab + " input[type='checkbox']:checked").each(function() {
622 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
626 function PrintSlip(id, a) {
627 var link = 'article-request-slip.pl?id='+id;
628 window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
630 $(".ar-print-request").on("click", function (e){
632 HandleMulti(PrintSlip, $(this).data('ar-id'));
635 $('#modal-cancellation-reason').on('change', function(e) {
636 let reason = $(this).val();
637 $('#modal-notes').attr('disabled', !!reason);
640 // Confirm cancellation of article requests
643 $("#cancelModalConfirmBtn").on("click",function(e) {
644 let reason = $("#modal-cancellation-reason").val();
645 let notes = $("#modal-notes").val();
646 let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
648 HandleMulti(function(id, a) {
649 var table_row = a.closest('tr');
650 table_row.find('.ar-process-request').remove();
651 table_row.find('input[type="checkbox"]').prop('checked', false);
654 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
658 url: '/api/v1/article_requests/'+id+query,
659 success: function( data ) {
660 active_datatable.row( a.closest('tr') ).remove().draw();
662 activateBatchActions( active_tab );
665 }, cancel_id, cancel_a)
668 function PrintMultipleSlip() {
670 $( active_tab + " input[type='checkbox']:checked").each(function() {
671 ids.push($(this).attr('reqid'));
673 var link = 'article-request-slip.pl?multi=1&id='+ids.join(',');
674 window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
676 $(".ar-print-multiple-requests").on("click", function (e){
681 function Cancel( id, a ) {
685 $('#cancelModal').modal();
687 $(".ar-cancel-request").on("click", function (e){
689 HandleMulti(Cancel, $(this).data('ar-id'), $(this));
692 async function Process( id, a ) {
693 var table_row = a.closest('tr');
694 var table = a.closest('table');
695 var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
697 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
699 const client = APIClient.article_request;
700 await client.articleRequests.process(id).then(
702 $("img.spinner").remove();
703 table_row.find('.ar-process-request').remove();
704 table_row.find('input[type="checkbox"]').prop('checked', false);
705 orig_datatable.row( table_row ).remove().draw();
706 processing_datatable.row.add( table_row ).draw();
708 activateBatchActions( active_tab );
711 console.warn("Something wrong happened: %s".format(error));
715 $(".ar-process-request").on("click", function (e){
717 HandleMulti(Process, $(this).data('ar-id'), $(this));
720 async function Complete( id, a ) {
721 // if it is a scan, check if urls field is filled
722 var urlspan = $('span#url_'+id);
723 if( urlspan.length>0 && urlspan.text() === '' ) {
724 alert( _("Please fill URL before completing request.") );
727 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
728 const client = APIClient.article_request;
729 await client.articleRequests.complete(id).then(
731 $("img.spinner").remove();
732 active_datatable.row( a.closest('tr') ).remove().draw();
734 activateBatchActions( active_tab );
737 console.warn("Something wrong happened: %s".format(error));
741 $(".ar-complete-request").on("click", function (e){
743 HandleMulti(Complete, $(this).data('ar-id'), $(this));
746 async function SetPending( id, a ) {
747 var table_row = a.closest('tr');
748 table_row.find('.ar-set-pending-request').remove();
749 table_row.find('input[type="checkbox"]').prop('checked', false);
750 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
751 const client = APIClient.article_request;
752 await client.articleRequests.pending(id).then(
754 $("img.spinner").remove();
755 requested_datatable.row( table_row ).remove().draw();
756 pending_datatable.row.add( table_row ).draw();
758 activateBatchActions( active_tab );
761 console.warn("Something wrong happened: %s".format(error));
765 $(".ar-set-pending-request").on("click", function (e){
767 HandleMulti(SetPending, $(this).data('ar-id'), $(this));
770 function UpdateTabCounts() {
771 $("#ar_requested_count").html( requested_datatable.rows().count() );
772 $("#ar_pending_count").html( pending_datatable.rows().count() );
773 $("#ar_processing_count").html( processing_datatable.rows().count() );
776 function EditURLs(id) {
777 var urls = $('span#url_'+ id).text();
778 $('#myModal textarea').val(urls);
779 $('#myModal textarea').attr('ar_id', id);
780 $('#myModal').modal('show');
782 $(".ar-edit-urls").on("click", function (e){
784 HandleMulti(EditURLs, $(this).data('ar-id'));
787 async function SaveURLs(newurl) {
788 var id = $('#myModal textarea').attr('ar_id');
789 $('span#url_'+ id).text(newurl);
791 $('span#url_yesno_'+id).text(_("Yes"));
793 $('span#url_yesno_'+id).text(_("No"));
795 const client = APIClient.article_request;
796 await client.articleRequests.update_urls(id, newurl).then(
800 console.warn("Something wrong happened: %s".format(error));
804 $( '#myModal button' ).on("click", function () {
805 SaveURLs( $('#myModal textarea').val() );
811 [% INCLUDE 'intranet-bottom.inc' %]