|
Lines 344-349
sub CanBookBeReserved{
Link Here
|
| 344 |
return { status =>'alreadypossession' }; |
344 |
return { status =>'alreadypossession' }; |
| 345 |
} |
345 |
} |
| 346 |
|
346 |
|
|
|
347 |
if ( $params->{itemtype} |
| 348 |
and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) |
| 349 |
{ |
| 350 |
# biblio-level, item type-contrained |
| 351 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 352 |
my $reservesallowed = Koha::CirculationRules->get_effective_rule( |
| 353 |
{ |
| 354 |
itemtype => $params->{itemtype}, |
| 355 |
categorycode => $patron->categorycode, |
| 356 |
branchcode => $pickup_branchcode, |
| 357 |
rule_name => 'reservesallowed', |
| 358 |
} |
| 359 |
)->rule_value; |
| 360 |
|
| 361 |
$reservesallowed = ($reservesallowed eq '') ? undef : $reservesallowed; |
| 362 |
|
| 363 |
my $count = $patron->holds->search( |
| 364 |
{ |
| 365 |
'-or' => [ |
| 366 |
{ 'me.itemtype' => $params->{itemtype} }, |
| 367 |
{ 'item.itype' => $params->{itemtype} } |
| 368 |
] |
| 369 |
}, |
| 370 |
{ |
| 371 |
join => ['item'] |
| 372 |
} |
| 373 |
)->count; |
| 374 |
|
| 375 |
return { status => '' } |
| 376 |
if defined $reservesallowed and $reservesallowed < $count + 1; |
| 377 |
} |
| 378 |
|
| 347 |
my $items; |
379 |
my $items; |
| 348 |
#get items linked via host records |
380 |
#get items linked via host records |
| 349 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
381 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
|
Lines 524-538
sub CanItemBeReserved {
Link Here
|
| 524 |
|
556 |
|
| 525 |
# If using item-level itypes, fall back to the record |
557 |
# If using item-level itypes, fall back to the record |
| 526 |
# level itemtype if the hold has no associated item |
558 |
# level itemtype if the hold has no associated item |
| 527 |
$querycount .= |
559 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
| 528 |
C4::Context->preference('item-level_itypes') |
560 |
if ( C4::Context->preference('item-level_itypes') ) { |
| 529 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
561 |
$querycount .= q{ |
| 530 |
: " AND biblioitems.itemtype = ?" |
562 |
AND ( COALESCE( items.itype, biblioitems.itemtype ) = ? |
| 531 |
if defined $ruleitemtype; |
563 |
OR reserves.itemtype = ? ) |
|
|
564 |
}; |
| 565 |
} |
| 566 |
else { |
| 567 |
$querycount .= q{ |
| 568 |
AND ( biblioitems.itemtype = ? |
| 569 |
OR reserves.itemtype = ? ) |
| 570 |
}; |
| 571 |
} |
| 572 |
} |
| 573 |
elsif ( defined $ruleitemtype ) { |
| 574 |
# If using item-level itypes, fall back to the record |
| 575 |
# level itemtype if the hold has no associated item |
| 576 |
$querycount .= |
| 577 |
C4::Context->preference('item-level_itypes') |
| 578 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
| 579 |
: " AND biblioitems.itemtype = ?"; |
| 580 |
} |
| 532 |
|
581 |
|
| 533 |
my $sthcount = $dbh->prepare($querycount); |
582 |
my $sthcount = $dbh->prepare($querycount); |
| 534 |
|
583 |
|
| 535 |
if ( defined $ruleitemtype ) { |
584 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
|
|
585 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype, $ruleitemtype ); |
| 586 |
} |
| 587 |
elsif ( defined $ruleitemtype ) { |
| 536 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
588 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
| 537 |
} |
589 |
} |
| 538 |
else { |
590 |
else { |