Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 113 lines (103 sloc) 5.277 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 # print $query;
69
70 }else{
533c38d fix for #229
tipaul authored
71 $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
72 $data{'joining'}=format_date_in_iso($data{'joining'});
335c15d Fixed BBug #291
wolfpac444 authored
73 $data{'expiry'}=format_date_in_iso($data{'expiry'});
d0374d0 Initial revision
rangi authored
74 $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
75 firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity,
d0374d0 Initial revision
rangi authored
76 altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname,
b31ff7e fixes for bug 246 (zipcode), 207 (display of institutional member) an…
tipaul authored
77 initials,ethnicity,borrowernumber,physstreet,branchcode,zipcode,homezipcode) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}',
d0374d0 Initial revision
rangi authored
78 '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}',
a09fc08 Added the stuff for the text messaging field -- Fixed bug #219
wolfpac444 authored
79 '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}','$data{'textmessaging'}',
d0374d0 Initial revision
rangi authored
80 '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
81 '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}',
82 '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}',
b31ff7e fixes for bug 246 (zipcode), 207 (display of institutional member) an…
tipaul authored
83 '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}','$data{'branchcode'}',$data{'zipcode'},$data{'homezipcode'})";
d0374d0 Initial revision
rangi authored
84 }
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
85 # ok if its an adult (type) it may have borrowers that depend on it as a guarantor
86 # so when we update information for an adult we should check for guarantees and update the relevant part
87 # of their records, ie addresses and phone numbers
88
89 if ($data{'categorycode'} eq 'A' || $data{'categorycode'} eq 'W'){
90 # is adult check guarantees;
91 my ($count,$guarantees)=findguarantees($data{'borrowernumber'});
92 for (my $i=0;$i<$count;$i++){
0376493 refactored slashifyDate function out of inline code, created C4/Koha.pm
pate authored
93 # FIXME
94 # It looks like the $i is only being returned to handle walking through
95 # the array, which is probably better done as a foreach loop.
96 #
5374431 Modify an adult with guarantees now modifies the guarantees also.
rangi authored
97 my $guaquery="update borrowers set streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',
98 streetcity='$data{'streetcity'}',phoneday='$data{'phoneday'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}'
99 ,streetaddress='$data{'address'}'
100 where borrowernumber='$guarantees->[$i]->{'borrowernumber'}'";
101 my $sth3=$dbh->prepare($guaquery);
102 $sth3->execute;
103 $sth3->finish;
104 }
105 }
106
d0374d0 Initial revision
rangi authored
107 #print $query;
108 my $sth2=$dbh->prepare($query);
109 $sth2->execute;
110 $sth2->finish;
111 $sth->finish;
112 print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");
Something went wrong with that request. Please try again.