|
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->{patron_attributes} = C4::Members::Attributes::GetBorrowerAttributes( $patron->{borrowernumber} ); |
| 336 |
push @borrowers, $borrower; |
344 |
$max_nb_attr = scalar( @{ $patron->{patron_attributes} } ) |
|
|
345 |
if scalar( @{ $patron->{patron_attributes} } ) > $max_nb_attr; |
| 346 |
push @borrowers, $patron; |
| 337 |
} |
347 |
} |
| 338 |
} |
348 |
} |
| 339 |
my @patron_attributes_option; |
349 |
my @patron_attributes_option; |
|
Lines 363-385
$template->param(
Link Here
|
| 363 |
); |
373 |
); |
| 364 |
output_html_with_http_headers $input, $cookie, $template->output; |
374 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 365 |
exit; |
375 |
exit; |
| 366 |
|
|
|
| 367 |
sub GetBorrowerInfos { |
| 368 |
my ( %info ) = @_; |
| 369 |
my $borrower = Koha::Patrons->find( \%info ); |
| 370 |
if ( $borrower ) { |
| 371 |
$borrower = $borrower->unblessed; |
| 372 |
for ( qw(dateenrolled dateexpiry) ) { |
| 373 |
my $userdate = $borrower->{$_}; |
| 374 |
unless ($userdate && $userdate ne "0000-00-00" and $userdate ne "9999-12-31") { |
| 375 |
$borrower->{$_} = ''; |
| 376 |
next; |
| 377 |
} |
| 378 |
$borrower->{$_} = $userdate || ''; |
| 379 |
} |
| 380 |
$borrower->{category_description} = Koha::Patron::Categories->find( $borrower->{categorycode} )->{description}; |
| 381 |
my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} ); |
| 382 |
$borrower->{patron_attributes} = $attr_loop; |
| 383 |
} |
| 384 |
return $borrower; |
| 385 |
} |
| 386 |
- |