From 92cf37f8971b00d19855412e9c885a5206563405 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" 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 | 17 +++--- acqui/addorder.pl | 2 +- .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 54 +++++++++++-------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index ed9c215..42a58c4 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1580,7 +1580,7 @@ sub SearchOrder { =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 @@ -1589,21 +1589,22 @@ cancelled. =cut sub DelOrder { - my ( $bibnum, $ordernumber ) = @_; + my ($ordernumber,$bibnum) = @_; my $dbh = C4::Context->dbh; my $query = " UPDATE aqorders SET datecancellationprinted=now() - 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 ($bibnum) { + my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); + foreach my $itemnumber (@itemnumbers){ + C4::Items::DelItem( $dbh, $bibnum, $itemnumber ); + } } - } =head3 TransferOrder diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 42324aa..ebbb96a 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -251,7 +251,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 67e299d..0f12485 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -336,8 +336,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 %] @@ -387,27 +391,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 %] @@ -445,7 +453,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.2.5