Replaced expressions of the form "$x = $x <op> $y" with "$x <op>= $y".
[koha.git] / newimember.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to print confirmation screen, then if accepted calls itself to insert data
6
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
25 use strict;
26 use C4::Output;
27 use C4::Input;
28 use CGI;
29 use Date::Manip;
30
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);
42 }
43 my $ok=0;
44
45 my $string="The following compulsary fields have been left blank. Please push the back button
46 and try again<p>";
47 if ($data{'cardnumber_institution'} eq ''){
48   $string.="Cardnumber<br>";
49   $ok=1;
50 }
51 if ($data{'institution_name'} eq ''){
52   $string.="Institution Name<br>";
53   $ok=1;
54 }
55 if ($data{'address'} eq ''){
56   $string.="Postal Address<br>";
57   $ok=1;
58 }
59 if ($data{'city'} eq ''){
60   $string.="City<br>";
61   $ok=1;
62 }
63 if ($data{'contactname'} eq ''){
64   $string.="Contact Name";
65   $ok=1;
66 }
67 #print $input->Dump;
68 #print $string;
69 print startmenu('member');
70 if ($ok ==1){
71   print $string;
72 } else {
73   my $valid=checkdigit(\%env,$data{"cardnumber_institution"});
74   if ($valid != 1){
75     print "Invalid cardnumber";
76   } else {
77
78      my @inputs;
79      my $i=0;
80      while (my ($key, $value) = each %data) {
81        $value=~ s/\"/%22/g;
82        $inputs[$i]=["hidden","$key","$value"];
83        $i++;
84      }
85      $inputs[$i]=["submit","submit","submit"];
86      print mkformnotable("/cgi-bin/koha/insertidata.pl",@inputs);
87   }
88 }
89 print endmenu('member');
90 print endpage();