From 4b77b784f0d4ff9bc1e53526aa912f88cd3b1c7f 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" 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) --- C4/Acquisition.pm | 21 +++---- acqui/addorder.pl | 2 +- .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 58 +++++++++++--------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 74aae85..82d03b0 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1570,7 +1570,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 @@ -1579,21 +1579,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 ); + } + } } =head2 FUNCTIONS ABOUT PARCELS 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 ccc97d5..d9f78fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -330,8 +330,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 (order.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 %] @@ -365,27 +369,31 @@ Modify - [% 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 + [% UNLESS (books_loo.biblionumber) %] + Delete order
+ [% ELSE %] + [% 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 %] @@ -423,8 +431,8 @@

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