3 #script to enter borrower data into the data base
4 #needs to be moved into a perl module
5 # written 9/11/99 by chris@katipo.co.nz
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
32 #print $input->header;
35 #get all the data into a hash
36 my @names=$input->param;
43 foreach my $key (@names){
44 $data{$key}=$input->param($key);
46 my $dbh = C4::Context->dbh;
47 my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?");
48 $sth->execute($data{'borrowernumber'});
49 if (my $data2=$sth->fetchrow_hashref){
50 $sth2=$dbh->prepare("update borrowers set title=?,expiry=?,
51 cardnumber=?,sex=?,ethnotes=?,
52 streetaddress=?,faxnumber=?,firstname=?,
53 altnotes=?,dateofbirth=?,contactname=?,
54 emailaddress=?,dateenrolled=?,streetcity=?,
55 altrelationship=?,othernames=?,phoneday=?,
56 city=?,area=?,phone=?,
57 borrowernotes=?,altphone=?,surname=?,
58 initials=?,physstreet=?,ethnicity=?,
59 gonenoaddress=?,lost=?,debarred=?,
60 textmessaging=?, branchcode = ?,
61 zipcode = ?,homezipcode=?
62 where borrowernumber=?");
63 $sth2->execute($data{'title'},$data{'expiry'},
64 $data{'cardnumber_institution'},$data{'sex'},$data{'ethnicnotes'},
65 $data{'address'},$data{'faxnumber'},$data{'firstname'},
66 $data{'altnotes'},$data{'dateofbirth'},$data{'contactname'},
67 $data{'emailaddress'},$data{'joining'},$data{'streetcity'},
68 $data{'altrelationship'},$data{'othernames'},$data{'phoneday'},
69 $data{'city'},$data{'area'},$data{'phone'},
70 $data{'borrowernotes'},$data{'altphone'},$data{'institution_name'},
71 $data{'initials'},$data{'streetaddress'},$data{'ethnicity'},
72 $data{'gna'},$data{'lost'},$data{'debarred'},
73 $data{'textmessaging'},$data{'branchcode'},
74 $data{'zipcode'},$data{'homezipcode'},
75 $data{'borrowernumber'});
77 my $surname=$data{'institution_name'};
78 # note for code reading : 5 on each line
79 $sth2=$dbh->prepare("insert into borrowers (
80 title, expiry, cardnumber, sex, ethnotes,
81 streetaddress, faxnumber, firstname, altnotes, dateofbirth,
82 contactname, emailaddress, dateenrolled, streetcity, altrelationship,
83 othernames, phoneday, categorycode, city, area,
84 phone, borrowernotes, altphone, surname, initials,
85 ethnicity, borrowernumber,guarantor, school, branchcode,
95 $sth2->execute('', $data{'expiry'}, $data{'cardnumber_institution'}, '', $data{'ethnotes'},
96 $data{'address'}, $data{'faxnumber'}, $surname, $data{'altnotes'}, '',
97 $data{'contactname'},$data{'emailaddress'}, $data{'streetcity'}, $data{'altrelationship'}, # only 4 because of now()
98 $data{'othernames'}, $data{'phoneday'}, 'I', $data{'city'}, $data{'area'},
99 ''.$data{'phone'}, $data{'borrowernotes'}, $data{'altphone'}, $surname, ''.$data{'initials'},
100 $data{'ethnicity'}, $data{'borrowernumber'}, '', '', $data{'branchcode'},
101 $data{'zipcode'}, $data{'homezipcode'});
107 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");