From 5f6e10636ca5ba7ddfec9d9bf8ab9572478daa35 Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 11 Sep 2001 02:03:26 +0000 Subject: [PATCH] Fixing member deletion, so that it checks fines, issues and guarantees before deleting --- deletemem.pl | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/deletemem.pl b/deletemem.pl index de643cee24..dd16d45eb4 100755 --- a/deletemem.pl +++ b/deletemem.pl @@ -18,19 +18,40 @@ my $input = new CGI; my $member=$input->param('member'); my %env; $env{'nottodayissues'}=1; -my %member2; -$member2{'borrowernumber'}=$member; -my $issues=currentissues(\%env,\%member2); -my $i=0; -foreach (sort keys %$issues) { + my %member2; + $member2{'borrowernumber'}=$member; + my $issues=currentissues(\%env,\%member2); + my $i=0; + foreach (sort keys %$issues) { $i++; -} -if ($i > 0){ + } + my ($bor,$flags)=getpatroninformation(\%env, $member,''); +my $dbh=C4Connect; +my $query="Select * from borrowers where guarantor='$member'"; +my $sth=$dbh->prepare($query); +$sth->execute; +my $data=$sth->fetchrow_hashref; +$sth->finish; +$dbh->disconnect; + + +if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){ print $input->header; - print "error borrower has items on issue"; + print ""; + if ($i > 0){ + print ""; + } + if ($flags->{'CHARGES'} ne ''){ + print ""; + } + if ($data ne ''){ + print ""; + } + print "
Items on Issue$i
Charges$flags->{'CHARGES'}->{'message'}
Guarantees
"; + } else { - delmember($member); - print $input->redirect("/members/"); + delmember($member); + print $input->redirect("/members/"); } sub delmember{ @@ -54,5 +75,9 @@ sub delmember{ $sth=$dbh->prepare($query); $sth->execute; $sth->finish; + $query="Delete from reserves where borrowernumber='$member'"; + $sth=$dbh->prepare($query); + $sth->execute; + $sth->finish; $dbh->disconnect; } -- 2.39.5