2 # NOTE: This file uses standard 8-space tabs
3 # DO NOT SET TAB SIZE TO 4
7 #script to set up screen for modification of borrower details
8 #written 20/12/99 by chris@katipo.co.nz
11 # Copyright 2000-2002 Katipo Communications
13 # This file is part of Koha.
15 # Koha is free software; you can redistribute it and/or modify it under the
16 # terms of the GNU General Public License as published by the Free Software
17 # Foundation; either version 2 of the License, or (at your option) any later
20 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License along with
25 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
26 # Suite 330, Boston, MA 02111-1307 USA
32 use C4::Interface::CGI::Output;
42 my ($template, $loggedinuser, $cookie)
43 = get_template_and_user({template_name => "members/memberentry.tmpl",
47 flagsrequired => {borrowers => 1},
51 my $member=$input->param('bornum');
53 $member=NewBorrowerNumber();
55 my $type=$input->param('type') || '';
56 my $modify=$input->param('modify.x');
57 my $delete=$input->param('delete.x');
59 print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$member");
61 } else { # this else goes down the whole script
63 $template->param( header => 'Update Member Details'); # bad templating style
65 $template->param( header => 'Add New Member');
68 my $data=borrdata('',$member);
71 $template->param( updtype => 'I');
73 $template->param( updtype => 'M');
76 my $cardnumber=C4::Members::fixup_cardnumber($data->{'cardnumber'});
78 if ($data->{'sex'} eq 'F'){
79 $template->param(female => 1);
82 my @titles = ('Miss', 'Mrs', 'Ms', 'Mr', 'Dr', 'Sir');
83 # FIXME - Assumes English. This ought to be made part of i18n.
87 my $title = shift @titles;
88 $row{'title'} = $title;
89 if ($data->{'title'} eq $title) {
90 $row{'selected'}=' selected';
94 push(@titledata, \%row);
97 my ($categories,$labels)=ethnicitycategories();
98 my $ethnicitycategoriescount=$#{$categories};
100 if ($ethnicitycategoriescount>=0) {
101 $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
102 -values=>$categories,
103 -default=>$data->{'ethnicity'},
105 $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
108 ($categories,$labels)=borrowercategories();
109 my $catcodepopup = CGI::popup_menu(-name=>'categorycode',
110 -values=>$categories,
111 -default=>$data->{'categorycode'},
114 my @areas = ('L','F','S','H','K','O','X','Z','V');
115 my %arealabels = ('L' => 'Levin',
120 'O' => 'Out of District',
121 'X' => 'Temporary Visitor',
122 'Z' => 'Interloan Libraries',
128 my $shortcut = shift @areas;
129 $row{'shortcut'} = $shortcut;
130 if ($data->{'area'} eq $shortcut) {
131 $row{'selected'}=' selected';
135 $row{'area'}=$arealabels{$shortcut};
136 push(@areadata, \%row);
140 my @relationships = ('workplace', 'relative','friend', 'neighbour');
142 while (@relationships) {
143 my $relship = shift @relationships;
144 my %row = ('relationship' => $relship);
145 if ($data->{'altrelationship'} eq $relship) {
146 $row{'selected'}=' selected';
150 push(@relshipdata, \%row);
153 # %flags: keys=$data-keys, datas=[formname, HTML-explanation]
154 my %flags = ('gonenoaddress' => ['gna', 'Gone no address'],
155 'lost' => ['lost', 'Lost'],
156 'debarred' => ['debarred', 'Debarred']);
159 foreach (keys(%flags)) {
161 my %row = ('key' => $key,
162 'name' => $flags{$key}[0],
163 'html' => $flags{$key}[1]);
165 $row{'yes'}=' checked';
169 $row{'no'}=' checked';
171 push(@flagdata, \%row);
175 $template->param( modify => 1 );
178 #Convert dateofbirth to correct format
179 $data->{'dateofbirth'}=ParseDate($data->{'dateofbirth'});
180 $data->{'dateofbirth'}=UnixDate($data->{'dateofbirth'},'%d/%m/%Y');
185 firstname => $data->{'firstname'},
186 surname => $data->{'surname'},
187 othernames => $data->{'othernames'},
188 initials => $data->{'initials'},
189 ethcatpopup => $ethcatpopup,
190 catcodepopup => $catcodepopup,
191 streetaddress => $data->{'streetaddress'},
192 streetcity => $data->{'streetcity'},
193 city => $data->{'city'},
194 phone => $data->{'phone'},
195 phoneday => $data->{'phoneday'},
196 faxnumber => $data->{'faxnumber'},
197 emailaddress => $data->{'emailaddress'},
198 contactname => $data->{'contactname'},
199 altphone => $data->{'altphone'},
200 altnotes => $data->{'altnotes'},
201 borrowernotes => $data->{'borrowernotes'},
202 flagloop => \@flagdata,
203 relshiploop => \@relshipdata,
204 titleloop => \@titledata,
205 arealoop => \@areadata,
206 dateenrolled => $data->{'dateenrolled'},
207 expiry => $data->{'expiry'},
208 cardnumber => $cardnumber,
209 dateofbirth => $data->{'dateofbirth'});
211 output_html_with_http_headers $input, $cookie, $template->output;