X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=members%2Fmemberentry.pl;h=c665b6e9574002513e83fba941571b374b54dac6;hb=97446f86ced2c2d6d4d7a11b97ed81a5a0a25d95;hp=063e4891ff5378be8d67d4abfa6c01a6fc7df96a;hpb=3f35705ddcc3eff0df658faf12320a6e8671b668;p=koha_fer diff --git a/members/memberentry.pl b/members/memberentry.pl index 063e4891ff..c665b6e957 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl # Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN +# Copyright 2010 BibLibre # # This file is part of Koha. # @@ -70,14 +71,15 @@ my $destination = $input->param('destination'); my $cardnumber = $input->param('cardnumber'); my $check_member = $input->param('check_member'); my $nodouble = $input->param('nodouble'); -$nodouble = 1 if $op eq 'modify'; # FIXME hack to represent fact that if we're - # modifying an existing patron, it ipso facto - # isn't a duplicate. Marking FIXME because this - # script needs to be refactored. -my $select_city = $input->param('select_city'); -my $nok = $input->param('nok'); -my $guarantorinfo = $input->param('guarantorinfo'); -my $step = $input->param('step') || 0; +my $duplicate = $input->param('duplicate'); +$nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to represent fact that if we're + # modifying an existing patron, it ipso facto + # isn't a duplicate. Marking FIXME because this + # script needs to be refactored. +my $select_city = $input->param('select_city'); +my $nok = $input->param('nok'); +my $guarantorinfo = $input->param('guarantorinfo'); +my $step = $input->param('step') || 0; my @errors; my $default_city; # $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2 @@ -98,9 +100,10 @@ my @field_check=split(/\|/,$check_BorrowerMandatoryField); foreach (@field_check) { $template->param( "mandatory$_" => 1); } -$template->param("add"=>1) if ($op eq 'add'); -$template->param("checked" => 1) if (defined($nodouble) && $nodouble eq 1); -($borrower_data = GetMember( 'borrowernumber'=>$borrowernumber )) if ($op eq 'modify' or $op eq 'save'); +$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 ); +( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ); 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. @@ -116,9 +119,9 @@ $category_type="A" unless $category_type; # FIXME we should display a error mess %data = %$borrower_data if ($borrower_data); # initialize %newdata -my %newdata; # comes from $input->param() -if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') { - my @names= ($borrower_data && $op ne 'save') ? keys %$borrower_data : $input->param(); +my %newdata; # comes from $input->param() +if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) { + my @names = ( $borrower_data && $op ne 'save' ) ? keys %$borrower_data : $input->param(); foreach my $key (@names) { if (defined $input->param($key)) { $newdata{$key} = $input->param($key); @@ -275,8 +278,8 @@ if ($op eq 'save' || $op eq 'insert'){ } } -if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save') and ($step == 0 or $step == 3 )){ - if (exists ($newdata{'dateexpiry'}) && !($newdata{'dateexpiry'})){ +if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){ + unless ($newdata{'dateexpiry'}){ my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso'); $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2); } @@ -293,6 +296,7 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ if ($op eq 'insert'){ # we know it's not a duplicate borrowernumber or there would already be an error $borrowernumber = &AddMember(%newdata); + $newdata{'borrowernumber'} = $borrowernumber; # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode. if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) { @@ -384,6 +388,11 @@ if ($op eq "modify") { $template->param( updtype => 'M',modify => 1 ); $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step; } +if ( $op eq "duplicate" ) { + $template->param( updtype => 'I' ); + $template->param( step_1 => 1, step_2 => 1, step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1 ) unless $step; +} + # my $cardnumber=$data{'cardnumber'}; $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add'; if(!defined($data{'sex'})){ @@ -610,6 +619,10 @@ if ($nok) { if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){ $data{'dateenrolled'}=C4::Dates->today('iso'); } +if ( $op eq 'duplicate' ) { + $data{'dateenrolled'} = C4::Dates->today('iso'); + $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, $data{'dateenrolled'} ); +} if (C4::Context->preference('uppercasesurnames')) { $data{'surname'} =uc($data{'surname'} ); $data{'contactname'}=uc($data{'contactname'});