From e92602b3c4b7f038d66ae9043609eba7d1771f63 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 13 Aug 2012 16:34:35 +0200 Subject: [PATCH 2/2] Bug 7583 follow-up: Prevent users to cancel receipt if they can't Disable the link for cancelling instead of displaying an error message after the click. This is only valid if parent order line is received, not if it's deleted. When the user gets his mouse over the disabled link, he gets a message telling him which order (ordernumber) blocks him so he knows immediately which receipt to cancel. Also improve error messages for non technical people --- acqui/parcel.pl | 10 ++++++- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 29 ++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 548e9c4..3734198 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -186,7 +186,6 @@ for (my $i = 0 ; $i < $countlines ; $i++) { $line{gst} = $gst; $line{total} = sprintf($cfstr, $total); $line{booksellerid} = $booksellerid; - push @loop_received, \%line; $totalprice += $parcelitems[$i]->{'unitprice'}; $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); @@ -195,6 +194,15 @@ for (my $i = 0 ; $i < $countlines ; $i++) { $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; + if ( $line{parent_ordernumber} != $line{ordernumber} ) { + if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } + @parcelitems ) + { + $line{cannot_cancel} = 1; + } + } + + push @loop_received, \%line; #double FIXME - totalfreight is redefined later. # FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. 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 70fd74a..7abc106 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -229,11 +229,15 @@ Cannot cancel receipt. Possible reasons : [% END %] @@ -420,7 +424,22 @@ [% loop_receive.ecost %] [% loop_receive.unitprice %] [% loop_receive.total %] - Cancel receipt + + [% IF (loop_receive.cannot_cancel) %] + [% span_title = BLOCK %] + Cannot cancel receipt of this order line because it + was created from a partial receipt of order line no. + [% loop_receive.parent_ordernumber %], which is + already received. Try cancelling this one first and + retry. + [% END %] + + Can't cancel receipt + + [% ELSE %] + Cancel receipt + [% END %] + [% END %] -- 1.7.10.4