Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 89 lines (81 sloc) 3.975 kb
d0374d0 Initial revision
rangi authored
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;
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
10 use C4::Search;
d0374d0 Initial revision
rangi authored
11 use Date::Manip;
12 use strict;
13
14 my $input= new CGI;
15 #print $input->header;
16 #print $input->dump;
17
18 #get all the data into a hash
19 my @names=$input->param;
20 my %data;
21 my $keyfld;
22 my $keyval;
23 my $problems;
24 my $env;
25 foreach my $key (@names){
26 $data{$key}=$input->param($key);
c79e7cd Fixing stupid bug that was causing the sql insert command to break if a ...
rangi authored
27 $data{$key}=~ s/\'/\\\'/g;
28 $data{$key}=~ s/\"/\\\"/g;
d0374d0 Initial revision
rangi authored
29 }
30 my $dbh=C4Connect;
31 my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}";
32 my $sth=$dbh->prepare($query);
33 $sth->execute;
34 if (my $data=$sth->fetchrow_hashref){
35 $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
36 cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
37 streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
38 altnotes='$data{'altnotes'}',dateofbirth='$data{'dateofbirth'}',contactname='$data{'contactname'}',
39 emailaddress='$data{'emailaddress'}',dateenrolled='$data{'joining'}',streetcity='$data{'streetcity'}',
40 altrelationship='$data{'altrelationship'}',othernames='$data{'othernames'}',phoneday='$data{'phoneday'}',
41 categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
42 borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
c8b9187 Added the functionality to allow librarians to manipulate the flag statu...
rangi authored
43 initials='$data{'initials'}',streetaddress='$data{'address'}',ethnicity='$data{'ethnicity'}',
44 gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}'
d0374d0 Initial revision
rangi authored
45 where borrowernumber=$data{'borrowernumber'}";
46 # print $query;
47
48 }else{
49 $data{'dateofbirth'}=ParseDate($data{'dateofbirth'});
50 $data{'dateofbirth'}=UnixDate($data{'dateofbirth'},'%Y-%m-%d');
51 $data{'joining'}=ParseDate($data{'joining'});
52 $data{'joining'}=UnixDate($data{'joining'},'%Y-%m-%d');
53 $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
54 firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity,
55 altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
56 initials,ethnicity,borrowernumber) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
57 '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
58 '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}',
59 '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
60 '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}',
61 '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}',
62 '$data{'ethnicity'}','$data{'borrowernumber'}')";
63 }
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
64 # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
65 # so when we update information for an adult we should check for guarantees and update the relevant part
66 # of their records, ie addresses and phone numbers
67
68 if ($data{'categorycode'} eq 'A' || $data{'categorycode'} eq 'W'){
69 # is adult check guarantees;
70 my ($count,$guarantees)=findguarantees($data{'borrowernumber'});
71 for (my $i=0;$i<$count;$i++){
72 my $guaquery="update borrowers set streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',
73 streetcity='$data{'streetcity'}',phoneday='$data{'phoneday'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}'
74 ,streetaddress='$data{'address'}'
75 where borrowernumber='$guarantees->[$i]->{'borrowernumber'}'";
76 my $sth3=$dbh->prepare($guaquery);
77 $sth3->execute;
78 $sth3->finish;
79 }
80 }
81
d0374d0 Initial revision
rangi authored
82 #print $query;
83 my $sth2=$dbh->prepare($query);
84 $sth2->execute;
85 $sth2->finish;
86 $sth->finish;
87 $dbh->disconnect;
88 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");
Something went wrong with that request. Please try again.