Closes bug 488 re Webserver config. Also improves display a little and removes some...
[koha.git] / insertdata.pl
index a14578b..28ac495 100755 (executable)
@@ -27,11 +27,10 @@ use C4::Context;
 use C4::Input;
 use C4::Search;
 use Date::Manip;
+use C4::Date;
 use strict;
 
 my $input= new CGI;
-#print $input->header;
-#print $input->dump;
 
 #get all the data into a hash
 my @names=$input->param;
@@ -49,7 +48,10 @@ my $dbh = C4::Context->dbh;
 my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}";
 my $sth=$dbh->prepare($query);
 $sth->execute;
-if (my $data=$sth->fetchrow_hashref){
+if (my $data2=$sth->fetchrow_hashref){
+  $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
+  $data{'joining'}=format_date_in_iso($data{'joining'});
+  $data{'expiry'}=format_date_in_iso($data{'expiry'});
   $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
   cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
   streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
@@ -59,25 +61,25 @@ if (my $data=$sth->fetchrow_hashref){
   categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
   borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
   initials='$data{'initials'}',physstreet='$data{'streetaddress'}',ethnicity='$data{'ethnicity'}',
-  gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}',textmessaging='$data{'textmessaging'}'
+  gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}',
+  textmessaging='$data{'textmessaging'}', branchcode = '$data{'branchcode'}',
+  zipcode = '$data{'zipcode'}',homezipcode='$data{'homezipcode'}'
   where borrowernumber=$data{'borrowernumber'}";
-#  print $query;
 
 }else{
-  $data{'dateofbirth'}=ParseDate($data{'dateofbirth'});
-  $data{'dateofbirth'}=UnixDate($data{'dateofbirth'},'%Y-%m-%d');
-  $data{'joining'}=ParseDate($data{'joining'});
-  $data{'joining'}=UnixDate($data{'joining'},'%Y-%m-%d');
+  $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
+  $data{'joining'}=format_date_in_iso($data{'joining'});
+  $data{'expiry'}=format_date_in_iso($data{'expiry'});
   $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
   firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity,
   altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
-  initials,ethnicity,borrowernumber,physstreet) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
+  initials,ethnicity,borrowernumber,physstreet,branchcode,zipcode,homezipcode) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
   '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
   '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}','$data{'textmessaging'}',
   '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
   '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}',
   '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}',
-  '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}')";
+  '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}','$data{'branchcode'}','$data{'zipcode'}','$data{'homezipcode'}')";
 }
 # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
 # so when we update information for an adult we should check for guarantees and update the relevant part