@@ -, +, @@ cannot add a URL to a photocopy request. --- .../prog/en/modules/circ/article-requests.tt | 77 +++++++++++++++++++++- svc/article_request | 7 +- 2 files changed, 81 insertions(+), 3 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt +++ a/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' %] @@ -69,6 +93,7 @@ Article requests + [% PROCESS urls_modal %] @@ -121,6 +146,7 @@ Enumeration Barcode Format + URLs Patron Date Actions @@ -186,6 +212,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 %] @@ -197,7 +224,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 %] @@ -224,6 +251,7 @@ Enumeration Barcode Format + URLs Patron Date Actions @@ -287,6 +315,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 %] @@ -298,7 +327,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 %] @@ -349,6 +378,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 }, @@ -444,6 +486,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", @@ -465,6 +513,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 %] --- a/svc/article_request +++ a/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 } ); --
@@ -197,7 +224,7 @@
@@ -298,7 +327,7 @@