From a36a7e1e61ac0ef7b2b79065432f028edef9d49e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 15 Nov 2010 08:09:11 -0500 Subject: [PATCH 1/2] Fix for Bug 5004, Don't block deletion of cities when instances exist in borrowers table Signed-off-by: Galen Charlton Signed-off-by: Chris Cormack --- admin/cities.pl | 9 ++------- .../intranet-tmpl/prog/en/modules/admin/cities.tmpl | 10 ---------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/admin/cities.pl b/admin/cities.pl index 3e33a717c6..58e33aed17 100755 --- a/admin/cities.pl +++ b/admin/cities.pl @@ -86,15 +86,10 @@ if ($op eq 'add_form') { # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { $template->param(delete_confirm => 1); - my $sth=$dbh->prepare("select count(*) as total from borrowers,cities where borrowers.city=cities.city_name and cityid=?"); - # FIXME: this check used to pretend there was a FK "select_city" in borrowers. + my $sth=$dbh->prepare("select cityid,city_name,city_zipcode from cities where cityid=?"); $sth->execute($cityid); - my $total = $sth->fetchrow_hashref; - my $sth2=$dbh->prepare("select cityid,city_name,city_zipcode from cities where cityid=?"); - $sth2->execute($cityid); - my $data=$sth2->fetchrow_hashref; + my $data=$sth->fetchrow_hashref; $template->param( - total => $total->{'total'}, city_name => $data->{'city_name'}, city_zipcode => $data->{'city_zipcode'}, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tmpl index 62055da444..203d19b7dc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tmpl @@ -69,14 +69,8 @@ - -
-

Cannot Delete City ""

-

This record is used times. Impossible to delete it

-

Delete City "?"

- @@ -89,16 +83,12 @@
City id
" method="post"> - - - " />
" method="get"> -
From 14b66041f0dc08a5618985b44e1816a6c9978f45 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 15 Nov 2010 18:13:32 -0500 Subject: [PATCH 2/2] Another bug 5004 fix, this time for road types The road types interface didn't block deletion of road types in use, but the script included the same queries that cities.pl did, as if it intended to. Signed-off-by: Galen Charlton Signed-off-by: Chris Cormack --- admin/roadtype.pl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/admin/roadtype.pl b/admin/roadtype.pl index 544d48850b..a75659437f 100755 --- a/admin/roadtype.pl +++ b/admin/roadtype.pl @@ -98,18 +98,10 @@ if ($op eq 'add_form') { } elsif ($op eq 'delete_confirm') { $template->param(delete_confirm => 1); my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select count(*) as total from borrowers,roadtype where borrowers.streettype=roadtype.road_type and roadtypeid=?"); - $sth->execute($roadtypeid); - my $total = $sth->fetchrow_hashref; - $sth->finish; - $template->param(total => $total->{'total'}); my $sth2=$dbh->prepare("select roadtypeid,road_type from roadtype where roadtypeid=?"); $sth2->execute($roadtypeid); my $data=$sth2->fetchrow_hashref; $sth2->finish; - if ($total->{'total'} >0) { - $template->param(totalgtzero => 1); - } $template->param( road_type => ( $data->{'road_type'}),