5 #script to delete items
10 # Copyright 2000-2002 Katipo Communications
12 # This file is part of Koha.
14 # Koha is free software; you can redistribute it and/or modify it under the
15 # terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
19 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License along with
24 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
25 # Suite 330, Boston, MA 02111-1307 USA
32 use C4::Interface::CGI::Output;
34 use C4::Circulation::Circ2;
41 $flagsrequired->{borrowers}=1;
42 my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
46 #print $input->header;
47 my $member=$input->param('member');
49 $env{'nottodayissues'}=1;
51 $member2{'borrowernumber'}=$member;
52 my $issues=currentissues(\%env,\%member2);
54 foreach (sort keys %$issues) {
57 my ($bor,$flags)=getpatroninformation(\%env, $member,'');
59 if (C4::Context->preference("IndependantBranches")) {
60 my $userenv = C4::Context->userenv;
61 unless ($userenv->{flags} == 1){
62 unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
63 warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
64 print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$member");
70 my $dbh = C4::Context->dbh;
71 my $sth=$dbh->prepare("Select * from borrowers where guarantor=?");
72 $sth->execute($member);
73 my $data=$sth->fetchrow_hashref;
77 if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){
78 my ($template, $borrowernumber, $cookie)
79 = get_template_and_user({template_name => "members/deletemem.tmpl",
83 flagsrequired => {circulate => 1},
86 # print $input->header;
87 $template->param(bornum => $member);
89 $template->param(ItemsOnIssues => $i);
91 if ($flags->{'CHARGES'} ne '') {
92 $template->param(charges => $flags->{'CHARGES'}->{'message'});
95 $template->param(guarantees => 1);
97 # print "<table border=1>";
99 # print "<TR><TD>Items on Issue</td><td align=right>$i</td></tr>";
101 # if ($flags->{'CHARGES'} ne ''){
102 # print "<TR><TD>Charges</td><td>$flags->{'CHARGES'}->{'message'}</tr>";
105 # print "<TR><TD>Guarantees</td></tr>";
108 output_html_with_http_headers $input, $cookie, $template->output;
112 print $input->redirect("/cgi-bin/koha/members/members-home.pl");
117 my $dbh = C4::Context->dbh;
118 my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?");
119 $sth->execute($member);
120 my @data=$sth->fetchrow_array;
122 $sth=$dbh->prepare("Insert into deletedborrowers values (".("?,"x(scalar(@data)-1))."?)");
123 $sth->execute(@data);
125 $sth=$dbh->prepare("Delete from borrowers where borrowernumber=?");
126 $sth->execute($member);
128 $sth=$dbh->prepare("Delete from reserves where borrowernumber=?");
129 $sth->execute($member);