Initial revision
[wip/koha-chris_n.git] / insertidata.pl
1 #!/usr/bin/perl
2
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
6
7 use CGI;
8 use C4::Database;
9 use C4::Input;
10 use Date::Manip;
11 use strict;
12
13 my $input= new CGI;
14 #print $input->header;
15 #print $input->Dump;
16
17 #get all the data into a hash
18 my @names=$input->param;
19 my %data;
20 my $keyfld;
21 my $keyval;
22 my $problems;
23 my $env;
24 foreach my $key (@names){
25   $data{$key}=$input->param($key);
26 }
27 my $dbh=C4Connect;
28 my $surname=$data{'institution_name'};
29 my $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
30 firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity,
31 altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
32 initials,ethnicity,borrowernumber,guarantor,school) 
33 values ('','$data{'expiry'}','$data{'cardnumber_institution'}',
34 '','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
35 '$data{'firstname'}','$data{'altnotes'}','','$data{'contactname'}',
36 '$data{'emailaddress'}',
37 now(),'$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
38 '$data{'phoneday'}','I','$data{'city'}','$data{'area'}','$data{'phone'}',
39 '$data{'borrowernotes'}','$data{'altphone'}','$surname','$data{'initials'}',
40 '$data{'ethnicity'}','$data{'borrowernumber'}','','')";
41
42
43 #print $query;
44   my $sth2=$dbh->prepare($query);
45   $sth2->execute;
46   $sth2->finish;
47 #$sth->finish;
48
49 $dbh->disconnect;
50 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");