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