Lines 26-65
Link Here
|
26 |
|
26 |
|
27 |
<ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]"> |
27 |
<ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]"> |
28 |
<li> |
28 |
<li> |
29 |
<a class="ar-set-pending-request" href="#" onclick="HandleMulti( SetPending, [% id_arg | html %], $(this) ); return false;"> |
29 |
<a class="ar-set-pending-request" href="#"> |
30 |
<i class="fa fa-bars"></i> |
30 |
<i class="fa fa-bars"></i> |
31 |
Set request as pending |
31 |
Set request as pending |
32 |
</a> |
32 |
</a> |
33 |
|
33 |
|
34 |
<a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;"> |
34 |
<a class="ar-process-request" data-ar-id="[% id_arg | uri %]" href="#"> |
35 |
<i class="fa fa-cog"></i> |
35 |
<i class="fa fa-cog"></i> |
36 |
Process request |
36 |
Process request |
37 |
</a> |
37 |
</a> |
38 |
|
38 |
|
39 |
[% IF id_arg && format=='SCAN' %] |
39 |
[% IF id_arg && format=='SCAN' %] |
40 |
<a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg | html %], $(this) ); return false;"> |
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> |
41 |
<i class="fa-solid fa-pencil" aria-hidden="true"></i> |
42 |
Edit URLs |
42 |
Edit URLs |
43 |
</a> |
43 |
</a> |
44 |
[% END %] |
44 |
[% END %] |
45 |
|
45 |
|
46 |
<a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;"> |
46 |
<a class="ar-complete-request" href="#" data-ar-id="[% id_arg | uri %]" href="#"> |
47 |
<i class="fa fa-check-circle"></i> |
47 |
<i class="fa fa-check-circle"></i> |
48 |
Complete request |
48 |
Complete request |
49 |
</a> |
49 |
</a> |
50 |
|
50 |
|
51 |
<a class="ar-cancel-request" href="#" onclick="Cancel( [% id_arg | html %], $(this) ); return false;"> |
51 |
<a class="ar-cancel-request" href="#" data-ar-id="[% id_arg | uri %]" href="#"> |
52 |
<i class="fa fa-minus-circle"></i> |
52 |
<i class="fa fa-minus-circle"></i> |
53 |
Cancel request |
53 |
Cancel request |
54 |
</a> |
54 |
</a> |
55 |
|
55 |
|
56 |
[% IF id_arg %] |
56 |
[% IF id_arg %] |
57 |
<a class="ar-print-request" href="#" onclick="HandleMulti( PrintSlip, [% id_arg | html %], $(this) ); return false;"> |
57 |
<a class="ar-print-request" href="#" data-ar-id="[% id_arg | uri %]" href="#"> |
58 |
<i class="fa fa-print"></i> |
58 |
<i class="fa fa-print"></i> |
59 |
Print slip |
59 |
Print slip |
60 |
</a> |
60 |
</a> |
61 |
[% ELSE %] |
61 |
[% ELSE %] |
62 |
<a class="ar-print-request" href="#" onclick="PrintMultipleSlip(); return false;"> |
62 |
<a class="ar-print-multiple-requests" href="#"> |
63 |
<i class="fa fa-print"></i> |
63 |
<i class="fa fa-print"></i> |
64 |
Print slip |
64 |
Print slip |
65 |
</a> |
65 |
</a> |
Lines 577-585
Link Here
|
577 |
var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a'); |
577 |
var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a'); |
578 |
if( link.length > 0 ) link[0].focus(); |
578 |
if( link.length > 0 ) link[0].focus(); |
579 |
}); |
579 |
}); |
580 |
$( '#myModal button' ).on("click", function () { |
|
|
581 |
SaveURLs( $('#myModal textarea').val() ); |
582 |
}); |
583 |
|
580 |
|
584 |
requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, { |
581 |
requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, { |
585 |
"columnDefs": [ |
582 |
"columnDefs": [ |
Lines 630-635
Link Here
|
630 |
var link = 'article-request-slip.pl?id='+id; |
627 |
var link = 'article-request-slip.pl?id='+id; |
631 |
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); |
628 |
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); |
632 |
} |
629 |
} |
|
|
630 |
$(".ar-print-request").on("click", function (e){ |
631 |
e.preventDefault(); |
632 |
HandleMulti(PrintSlip, $(this).data('ar-id')); |
633 |
}); |
633 |
|
634 |
|
634 |
$('#modal-cancellation-reason').on('change', function(e) { |
635 |
$('#modal-cancellation-reason').on('change', function(e) { |
635 |
let reason = $(this).val(); |
636 |
let reason = $(this).val(); |
Lines 671-678
Link Here
|
671 |
}); |
672 |
}); |
672 |
var link = 'article-request-slip.pl?multi=1&id='+ids.join(','); |
673 |
var link = 'article-request-slip.pl?multi=1&id='+ids.join(','); |
673 |
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); |
674 |
window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); |
674 |
|
|
|
675 |
} |
675 |
} |
|
|
676 |
$(".ar-print-multiple-requests").on("click", function (e){ |
677 |
e.preventDefault(); |
678 |
PrintMultipleSlip(); |
679 |
}); |
676 |
|
680 |
|
677 |
function Cancel( id, a ) { |
681 |
function Cancel( id, a ) { |
678 |
cancel_id = id; |
682 |
cancel_id = id; |
Lines 680-736
Link Here
|
680 |
|
684 |
|
681 |
$('#cancelModal').modal(); |
685 |
$('#cancelModal').modal(); |
682 |
} |
686 |
} |
|
|
687 |
$(".ar-cancel-request").on("click", function (e){ |
688 |
e.preventDefault(); |
689 |
HandleMulti(Cancel, $(this).data('ar-id'), $(this)); |
690 |
}); |
683 |
|
691 |
|
684 |
function SetPending( id, a ) { |
692 |
</script> |
685 |
var table_row = a.closest('tr'); |
693 |
|
686 |
table_row.find('.ar-set-pending-request').remove(); |
694 |
<script async type="module"> |
687 |
table_row.find('input[type="checkbox"]').prop('checked', false); |
695 |
import { APIClient } from '/intranet-tmpl/prog/js/fetch/api-client.js'; |
688 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide(); |
|
|
689 |
$.ajax({ |
690 |
type: "POST", |
691 |
url: '/cgi-bin/koha/svc/article_request', |
692 |
data: { |
693 |
action: 'pending', |
694 |
id: id, |
695 |
}, |
696 |
success: function( data ) { |
697 |
$("img.spinner").remove(); |
698 |
requested_datatable.row( table_row ).remove().draw(); |
699 |
pending_datatable.row.add( table_row ).draw(); |
700 |
UpdateTabCounts(); |
701 |
activateBatchActions( active_tab ); |
702 |
}, |
703 |
dataType: 'json' |
704 |
}); |
705 |
} |
706 |
|
696 |
|
707 |
function Process( id, a ) { |
697 |
async function Process( id, a ) { |
708 |
var table_row = a.closest('tr'); |
698 |
var table_row = a.closest('tr'); |
709 |
var table = a.closest('table'); |
699 |
var table = a.closest('table'); |
710 |
var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable; |
700 |
var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable; |
711 |
table_row.find('.ar-process-request').remove(); |
|
|
712 |
table_row.find('input[type="checkbox"]').prop('checked', false); |
713 |
|
701 |
|
714 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide(); |
702 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide(); |
715 |
$.ajax({ |
703 |
|
716 |
type: "POST", |
704 |
const client = APIClient.article_request; |
717 |
url: '/cgi-bin/koha/svc/article_request', |
705 |
await client.articleRequests.process(id).then( |
718 |
data: { |
706 |
success => { |
719 |
action: 'process', |
|
|
720 |
id: id, |
721 |
}, |
722 |
success: function( data ) { |
723 |
$("img.spinner").remove(); |
707 |
$("img.spinner").remove(); |
|
|
708 |
table_row.find('.ar-process-request').remove(); |
709 |
table_row.find('input[type="checkbox"]').prop('checked', false); |
724 |
orig_datatable.row( table_row ).remove().draw(); |
710 |
orig_datatable.row( table_row ).remove().draw(); |
725 |
processing_datatable.row.add( table_row ).draw(); |
711 |
processing_datatable.row.add( table_row ).draw(); |
726 |
UpdateTabCounts(); |
712 |
UpdateTabCounts(); |
727 |
activateBatchActions( active_tab ); |
713 |
activateBatchActions( active_tab ); |
728 |
}, |
714 |
}, |
729 |
dataType: 'json' |
715 |
error => { |
730 |
}); |
716 |
console.warn("Something wrong happened: %s".format(error)); |
|
|
717 |
} |
718 |
); |
731 |
} |
719 |
} |
|
|
720 |
$(".ar-process-request").on("click", function (e){ |
721 |
e.preventDefault(); |
722 |
HandleMulti(Process, $(this).data('ar-id'), $(this)); |
723 |
}); |
732 |
|
724 |
|
733 |
function Complete( id, a ) { |
725 |
async function Complete( id, a ) { |
734 |
// if it is a scan, check if urls field is filled |
726 |
// if it is a scan, check if urls field is filled |
735 |
var urlspan = $('span#url_'+id); |
727 |
var urlspan = $('span#url_'+id); |
736 |
if( urlspan.length>0 && urlspan.text() === '' ) { |
728 |
if( urlspan.length>0 && urlspan.text() === '' ) { |
Lines 738-758
Link Here
|
738 |
return; |
730 |
return; |
739 |
} |
731 |
} |
740 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide(); |
732 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide(); |
741 |
$.ajax({ |
733 |
const client = APIClient.article_request; |
742 |
type: "POST", |
734 |
await client.articleRequests.complete(id).then( |
743 |
url: '/cgi-bin/koha/svc/article_request', |
735 |
success => { |
744 |
data: { |
736 |
$("img.spinner").remove(); |
745 |
action: 'complete', |
|
|
746 |
id: id, |
747 |
}, |
748 |
success: function( data ) { |
749 |
active_datatable.row( a.closest('tr') ).remove().draw(); |
737 |
active_datatable.row( a.closest('tr') ).remove().draw(); |
750 |
UpdateTabCounts(); |
738 |
UpdateTabCounts(); |
751 |
activateBatchActions( active_tab ); |
739 |
activateBatchActions( active_tab ); |
752 |
}, |
740 |
}, |
753 |
dataType: 'json' |
741 |
error => { |
754 |
}); |
742 |
console.warn("Something wrong happened: %s".format(error)); |
|
|
743 |
} |
744 |
); |
755 |
} |
745 |
} |
|
|
746 |
$(".ar-complete-request").on("click", function (e){ |
747 |
e.preventDefault(); |
748 |
HandleMulti(Complete, $(this).data('ar-id'), $(this)); |
749 |
}); |
750 |
|
751 |
async function SetPending( id, a ) { |
752 |
var table_row = a.closest('tr'); |
753 |
table_row.find('.ar-set-pending-request').remove(); |
754 |
table_row.find('input[type="checkbox"]').prop('checked', false); |
755 |
a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide(); |
756 |
const client = APIClient.article_request; |
757 |
await client.articleRequests.pending(id).then( |
758 |
success => { |
759 |
$("img.spinner").remove(); |
760 |
requested_datatable.row( table_row ).remove().draw(); |
761 |
pending_datatable.row.add( table_row ).draw(); |
762 |
UpdateTabCounts(); |
763 |
activateBatchActions( active_tab ); |
764 |
}, |
765 |
error => { |
766 |
console.warn("Something wrong happened: %s".format(error)); |
767 |
} |
768 |
); |
769 |
} |
770 |
$(".ar-set-pending-request").on("click", function (e){ |
771 |
e.preventDefault(); |
772 |
HandleMulti(SetPending, $(this).data('ar-id'), $(this)); |
773 |
}); |
756 |
|
774 |
|
757 |
function UpdateTabCounts() { |
775 |
function UpdateTabCounts() { |
758 |
$("#ar_requested_count").html( requested_datatable.rows().count() ); |
776 |
$("#ar_requested_count").html( requested_datatable.rows().count() ); |
Lines 766-773
Link Here
|
766 |
$('#myModal textarea').attr('ar_id', id); |
784 |
$('#myModal textarea').attr('ar_id', id); |
767 |
$('#myModal').modal('show'); |
785 |
$('#myModal').modal('show'); |
768 |
} |
786 |
} |
|
|
787 |
$(".ar-edit-urls").on("click", function (e){ |
788 |
e.preventDefault(); |
789 |
HandleMulti(EditURLs, $(this).data('ar-id')); |
790 |
}); |
769 |
|
791 |
|
770 |
function SaveURLs(newurl) { |
792 |
async function SaveURLs(newurl) { |
771 |
var id = $('#myModal textarea').attr('ar_id'); |
793 |
var id = $('#myModal textarea').attr('ar_id'); |
772 |
$('span#url_'+ id).text(newurl); |
794 |
$('span#url_'+ id).text(newurl); |
773 |
if(newurl) |
795 |
if(newurl) |
Lines 775-789
Link Here
|
775 |
else |
797 |
else |
776 |
$('span#url_yesno_'+id).text(_("No")); |
798 |
$('span#url_yesno_'+id).text(_("No")); |
777 |
|
799 |
|
778 |
$.ajax({ |
800 |
const client = APIClient.article_request; |
779 |
type: "POST", |
801 |
await client.articleRequests.update_urls(id, newurl).then( |
780 |
url: '/cgi-bin/koha/svc/article_request', |
802 |
success => { |
781 |
data: { action: 'update_urls', id: id, urls: newurl }, |
803 |
}, |
782 |
dataType: 'json', |
804 |
error => { |
783 |
error: function() { alert('Error: Saving URL failed!'); }, |
805 |
console.warn("Something wrong happened: %s".format(error)); |
784 |
success: function(data) { if(!data.success) alert('Saving URL failed!'); }, |
806 |
} |
785 |
}); |
807 |
); |
786 |
} |
808 |
} |
|
|
809 |
$( '#myModal button' ).on("click", function () { |
810 |
SaveURLs( $('#myModal textarea').val() ); |
811 |
}); |
812 |
|
787 |
</script> |
813 |
</script> |
788 |
[% END %] |
814 |
[% END %] |
789 |
|
815 |
|