From 96fc2b93179d9a5136984eb3ce6c0b2dca20f4bd 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 and internal note to late orders page
Followed test plan and patch worked as described. Also ran QA test tools
and all modified files passed.
Signed-off-by: Alex Buckley
---
C4/Acquisition.pm | 23 +++++++++++++++++
acqui/lateorders-export.pl | 2 ++
acqui/lateorders.pl | 14 ++++++++++
.../en/includes/csv_headers/acqui/lateorders.tt | 2 +-
.../prog/en/modules/acqui/lateorders.tt | 30 +++++++++++++++++++++-
5 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 950498e..ea13caf 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -93,6 +93,8 @@ BEGIN {
&NotifyOrderUsers
&FillWithDefaultValues
+
+ &ModNotesOrder
);
}
@@ -1366,6 +1368,25 @@ sub ModOrder {
#------------------------------------------------------------#
+=head3 ModNotesOrder
+
+ ModNotesOrder($orders);
+
+Modifies internal and vendor note off all items in orders
+
+=cut
+
+sub ModNotesOrder{
+ my $orders = shift;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("UPDATE aqorders SET order_internalnote = ?, order_vendornote = ? WHERE ordernumber = ?");
+ foreach my $ordernumber (keys %$orders) {
+ $sth->execute($orders->{$ordernumber}->{'i'}, $orders->{$ordernumber}->{'v'}, $ordernumber) if ($orders->{$ordernumber}->{'i'} || $orders->{$ordernumber}->{'v'});
+ }
+}
+
+ #------------------------------------------------------------#
+
=head3 ModItemOrder
ModItemOrder($itemnumber, $ordernumber);
@@ -2119,6 +2140,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,
diff --git a/acqui/lateorders-export.pl b/acqui/lateorders-export.pl
index c8d86e6..70f73e2 100755
--- a/acqui/lateorders-export.pl
+++ b/acqui/lateorders-export.pl
@@ -53,6 +53,8 @@ for my $ordernumber ( @ordernumbers ) {
basketno => $order->{basketno},
claims_count => $order->{claims_count},
claimed_date => $order->{claimed_date},
+ internalnote => $order->{internaldate},
+ vendornote => $order->{vendornote},
}
;
}
diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl
index 9febcf6..1f440ca 100755
--- a/acqui/lateorders.pl
+++ b/acqui/lateorders.pl
@@ -122,6 +122,20 @@ if ($op and $op eq "send_alert"){
}
}
+if ($op && $op eq "save"){
+ my $listorders;
+ my $ordernumber;
+ my @orders = $input->param;
+
+ foreach my $order (@orders){
+ if ( $order ne "op"){
+ my @split = split (/_/,$order);
+ $listorders->{$split[0]}->{$split[1]} = $input->param($order);
+ }
+ }
+ ModNotesOrder($listorders);
+}
+
my @parameters = ( $delay );
push @parameters, $estimateddeliverydatefrom_dt
? $estimateddeliverydatefrom_dt->ymd()
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 a853d5f..670daa4 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 +1 @@
-[%- BLOCK -%]ORDER DATE,ESTIMATED DELIVERY DATE,VENDOR,INFORMATION,TOTAL COST,BASKET,CLAIMS COUNT,CLAIMED DATE[%- END -%]
+[%- BLOCK -%]ORDER DATE,ESTIMATED DELIVERY DATE,VENDOR,INFORMATION,TOTAL COST,BASKET,CLAIMS COUNT,CLAIMED DATE,INTERNAL NOTE,VENDOR NOTE[%- 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 2363765..d838834 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
@@ -64,6 +64,29 @@ $(document).ready(function() {
location.href = url;
return false;
});
+ // Update all notes
+ $("#savenotes").click(function(){
+ 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']");
+ var vendornote = $(all_nodes[i]).find("input[name='vendornote']");
+ data.append(order[0].value + "_i",internalnote[0].value);
+ data.append(order[0].value + "_v",vendornote[0].value);
+ }
+
+ req.open("POST",url);
+ req.send(data);
+ req.onreadystatechange = function () {
+ if (req.readyState == '4' ){
+ alert(_("all notes is modified correctly"));
+ }
+ }
+ });
});
//]]>
@@ -127,6 +150,8 @@ $(document).ready(function() {
Fund |
Claims count |
Claimed date |
+ Internal note |
+ Vendor note |
@@ -191,6 +216,8 @@ $(document).ready(function() {
[% END %]
+ |
+ |
[% END %]
@@ -198,7 +225,7 @@ $(document).ready(function() {
Total |
[% total %] |
- |
+ |
@@ -209,6 +236,7 @@ $(document).ready(function() {
[% UNLESS lateorder.budget_lock %]
[% END %]
+
[% ELSE %]There are no late orders.
--
2.1.4