use strict;
# external modules
-use Date::Calc qw/Today/;
use CGI;
# use Digest::MD5 qw(md5_base64);
use C4::Log;
use C4::Branch; # GetBranches
+#use Smart::Comments;
+
use vars qw($debug);
BEGIN {
my $name_city=$input->param('name_city');
my $nodouble=$input->param('nodouble');
my $select_city=$input->param('select_city');
+my $zipcode=$input->param('zipcode');
+my $city=$input->param('city');
my $nok=$input->param('nok');
my $guarantorinfo=$input->param('guarantorinfo');
my $step=$input->param('step') || 0;
($borrower_data = GetMember($borrowernumber,'borrowernumber')) if ($op eq 'modify' or $op eq 'save');
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
my $category_type = $input->param('category_type');
+my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
unless ($category_type or !($categorycode)){
my $borrowercategory= GetBorrowercategory($categorycode);
$category_type = $borrowercategory->{'category_type'};
###############test to take the right zipcode and city name ##############
if ( $guarantorid eq ''){
- if ($select_city){
- my ($borrower_city,$borrower_zipcode)=&getzipnamecity($select_city);
- $newdata{'city'}= $borrower_city;
- $newdata{'zipcode'}=$borrower_zipcode;
- }
+ $newdata{'city'}= $city;
+ $newdata{'zipcode'}=$zipcode;
}
+
#builds default userid
if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
my $onefirstnameletter = substr($data{'firstname'},0,1);
my $age = GetAge($newdata{dateofbirth});
my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});
my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
- if (($age > $high) or ($age < $low)) {
+ if (($high && ($age > $high)) or ($age < $low)) {
push @errors, 'ERROR_age_limitations';
$template->param('ERROR_age_limitations' => "$low to $high");
}
if ($op eq 'modify' || $op eq 'insert'){
unless ($newdata{'dateexpiry'}){
- my $arg2 = $newdata{'dateenrolled'} || sprintf('%04d-%02d-%02d', Today());
+ my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
$newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
}
}
&ModMember(%newdata);
}
print scalar ($destination eq "circ") ?
- $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}") :
+ $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
$input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
exit; # You can only send 1 redirect! After that, content or other headers don't matter.
}
}
}
if ($op eq 'add'){
- $template->param( updtype => 'I',step_1=>1,step_2=>1,step_3=>1);
+ my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
+ $data{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
+ $template->param( updtype => 'I',step_1=>1,step_2=>1,step_3=>1);
+
}
if ($op eq "modify") {
$template->param( updtype => 'M',modify => 1 );
}
my @typeloop;
-foreach (qw(C A S P I)){
+foreach ( ($new_c_type) ? ($new_c_type) : qw(C A S P I X)){
my $action="WHERE category_type=?";
($categories,$labels)=GetborCatFromCatType($_,$action);
my @categoryloop;
#Formatting data for display
if ($data{'dateenrolled'} eq ''){
- my $today = sprintf('%04d-%02d-%02d', Today()); # ISO format
- $data{'dateenrolled'}=$today;
+ $data{'dateenrolled'}=C4::Dates->today('iso');
}
if (C4::Context->preference('uppercasesurnames')) {
$data{'surname'} =uc($data{'surname'} );
$template->param( $_ => $data{$_});
}
-$template->param( "showguarantor" => ($category_type=~/A|I|S/) ? 0 : 1); # associate with step to know where you are
+$template->param( "showguarantor" => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
$debug and warn "memberentry step: $step";
$template->param(%data);
$template->param( "step_$step" => 1) if $step; # associate with step to know where u are