- $template->param(itemtype => $itemtype,
- description => $data->{description},
- renewalsallowed => $data->{renewalsallowed},
- rentalcharge => sprintf("%.2f",$data->{rentalcharge}),
- imageurl => $data->{imageurl},
- total => $total);
- # END $OP eq DELETE_CONFIRM
-################## DELETE_CONFIRMED ##################################
-# called by delete_confirm, used to effectively confirm deletion of data in DB
-} elsif ($op eq 'delete_confirmed') {
- #start the page and read in includes
- my $dbh = C4::Context->dbh;
- my $itemtype=uc($input->param('itemtype'));
- my $sth=$dbh->prepare("delete from itemtypes where itemtype=?");
- $sth->execute($itemtype);
- $sth = $dbh->prepare("delete from issuingrules where itemtype=?");
- $sth->execute($itemtype);
- $sth->finish;
- print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=itemtypes.pl\"></html>";
- exit;
- # END $OP eq DELETE_CONFIRMED
-################## DEFAULT ##################################
-} else { # DEFAULT
- my $env;
- my ($count,$results)=StringSearch($env,$searchfield,'web');
-
- my $page = $input->param('page') || 1;
- my $first = ($page - 1) * $pagesize;
+ # END $OP eq ADD_VALIDATE
+################## DELETE_CONFIRM ##################################
+ # called by default form, used to confirm deletion of data in DB
+}
+elsif ( $op eq 'delete_confirm' ) {
+ # Check both items and biblioitems
+ my $sth = $dbh->prepare('
+ SELECT COUNT(*) AS total FROM (
+ SELECT itemtype AS t FROM biblioitems
+ UNION ALL
+ SELECT itype AS t FROM items
+ ) AS tmp
+ WHERE tmp.t=?
+ ');
+ $sth->execute($itemtype);
+ my $total = $sth->fetchrow_hashref->{'total'};