From 7d85ab88d84942fcff0c0270bf6d4d94f2fd0f8b Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Tue, 16 Jul 2019 15:24:51 -0400 Subject: [PATCH] Bug 12502: (follow-up) Use modal to add/edit order notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace inputs to edit notes by a link opening a modal, similar to the basket summary page. This makes it possible for the notes to appear in the datatable exports. Also fix exporting with the export as csv button at the bottom of the page to export notes. Test plan : 1) In the late orders table (acqui/lateorders.pl), a link should appear in both the internal and vendor note column, following the current value if it exist. -> This link should read "Add ..." if there is no existing note or "Edit ..." if there is. 2) Click on the link. A modal should appear. Confirm that saving a note works as expected. 3) Try exporting to any format using either the button at the top of the table or the one at the bottom of the page. -> The three new columns and their values should appear in the export. Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer --- acqui/lateorders-export.pl | 4 +- acqui/lateorders.pl | 22 ----- .../prog/en/modules/acqui/csv/lateorders.tt | 5 +- .../prog/en/modules/acqui/lateorders.tt | 104 ++++++++++++++------- 4 files changed, 78 insertions(+), 57 deletions(-) diff --git a/acqui/lateorders-export.pl b/acqui/lateorders-export.pl index 332f65296b..cefe613be0 100755 --- a/acqui/lateorders-export.pl +++ b/acqui/lateorders-export.pl @@ -53,8 +53,8 @@ for my $ordernumber ( @ordernumbers ) { basketno => $order->{basketno}, claims_count => $order->{claims_count}, claimed_date => $order->{claimed_date}, - internalnote => $order->{internalnote}, - vendornote => $order->{vendornote}, + internalnote => $order->{order_internalnote}, + vendornote => $order->{order_vendornote}, isbn => $order->{isbn}, } ; diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 5232dd7e05..e2e0ee21db 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -123,28 +123,6 @@ if ($op and $op eq "send_alert"){ } } -if ($op && $op eq "save"){ - my $listorders; - my @orders = $input->param; - - foreach my $order (@orders){ - if ( $order ne "op"){ - my @split = split (/_/,$order); - $listorders->{$split[0]}->{$split[1]} = $input->param($order); - } - } - - my $orders_rs = Koha::Acquisition::Orders->search({ ordernumber => [ keys %$listorders ] }); - while ( my $order = $orders_rs->next ) { - my $internalnote = $listorders->{$order->ordernumber}->{i}; - my $vendornote = $listorders->{$order->ordernumber}->{v}; - - $order->order_internalnote($internalnote) if defined $internalnote; - $order->order_vendornote($vendornote) if defined $vendornote; - $order->store; - } -} - my @parameters = ( $delay ); push @parameters, $estimateddeliverydatefrom_dt ? $estimateddeliverydatefrom_dt->ymd() diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt index 68b24679e3..1ce7d8cceb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt @@ -13,7 +13,10 @@ "[% o.unitpricesupplier | html %] x [% o.quantity_to_receive | html %] = [% o.subtotal | html %] ([% o.budget | html %])"[%- delimiter | html -%] "[% o.basketname | html %] ([% o.basketno | html %])"[%- delimiter | html -%] "[% o.claims_count | html %]"[%- delimiter | html -%] -"[% o.claimed_date | html %]" +"[% o.claimed_date | html %]"[%- delimiter | html -%] +"[% o.internalnote | html %]"[%- delimiter | html -%] +"[% o.vendornote | html %]"[%- delimiter | html -%] +"[% o.isbn | html %]" [%- INCLUDE empty_line.inc -%] [%- END -%] [%- delimiter | html -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt index caa5653c2a..5d3c78dd3c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -138,8 +138,34 @@ [% END %] - - + + [% IF ( lateorder.internalnote ) %] +

+ [% lateorder.internalnote | html %] + + Edit internal note + +

+ [% ELSE %] + + Add internal note + + [% END %] + + + [% IF ( lateorder.vendornote ) %] +

+ [% lateorder.vendornote | html %] + + Edit vendor note + +

+ [% ELSE %] + + Add vendor note + + [% END %] + [% lateorder.isbn | $raw %] [% END %] @@ -204,6 +230,30 @@ + + + [% MACRO jsinclude BLOCK %] [% Asset.js("js/acquisitions-menu.js") | $raw %] [% INCLUDE 'datatables.inc' %] @@ -263,37 +313,27 @@ location.href = url; return false; }); - // Update all notes - $("#savenotes").click(function(){ - $("#savenotes").after("\"\" "+_("Loading")+""); - var all_nodes = $(late_orderst.fnGetNodes()); - var req = new XMLHttpRequest(); - var url = '/cgi-bin/koha/acqui/lateorders.pl'; - var data = new FormData(); - data.append("op","save"); - for (var i = 0; i < all_nodes.length; i++) { - var order = $(all_nodes[i]).find("input[name='ordernumber']"); - var internalnote = $(all_nodes[i]).find("input[name='internalnote']")[0].value; - var vendornote = $(all_nodes[i]).find("input[name='vendornote']")[0].value; - var internalnote_key = order[0].value + "_i"; - var vendornote_key = order[0].value + "_v"; - data.append(internalnote_key, internalnote); - data.append(vendornote_key, vendornote); - } - req.open("POST",url); - req.send(data); - req.onreadystatechange = function () { - $("#loading").remove(); - if (req.readyState == '4' ){ - if ( req.status == 200 ){ - alert(_("Notes successfully saved")); - } - else { - alert(_("Error while saving the notes. Please try again")); - } - } - } + $(".edit_note").on("click", function(e) { + e.preventDefault(); + var ordernumber = $(this).data("ordernumber"); + var note_type = $(this).data("note_type"); + var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")"; + var note_text = $( "#" + note_type + "-note-" + ordernumber ).html(); + $("#noteEditor .modal-title").text(modalTitle); + $("#ordernumber").val( ordernumber ); + $("#ordernotes").html( note_text ); + $("#type").val( note_type ); + $("#noteEditor").modal("show"); + $("#ordernotes").focus(); + }); + + $("#noteEditor").on('hidden.bs.modal', function (e) { + $("#noteEditorLabel").html(""); + $("#noteEditor .modal-title").text(""); + $("#ordernotes").html( "" ); + $("#ordernumber").val(""); + $("#type").val(""); }); }); -- 2.11.0