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.

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