From 34dfe783c6e13f8298c4e296860711e44889980d Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Mon, 25 Sep 2017 15:18:38 -0400 Subject: [PATCH] Bug 12502: Add vendor note, internal note, ordernumber and isbn to late orders page MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Test plan: 0) Make sure you have a late order a) Create a test vendor unless you have one b) Create a test basket unless you have one c) Close the basket to mark the order as late 1) Go to the late orders table Before patch : Orderno, ISBN, vendor notes, internal notes are absent After patch: fields are present 2) Edit the vendor note and/or the internal note 3) Press the save notes button 4) Refresh page and cache (CTRL+F5), if notes have been correctly saved, your modifications should be displayed. Signed-off-by: Alex Buckley Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- C4/Acquisition.pm | 5 +- acqui/lateorders-export.pl | 3 ++ acqui/lateorders.pl | 23 +++++++++ admin/columns_settings.yml | 9 ++++ .../includes/csv_headers/acqui/lateorders.tt | 2 +- .../prog/en/modules/acqui/lateorders.tt | 47 ++++++++++++++++++- 6 files changed, 85 insertions(+), 4 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index d99b39aab9..c8bdf1ba83 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2165,7 +2165,7 @@ sub GetLateOrders { my @query_params = (); my $select = " SELECT aqbasket.basketno, - aqorders.ordernumber, + aqorders.ordernumber AS ordernumber, DATE(aqbasket.closedate) AS orderdate, aqbasket.basketname AS basketname, aqbasket.basketgroupid AS basketgroupid, @@ -2174,6 +2174,8 @@ sub GetLateOrders { aqorders.ecost AS unitpricelib, aqorders.claims_count AS claims_count, aqorders.claimed_date AS claimed_date, + aqorders.order_internalnote AS internalnote, + aqorders.order_vendornote AS vendornote, aqbudgets.budget_name AS budget, borrowers.branchcode AS branch, aqbooksellers.name AS supplier, @@ -2181,6 +2183,7 @@ sub GetLateOrders { biblio.author, biblio.title, biblioitems.publishercode AS publisher, biblioitems.publicationyear, + biblioitems.isbn AS isbn, ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate, "; my $from = " diff --git a/acqui/lateorders-export.pl b/acqui/lateorders-export.pl index c8d86e6be4..332f65296b 100755 --- a/acqui/lateorders-export.pl +++ b/acqui/lateorders-export.pl @@ -53,6 +53,9 @@ for my $ordernumber ( @ordernumbers ) { basketno => $order->{basketno}, claims_count => $order->{claims_count}, claimed_date => $order->{claimed_date}, + internalnote => $order->{internalnote}, + vendornote => $order->{vendornote}, + isbn => $order->{isbn}, } ; } diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl index 9febcf65c9..5232dd7e05 100755 --- a/acqui/lateorders.pl +++ b/acqui/lateorders.pl @@ -53,6 +53,7 @@ use C4::Context; use C4::Acquisition; use C4::Letters; use Koha::DateUtils; +use Koha::Acquisition::Orders; my $input = new CGI; my ($template, $loggedinuser, $cookie) = get_template_and_user( @@ -122,6 +123,28 @@ 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/admin/columns_settings.yml b/admin/columns_settings.yml index e4353226a1..f604f7925e 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -37,6 +37,8 @@ modules: columnname: checkbox cannot_be_toggled: 1 cannot_be_modified: 1 + - + columnname: order_line - columnname: order_date - @@ -59,6 +61,13 @@ modules: columnname: claims_count - columnname: claimed_date + - + columnname: internal_note + - + columnname: vendor_note + - + columnname: isbn + basket: orders: - diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt index 8231efbfc1..f15f54586e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt @@ -1,4 +1,4 @@ [%- USE Koha -%] [%- SET delimiter = Koha.Preference( 'delimiter' ) || ',' -%] -[%- BLOCK -%]ORDER DATE[%- delimiter | html -%]ESTIMATED DELIVERY DATE[%- delimiter | html -%]VENDOR[%- delimiter | html -%]INFORMATION[%- delimiter | html -%]TOTAL COST[%- delimiter | html -%]BASKET[%- delimiter | html -%]CLAIMS COUNT[%- delimiter | html -%]CLAIMED DATE[%- END -%] +[%- BLOCK -%]ORDER DATE[%- delimiter | html -%]ESTIMATED DELIVERY DATE[%- delimiter | html -%]VENDOR[%- delimiter | html -%]INFORMATION[%- delimiter | html -%]TOTAL COST[%- delimiter | html -%]BASKET[%- delimiter | html -%]CLAIMS COUNT[%- delimiter | html -%]CLAIMED DATE[%- delimiter | html -%]INTERNAL NOTE[%- delimiter | html -%]VENDOR NOTE[%- delimiter | html -%]ISBN[%- END -%] 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 8773505d17..caa5653c2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -56,6 +56,7 @@ [% ELSE %] [% END %] + Order line Order date Estimated delivery date Vendor @@ -67,6 +68,9 @@ Fund Claims count Claimed date + Internal note + Vendor note + ISBN @@ -75,6 +79,9 @@ + + [% lateorder.ordernumber | $raw %] + [% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince | html %] days) @@ -131,14 +138,17 @@ [% END %] + + + [% lateorder.isbn | $raw %] [% END %] - Total + Total [% total | html %] -   +   @@ -149,6 +159,7 @@ [% UNLESS lateorder.budget_lock %] [% END %] +

[% ELSE %]

There are no late orders.

@@ -252,6 +263,38 @@ 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")); + } + } + } + }); }); [% END %] -- 2.39.5