X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=members%2Fmemberentry.pl;h=4b410a7036127452cbe3221572354ff816d8e662;hb=9c5e40e4923179bf0b2b630d3e09797dc4c1fdb0;hp=6b0e8464dd6614289f4085192be4d3d3da1c19c0;hpb=c8eb5eab63b04fdc8406dc2e45ed4032456a48ab;p=koha.git diff --git a/members/memberentry.pl b/members/memberentry.pl index 6b0e8464dd..4b410a7036 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -41,6 +41,8 @@ use C4::Log; use C4::Letters; use C4::Branch; # GetBranches use C4::Form::MessagingPreferences; +use Koha::Borrower::Debarments; +use Koha::DateUtils; use vars qw($debug); @@ -62,6 +64,7 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {borrowers => 1}, debug => ($debug) ? 1 : 0, }); + my $guarantorid = $input->param('guarantorid'); my $borrowernumber = $input->param('borrowernumber'); my $actionType = $input->param('actionType') || ''; @@ -90,6 +93,29 @@ my $borrower_data; my $NoUpdateLogin; my $userenv = C4::Context->userenv; + +## Deal with debarments +$template->param( + debarments => GetDebarments( { borrowernumber => $borrowernumber } ) ); +my @debarments_to_remove = $input->param('remove_debarment'); +foreach my $d ( @debarments_to_remove ) { + DelDebarment( $d ); +} +if ( $input->param('add_debarment') ) { + + my $expiration = $input->param('debarred_expiration'); + $expiration = $expiration ? output_pref( dt_from_string($expiration), 'iso' ) : undef; + + AddUniqueDebarment( + { + borrowernumber => $borrowernumber, + type => 'MANUAL', + comment => $input->param('debarred_comment'), + expiration => $expiration, + } + ); +} + $template->param("uppercasesurnames" => C4::Context->preference('uppercasesurnames')); my $minpw = C4::Context->preference('minPasswordLength'); @@ -142,16 +168,6 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } } - ## 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'); # @@ -254,7 +270,18 @@ $newdata{'country'} = $input->param('country') if defined($input->param('country #builds default userid if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){ - $newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'}); + if ( ( defined $newdata{'firstname'} ) && ( defined $newdata{'surname'} ) ) { + # Full page edit, firstname and surname input zones are present + $newdata{'userid'} = Generate_Userid( $borrowernumber, $newdata{'firstname'}, $newdata{'surname'} ); + } + elsif ( ( defined $data{'firstname'} ) && ( defined $data{'surname'} ) ) { + # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used + # Still, if the userid field is erased, we can create a new userid with available firstname and surname + $newdata{'userid'} = Generate_Userid( $borrowernumber, $data{'firstname'}, $data{'surname'} ); + } + else { + $newdata{'userid'} = $data{'userid'}; + } } $debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry); @@ -281,7 +308,7 @@ if ($op eq 'save' || $op eq 'insert'){ $newdata{'surname'} = uc($newdata{'surname'}); } - if (C4::Context->preference("IndependantBranches")) { + if (C4::Context->preference("IndependentBranches")) { if ($userenv && $userenv->{flags} % 2 != 1){ $debug and print STDERR " $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch}; unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){ @@ -304,7 +331,7 @@ if ($op eq 'save' || $op eq 'insert'){ foreach my $attr (@$extended_patron_attributes) { unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) { push @errors, "ERROR_extended_unique_id_failed"; - $template->param(ERROR_extended_unique_id_failed => "$attr->{code}/$attr->{value}"); + $template->param(ERROR_extended_unique_id_failed_value => "$attr->{code}/$attr->{value}"); } } } @@ -411,7 +438,7 @@ if ($nok or !$nodouble){ $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1); } } -if (C4::Context->preference("IndependantBranches")) { +if (C4::Context->preference("IndependentBranches")) { my $userenv = C4::Context->userenv; if ($userenv->{flags} % 2 != 1 && $data{'branchcode'}){ unless ($userenv->{branch} eq $data{'branchcode'}){ @@ -646,13 +673,11 @@ if ( $op eq 'duplicate' ) { $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, $data{'dateenrolled'} ); } if (C4::Context->preference('uppercasesurnames')) { - $data{'surname'} =uc($data{'surname'} ); - $data{'contactname'}=uc($data{'contactname'}); + $data{'surname'} &&= uc( $data{'surname'} ); + $data{'contactname'} &&= uc( $data{'contactname'} ); } -$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)) { +foreach (qw(dateenrolled dateexpiry dateofbirth)) { $data{$_} = format_date($data{$_}); # back to syspref for display $template->param( $_ => $data{$_}); } @@ -700,8 +725,6 @@ $template->param( borrotitlepopup => $borrotitlepopup, guarantorinfo => $guarantorinfo, flagloop => \@flagdata, - dateformat => C4::Dates->new()->visual(), - C4::Context->preference('dateformat') => 1, check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function category_type =>$category_type, modify => $modify,