*** empty log message ***
[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 #modified 2002/12/16 by hdl@ifrance.com : Templating
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use strict;
27 use C4::Output;
28 use C4::Input;
29 use CGI;
30 use Date::Manip;
31 use HTML::Template;
32
33 my %env;
34 my $input = new CGI;
35 #get varibale that tells us whether to show confirmation page
36 #or insert data
37 my $insert=$input->param('insert');
38
39 my $template=gettemplate("newimember.tmpl");
40 #get rest of data
41 my %data;
42 my @names=$input->param;
43 foreach my $key (@names){
44   $data{$key}=$input->param($key);
45 }
46 my $ok=0;
47
48 my $string="The following compulsary fields have been left blank. Please push the back button
49 and try again<p>";
50 if ($data{'cardnumber_institution'} eq ''){
51   $string.="Cardnumber<br>";
52   $ok=1;
53 }
54 if ($data{'institution_name'} eq ''){
55   $string.="Institution Name<br>";
56   $ok=1;
57 }
58 if ($data{'address'} eq ''){
59   $string.="Postal Address<br>";
60   $ok=1;
61 }
62 if ($data{'city'} eq ''){
63   $string.="City<br>";
64   $ok=1;
65 }
66 if ($data{'contactname'} eq ''){
67   $string.="Contact Name";
68   $ok=1;
69 }
70 #print $input->Dump;
71 #print $string;
72 #print startmenu('member');
73
74 $template->param( missingloop => ($ok==1));
75 $template->param( string => $string);
76 if ($ok !=1) {
77         my $valid=checkdigit(\%env,$data{"cardnumber_institution"});
78         $template->param( invalid => ($valid !=1));
79         if (valid==1){
80                 my @inputs;
81                 while (my ($key, $value) = each %data) {
82                         $value=~ s/\"/%22/g;
83                         my %line;
84                         $line{'key'}=$key;
85                         $line{'value'}=$value;
86                         push(@inputs, \%line);
87                         }
88                 $template->param(inputsloop => \@inputs);
89   }
90 }
91 print "Content-Type: text/html\n\n", $template->output;
92