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 <Katrin.Fischer.83@web.de>
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 <ian.walls@bywatersolutions.com>

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Christophe Croullebois 2011-10-15 21:21:35 +02:00 committed by Chris Cormack
parent 4d67e69107
commit dcfb5e63c9
2 changed files with 77 additions and 40 deletions

View file

@ -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;

View file

@ -131,6 +131,24 @@
pendingExpand();
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function confirm_delete_item(ordernumber, biblionumber) {
var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
if (is_confirmed) {
window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber;
}
}
function confirm_delete_biblio(ordernumber, biblionumber) {
var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
if (is_confirmed) {
window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
}
}
//]]>
</script>
@ -197,6 +215,7 @@
<th>Unit cost</th>
<th>Order cost</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
</thead>
<tfoot>
@ -205,6 +224,7 @@
<td>&nbsp;</td>
<td>[% ordergrandtotal %]</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tfoot>
<tbody class="filterclass">
@ -227,8 +247,32 @@
<td>[% loop_order.ecost %]</td>
<td>[% loop_order.ordertotal %]</td>
<td>
<a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a> /
<a href="parcel.pl?type=intra&amp;ordernumber=[% loop_order.ordernumber %]&amp;biblionumber=[% loop_order.biblionumber %]&amp;action=cancelorder&amp;supplierid=[% loop_order.supplierid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]" onclick="return confirm(_('Are you sure you want to cancel this order?'));">Cancel</a>
<a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a>
</td>
<td>
[% IF ( loop_order.left_holds_on_order ) %]
<span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
[% ELSE %]
<a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
[% END %]
[% IF ( loop_order.can_del_bib ) %]
<a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
[% ELSE %]
<span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
[% END %]
[% IF ( loop_order.left_item ) %]
<b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
[% END %]
[% IF ( loop_order.left_biblio ) %]
<b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
[% END %]
[% IF ( loop_order.left_subscription ) %]
<b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
[% END %]
[% IF ( loop_order.left_holds ) %]
<b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
[% END %]
</td>
</tr>
[% END %]