Replaced expressions of the form "$x = $x <op> $y" with "$x <op>= $y".
[koha.git] / deletemem.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to delete items
6 #written 2/5/00
7 #by chris@katipo.co.nz
8
9
10 # Copyright 2000-2002 Katipo Communications
11 #
12 # This file is part of Koha.
13 #
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
17 # version.
18 #
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.
22 #
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
26
27 use strict;
28
29 use CGI;
30 use C4::Context;
31 use C4::Search;
32 use C4::Output;
33 use C4::Circulation::Circ2;
34 #use C4::Acquisitions;
35
36 my $input = new CGI;
37 #print $input->header;
38 my $member=$input->param('member');
39 my %env;
40 $env{'nottodayissues'}=1;
41  my %member2;
42  $member2{'borrowernumber'}=$member;
43  my $issues=currentissues(\%env,\%member2);
44  my $i=0;
45  foreach (sort keys %$issues) {
46   $i++;
47  }
48   my ($bor,$flags)=getpatroninformation(\%env, $member,'');
49 my $dbh = C4::Context->dbh;
50 my $query="Select * from borrowers where guarantor='$member'";
51 my $sth=$dbh->prepare($query);
52 $sth->execute;
53 my $data=$sth->fetchrow_hashref;
54 $sth->finish;
55
56
57 if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){
58   print $input->header;
59   print "<table border=1>";
60   if ($i > 0){
61       print "<TR><TD>Items on Issue</td><td align=right>$i</td></tr>";
62   }
63   if ($flags->{'CHARGES'} ne ''){
64       print "<TR><TD>Charges</td><td>$flags->{'CHARGES'}->{'message'}</tr>";
65   }
66   if ($data ne ''){
67       print "<TR><TD>Guarantees</td></tr>";
68   }
69   print "</table>";
70
71 } else {
72          delmember($member);
73          print $input->redirect("/members/");
74 }
75
76 sub delmember{
77   my ($member)=@_;
78   my $dbh = C4::Context->dbh;
79   my $query="Select * from borrowers where borrowernumber='$member'";
80   my $sth=$dbh->prepare($query);
81   $sth->execute;
82   my @data=$sth->fetchrow_array;
83   $sth->finish;
84   $query="Insert into deletedborrowers values (";
85   foreach my $temp (@data){
86     $query .= "'$temp',";
87   }
88   $query=~ s/\,$/\)/;
89   #  print $query;
90   # FIXME - Use $dbh->do()
91   $sth=$dbh->prepare($query);
92   $sth->execute;
93   $sth->finish;
94   # FIXME - Use $dbh->do()
95   $query = "Delete from borrowers where borrowernumber='$member'";
96   $sth=$dbh->prepare($query);
97   $sth->execute;
98   $sth->finish;
99   # FIXME - Use $dbh->do()
100   $query="Delete from reserves where borrowernumber='$member'";
101   $sth=$dbh->prepare($query);
102   $sth->execute;
103   $sth->finish;
104 }