Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 112 lines (102 sloc) 5.17 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 a ...
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;
51 if (my $data=$sth->fetchrow_hashref){
335c15d Fixed BBug #291
wolfpac444 authored
52 <<<<<<< insertdata.pl
533c38d fix for #229
tipaul authored
53 $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
54 $data{'joining'}=format_date_in_iso($data{'joining'});
335c15d Fixed BBug #291
wolfpac444 authored
55 $data{'expiry'}=format_date_in_iso($data{'expiry'});
d0374d0 Initial revision
rangi authored
56 $query="update borrowers set title='$data{'title'}',expiry='$data{'expiry'}',
57 cardnumber='$data{'cardnumber'}',sex='$data{'sex'}',ethnotes='$data{'ethnicnotes'}',
58 streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}',firstname='$data{'firstname'}',
59 altnotes='$data{'altnotes'}',dateofbirth='$data{'dateofbirth'}',contactname='$data{'contactname'}',
60 emailaddress='$data{'emailaddress'}',dateenrolled='$data{'joining'}',streetcity='$data{'streetcity'}',
61 altrelationship='$data{'altrelationship'}',othernames='$data{'othernames'}',phoneday='$data{'phoneday'}',
62 categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}',
63 borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}',
7460065 Fixed bug #218
wolfpac444 authored
64 initials='$data{'initials'}',physstreet='$data{'streetaddress'}',ethnicity='$data{'ethnicity'}',
66ecfe5 see #265
tipaul authored
65 gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}',textmessaging='$data{'textmessaging'}', branchcode = '$data{'branchcode'}'
d0374d0 Initial revision
rangi authored
66 where borrowernumber=$data{'borrowernumber'}";
67 # print $query;
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'});
335c15d Fixed BBug #291
wolfpac444 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,
66ecfe5 see #265
tipaul authored
76 initials,ethnicity,borrowernumber,physstreet,branchcode) 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'}',
66ecfe5 see #265
tipaul authored
82 '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}','$data{'branchcode'}')";
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.