bugfix
[koha.git] / newjmember.pl
blob33427d8ea2188376a95955a020a8757ee6df8c95
1 #!/usr/bin/perl
3 # $Id$
5 #script to print confirmation screen, then if accepted calls itself to insert data
6 # FIXME - Yes, but what does it _do_?
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
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.
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.
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
25 use strict;
26 use C4::Output;
27 use C4::Input;
28 use CGI;
29 use Date::Manip;
31 my %env;
32 my $input = new CGI;
33 #get varibale that tells us whether to show confirmation page
34 #or insert data
35 my $insert=$input->param('insert');
36 print $input->header;
37 #get rest of data
38 my %data;
39 my @names=$input->param;
40 foreach my $key (@names){
41 $data{$key}=$input->param($key);
43 my $ok=0;
45 my $string="The following compulsary fields have been left blank. Please push the back button
46 and try again<p>";
47 for (my $i=0;$i<3;$i++){
48 my $number=$data{"cardnumber_child_$i"};
49 my $firstname=$data{"firstname_child_$i"};
50 my $surname=$data{"surname_child_$i"};
51 my $dob=$data{"dateofbirth_child_$i"};
52 my $sex=$data{"sex_child_$i"};
53 if ($number eq ''){
54 if ($i == 0){
55 $string.=" Cardnumber<br>";
56 $ok=1;
58 } else {
59 if ($firstname eq ''){
60 $string.=" Given Names<br>";
61 $ok=1;
63 if ($surname eq ''){
64 $string.=" Surname<br>";
65 $ok=1;
67 if ($dob eq ''){
68 $string.=" Date Of Birth<br>";
69 $ok=1;
71 if ($sex eq ''){
72 $string.=" Gender <br>";
73 $ok=1;
75 my $valid=checkdigit(\%env,$data{"cardnumber_child_$i"});
76 if ($valid != 1){
77 $ok=1;
78 $string.=" Invalid Cardnumber $number<br>";
83 print startpage();
84 print startmenu('member');
86 if ($ok == 0){
87 print mkheadr(1,'Confirm Record');
88 my $main="#99cc33";
89 my $image="/images/background-mem.gif";
90 for (my $i=0;$i<3;$i++){
91 if ($data{"cardnumber_child_$i"} ne ''){
92 print mktablehdr;
93 print mktablerow(2,$main,bold('NEW MEMBER'),"",$image);
94 my $name=$data{"firstname_child_$i"}.$data{"surname_child_$i"};
95 print mktablerow(2,'white',bold('Name'),$name);
96 print mktablerow(2,$main,bold('MEMBERSHIP DETAILS'),"",$image);
97 print mktablerow(2,'white',bold('Membership Number'),$data{"bornumber_child_$i"});
98 print mktablerow(2,'white',bold('Date of Birth'),$data{"dateofbirth_child_$i"});
99 my $sex;
100 if ($data{"sex_child_$i"} eq 'M'){
101 $sex="Male";
102 } else {
103 $sex="Female";
105 print mktablerow(2,'white',bold('Sex'),$sex);
106 print mktablerow(2,'white',bold('School'),$data{"school_child_$i"});
107 print mktablerow(2,'white',bold('General Notes'),$data{"altnotes_child_$i"});
109 print mktableft;
110 print "<p>";
113 my $i=0;
114 my @inputs;
115 while (my ($key, $value) = each %data) {
116 $value=~ s/\"/%22/g;
117 $inputs[$i]=["hidden","$key","$value"];
118 $i++;
120 $inputs[$i]=["submit","submit","submit"];
121 print mkformnotable("/cgi-bin/koha/insertjdata.pl",@inputs);
123 } else {
126 #print $input->dump;
127 print $string;
129 print endmenu('member');
130 print endpage();