Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 112 lines (102 sloc) 5.263 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
1e67687 Added copyright statement to all .pl and .pm files
tonnesen authored
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
24
d0374d0 Initial revision
rangi authored
25 use CGI;
dbca398 Merged with arensb-context branch: use C4::Context->dbh instead of
arensb authored
26 use C4::Context;
d0374d0 Initial revision
rangi authored
27 use C4::Input;
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
28 use C4::Search;
d0374d0 Initial revision
rangi authored
29 use Date::Manip;
00d780e Hmm.. having problems getting my changes to Date.pm saved...
wolfpac444 authored
30 use C4::Date;
d0374d0 Initial revision
rangi authored
31 use strict;
32
33 my $input= new CGI;
34
35 #get all the data into a hash
36 my @names=$input->param;
37 my %data;
38 my $keyfld;
39 my $keyval;
40 my $problems;
41 my $env;
42 foreach my $key (@names){
43 $data{$key}=$input->param($key);
c79e7cd Fixing stupid bug that was causing the sql insert command to break if…
rangi authored
44 $data{$key}=~ s/\'/\\\'/g;
45 $data{$key}=~ s/\"/\\\"/g;
d0374d0 Initial revision
rangi authored
46 }
dbca398 Merged with arensb-context branch: use C4::Context->dbh instead of
arensb authored
47 my $dbh = C4::Context->dbh;
d0374d0 Initial revision
rangi authored
48 my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}";
49 my $sth=$dbh->prepare($query);
50 $sth->execute;
b31ff7e fixes for bug 246 (zipcode), 207 (display of institutional member) an…
tipaul authored
51 if (my $data2=$sth->fetchrow_hashref){
533c38d fix for #229
tipaul authored
52 $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
53 $data{'joining'}=format_date_in_iso($data{'joining'});
335c15d Fixed BBug #291
wolfpac444 authored
54 $data{'expiry'}=format_date_in_iso($data{'expiry'});
d0374d0 Initial revision
rangi authored
55 $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
56 cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
57 streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
58 altnotes='$data{'altnotes'}',dateofbirth='$data{'dateofbirth'}',contactname='$data{'contactname'}',
59 emailaddress='$data{'emailaddress'}',dateenrolled='$data{'joining'}',streetcity='$data{'streetcity'}',
60 altrelationship='$data{'altrelationship'}',othernames='$data{'othernames'}',phoneday='$data{'phoneday'}',
61 categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
62 borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
7460065 Fixed bug #218
wolfpac444 authored
63 initials='$data{'initials'}',physstreet='$data{'streetaddress'}',ethnicity='$data{'ethnicity'}',
b31ff7e fixes for bug 246 (zipcode), 207 (display of institutional member) an…
tipaul authored
64 gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}',
65 textmessaging='$data{'textmessaging'}', branchcode = '$data{'branchcode'}',
66 zipcode = '$data{'zipcode'}',homezipcode='$data{'homezipcode'}'
d0374d0 Initial revision
rangi authored
67 where borrowernumber=$data{'borrowernumber'}";
68
69 }else{
533c38d fix for #229
tipaul authored
70 $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
71 $data{'joining'}=format_date_in_iso($data{'joining'});
f577462 inserting some missing '
tipaul authored
72 $data{'expiry'}=format_date_in_iso($data{'expiry'});
d0374d0 Initial revision
rangi authored
73 $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
a09fc08 Added the stuff for the text messaging field -- Fixed bug #219
wolfpac444 authored
74 firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity,
d0374d0 Initial revision
rangi authored
75 altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
b31ff7e fixes for bug 246 (zipcode), 207 (display of institutional member) an…
tipaul authored
76 initials,ethnicity,borrowernumber,physstreet,branchcode,zipcode,homezipcode) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
d0374d0 Initial revision
rangi authored
77 '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
a09fc08 Added the stuff for the text messaging field -- Fixed bug #219
wolfpac444 authored
78 '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}','$data{'textmessaging'}',
d0374d0 Initial revision
rangi authored
79 '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
80 '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}',
81 '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}',
f577462 inserting some missing '
tipaul authored
82 '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}','$data{'branchcode'}','$data{'zipcode'}','$data{'homezipcode'}')";
d0374d0 Initial revision
rangi authored
83 }
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
84 # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
85 # so when we update information for an adult we should check for guarantees and update the relevant part
86 # of their records, ie addresses and phone numbers
87
88 if ($data{'categorycode'} eq 'A' || $data{'categorycode'} eq 'W'){
89 # is adult check guarantees;
90 my ($count,$guarantees)=findguarantees($data{'borrowernumber'});
91 for (my $i=0;$i<$count;$i++){
0376493 refactored slashifyDate function out of inline code, created C4/Koha.pm
pate authored
92 # FIXME
93 # It looks like the $i is only being returned to handle walking through
94 # the array, which is probably better done as a foreach loop.
95 #
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
96 my $guaquery="update borrowers set streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',
97 streetcity='$data{'streetcity'}',phoneday='$data{'phoneday'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}'
98 ,streetaddress='$data{'address'}'
99 where borrowernumber='$guarantees->[$i]->{'borrowernumber'}'";
100 my $sth3=$dbh->prepare($guaquery);
101 $sth3->execute;
102 $sth3->finish;
103 }
104 }
105
d0374d0 Initial revision
rangi authored
106 #print $query;
107 my $sth2=$dbh->prepare($query);
108 $sth2->execute;
109 $sth2->finish;
110 $sth->finish;
111 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");
Something went wrong with that request. Please try again.