From f9fad6c5a61464b00edeece35492c4987b04cd31 Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Sat, 14 Sep 2013 12:28:21 +0200 Subject: [PATCH] Bug 10869: Allow the deletion of order line if the record is deleted This patch fixes 2 issues : (medium issue) It is not possible to delete an order in a basket if the biblio record is deleted. (minor issue) There is a useless hyperlink around "Deleted bibliographic notice", and "notice" is a frenchism for "record" Biblionumber was passed to the function as 1st parameter, which made impossible to suppress an order whose associated biblio record was suppressed. Moreover, the biblionumber is not needed to get and suppress the order, but only to suppress items, in a second step. Change made to Acquisitions::DelOrder: - I changed the order of the 2 parameters: now $ordernumber as 1st parameter and $biblionumber as 2d parameter - I renamed $bibnum to $biblionumber - I removed $biblionumber from the main SQL query of the function - I suppressed useless $sth->finish - if no $biblionumber is provided, Koha does not try to suppress the items linked created by acq process Change made to the calls to Acquisitions::DelOrder in Koha's code, to change the order of the parameters - in addorder.pl - in basket.pl - in UT t/db_dependant/Acquisition.t Change made in template basket.tt. This bug was signed off by Cedric some time ago, but it needs a second sign off, because I had to made some little changes. To test : 1. Fill a basket with some records (some records with items or holds, some without items) 2. Supress one of the record 3. In the basket (refresh the screen) check that "Deleted bibliographic notice" line was replaced with "Deleted bibliographic record", without hyperlink arround 4. Delete this order with the link "Delete order" to the right column of the table 5. Check there is a new line in the "Deleted orders" table 6. Check there is no regression : delete an other order (one with no item), then check you cannot delete an order with an item (like before patch) Signed-off-by: Cedric Vita --- C4/Acquisition.pm | 19 ++++++++++--------- acqui/basket.pl | 2 +- .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 7 ++++++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 384b598e43..aa571489e2 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1908,22 +1908,23 @@ sub DelOrder { $query .= ", cancellationreason = ? "; } $query .= " - WHERE biblionumber=? AND ordernumber=? + WHERE ordernumber=? "; my $sth = $dbh->prepare($query); if($reason) { - $sth->execute($reason, $bibnum, $ordernumber); + $sth->execute($reason, $ordernumber); } else { - $sth->execute( $bibnum, $ordernumber ); + $sth->execute( $ordernumber ); } $sth->finish; + if ($bibnum) { + my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); + foreach my $itemnumber (@itemnumbers){ + my $delcheck = C4::Items::DelItemCheck( $bibnum, $itemnumber ); - my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); - foreach my $itemnumber (@itemnumbers){ - my $delcheck = C4::Items::DelItemCheck( $bibnum, $itemnumber ); - - if($delcheck != 1) { - $error->{'delitem'} = 1; + if($delcheck != 1) { + $error->{'delitem'} = 1; + } } } diff --git a/acqui/basket.pl b/acqui/basket.pl index 9f2ffdf7e1..9d533bc5ff 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -124,7 +124,7 @@ if ( $op eq 'delete_confirm' ) { my @orders = GetOrders($basketno); #Delete all orders included in that basket, and all items received. foreach my $myorder (@orders){ - DelOrder($myorder->{biblionumber},$myorder->{ordernumber}); + DelOrder($myorder->{biblionumber} || '', $myorder->{ordernumber}); } # if $delbiblio = 1, delete the records if possible if ((defined $delbiblio)and ($delbiblio ==1)){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index b870d835e8..e7c48918a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -500,6 +500,10 @@ [% END %] + [% UNLESS (books_loo.biblionumber) %] + Delete order
+ [% ELSE %] + [% IF ( books_loo.left_holds_on_order ) %] Can't cancel order
[% ELSE %] @@ -522,6 +526,7 @@ [% IF ( books_loo.left_holds ) %] [% books_loo.holds | html %] hold(s) left [% END %] + [% END %] [% END %] [% END %] @@ -563,7 +568,7 @@

[% IF ( order.order_received ) %] (rcvd)[% END %] - [% IF (order.title) %] + [% IF (order.biblionumber) %] [% order.title | html %][% IF order.author %] by [% order.author | html %][% END %] [% ELSE %] Deleted bibliographic record, can't find title -- 2.11.0