|
Lines 330-335
sub CanBookBeReserved{
Link Here
|
| 330 |
return { status =>'alreadypossession' }; |
330 |
return { status =>'alreadypossession' }; |
| 331 |
} |
331 |
} |
| 332 |
|
332 |
|
|
|
333 |
if ( $params->{itemtype} |
| 334 |
and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) |
| 335 |
{ |
| 336 |
# biblio-level, item type-contrained |
| 337 |
my $patron = Koha::Patrons->find($borrowernumber); |
| 338 |
my $reservesallowed = Koha::CirculationRules->get_effective_rule( |
| 339 |
{ |
| 340 |
itemtype => $params->{itemtype}, |
| 341 |
categorycode => $patron->categorycode, |
| 342 |
branchcode => $pickup_branchcode, |
| 343 |
rule_name => 'reservesallowed', |
| 344 |
} |
| 345 |
)->rule_value; |
| 346 |
my $count = $patron->holds->search( |
| 347 |
{ |
| 348 |
'-or' => [ |
| 349 |
{ 'me.itemtype' => $params->{itemtype} }, |
| 350 |
{ 'item.itype' => $params->{itemtype} } |
| 351 |
] |
| 352 |
}, |
| 353 |
{ |
| 354 |
join => ['item'] |
| 355 |
} |
| 356 |
)->count; |
| 357 |
|
| 358 |
return { status => '' } |
| 359 |
unless $reservesallowed > $count; |
| 360 |
} |
| 361 |
|
| 333 |
my $items; |
362 |
my $items; |
| 334 |
#get items linked via host records |
363 |
#get items linked via host records |
| 335 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
364 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
|
Lines 510-524
sub CanItemBeReserved {
Link Here
|
| 510 |
|
539 |
|
| 511 |
# If using item-level itypes, fall back to the record |
540 |
# If using item-level itypes, fall back to the record |
| 512 |
# level itemtype if the hold has no associated item |
541 |
# level itemtype if the hold has no associated item |
| 513 |
$querycount .= |
542 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
| 514 |
C4::Context->preference('item-level_itypes') |
543 |
if ( C4::Context->preference('item-level_itypes') ) { |
| 515 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
544 |
$querycount .= q{ |
| 516 |
: " AND biblioitems.itemtype = ?" |
545 |
AND ( COALESCE( items.itype, biblioitems.itemtype ) = ? |
| 517 |
if defined $ruleitemtype; |
546 |
OR reserves.itemtype = ? ) |
|
|
547 |
}; |
| 548 |
} |
| 549 |
else { |
| 550 |
$querycount .= q{ |
| 551 |
AND ( biblioitems.itemtype = ? |
| 552 |
OR reserves.itemtype = ? ) |
| 553 |
}; |
| 554 |
} |
| 555 |
} |
| 556 |
elsif ( defined $ruleitemtype ) { |
| 557 |
# If using item-level itypes, fall back to the record |
| 558 |
# level itemtype if the hold has no associated item |
| 559 |
$querycount .= |
| 560 |
C4::Context->preference('item-level_itypes') |
| 561 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
| 562 |
: " AND biblioitems.itemtype = ?"; |
| 563 |
} |
| 518 |
|
564 |
|
| 519 |
my $sthcount = $dbh->prepare($querycount); |
565 |
my $sthcount = $dbh->prepare($querycount); |
| 520 |
|
566 |
|
| 521 |
if ( defined $ruleitemtype ) { |
567 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
|
|
568 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype, $ruleitemtype ); |
| 569 |
} |
| 570 |
elsif ( defined $ruleitemtype ) { |
| 522 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
571 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
| 523 |
} |
572 |
} |
| 524 |
else { |
573 |
else { |