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
14 #print $input->header;
17 #get all the data into a hash
18 my @names=$input->param;
24 foreach my $key (@names){
25 $data{$key}=$input->param($key);
29 for (my $i=0;$i<3;$i++){
30 my $query="Select * from borrowers where borrowernumber=$data{'bornumber_child_$i'}";
31 my $sth=$dbh->prepare($query);
33 if (my $data=$sth->fetchrow_hashref){
34 $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
35 cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
36 streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
37 altnotes='$data{'altnotes'}',dateofbirth='$data{'dateofbirth'}',contactname='$data{'contactname'}',
38 emailaddress='$data{'emailaddress'}',dateenrolled='$data{'joining'}',streetcity='$data{'streetcity'}',
39 altrelationship='$data{'altrelationship'}',othernames='$data{'othernames'}',phoneday='$data{'phoneday'}',
40 categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
41 borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
42 initials='$data{'initials'}',streetaddress='$data{'address'}',ethnicity='$data{'ethnicity'}'
43 where borrowernumber=$data{'borrowernumber'}";
46 }elsif ($data{"cardnumber_child_$i"} ne ''){
47 my $dob=$data{"dateofbirth_child_$i"};
49 $dob=UnixDate($dob,'%Y-%m-%d');
50 $data{'joining'}=ParseDate("today");
51 $data{'joining'}=UnixDate($data{'joining'},'%Y-%m-%d');
52 my $cardnumber=$data{"cardnumber_child_$i"};
53 my $bornum=$data{"bornumber_child_$i"};
54 my $firstname=$data{"firstname_child_$i"};
55 my $surname=$data{"surname_child_$i"};
56 my $school=$data{"school_child_$i"};
57 my $guarant=$data{'borrowernumber'};
58 my $notes=$data{"altnotes_child_$i"};
59 my $sex=$data{"sex_child_$i"};
60 $data{'contactname'}=$data{'firstname_guardian'}." ".$data{'surname_guardian'};
61 $data{'altrelationship'}="Guarantor";
62 $data{'altphone'}=$data{'phone'};
63 $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
64 firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity,
65 altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
66 initials,ethnicity,borrowernumber,guarantor,school)
67 values ('','$data{'expiry'}',
69 '$sex','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
70 '$firstname','$data{'altnotes'}','$dob','$data{'contactname'}','$data{'emailaddress'}',
71 '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
72 '$data{'phoneday'}','C','$data{'city'}','$data{'area'}','$data{'phone'}',
73 '$notes','$data{'altphone'}','$surname','$data{'initials'}',
74 '$data{'ethnicity'}','$bornum','$guarant','$school')";
78 my $sth2=$dbh->prepare($query);
84 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");