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