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

(-)a/tools/modborrowers.pl (-35 / +24 lines)
Lines 51-56 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
51
    }
51
    }
52
);
52
);
53
53
54
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
55
54
my %cookies   = parse CGI::Cookie($cookie);
56
my %cookies   = parse CGI::Cookie($cookie);
55
my $sessionID = $cookies{'CGISESSID'}->value;
57
my $sessionID = $cookies{'CGISESSID'}->value;
56
my $dbh       = C4::Context->dbh;
58
my $dbh       = C4::Context->dbh;
Lines 62-68 if ( $op eq 'show' ) { Link Here
62
    my $patron_list_id = $input->param('patron_list_id');
64
    my $patron_list_id = $input->param('patron_list_id');
63
    my @borrowers;
65
    my @borrowers;
64
    my @cardnumbers;
66
    my @cardnumbers;
65
    my @notfoundcardnumbers;
67
    my ( @notfoundcardnumbers, @from_another_group_of_libraries );
66
68
67
    # Get cardnumbers from a file or the input area
69
    # Get cardnumbers from a file or the input area
68
    my @contentlist;
70
    my @contentlist;
Lines 86-96 if ( $op eq 'show' ) { Link Here
86
88
87
    my $max_nb_attr = 0;
89
    my $max_nb_attr = 0;
88
    for my $cardnumber ( @cardnumbers ) {
90
    for my $cardnumber ( @cardnumbers ) {
89
        my $borrower = GetBorrowerInfos( cardnumber => $cardnumber );
91
        my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
90
        if ( $borrower ) {
92
        if ( $patron ) {
91
            $max_nb_attr = scalar( @{ $borrower->{patron_attributes} } )
93
            if ( $logged_in_user->can_see_patron_infos( $patron ) ) {
92
                if scalar( @{ $borrower->{patron_attributes} } ) > $max_nb_attr;
94
                $patron = $patron->unblessed;
93
            push @borrowers, $borrower;
95
                $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} );
96
                $max_nb_attr = scalar( @{ $patron->{patron_attributes} } )
97
                    if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr;
98
                push @borrowers, $patron;
99
            } else {
100
                push @notfoundcardnumbers, $cardnumber;
101
            }
94
        } else {
102
        } else {
95
            push @notfoundcardnumbers, $cardnumber;
103
            push @notfoundcardnumbers, $cardnumber;
96
        }
104
        }
Lines 289-296 if ( $op eq 'do' ) { Link Here
289
            $infos->{borrowernumber} = $borrowernumber;
297
            $infos->{borrowernumber} = $borrowernumber;
290
            my $success = ModMember(%$infos);
298
            my $success = ModMember(%$infos);
291
            if (!$success) {
299
            if (!$success) {
292
                my $borrowerinfo = GetBorrowerInfos( borrowernumber => $borrowernumber );
300
                my $patron = Koha::Patrons->find( $borrowernumber );
293
                $infos->{cardnumber} = $borrowerinfo->{cardnumber} || '';
301
                $infos->{cardnumber} = $patron ? $patron->cardnumber || '' : '';
294
                push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
302
                push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
295
            }
303
            }
296
        }
304
        }
Lines 329-339 if ( $op eq 'do' ) { Link Here
329
    my @borrowers;
337
    my @borrowers;
330
    my $max_nb_attr = 0;
338
    my $max_nb_attr = 0;
331
    for my $borrowernumber ( @borrowernumbers ) {
339
    for my $borrowernumber ( @borrowernumbers ) {
332
        my $borrower = GetBorrowerInfos( borrowernumber => $borrowernumber );
340
        my $patron = Koha::Patrons->find( $borrowernumber );
333
        if ( $borrower ) {
341
        if ( $patron ) {
334
            $max_nb_attr = scalar( @{ $borrower->{patron_attributes} } )
342
            $patron = $patron->unblessed;
335
                if scalar( @{ $borrower->{patron_attributes} } ) > $max_nb_attr;
343
            $patron->{category_description} = $patron->category->description;
336
            push @borrowers, $borrower;
344
            $patron->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} );
345
            $max_nb_attr = scalar( @{ $patron->{patron_attributes} } )
346
                if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr;
347
            push @borrowers, $patron;
337
        }
348
        }
338
    }
349
    }
339
    my @patron_attributes_option;
350
    my @patron_attributes_option;
Lines 363-386 $template->param( Link Here
363
);
374
);
364
output_html_with_http_headers $input, $cookie, $template->output;
375
output_html_with_http_headers $input, $cookie, $template->output;
365
exit;
376
exit;
366
367
sub GetBorrowerInfos {
368
    my ( %info ) = @_;
369
    my $patron = Koha::Patrons->find( \%info );
370
    my $borrower;
371
    if ( $patron ) {
372
        $borrower = $patron->unblessed;
373
        for ( qw(dateenrolled dateexpiry) ) {
374
            my $userdate = $borrower->{$_};
375
            unless ($userdate && $userdate ne "0000-00-00" and $userdate ne "9999-12-31") {
376
                $borrower->{$_} = '';
377
                next;
378
            }
379
            $borrower->{$_} = $userdate || '';
380
        }
381
        $borrower->{category_description} = $patron->category->description;
382
        my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} );
383
        $borrower->{patron_attributes} = $attr_loop;
384
    }
385
    return $borrower;
386
}
387
- 

Return to bug 18403