View | Details | Raw Unified | Return to bug 19936
Collapse All | Expand All

(-)a/C4/Members.pm (-2 / +2 lines)
Lines 398-406 sub AddMember { Link Here
398
        }
398
        }
399
    }
399
    }
400
400
401
    my $p = Koha::Patron->new( { userid => $data{userid} } );
401
    my $p = Koha::Patron->new( { userid => $data{userid}, firstname => $data{firstname}, surname => $data{surname} } );
402
    # generate a proper login if none provided
402
    # generate a proper login if none provided
403
    $data{'userid'} = Generate_Userid( $data{'borrowernumber'}, $data{'firstname'}, $data{'surname'} )
403
    $data{'userid'} = $p->generate_userid
404
      if ( $data{'userid'} eq '' || ! $p->has_valid_userid );
404
      if ( $data{'userid'} eq '' || ! $p->has_valid_userid );
405
405
406
    # add expiration date if it isn't already there
406
    # add expiration date if it isn't already there
(-)a/members/memberentry.pl (-4 / +12 lines)
Lines 151-158 $template->param( "add" => 1 ) if ( $op eq 'add' ); Link Here
151
$template->param( "quickadd" => 1 ) if ( $quickadd );
151
$template->param( "quickadd" => 1 ) if ( $quickadd );
152
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
152
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
153
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
153
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 );
154
my $patron;
154
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
155
if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) {
155
    my $patron = Koha::Patrons->find( $borrowernumber );
156
157
    $patron = Koha::Patrons->find( $borrowernumber );
156
    unless ( $patron ) {
158
    unless ( $patron ) {
157
        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
159
        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
158
        exit;
160
        exit;
Lines 160-165 if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) { Link Here
160
162
161
    $borrower_data = $patron->unblessed;
163
    $borrower_data = $patron->unblessed;
162
    $borrower_data->{category_type} = $patron->category->category_type;
164
    $borrower_data->{category_type} = $patron->category->category_type;
165
} else {
166
    $patron = Koha::Patron->new;
163
}
167
}
164
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
168
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
165
my $category_type = $input->param('category_type') || '';
169
my $category_type = $input->param('category_type') || '';
Lines 281-292 $newdata{'lang'} = $input->param('lang') if defined($input->param('lang')) Link Here
281
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ ) {
285
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ ) {
282
    if ( ( defined $newdata{'firstname'} ) && ( defined $newdata{'surname'} ) ) {
286
    if ( ( defined $newdata{'firstname'} ) && ( defined $newdata{'surname'} ) ) {
283
        # Full page edit, firstname and surname input zones are present
287
        # Full page edit, firstname and surname input zones are present
284
        $newdata{'userid'} = Generate_Userid( $borrowernumber, $newdata{'firstname'}, $newdata{'surname'} );
288
        $patron->firstname($newdata{firstname});
289
        $patron->surname($newdata{surname});
290
        $newdata{'userid'} = $patron->generate_userid;
285
    }
291
    }
286
    elsif ( ( defined $data{'firstname'} ) && ( defined $data{'surname'} ) ) {
292
    elsif ( ( defined $data{'firstname'} ) && ( defined $data{'surname'} ) ) {
287
        # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used
293
        # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used
288
        # Still, if the userid field is erased, we can create a new userid with available firstname and surname
294
        # Still, if the userid field is erased, we can create a new userid with available firstname and surname
289
        $newdata{'userid'} = Generate_Userid( $borrowernumber, $data{'firstname'}, $data{'surname'} );
295
        # FIXME clean thiscode newdata vs data is very confusing
296
        $patron->firstname($data{firstname});
297
        $patron->surname($data{surname});
298
        $newdata{'userid'} = $patron->generate_userid;
290
    }
299
    }
291
    else {
300
    else {
292
        $newdata{'userid'} = $data{'userid'};
301
        $newdata{'userid'} = $data{'userid'};
293
- 

Return to bug 19936