-my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
-$sth->execute($member);
-my $data=$sth->fetchrow_hashref;
-if ($countissues > 0 or $flags->{'CHARGES'} or $data->{'borrowernumber'}){
- # print $input->header;
-
- my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'});
- $template->param( picture => 1 ) if $picture;
-
- $template->param(borrowernumber => $member,
- surname => $bor->{'surname'},
- title => $bor->{'title'},
- cardnumber => $bor->{'cardnumber'},
- firstname => $bor->{'firstname'},
- categorycode => $bor->{'categorycode'},
- category_type => $bor->{'category_type'},
- categoryname => $bor->{'description'},
- address => $bor->{'address'},
- address2 => $bor->{'address2'},
- city => $bor->{'city'},
- zipcode => $bor->{'zipcode'},
- country => $bor->{'country'},
- phone => $bor->{'phone'},
- email => $bor->{'email'},
- branchcode => $bor->{'branchcode'},
- branchname => GetBranchName($bor->{'branchcode'}),
+my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
+if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_guarantor or $deletelocal == 0) {
+ $template->param( picture => 1 ) if $patron->image;
+
+ $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
+
+ $template->param(
+ # FIXME The patron object should be passed to the template
+ borrowernumber => $patron->borrowernumber,
+ surname => $patron->surname,
+ title => $patron->title,
+ cardnumber => $patron->cardnumber,
+ firstname => $patron->firstname,
+ categorycode => $patron->categorycode,
+ category_type => $patron->category->category_type,
+ categoryname => $patron->category->description,
+ address => $patron->address,
+ address2 => $patron->address2,
+ city => $patron->city,
+ zipcode => $patron->zipcode,
+ country => $patron->country,
+ phone => $patron->phone,
+ email => $patron->email,
+ branchcode => $patron->branchcode,