Lines 25-31
use C4::Items;
Link Here
|
25 |
use C4::Circulation; |
25 |
use C4::Circulation; |
26 |
use C4::Accounts; |
26 |
use C4::Accounts; |
27 |
use C4::Biblio; |
27 |
use C4::Biblio; |
28 |
use C4::Reserves qw(AddReserve GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest); |
28 |
use C4::Reserves qw(AddReserve CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest); |
29 |
use C4::Context; |
29 |
use C4::Context; |
30 |
use C4::AuthoritiesMarc; |
30 |
use C4::AuthoritiesMarc; |
31 |
use XML::Simple; |
31 |
use XML::Simple; |
Lines 37-42
use C4::Members::Attributes qw(GetBorrowerAttributes);
Link Here
|
37 |
|
37 |
|
38 |
use Koha::Biblios; |
38 |
use Koha::Biblios; |
39 |
use Koha::Libraries; |
39 |
use Koha::Libraries; |
|
|
40 |
use Koha::Patrons; |
40 |
|
41 |
|
41 |
=head1 NAME |
42 |
=head1 NAME |
42 |
|
43 |
|
Lines 365-370
sub GetPatronInfo {
Link Here
|
365 |
my $borrowernumber = $cgi->param('patron_id'); |
366 |
my $borrowernumber = $cgi->param('patron_id'); |
366 |
my $borrower = GetMemberDetails( $borrowernumber ); |
367 |
my $borrower = GetMemberDetails( $borrowernumber ); |
367 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
368 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
|
|
369 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
368 |
|
370 |
|
369 |
# Cleaning the borrower hashref |
371 |
# Cleaning the borrower hashref |
370 |
$borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; |
372 |
$borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; |
Lines 404-415
sub GetPatronInfo {
Link Here
|
404 |
if ( $cgi->param('show_holds') && $cgi->param('show_holds') eq "1" ) { |
406 |
if ( $cgi->param('show_holds') && $cgi->param('show_holds') eq "1" ) { |
405 |
|
407 |
|
406 |
# Get borrower's reserves |
408 |
# Get borrower's reserves |
407 |
my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); |
409 |
my $holds = $patron->holds; |
408 |
foreach my $reserve (@reserves) { |
410 |
while ( my $hold = $holds->next ) { |
409 |
|
411 |
|
|
|
412 |
my $unblessed_hold = $hold->unblessed; |
410 |
# Get additional informations |
413 |
# Get additional informations |
411 |
my $item = GetBiblioFromItemNumber( $reserve->{'itemnumber'}, undef ); |
414 |
my $item = GetBiblioFromItemNumber( $hold->itemnumber, undef ); |
412 |
my $library = Koha::Libraries->find( $reserve->{branchcode} ); |
415 |
my $library = Koha::Libraries->find( $hold->branchcode ); # Should $hold->get_library |
413 |
my $branchname = $library ? $library->branchname : ''; |
416 |
my $branchname = $library ? $library->branchname : ''; |
414 |
|
417 |
|
415 |
# Remove unwanted fields |
418 |
# Remove unwanted fields |
Lines 417-427
sub GetPatronInfo {
Link Here
|
417 |
delete $item->{'more_subfields_xml'}; |
420 |
delete $item->{'more_subfields_xml'}; |
418 |
|
421 |
|
419 |
# Add additional fields |
422 |
# Add additional fields |
420 |
$reserve->{'item'} = $item; |
423 |
$unblessed_hold->{item} = $item; |
421 |
$reserve->{'branchname'} = $branchname; |
424 |
$unblessed_hold->{branchname} = $branchname; |
422 |
$reserve->{'title'} = GetBiblio( $reserve->{'biblionumber'} )->{'title'}; |
425 |
$unblessed_hold->{title} = GetBiblio( $hold->biblionumber )->{'title'}; # Should be $hold->get_biblio |
|
|
426 |
|
427 |
push @{ $borrower->{holds}{hold} }, $unblessed_hold; |
423 |
} |
428 |
} |
424 |
$borrower->{'holds'}->{'hold'} = \@reserves; |
|
|
425 |
} |
429 |
} |
426 |
|
430 |
|
427 |
# Issues management |
431 |
# Issues management |
Lines 490-495
sub GetServices {
Link Here
|
490 |
my $borrower = GetMemberDetails( $borrowernumber ); |
494 |
my $borrower = GetMemberDetails( $borrowernumber ); |
491 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
495 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
492 |
|
496 |
|
|
|
497 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
498 |
|
493 |
# Get the item, or return an error code if not found |
499 |
# Get the item, or return an error code if not found |
494 |
my $itemnumber = $cgi->param('item_id'); |
500 |
my $itemnumber = $cgi->param('item_id'); |
495 |
my $item = GetItem( $itemnumber ); |
501 |
my $item = GetItem( $itemnumber ); |
Lines 509-518
sub GetServices {
Link Here
|
509 |
} |
515 |
} |
510 |
|
516 |
|
511 |
# Reserve cancellation management |
517 |
# Reserve cancellation management |
512 |
my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); |
518 |
my $holds = $patron->holds; |
513 |
my @reserveditems; |
519 |
my @reserveditems; |
514 |
foreach my $reserve (@reserves) { |
520 |
while ( my $hold = $holds->next ) { # FIXME This could be improved |
515 |
push @reserveditems, $reserve->{'itemnumber'}; |
521 |
push @reserveditems, $hold->itemnumber; |
516 |
} |
522 |
} |
517 |
if ( grep { $itemnumber eq $_ } @reserveditems ) { |
523 |
if ( grep { $itemnumber eq $_ } @reserveditems ) { |
518 |
push @availablefor, 'hold cancellation'; |
524 |
push @availablefor, 'hold cancellation'; |