New system preference for setting date format when entering patron birth dates.
[koha.git] / newjmember.pl
blob56d47c3b49d3f3ae98437a4ce99b89776a5ccf3c
1 #!/usr/bin/perl
3 #script to print confirmation screen, then if accepted calls itself to insert data
5 use strict;
6 use C4::Output;
7 use C4::Input;
8 use C4::Auth;
9 use CGI;
10 use Date::Manip;
12 my %env;
13 my $input = new CGI;
14 my $flagsrequired;
15 $flagsrequired->{borrower}=1;
16 my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
17 #get varibale that tells us whether to show confirmation page
18 #or insert data
19 my $insert=$input->param('insert');
20 print $input->header;
21 #get rest of data
22 my %data;
23 my @names=$input->param;
24 foreach my $key (@names){
25 $data{$key}=$input->param($key);
27 my $ok=0;
29 my $string="The following compulsary fields have been left blank. Please push the back button
30 and try again<p>";
31 for (my $i=0;$i<3;$i++){
32 my $number=$data{"cardnumber_child_$i"};
33 my $firstname=$data{"firstname_child_$i"};
34 my $surname=$data{"surname_child_$i"};
35 my $dob=$data{"dateofbirth_child_$i"};
36 my $sex=$data{"sex_child_$i"};
37 if ($number eq ''){
38 if ($i == 0){
39 $string.=" Cardnumber<br>";
40 $ok=1;
42 } else {
43 if ($firstname eq ''){
44 $string.=" Given Names<br>";
45 $ok=1;
47 if ($surname eq ''){
48 $string.=" Surname<br>";
49 $ok=1;
51 if ($dob eq ''){
52 $string.=" Date Of Birth<br>";
53 $ok=1;
55 if ($sex eq ''){
56 $string.=" Gender <br>";
57 $ok=1;
59 my $valid=checkdigit(\%env,$data{"cardnumber_child_$i"});
60 if ($valid != 1){
61 $ok=1;
62 $string.=" Invalid Cardnumber $number<br>";
67 print startpage();
68 print startmenu('member');
70 if ($ok == 0){
71 print mkheadr(1,'Confirm Record');
72 my $main="#99cc33";
73 my $image="/images/background-mem.gif";
74 for (my $i=0;$i<3;$i++){
75 if ($data{"cardnumber_child_$i"} ne ''){
76 print mktablehdr;
77 print mktablerow(2,$main,bold('NEW MEMBER'),"",$image);
78 my $name=$data{"firstname_child_$i"}.$data{"surname_child_$i"};
79 print mktablerow(2,'white',bold('Name'),$name);
80 print mktablerow(2,$main,bold('MEMBERSHIP DETAILS'),"",$image);
81 print mktablerow(2,'white',bold('Membership Number'),$data{"bornumber_child_$i"});
82 print mktablerow(2,'white',bold('Date of Birth'),$data{"dateofbirth_child_$i"});
83 my $sex;
84 if ($data{"sex_child_$i"} eq 'M'){
85 $sex="Male";
86 } else {
87 $sex="Female";
89 print mktablerow(2,'white',bold('Sex'),$sex);
90 print mktablerow(2,'white',bold('School'),$data{"school_child_$i"});
91 print mktablerow(2,'white',bold('General Notes'),$data{"altnotes_child_$i"});
93 print mktableft;
94 print "<p>";
97 my $i=0;
98 my @inputs;
99 while (my ($key, $value) = each %data) {
100 $value=~ s/\"/%22/g;
101 $inputs[$i]=["hidden","$key","$value"];
102 $i++;
104 $inputs[$i]=["submit","submit","submit"];
105 print mkformnotable("/cgi-bin/koha/insertjdata.pl",@inputs);
107 } else {
110 #print $input->dump;
111 print $string;
113 print endmenu('member');
114 print endpage();