From 20539a65befadf5fb0538d814e583bbde27c39e3 Mon Sep 17 00:00:00 2001 From: Yohann Dufour Date: Tue, 1 Jul 2014 09:59:36 +0200 Subject: [PATCH] Bug 12508: adding an error message if a contract cannot be removed If a contract cannot be removed, no errors is displayed. Now, it displays an dialog messag error and the list of contracts. Test plan: 1) Log on with a superlibrarian permission 2) Go on the page acqui/supplier.pl (Acquisitions > Button "New vendor") 3) Record a vendor with a nonzero "name" 4) Go on the page admin/aqcontract.pl (click on the "Contracts" item in the menu) 5) Click on the button "New" > "Contract" and record a new one 6) Click on "New" > "Basket" and record a basket by selectioning the created contract 7) Click on the contract name, then click on the "Contracts" item in the left menu 8) Try to delete this contract, an error is displayed : "Contract has not been deleted. Maybe a basket linked to this contract exists." 9) Delete the basket linked to the contract 10) Delete the contract, no errors is displayed --- admin/aqcontract.pl | 19 +++++++++++-------- .../intranet-tmpl/prog/en/modules/admin/aqcontract.tt | 5 +++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index d7166e3..8cfb517 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -33,7 +33,7 @@ use C4::Contract; my $input = new CGI; my $contractnumber = $input->param('contractnumber'); my $booksellerid = $input->param('booksellerid'); -my $op = $input->param('op') || ''; +my $op = $input->param('op') || 'list'; my $bookseller = GetBookSellerFromId($booksellerid); @@ -133,17 +133,20 @@ elsif ( $op eq 'delete_confirm' ) { } #DELETE_CONFIRMED: called by delete_confirm, used to effectively confirm deletion of data in DB elsif ( $op eq 'delete_confirmed' ) { - $template->param( delete_confirmed => 1 ); + my $deleted = DelContract( { contractnumber => $contractnumber } ); - DelContract( { contractnumber => $contractnumber } ); - - print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?booksellerid=$booksellerid"); - exit; + if ( $deleted ) { + print $input->redirect("/cgi-bin/koha/acqui/supplier.pl?booksellerid=$booksellerid"); + exit; + } else { + $template->param( error => 'not_deleted' ); + $op = 'list'; + } - # END $OP eq DELETE_CONFIRMED + # END $OP eq LIST } # DEFAULT: Builds a list of contracts and displays them -else { +if ( $op eq 'list' ) { $template->param(else => 1); # get contracts diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt index 34040bd..b4a6e0c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt @@ -90,6 +90,11 @@ function Check(ff) {
[% INCLUDE 'acquisitions-toolbar.inc' %] + +[% IF error == 'not_deleted' %] +
Contract has not been deleted. Maybe a basket linked to this contract exists.
+[% END %] + [% IF ( add_form ) %]
-- 1.9.1