From 5ed631c8509d56083651389ab8b5791304556b86 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Mon, 23 Nov 2009 10:20:00 +0100 Subject: [PATCH] (bug #3802) fix branch deletion checks This fix checks that are done when a branch is deleted, and the message shown. Now it check for borrowers and items attached to the deleted branch. --- admin/branches.pl | 11 +++++++---- .../intranet-tmpl/prog/en/modules/admin/branches.tmpl | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/admin/branches.pl b/admin/branches.pl index 8150a1de28..744ccfbd0c 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -114,10 +114,13 @@ elsif ( $op eq 'delete' ) { # check to see if the branchcode is being used in the database somewhere.... my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("select count(*) from items where holdingbranch=? or homebranch=?"); - $sth->execute( $branchcode, $branchcode ); - my ($total) = $sth->fetchrow_array; - if ($total) { + my $sthitems = $dbh->prepare("select count(*) from items where holdingbranch=? or homebranch=?"); + my $sthborrowers = $dbh->prepare("select count(*) from borrowers where branchcode=?"); + $sthitems->execute( $branchcode, $branchcode ); + $sthborrowers->execute( $branchcode ); + my ($totalitems) = $sthitems->fetchrow_array; + my ($totalborrowers) = $sthitems->fetchrow_array; + if ($totalitems or $totalborrowers) { $template->param( else => 1 ); default("MESSAGE7", $template); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl index b3ecf07670..de96c186df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tmpl @@ -156,7 +156,7 @@
Library category added
Library category modified
Library category deleted
-
Library cannot be deleted because there are patrons using that library
+
Library cannot be deleted because there are patrons or items using that library
Category cannot be deleted because there are libraries using that category
-- 2.39.5