From a72a29bc7e7a6a8bd10a0406897210805821d085 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 Content-Type: text/plain; charset=utf-8 [I integrated a small followup by P. Poulain, changing the name of $bibnum to $biblionumber in DelOrder It was more simple for rebasing] 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" I had to change the behavior of Acquisitions::DelOrder (which is used only by addorder.pl file), a line in addorder.pl, and a few lines in template basket.tt. 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 : felete 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 | 18 +++--- acqui/addorder.pl | 2 +- .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 54 +++++++++++-------- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 56c2d7f..4cd6e0b 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1752,7 +1752,7 @@ sub SearchOrders { =head3 DelOrder - &DelOrder($biblionumber, $ordernumber); + &DelOrder($ordernumber, $biblionumber); Cancel the order with the given order and biblio numbers. It does not delete any entries in the aqorders table, it merely marks them as @@ -1761,21 +1761,22 @@ cancelled. =cut sub DelOrder { - my ( $bibnum, $ordernumber ) = @_; + my ($ordernumber,$biblionumber) = @_; my $dbh = C4::Context->dbh; my $query = " UPDATE aqorders SET datecancellationprinted=now(), orderstatus='cancelled' - WHERE biblionumber=? AND ordernumber=? + WHERE ordernumber=? "; my $sth = $dbh->prepare($query); - $sth->execute( $bibnum, $ordernumber ); + $sth->execute($ordernumber ); $sth->finish; - my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); - foreach my $itemnumber (@itemnumbers){ - C4::Items::DelItem( $dbh, $bibnum, $itemnumber ); + if ($biblionumber) { + my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); + foreach my $itemnumber (@itemnumbers){ + C4::Items::DelItem( $dbh, $biblionumber, $itemnumber ); + } } - } =head3 TransferOrder @@ -2242,7 +2243,6 @@ sub GetHistory { LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber "; - if ( C4::Context->preference("IndependentBranches") ) { $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"; } diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 1b05f07..5a34856 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -323,7 +323,7 @@ if ( $orderinfo->{quantity} ne '0' ) { else { # qty=0, delete the line my $biblionumber = $input->param('biblionumber'); - DelOrder( $biblionumber, $$orderinfo{ordernumber} ); + DelOrder($$orderinfo{ordernumber}, $biblionumber ); if ($orderinfo->{delbiblio} == 1){ DelBiblio($biblionumber); } 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 da78b7b..c65a6ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -470,8 +470,12 @@ [% IF ( books_loo.order_received ) %][% ELSE %][% IF ( books_loo.toggle ) %][% ELSE %][% END %][% END %]

[% IF ( books_loo.order_received ) %] (rcvd)[% END %] - [% books_loo.title |html %] by [% books_loo.author %] -
+ [% IF (books_loo.biblionumber) %] + [% books_loo.title |html %] by [% books_loo.author %] +
+ [% ELSE %] + Deleted bibliographic record, can't find title
+ [% END %] [% IF ( books_loo.isbn ) %] - [% books_loo.isbn %][% END %] [% IF ( books_loo.issn ) %] - [% books_loo.issn %][% END %] [% IF ( books_loo.publishercode ) %], [% books_loo.publishercode %][% END %] @@ -523,27 +527,31 @@ [% END %] - [% IF ( books_loo.left_holds_on_order ) %] - Can't delete order
+ [% UNLESS (books_loo.biblionumber) %] + Delete order
[% ELSE %] - Delete order
- [% END %] - [% IF ( books_loo.can_del_bib ) %] - Delete order and catalog record
- [% ELSE %] - Can't delete order and catalog record
- [% END %] - [% IF ( books_loo.left_item ) %] - [% books_loo.items %] item(s) left
- [% END %] - [% IF ( books_loo.left_biblio ) %] - [% books_loo.biblios %] order(s) left
- [% END %] - [% IF ( books_loo.left_subscription ) %] - [% books_loo.subscriptions %] subscription(s) left
- [% END %] - [% IF ( books_loo.left_holds ) %] - [% books_loo.holds %] hold(s) left + [% IF ( books_loo.left_holds_on_order ) %] + Can't delete order
+ [% ELSE %] + Delete order
+ [% END %] + [% IF ( books_loo.can_del_bib ) %] + Delete order and catalog record
+ [% ELSE %] + Can't delete order and catalog record
+ [% END %] + [% IF ( books_loo.left_item ) %] + [% books_loo.items %] item(s) left
+ [% END %] + [% IF ( books_loo.left_biblio ) %] + [% books_loo.biblios %] order(s) left
+ [% END %] + [% IF ( books_loo.left_subscription ) %] + [% books_loo.subscriptions %] subscription(s) left
+ [% END %] + [% IF ( books_loo.left_holds ) %] + [% books_loo.holds %] hold(s) left + [% END %] [% END %] [% END %] @@ -581,7 +589,7 @@

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