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;
41 my ($template, $loggedinuser, $cookie)
42 = get_template_and_user({template_name => "members/memberentry.tmpl",
46 flagsrequired => {borrowers => 1},
50 my $member=$input->param('bornum');
52 $member=NewBorrowerNumber();
54 my $type=$input->param('type') || '';
55 my $modify=$input->param('modify.x');
56 my $delete=$input->param('delete.x');
58 print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$member");
60 } else { # this else goes down the whole script
62 $template->param( header => 'Update Member Details'); # bad templating style
64 $template->param( header => 'Add New Member');
67 my $data=borrdata('',$member);
70 $template->param( updtype => 'I');
72 $template->param( updtype => 'M');
75 my $cardnumber=C4::Members::fixup_cardnumber($data->{'cardnumber'});
77 if ($data->{'sex'} eq 'F'){
78 $template->param(female => 1);
81 my @titles = ('Miss', 'Mrs', 'Ms', 'Mr', 'Dr', 'Sir');
82 # FIXME - Assumes English. This ought to be made part of i18n.
86 my $title = shift @titles;
87 $row{'title'} = $title;
88 if ($data->{'title'} eq $title) {
89 $row{'selected'}=' selected';
93 push(@titledata, \%row);
96 my ($categories,$labels)=ethnicitycategories();
97 my $ethnicitycategoriescount=$#{$categories};
99 if ($ethnicitycategoriescount>=0) {
100 $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
101 -values=>$categories,
102 -default=>$data->{'ethnicity'},
104 $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
107 ($categories,$labels)=borrowercategories();
108 my $catcodepopup = CGI::popup_menu(-name=>'categorycode',
109 -values=>$categories,
110 -default=>$data->{'categorycode'},
113 my @areas = ('L','F','S','H','K','O','X','Z','V');
114 my %arealabels = ('L' => 'Levin',
119 'O' => 'Out of District',
120 'X' => 'Temporary Visitor',
121 'Z' => 'Interloan Libraries',
127 my $shortcut = shift @areas;
128 $row{'shortcut'} = $shortcut;
129 if ($data->{'area'} eq $shortcut) {
130 $row{'selected'}=' selected';
134 $row{'area'}=$arealabels{$shortcut};
135 push(@areadata, \%row);
139 my @relationships = ('workplace', 'relative','friend', 'neighbour');
141 while (@relationships) {
142 my $relship = shift @relationships;
143 my %row = ('relationship' => $relship);
144 if ($data->{'altrelationship'} eq $relship) {
145 $row{'selected'}=' selected';
149 push(@relshipdata, \%row);
152 # %flags: keys=$data-keys, datas=[formname, HTML-explanation]
153 my %flags = ('gonenoaddress' => ['gna', 'Gone no address'],
154 'lost' => ['lost', 'Lost'],
155 'debarred' => ['debarred', 'Debarred']);
158 foreach (keys(%flags)) {
160 my %row = ('key' => $key,
161 'name' => $flags{$key}[0],
162 'html' => $flags{$key}[1]);
164 $row{'yes'}=' checked';
168 $row{'no'}=' checked';
170 push(@flagdata, \%row);
174 $template->param( modify => 1 );
179 firstname => $data->{'firstname'},
180 surname => $data->{'surname'},
181 othernames => $data->{'othernames'},
182 initials => $data->{'initials'},
183 ethcatpopup => $ethcatpopup,
184 catcodepopup => $catcodepopup,
185 streetaddress => $data->{'streetaddress'},
186 streetcity => $data->{'streetcity'},
187 city => $data->{'city'},
188 phone => $data->{'phone'},
189 phoneday => $data->{'phoneday'},
190 faxnumber => $data->{'faxnumber'},
191 emailaddress => $data->{'emailaddress'},
192 contactname => $data->{'contactname'},
193 altphone => $data->{'altphone'},
194 altnotes => $data->{'altnotes'},
195 borrowernotes => $data->{'borrowernotes'},
196 flagloop => \@flagdata,
197 relshiploop => \@relshipdata,
198 titleloop => \@titledata,
199 arealoop => \@areadata,
200 dateenrolled => $data->{'dateenrolled'},
201 expiry => $data->{'expiry'},
202 cardnumber => $cardnumber,
203 dateofbirth => $data->{'dateofbirth'});
205 output_html_with_http_headers $input, $cookie, $template->output;