From dcfb5e63c9092efc396da98b51e079efc3b823f9 Mon Sep 17 00:00:00 2001 From: Christophe Croullebois Date: Sat, 15 Oct 2011 21:21:35 +0200 Subject: [PATCH] Bug 5680: Follow Up for Order cancelling improvement : the same for parcel.pl The same scope than in basket.pl Signed-off-by: Katrin Fischer Detailed information about possible deletion of orders on parcel page. 1) Delete order for record with 1 other item and item level hold OK. Record, item and hold remain, only on order item is deleted. 2) Delete order for ordered record with 1 item and title level hold OK. Deletion is not possible, before hold is cancelled. 3) Delete order for new record with only items connected to this order OK. Cancelling the order deletes record and item or only order, depending on link used. 4) Delete order for record with subscription. OK. Subscription remains untouched, item is deleted. Also checked: AcqCreateItem = on receive / in cataloging Links show and it's possible to delete the order or only the record using different links. Comments: There is a table sorter option for the last column with the delete links. I am not sure it is useful here, but it does work. Before patch is applied, the links use 'cancel' instead of 'delete'. I am not sure which is better and if it should be different on basket summary and order receive or the same on both. QA Comment: Made a small change to template language; blocking deletion because of items referred to holds instead. Changed text to refer to items. Signed-off-by: Ian Walls Signed-off-by: Chris Cormack --- acqui/parcel.pl | 69 +++++++++---------- .../prog/en/modules/acqui/parcel.tt | 48 ++++++++++++- 2 files changed, 77 insertions(+), 40 deletions(-) diff --git a/acqui/parcel.pl b/acqui/parcel.pl index ec5071bc2a..c256c6067c 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -140,44 +140,6 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -my $action = $input->param('action'); -my $ordernumber = $input->param('ordernumber'); -my $biblionumber = $input->param('biblionumber'); - -# If canceling an order -if ($action eq "cancelorder") { - - my $error_delitem; - my $error_delbiblio; - - # We delete the order - DelOrder($biblionumber, $ordernumber); - - # We delete all the items related to this order - my @itemnumbers = GetItemnumbersFromOrder($ordernumber); - foreach (@itemnumbers) { - my $delcheck = DelItemCheck(C4::Context->dbh, $biblionumber, $_); - # (should always success, as no issue should exist on item on order) - if ($delcheck != 1) { $error_delitem = 1; } - } - - # We get the number of remaining items - my $itemcount = GetItemsCount($biblionumber); - - # If there are no items left, - if ($itemcount eq 0) { - # We delete the record - $error_delbiblio = DelBiblio($biblionumber); - } - - if ($error_delitem || $error_delbiblio) { - if ($error_delitem) { $template->param(error_delitem => 1); } - if ($error_delbiblio) { $template->param(error_delbiblio => 1); } - } else { - $template->param(success_delorder => 1); - } -} - # If receiving error, report the error (coming from finishrecieve.pl(sic)). if( scalar(@rcv_err) ) { my $cnt=0; @@ -237,6 +199,7 @@ my @loop_orders = (); for (my $i = 0 ; $i < $countpendings ; $i++) { my %line; %line = %{$pendingorders->[$i]}; + $line{quantity}+=0; $line{quantityreceived}+=0; $line{unitprice}+=0; @@ -252,6 +215,36 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { $line{total} = $total; $line{supplierid} = $supplierid; $ordergrandtotal += $line{ecost} * $line{quantity}; + + my $biblionumber = $line{'biblionumber'}; + my $countbiblio = CountBiblioInOrders($biblionumber); + my $ordernumber = $line{'ordernumber'}; + my @subscriptions = GetSubscriptionsId ($biblionumber); + my $itemcount = GetItemsCount($biblionumber); + my $holds = GetHolds ($biblionumber); + my @items = GetItemnumbersFromOrder( $ordernumber ); + my $itemholds; + foreach my $item (@items){ + my $nb = GetItemHolds($biblionumber, $item); + if ($nb){ + $itemholds += $nb; + } + } + + # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 + $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); + $line{items} = ($itemcount) - (scalar @items); + $line{left_item} = 1 if $line{items} >= 1; + $line{left_biblio} = 1 if $countbiblio > 1; + $line{biblios} = $countbiblio - 1; + $line{left_subscription} = 1 if scalar @subscriptions >= 1; + $line{subscriptions} = scalar @subscriptions; + $line{left_holds} = 1 if $holds >= 1; + $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); + $line{holds} = $holds; + $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; + + push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); } $freight = $totalfreight unless $freight; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index e67b82e5d9..45eb5917cc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -131,6 +131,24 @@ pendingExpand(); } +//]]> + + @@ -197,6 +215,7 @@ Unit cost Order cost   +   @@ -205,6 +224,7 @@   [% ordergrandtotal %]   +   @@ -227,8 +247,32 @@ [% loop_order.ecost %] [% loop_order.ordertotal %] - Receive / - Cancel + Receive + + + + [% IF ( loop_order.left_holds_on_order ) %] + Can't delete order
+ [% ELSE %] + Delete order
+ [% END %] + [% IF ( loop_order.can_del_bib ) %] + Delete order and catalog record
+ [% ELSE %] + Can't delete order and catalog record
+ [% END %] + [% IF ( loop_order.left_item ) %] + [% loop_order.items %] item(s) left
+ [% END %] + [% IF ( loop_order.left_biblio ) %] + [% loop_order.biblios %] order(s) left
+ [% END %] + [% IF ( loop_order.left_subscription ) %] + [% loop_order.subscriptions %] subscription(s) left
+ [% END %] + [% IF ( loop_order.left_holds ) %] + [% loop_order.holds %] hold(s) left + [% END %] [% END %] -- 2.39.5