diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt index 8cf05a2d5f..e97eb8708b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt @@ -24,6 +24,13 @@ Process request + [% IF id_arg && format=='SCAN' %] + + + Edit URLs + + [% END %] + Complete request @@ -51,6 +58,23 @@ [% ELSIF myitem.notforloan < 0 %]On order [% END %] [% END %] +[% BLOCK urls_modal %] + + + + + Edit URL(s) + + + + + + + + +[% END %] [% INCLUDE 'header.inc' %] @@ -76,6 +100,7 @@ Article requests + [% PROCESS urls_modal %] @@ -128,6 +153,7 @@ Enumeration Barcode Format + URLs Patron Date Actions @@ -193,6 +219,7 @@ [% ar.item.enumchron | html %] [% ar.item.barcode | html %] [% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %] + [% IF ar.format == 'SCAN' %][% IF ar.urls %]Yes[% ELSE %]No[% END%][% ar.urls %][% END %] @@ -204,7 +231,7 @@ [% ar.created_on | $KohaDates %] - [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %] + [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %] [% END %] @@ -231,6 +258,7 @@ Enumeration Barcode Format + URLs Patron Date Actions @@ -294,6 +322,7 @@ [% ar.item.enumchron | html %] [% ar.item.barcode | html %] [% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %] + [% IF ar.format == 'SCAN' %][% IF ar.urls %]Yes[% ELSE %]No[% END%][% ar.urls %][% END %] @@ -305,7 +334,7 @@ [% ar.created_on | $KohaDates %] - [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %] + [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %] [% END %] @@ -356,6 +385,19 @@ else $('a.ar-process-request').show(); }); + $('#myModal').on("shown.bs.modal", function () { + $('#myModal textarea').focus(); + }); + $('#myModal').on("hidden.bs.modal", function () { + // Set focus back to dropdown + var id = $('#myModal textarea').attr('ar_id'); + var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a'); + if( link.length > 0 ) link[0].focus(); + }); + $( '#myModal button' ).on("click", function () { + SaveURLs( $('#myModal textarea').val() ); + }); + pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, { "aoColumnDefs": [ { "aTargets": [0, -1], "bSortable": false, "bSearchable": false }, @@ -451,6 +493,12 @@ } function Complete( id, a ) { + // if it is a scan, check if urls field is filled + var urlspan = $('span#url_'+id); + if( urlspan.length>0 && urlspan.text() === '' ) { + alert( _("Please fill URL before completing request.") ); + return; + } a.closest('td').prepend('').find('div.dropdown').hide(); $.ajax({ type: "POST", @@ -472,6 +520,31 @@ $("#ar_pending_count").html( pending_datatable.rows().count() ); $("#ar_processing_count").html( processing_datatable.rows().count() ); } + + function EditURLs(id) { + var urls = $('span#url_'+ id).text(); + $('#myModal textarea').val(urls); + $('#myModal textarea').attr('ar_id', id); + $('#myModal').modal('show'); + } + + function SaveURLs(newurl) { + var id = $('#myModal textarea').attr('ar_id'); + $('span#url_'+ id).text(newurl); + if(newurl) + $('span#url_yesno_'+id).text(_("Yes")); + else + $('span#url_yesno_'+id).text(_("No")); + + $.ajax({ + type: "POST", + url: '/cgi-bin/koha/svc/article_request', + data: { action: 'update_urls', id: id, urls: newurl }, + dataType: 'json', + error: function() { alert('Error: Saving URL failed!'); }, + success: function(data) { if(!data.success) alert('Saving URL failed!'); }, + }); + } [% END %] diff --git a/svc/article_request b/svc/article_request index e5c1759b2b..9d55d9a0ab 100755 --- a/svc/article_request +++ b/svc/article_request @@ -20,7 +20,7 @@ use Modern::Perl; -use CGI; +use CGI qw ( -utf8 ); use JSON qw(to_json); use C4::Auth qw(check_cookie_auth); @@ -58,6 +58,11 @@ if ($ar) { $ar->branchcode( $branchcode ) if $branchcode; $ar = $ar->store(); } + elsif( $action eq 'update_urls' ) { + my $urls = $cgi->param('urls') // q{}; + $ar->urls( $urls ); + $ar = $ar->store(); + } } print to_json( { success => $ar ? 1 : 0 } );
@@ -204,7 +231,7 @@
@@ -305,7 +334,7 @@