X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=members%2Fmemberentry.pl;h=d53f7f10fb9982664fbf867f7437f027cf7da5a7;hb=b1102502aa51ab3384cdfa94faf1237ce8208299;hp=be34cc41b0c6ea137403f42bd50526cc3d3dd51d;hpb=785af7310daa4633359755add9474e81f108d022;p=koha_fer diff --git a/members/memberentry.pl b/members/memberentry.pl index be34cc41b0..d53f7f10fb 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -100,6 +100,13 @@ my @field_check=split(/\|/,$check_BorrowerMandatoryField); foreach (@field_check) { $template->param( "mandatory$_" => 1); } +# function to designate unwanted fields +my $check_BorrowerUnwantedField=C4::Context->preference("BorrowerUnwantedField"); +@field_check=split(/\|/,$check_BorrowerUnwantedField); +foreach (@field_check) { + next unless m/\w/o; + $template->param( "no$_" => 1); +} $template->param( "add" => 1 ) if ( $op eq 'add' ); $template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); @@ -131,6 +138,17 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) $newdata{$key} =~ s/\"/"/g unless $key eq 'borrowernotes' or $key eq 'opacnote'; } } + + ## Manipulate debarred + if ( $newdata{debarred} ) { + $newdata{debarred} = $newdata{datedebarred} ? $newdata{datedebarred} : "9999-12-31"; + } elsif ( exists( $newdata{debarred} ) && !( $newdata{debarred} ) ) { + undef( $newdata{debarred} ); + undef( $newdata{debarredcomment} ); + } elsif ( exists( $newdata{debarredcomment} ) && $newdata{debarredcomment} eq "" ) { + undef( $newdata{debarredcomment} ); + } + my $dateobject = C4::Dates->new(); my $syspref = $dateobject->regexp(); # same syspref format for all 3 dates my $iso = $dateobject->regexp('iso'); # @@ -183,37 +201,42 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } #############test for member being unique ############# -if (($op eq 'insert') and !$nodouble){ - my $category_type_send=$category_type if ($category_type eq 'I'); - my $check_category; # recover the category code of the doublon suspect borrowers - # ($result,$categorycode) = checkuniquemember($collectivity,$surname,$firstname,$dateofbirth) - ($check_member,$check_category) = checkuniquemember( - $category_type_send, - ($newdata{surname} ? $newdata{surname} : $data{surname} ), - ($newdata{firstname} ? $newdata{firstname} : $data{firstname} ), - ($newdata{dateofbirth} ? $newdata{dateofbirth} : $data{dateofbirth}) - ); - if(!$check_member){ - $nodouble = 1; - } - # recover the category type if the borrowers is a doublon +if ( ( $op eq 'insert' ) and !$nodouble ) { + my $category_type_send; + if ( $category_type eq 'I' ) { + $category_type_send = $category_type; + } + my $check_category; # recover the category code of the doublon suspect borrowers + # ($result,$categorycode) = checkuniquemember($collectivity,$surname,$firstname,$dateofbirth) + ( $check_member, $check_category ) = checkuniquemember( + $category_type_send, + ( $newdata{surname} ? $newdata{surname} : $data{surname} ), + ( $newdata{firstname} ? $newdata{firstname} : $data{firstname} ), + ( $newdata{dateofbirth} ? $newdata{dateofbirth} : $data{dateofbirth} ) + ); + if ( !$check_member ) { + $nodouble = 1; + } + + # recover the category type if the borrowers is a doublon if ($check_category) { - my $tmpborrowercategory=GetBorrowercategory($check_category); - $check_categorytype=$tmpborrowercategory->{'category_type'}; - } + my $tmpborrowercategory = GetBorrowercategory($check_category); + $check_categorytype = $tmpborrowercategory->{'category_type'}; + } } #recover all data from guarantor address phone ,fax... if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P' )) { if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) { $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'}; - if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or - $data{'contactname'} ne $guarantordata->{'surname'} ) { - $newdata{'contactfirstname'}= $guarantordata->{'firstname'}; - $newdata{'contactname'} = $guarantordata->{'surname'}; - $newdata{'contacttitle'} = $guarantordata->{'title'}; + $newdata{'contactfirstname'}= $guarantordata->{'firstname'}; + $newdata{'contactname'} = $guarantordata->{'surname'}; + $newdata{'contacttitle'} = $guarantordata->{'title'}; + if ( $op eq 'add' ) { foreach (qw(streetnumber address streettype address2 - zipcode country city phone phonepro mobile fax email emailpro branchcode)) { + zipcode country city state phone phonepro mobile fax email emailpro branchcode + B_streetnumber B_streettype B_address B_address2 + B_city B_state B_zipcode B_country B_email B_phone)) { $newdata{$_} = $guarantordata->{$_}; } } @@ -221,12 +244,10 @@ if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P' )) { } ###############test to take the right zipcode, country and city name ############## -if (!defined($guarantorid) or $guarantorid eq '' or $guarantorid eq '0') { - # set only if parameter was passed from the form - $newdata{'city'} = $input->param('city') if defined($input->param('city')); - $newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode')); - $newdata{'country'} = $input->param('country') if defined($input->param('country')); -} +# set only if parameter was passed from the form +$newdata{'city'} = $input->param('city') if defined($input->param('city')); +$newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode')); +$newdata{'country'} = $input->param('country') if defined($input->param('country')); #builds default userid if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){ @@ -271,6 +292,8 @@ if ($op eq 'save' || $op eq 'insert'){ } my $password = $input->param('password'); + my $password2 = $input->param('password2'); + push @errors, "ERROR_password_mismatch" if ( $password ne $password2 ); push @errors, "ERROR_short_password" if( $password && $minpw && $password ne '****' && (length($password) < $minpw) ); if (C4::Context->preference('ExtendedPatronAttributes')) { @@ -324,12 +347,19 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ # if we manage to find a valid email address, send notice if ($emailaddr) { $newdata{emailaddr} = $emailaddr; - my $letter = getletter ('members', "ACCTDETAILS:$newdata{'branchcode'}") ; - # if $branch notice fails, then email a default notice instead. - $letter = getletter ('members', "ACCTDETAILS") if !$letter; - SendAlerts ( 'members' , \%newdata , $letter ) if $letter + my $err; + eval { + $err = SendAlerts ( 'members', \%newdata, "ACCTDETAILS" ); + }; + if ( $@ ) { + $template->param(error_alert => $@); + } elsif ( defined $err->{error} and $err->{error} eq "no_email" ) { + $template->{VARS}->{'error_alert'} = "no_email"; + } else { + $template->{VARS}->{'info_alert'} = 1; + } } - } + } if ($data{'organisations'}){ # need to add the members organisations @@ -380,7 +410,7 @@ if ($nok or !$nodouble){ } if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; - if ($userenv->{flags} % 2 != 1 && $data{branchcode}){ + if ($userenv->{flags} % 2 != 1 && $data{'branchcode'}){ unless ($userenv->{branch} eq $data{'branchcode'}){ print $input->redirect("/cgi-bin/koha/members/members-home.pl"); exit; @@ -498,7 +528,7 @@ my $borrotitlepopup = CGI::popup_menu(-name=>'title', -default=>$default_borrowertitle ); -my @relationships = split /,|\|/, C4::Context->preference('BorrowerRelationship'); +my @relationships = split /,|\|/, C4::Context->preference('borrowerRelationship'); my @relshipdata; while (@relationships) { my $relship = shift @relationships || ''; @@ -512,8 +542,7 @@ while (@relationships) { } my %flags = ( 'gonenoaddress' => ['gonenoaddress' ], - 'lost' => ['lost'], - 'debarred' => ['debarred']); + 'lost' => ['lost']); my @flagdata; @@ -554,7 +583,9 @@ if(scalar(@select_branch) > 0){ # -------------------------------------------------------------------------------------------------------- #in modify mod :default value from $CGIbranch comes from borrowers table #in add mod: default value come from branches table (ip correspendence) -$default=$data{'branchcode'} if ($op eq 'modify' || ($op eq 'add' && $category_type eq 'C' && $data{'branchcode'})); +if (defined ($data{'branchcode'}) and ( $op eq 'modify' || ( $op eq 'add' && $category_type eq 'C' ) )) { + $default = $data{'branchcode'}; +} $CGIbranch = CGI::scrolling_list(-id => 'branchcode', -name => 'branchcode', -values => \@select_branch, @@ -632,7 +663,10 @@ if (C4::Context->preference('uppercasesurnames')) { $data{'surname'} =uc($data{'surname'} ); $data{'contactname'}=uc($data{'contactname'}); } -foreach (qw(dateenrolled dateexpiry dateofbirth)) { + +$data{debarred} = C4::Overdues::CheckBorrowerDebarred($borrowernumber); +$data{datedebarred} = $data{debarred} if ( $data{debarred} && $data{debarred} ne "9999-12-31" ); +foreach (qw(dateenrolled dateexpiry dateofbirth datedebarred)) { $data{$_} = format_date($data{$_}); # back to syspref for display $template->param( $_ => $data{$_}); } @@ -673,7 +707,7 @@ $template->param(CGIbranch=>$CGIbranch) if ($CGIbranch); $template->param( nodouble => $nodouble, borrowernumber => $borrowernumber, #register number - guarantorid => (($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid, + guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid), ethcatpopup => $ethcatpopup, relshiploop => \@relshipdata, city_loop => $city_arrayref,