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 375-380
sub GetPatronInfo {
Link Here
|
375 |
my $borrowernumber = $cgi->param('patron_id'); |
376 |
my $borrowernumber = $cgi->param('patron_id'); |
376 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
377 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
377 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
378 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
|
|
379 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
378 |
|
380 |
|
379 |
# Cleaning the borrower hashref |
381 |
# Cleaning the borrower hashref |
380 |
my $flags = C4::Members::patronflags( $borrower ); |
382 |
my $flags = C4::Members::patronflags( $borrower ); |
Lines 414-436
sub GetPatronInfo {
Link Here
|
414 |
if ( $cgi->param('show_holds') && $cgi->param('show_holds') eq "1" ) { |
416 |
if ( $cgi->param('show_holds') && $cgi->param('show_holds') eq "1" ) { |
415 |
|
417 |
|
416 |
# Get borrower's reserves |
418 |
# Get borrower's reserves |
417 |
my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); |
419 |
my $holds = $patron->holds; |
418 |
foreach my $reserve (@reserves) { |
420 |
while ( my $hold = $holds->next ) { |
419 |
|
421 |
|
|
|
422 |
my $unblessed_hold = $hold->unblessed; |
420 |
# Get additional informations |
423 |
# Get additional informations |
421 |
my $item = GetBiblioFromItemNumber( $reserve->{'itemnumber'}, undef ); |
424 |
my $item = GetBiblioFromItemNumber( $hold->itemnumber, undef ); |
422 |
my $library = Koha::Libraries->find( $reserve->{branchcode} ); |
425 |
my $library = Koha::Libraries->find( $hold->branchcode ); # Should $hold->get_library |
423 |
my $branchname = $library ? $library->branchname : ''; |
426 |
my $branchname = $library ? $library->branchname : ''; |
424 |
|
427 |
|
425 |
# Remove unwanted fields |
428 |
# Remove unwanted fields |
426 |
delete $item->{'more_subfields_xml'}; |
429 |
delete $item->{'more_subfields_xml'}; |
427 |
|
430 |
|
428 |
# Add additional fields |
431 |
# Add additional fields |
429 |
$reserve->{'item'} = $item; |
432 |
$unblessed_hold->{item} = $item; |
430 |
$reserve->{'branchname'} = $branchname; |
433 |
$unblessed_hold->{branchname} = $branchname; |
431 |
$reserve->{'title'} = GetBiblio( $reserve->{'biblionumber'} )->{'title'}; |
434 |
$unblessed_hold->{title} = GetBiblio( $hold->biblionumber )->{'title'}; # Should be $hold->get_biblio |
|
|
435 |
|
436 |
push @{ $borrower->{holds}{hold} }, $unblessed_hold; |
432 |
} |
437 |
} |
433 |
$borrower->{'holds'}->{'hold'} = \@reserves; |
|
|
434 |
} |
438 |
} |
435 |
|
439 |
|
436 |
# Issues management |
440 |
# Issues management |
Lines 500-505
sub GetServices {
Link Here
|
500 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
504 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
501 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
505 |
return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; |
502 |
|
506 |
|
|
|
507 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
508 |
|
503 |
# Get the item, or return an error code if not found |
509 |
# Get the item, or return an error code if not found |
504 |
my $itemnumber = $cgi->param('item_id'); |
510 |
my $itemnumber = $cgi->param('item_id'); |
505 |
my $item = GetItem( $itemnumber ); |
511 |
my $item = GetItem( $itemnumber ); |
Lines 519-528
sub GetServices {
Link Here
|
519 |
} |
525 |
} |
520 |
|
526 |
|
521 |
# Reserve cancellation management |
527 |
# Reserve cancellation management |
522 |
my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); |
528 |
my $holds = $patron->holds; |
523 |
my @reserveditems; |
529 |
my @reserveditems; |
524 |
foreach my $reserve (@reserves) { |
530 |
while ( my $hold = $holds->next ) { # FIXME This could be improved |
525 |
push @reserveditems, $reserve->{'itemnumber'}; |
531 |
push @reserveditems, $hold->itemnumber; |
526 |
} |
532 |
} |
527 |
if ( grep { $itemnumber eq $_ } @reserveditems ) { |
533 |
if ( grep { $itemnumber eq $_ } @reserveditems ) { |
528 |
push @availablefor, 'hold cancellation'; |
534 |
push @availablefor, 'hold cancellation'; |