From 6763e2a7643d4cc3ca4b17e7d05b3a2c472bd3ea Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 5 Oct 2004 08:59:56 +0000 Subject: [PATCH] templating deletemember impossible when issues/debts/guarantees --- .../default/en/members/deletemem.tmpl | 17 ++++ members/deletemem.pl | 94 +++++++++++-------- 2 files changed, 73 insertions(+), 38 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/default/en/members/deletemem.tmpl diff --git a/koha-tmpl/intranet-tmpl/default/en/members/deletemem.tmpl b/koha-tmpl/intranet-tmpl/default/en/members/deletemem.tmpl new file mode 100644 index 0000000000..4b4293a8f6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/members/deletemem.tmpl @@ -0,0 +1,17 @@ + + +
+
+

Deletion impossible

+ +

Borrower has item(s) on issue

+ + +

Borrower has debt

+ + +

Borrower has guarantees

+ +
+
+ diff --git a/members/deletemem.pl b/members/deletemem.pl index e956d576db..e4b2bae0ac 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -29,9 +29,9 @@ use strict; use CGI; use C4::Context; use C4::Search; +use C4::Interface::CGI::Output; use C4::Output; use C4::Circulation::Circ2; -#use C4::Acquisitions; use C4::Auth; @@ -47,14 +47,14 @@ my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired); 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) { - $i++; - } - my ($bor,$flags)=getpatroninformation(\%env, $member,''); +my %member2; +$member2{'borrowernumber'}=$member; +my $issues=currentissues(\%env,\%member2); +my $i=0; +foreach (sort keys %$issues) { + $i++; +} +my ($bor,$flags)=getpatroninformation(\%env, $member,''); my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("Select * from borrowers where guarantor=?"); $sth->execute($member); @@ -63,38 +63,56 @@ $sth->finish; if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){ - print $input->header; - print ""; - if ($i > 0){ - print ""; - } - if ($flags->{'CHARGES'} ne ''){ - print ""; - } - if ($data ne ''){ - print ""; - } - print "
Items on Issue$i
Charges$flags->{'CHARGES'}->{'message'}
Guarantees
"; + my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "members/deletemem.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {circulate => 1}, + debug => 1, + }); + # print $input->header; + if ($i >0) { + $template->param(ItemsOnIssues => $i); + } + if ($flags->{'CHARGES'} ne '') { + $template->param(charges => $flags->{'CHARGES'}->{'message'}); + } + if ($data ne '') { + $template->param(guarantees => 1); + } +# print ""; +# if ($i > 0){ +# print ""; +# } +# if ($flags->{'CHARGES'} ne ''){ +# print ""; +# } +# if ($data ne ''){ +# print ""; +# } +# print "
Items on Issue$i
Charges$flags->{'CHARGES'}->{'message'}
Guarantees
"; +output_html_with_http_headers $input, $cookie, $template->output; } else { - delmember($member); - print $input->redirect("/cgi-bin/koha/members/members-home.pl"); + delmember($member); + print $input->redirect("/cgi-bin/koha/members/members-home.pl"); } sub delmember{ - my ($member)=@_; - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); - $sth->execute($member); - my @data=$sth->fetchrow_array; - $sth->finish; - $sth=$dbh->prepare("Insert into deletedborrowers values (".("?,"x(scalar(@data)-1))."?)"); - $sth->execute(@data); - $sth->finish; - $sth=$dbh->prepare("Delete from borrowers where borrowernumber=?"); - $sth->execute($member); - $sth->finish; - $sth=$dbh->prepare("Delete from reserves where borrowernumber=?"); - $sth->execute($member); - $sth->finish; + my ($member)=@_; + my $dbh = C4::Context->dbh; + my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); + $sth->execute($member); + my @data=$sth->fetchrow_array; + $sth->finish; + $sth=$dbh->prepare("Insert into deletedborrowers values (".("?,"x(scalar(@data)-1))."?)"); + $sth->execute(@data); + $sth->finish; + $sth=$dbh->prepare("Delete from borrowers where borrowernumber=?"); + $sth->execute($member); + $sth->finish; + $sth=$dbh->prepare("Delete from reserves where borrowernumber=?"); + $sth->execute($member); + $sth->finish; } -- 2.39.5