Lines 43-48
use C4::Dates qw/format_date/;
Link Here
|
43 |
use C4::Members; |
43 |
use C4::Members; |
44 |
use C4::Search; # enabled_staff_search_views |
44 |
use C4::Search; # enabled_staff_search_views |
45 |
use Koha::DateUtils; |
45 |
use Koha::DateUtils; |
|
|
46 |
use Koha::Holds; |
46 |
|
47 |
|
47 |
my $dbh = C4::Context->dbh; |
48 |
my $dbh = C4::Context->dbh; |
48 |
my $sth; |
49 |
my $sth; |
Lines 463-549
foreach my $biblionumber (@biblionumbers) {
Link Here
|
463 |
|
464 |
|
464 |
# existingreserves building |
465 |
# existingreserves building |
465 |
my @reserveloop; |
466 |
my @reserveloop; |
466 |
$reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 }); |
467 |
my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); |
467 |
foreach my $res ( sort { |
468 |
foreach my $res ( |
468 |
my $a_found = $a->{found} || ''; |
469 |
sort { |
469 |
my $b_found = $a->{found} || ''; |
470 |
my $a_found = $a->found() || ''; |
|
|
471 |
my $b_found = $a->found() || ''; |
470 |
$a_found cmp $b_found; |
472 |
$a_found cmp $b_found; |
471 |
} @$reserves ) { |
473 |
} @reserves |
|
|
474 |
) |
475 |
{ |
472 |
my %reserve; |
476 |
my %reserve; |
473 |
my @optionloop; |
477 |
my @optionloop; |
474 |
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { |
478 |
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { |
475 |
push( |
479 |
push( |
476 |
@optionloop, |
480 |
@optionloop, |
477 |
{ |
481 |
{ |
478 |
num => $i, |
482 |
num => $i, |
479 |
selected => ( $i == $res->{priority} ), |
483 |
selected => ( $i == $res->priority() ), |
480 |
} |
484 |
} |
481 |
); |
485 |
); |
482 |
} |
486 |
} |
483 |
|
487 |
|
484 |
if ( defined $res->{'found'} && ($res->{'found'} eq 'W' || $res->{'found'} eq 'T' )) { |
488 |
if ( $res->is_found() ) { |
485 |
my $item = $res->{'itemnumber'}; |
489 |
$reserve{'wait'} = 1; |
486 |
$item = GetBiblioFromItemNumber($item,undef); |
490 |
$reserve{'holdingbranch'} = $res->item()->holdingbranch(); |
487 |
$reserve{'wait'}= 1; |
491 |
$reserve{'biblionumber'} = $res->item()->biblionumber(); |
488 |
$reserve{'holdingbranch'}=$item->{'holdingbranch'}; |
492 |
$reserve{'barcodenumber'} = $res->item()->barcode(); |
489 |
$reserve{'biblionumber'}=$item->{'biblionumber'}; |
493 |
$reserve{'wbrcode'} = $res->branchcode(); |
490 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
494 |
$reserve{'itemnumber'} = $res->itemnumber(); |
491 |
$reserve{'wbrcode'} = $res->{'branchcode'}; |
495 |
$reserve{'wbrname'} = $res->branch()->branchname(); |
492 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
496 |
|
493 |
$reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'}; |
497 |
if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) { |
494 |
if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){ |
498 |
|
495 |
# Just because the holdingbranch matches the reserve branch doesn't mean the item |
499 |
# Just because the holdingbranch matches the reserve branch doesn't mean the item |
496 |
# has arrived at the destination, check for an open transfer for the item as well |
500 |
# has arrived at the destination, check for an open transfer for the item as well |
497 |
my ( $transfertwhen, $transfertfrom, $transferto ) = C4::Circulation::GetTransfers( $res->{itemnumber} ); |
501 |
my ( $transfertwhen, $transfertfrom, $transferto ) = |
498 |
if ( not $transferto or $transferto ne $res->{branchcode} ) { |
502 |
C4::Circulation::GetTransfers( $res->itemnumber() ); |
|
|
503 |
if ( not $transferto or $transferto ne $res->branchcode() ) { |
499 |
$reserve{'atdestination'} = 1; |
504 |
$reserve{'atdestination'} = 1; |
500 |
} |
505 |
} |
501 |
} |
506 |
} |
|
|
507 |
|
502 |
# set found to 1 if reserve is waiting for patron pickup |
508 |
# set found to 1 if reserve is waiting for patron pickup |
503 |
$reserve{'found'} = 1 if $res->{'found'} eq 'W'; |
509 |
$reserve{'found'} = $res->is_found(); |
504 |
$reserve{'intransit'} = 1 if $res->{'found'} eq 'T'; |
510 |
$reserve{'intransit'} = $res->is_in_transit(); |
505 |
} elsif ($res->{priority} > 0) { |
511 |
} |
506 |
if (defined($res->{itemnumber})) { |
512 |
elsif ( $res->priority() > 0 ) { |
507 |
my $item = GetItem($res->{itemnumber}); |
513 |
if ( my $item = $res->item() ) { |
508 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
514 |
$reserve{'itemnumber'} = $item->id(); |
509 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
515 |
$reserve{'barcodenumber'} = $item->barcode(); |
510 |
$reserve{'item_level_hold'} = 1; |
516 |
$reserve{'item_level_hold'} = 1; |
511 |
} |
517 |
} |
512 |
} |
518 |
} |
513 |
|
519 |
|
514 |
# get borrowers reserve info |
520 |
# get borrowers reserve info |
515 |
my $reserveborrowerinfo = GetMember( borrowernumber => $res->{'borrowernumber'} ); |
521 |
if ( C4::Context->preference('HidePatronName') ) { |
516 |
if (C4::Context->preference('HidePatronName')){ |
522 |
$reserve{'hidename'} = 1; |
517 |
$reserve{'hidename'} = 1; |
523 |
$reserve{'cardnumber'} = $res->borrower()->cardnumber(); |
518 |
$reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'}; |
524 |
} |
519 |
} |
525 |
$reserve{'expirationdate'} = format_date( $res-expirationdate() ) |
520 |
$reserve{'expirationdate'} = format_date( $res->{'expirationdate'} ) |
526 |
unless ( !defined( $res->expirationdate() ) || $res->expirationdate() eq '0000-00-00' ); |
521 |
unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' ); |
527 |
$reserve{'date'} = format_date( $res->reservedate() ); |
522 |
$reserve{'date'} = format_date( $res->{'reservedate'} ); |
528 |
$reserve{'borrowernumber'} = $res->borrowernumber(); |
523 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
529 |
$reserve{'biblionumber'} = $res->biblionumber(); |
524 |
$reserve{'biblionumber'} = $res->{'biblionumber'}; |
530 |
$reserve{'borrowernumber'} = $res->borrowernumber(); |
525 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
531 |
$reserve{'firstname'} = $res->borrower()->firstname(); |
526 |
$reserve{'firstname'} = $reserveborrowerinfo->{'firstname'}; |
532 |
$reserve{'surname'} = $res->borrower()->surname(); |
527 |
$reserve{'surname'} = $reserveborrowerinfo->{'surname'}; |
533 |
$reserve{'notes'} = $res->reservenotes(); |
528 |
$reserve{'notes'} = $res->{'reservenotes'}; |
534 |
$reserve{'wait'} = $res->is_waiting(); |
529 |
$reserve{'wait'} = |
535 |
$reserve{'waiting_date'} = $res->waitingdate(); |
530 |
( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) ); |
536 |
$reserve{'waiting_until'} = $res->is_waiting() ? $res->waiting_expires_on() : undef; |
531 |
$reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' ); |
537 |
$reserve{'constrainttypea'} = ( $res->constrainttype() eq 'a' ); |
532 |
$reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' ); |
538 |
$reserve{'constrainttypeo'} = ( $res->constrainttype() eq 'o' ); |
533 |
$reserve{'voldesc'} = $res->{'volumeddesc'}; |
539 |
$reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; |
534 |
$reserve{'ccode'} = $res->{'ccode'}; |
540 |
$reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; |
535 |
$reserve{'barcode'} = $res->{'barcode'}; |
541 |
$reserve{'priority'} = $res->priority(); |
536 |
$reserve{'priority'} = $res->{'priority'}; |
542 |
$reserve{'lowestPriority'} = $res->lowestPriority(); |
537 |
$reserve{'lowestPriority'} = $res->{'lowestPriority'}; |
543 |
$reserve{'optionloop'} = \@optionloop; |
538 |
$reserve{'optionloop'} = \@optionloop; |
544 |
$reserve{'suspend'} = $res->suspend(); |
539 |
$reserve{'suspend'} = $res->{'suspend'}; |
545 |
$reserve{'suspend_until'} = $res->suspend_until(); |
540 |
$reserve{'suspend_until'} = $res->{'suspend_until'}; |
546 |
$reserve{'reserve_id'} = $res->reserve_id(); |
541 |
$reserve{'reserve_id'} = $res->{'reserve_id'}; |
|
|
542 |
|
547 |
|
543 |
if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) { |
548 |
if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) { |
544 |
$reserve{'branchloop'} = [ GetBranchDetail($res->{'branchcode'}) ]; |
549 |
$reserve{'branchloop'} = [ GetBranchDetail( $res->branchcode() ) ]; |
545 |
} else { |
550 |
} |
546 |
$reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'}); |
551 |
else { |
|
|
552 |
$reserve{'branchloop'} = GetBranchesLoop( $res->branchcode() ); |
547 |
} |
553 |
} |
548 |
|
554 |
|
549 |
push( @reserveloop, \%reserve ); |
555 |
push( @reserveloop, \%reserve ); |
550 |
- |
|
|