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 |
|
347 |
$reservesallowed = ($reservesallowed eq '') ? undef : $reservesallowed; |
348 |
|
349 |
my $count = $patron->holds->search( |
350 |
{ |
351 |
'-or' => [ |
352 |
{ 'me.itemtype' => $params->{itemtype} }, |
353 |
{ 'item.itype' => $params->{itemtype} } |
354 |
] |
355 |
}, |
356 |
{ |
357 |
join => ['item'] |
358 |
} |
359 |
)->count; |
360 |
|
361 |
return { status => '' } |
362 |
if defined $reservesallowed and $reservesallowed < $count + 1; |
363 |
} |
364 |
|
333 |
my $items; |
365 |
my $items; |
334 |
#get items linked via host records |
366 |
#get items linked via host records |
335 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
367 |
my @hostitemnumbers = get_hostitemnumbers_of($biblionumber); |
Lines 510-524
sub CanItemBeReserved {
Link Here
|
510 |
|
542 |
|
511 |
# If using item-level itypes, fall back to the record |
543 |
# If using item-level itypes, fall back to the record |
512 |
# level itemtype if the hold has no associated item |
544 |
# level itemtype if the hold has no associated item |
513 |
$querycount .= |
545 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
514 |
C4::Context->preference('item-level_itypes') |
546 |
if ( C4::Context->preference('item-level_itypes') ) { |
515 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
547 |
$querycount .= q{ |
516 |
: " AND biblioitems.itemtype = ?" |
548 |
AND ( COALESCE( items.itype, biblioitems.itemtype ) = ? |
517 |
if defined $ruleitemtype; |
549 |
OR reserves.itemtype = ? ) |
|
|
550 |
}; |
551 |
} |
552 |
else { |
553 |
$querycount .= q{ |
554 |
AND ( biblioitems.itemtype = ? |
555 |
OR reserves.itemtype = ? ) |
556 |
}; |
557 |
} |
558 |
} |
559 |
elsif ( defined $ruleitemtype ) { |
560 |
# If using item-level itypes, fall back to the record |
561 |
# level itemtype if the hold has no associated item |
562 |
$querycount .= |
563 |
C4::Context->preference('item-level_itypes') |
564 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
565 |
: " AND biblioitems.itemtype = ?"; |
566 |
} |
518 |
|
567 |
|
519 |
my $sthcount = $dbh->prepare($querycount); |
568 |
my $sthcount = $dbh->prepare($querycount); |
520 |
|
569 |
|
521 |
if ( defined $ruleitemtype ) { |
570 |
if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) { |
|
|
571 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype, $ruleitemtype ); |
572 |
} |
573 |
elsif ( defined $ruleitemtype ) { |
522 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
574 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
523 |
} |
575 |
} |
524 |
else { |
576 |
else { |