Added two missing required Perl modules.
[koha.git] / newimember.pl
1 #!/usr/bin/perl
2
3 #script to print confirmation screen, then if accepted calls itself to insert data
4
5
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use strict;
24 use C4::Output;
25 use C4::Input;
26 use CGI;
27 use Date::Manip;
28
29 my %env;
30 my $input = new CGI;
31 #get varibale that tells us whether to show confirmation page
32 #or insert data
33 my $insert=$input->param('insert');
34 print $input->header;
35 #get rest of data
36 my %data;
37 my @names=$input->param;
38 foreach my $key (@names){                                                                                    
39   $data{$key}=$input->param($key);                                                                           
40 }  
41 my $ok=0;
42
43 my $string="The following compulsary fields have been left blank. Please push the back button
44 and try again<p>";
45 if ($data{'cardnumber_institution'} eq ''){
46   $string.="Cardnumber<br>";
47   $ok=1;
48 }
49 if ($data{'institution_name'} eq ''){
50   $string.="Institution Name<br>";
51   $ok=1;
52 }
53 if ($data{'address'} eq ''){
54   $string.="Postal Address<br>";
55   $ok=1;
56 }
57 if ($data{'city'} eq ''){
58   $string.="City<br>";
59   $ok=1;
60 }
61 if ($data{'contactname'} eq ''){
62   $string.="Contact Name";
63   $ok=1;
64 }
65 #print $input->Dump;
66 #print $string;
67 print startmenu('member');
68 if ($ok ==1){
69   print $string;
70 } else {
71   my $valid=checkdigit(\%env,$data{"cardnumber_institution"});
72   if ($valid != 1){
73     print "Invalid cardnumber";
74   } else {
75     
76      my @inputs;
77      my $i=0;
78      while (my ($key, $value) = each %data) {
79        $value=~ s/\"/%22/g;
80        $inputs[$i]=["hidden","$key","$value"];
81        $i++;                                  
82      }                                        
83      $inputs[$i]=["submit","submit","submit"];
84      print mkformnotable("/cgi-bin/koha/insertidata.pl",@inputs);   
85   }
86 }
87 print endmenu('member');
88 print endpage();