Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.9 KiB

  1. #!/usr/bin/perl
  2. #script to enter borrower data into the data base
  3. #needs to be moved into a perl module
  4. # written 9/11/99 by chris@katipo.co.nz
  5. use CGI;
  6. use C4::Database;
  7. use C4::Input;
  8. use Date::Manip;
  9. use strict;
  10. my $input= new CGI;
  11. #print $input->header;
  12. #print $input->dump;
  13. #get all the data into a hash
  14. my @names=$input->param;
  15. my %data;
  16. my $keyfld;
  17. my $keyval;
  18. my $problems;
  19. my $env;
  20. foreach my $key (@names){
  21. $data{$key}=$input->param($key);
  22. }
  23. my $dbh=C4Connect;
  24. my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}";
  25. my $sth=$dbh->prepare($query);
  26. $sth->execute;
  27. if (my $data=$sth->fetchrow_hashref){
  28. $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
  29. cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
  30. streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
  31. altnotes='$data{'altnotes'}',dateofbirth='$data{'dateofbirth'}',contactname='$data{'contactname'}',
  32. emailaddress='$data{'emailaddress'}',dateenrolled='$data{'joining'}',streetcity='$data{'streetcity'}',
  33. altrelationship='$data{'altrelationship'}',othernames='$data{'othernames'}',phoneday='$data{'phoneday'}',
  34. categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
  35. borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
  36. initials='$data{'initials'}',streetaddress='$data{'address'}',ethnicity='$data{'ethnicity'}'
  37. where borrowernumber=$data{'borrowernumber'}";
  38. # print $query;
  39. }else{
  40. $data{'dateofbirth'}=ParseDate($data{'dateofbirth'});
  41. $data{'dateofbirth'}=UnixDate($data{'dateofbirth'},'%Y-%m-%d');
  42. $data{'joining'}=ParseDate($data{'joining'});
  43. $data{'joining'}=UnixDate($data{'joining'},'%Y-%m-%d');
  44. $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
  45. firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity,
  46. altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
  47. initials,ethnicity,borrowernumber) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
  48. '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
  49. '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}',
  50. '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
  51. '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}',
  52. '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}',
  53. '$data{'ethnicity'}','$data{'borrowernumber'}')";
  54. }
  55. #print $query;
  56. my $sth2=$dbh->prepare($query);
  57. $sth2->execute;
  58. $sth2->finish;
  59. $sth->finish;
  60. $dbh->disconnect;
  61. print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");