From 9603590780e7203890b9960bd25db8f3f5be1520 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 10 Nov 2020 11:31:30 +0000 Subject: [PATCH] Bug 23971: (follow-up) Log entire objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As requested by Tomás and Jonathan, we now log the entire basket object when logging an action. --- C4/Acquisition.pm | 31 ++++++++++++++++++++++++++----- Koha/EDI.pm | 11 +++++++++++ acqui/addorder.pl | 6 +++++- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 920fd5b239..5652f2b2f1 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -45,6 +45,7 @@ use C4::Koha; use MARC::Field; use MARC::Record; +use JSON qw(to_json); use Time::localtime; @@ -207,7 +208,13 @@ sub NewBasket { # Log the basket creation if (C4::Context->preference("AcqLog")) { - logaction('ACQUISITIONS', 'ADD_BASKET', $basket); + my $created = Koha::Acquisition::Baskets->find( $basket ); + logaction( + 'ACQUISITIONS', + 'ADD_BASKET', + $basket, + to_json($created->unblessed) + ); } return $basket; @@ -235,10 +242,12 @@ sub ReopenBasket { # Log the basket reopening if (C4::Context->preference("AcqLog")) { + my $reopened = Koha::Acquisition::Baskets->find( $basketno ); logaction( 'ACQUISITIONS', 'REOPEN_BASKET', - $basketno + $basketno, + to_json($reopened->unblessed) ); } return; @@ -518,10 +527,14 @@ sub ModBasket { # Log the basket update if (C4::Context->preference("AcqLog")) { + my $modified = Koha::Acquisition::Baskets->find( + $basketinfo->{basketno} + ); logaction( 'ACQUISITIONS', 'MODIFY_BASKET', - $basketinfo->{'basketno'} + $basketinfo->{basketno}, + to_json($modified->unblessed) ); } @@ -585,10 +598,14 @@ sub ModBasketHeader { # Log the basket update if (C4::Context->preference("AcqLog")) { + my $modified = Koha::Acquisition::Baskets->find( + $basketno + ); logaction( 'ACQUISITIONS', 'MODIFY_BASKET_HEADER', - $basketno + $basketno, + to_json($modified->unblessed) ); } @@ -778,7 +795,11 @@ sub ModBasketUsers { logaction( 'ACQUISITIONS', 'MODIFY_BASKET_USERS', - $basketno + $basketno, + to_json({ + basketno => $basketno, + basketusers => @basketusers_ids + }) ); } diff --git a/Koha/EDI.pm b/Koha/EDI.pm index 3b6afbe959..af702c3d36 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -594,9 +594,20 @@ sub process_quote { } ); Koha::Acquisition::Baskets->find($b)->close; + # Log the approval + if (C4::Context->preference("AcqLog")) { + my $approved = Koha::Acquisition::Baskets->find( $b ); + logaction( + 'ACQUISITIONS', + 'APPROVE_BASKET', + $b, + to_json($approved->unblessed) + ); + } } } + return; } diff --git a/acqui/addorder.pl b/acqui/addorder.pl index cd69a4d251..74da873128 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -119,6 +119,7 @@ if it is an order from an existing suggestion : the id of this suggestion. use Modern::Perl; use CGI qw ( -utf8 ); +use JSON qw ( to_json ); use C4::Auth; # get_template_and_user use C4::Acquisition; # ModOrder use C4::Suggestions; # ModStatus @@ -129,6 +130,7 @@ use C4::Output; use C4::Log qw(logaction); use Koha::Acquisition::Currencies; use Koha::Acquisition::Orders; +use Koha::Acquisition::Baskets; use C4::Barcodes; ### "-------------------- addorder.pl ----------" @@ -362,10 +364,12 @@ if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { } if (C4::Context->preference("AcqLog") && $basketno) { + my $modified = Koha::Acquisition::Baskets->find( $basketno ); logaction( 'ACQUISITIONS', 'MODIFY_BASKET', - $basketno + $basketno, + to_json($modified->unblessed) ); } -- 2.20.1