Lines 331-336
sub CanBookBeReserved{
Link Here
|
331 |
return { status =>'alreadypossession' }; |
331 |
return { status =>'alreadypossession' }; |
332 |
} |
332 |
} |
333 |
|
333 |
|
|
|
334 |
if ( $params->{itemtype} ) { |
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 |
|
334 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
365 |
my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); |
335 |
#get items linked via host records |
366 |
#get items linked via host records |
336 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
367 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
Lines 489-504
sub CanItemBeReserved {
Link Here
|
489 |
|
520 |
|
490 |
# If using item-level itypes, fall back to the record |
521 |
# If using item-level itypes, fall back to the record |
491 |
# level itemtype if the hold has no associated item |
522 |
# level itemtype if the hold has no associated item |
492 |
$querycount .= |
523 |
if ( defined $ruleitemtype ) { |
493 |
C4::Context->preference('item-level_itypes') |
524 |
if ( C4::Context->preference('item-level_itypes') ) { |
494 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
525 |
$querycount .= q{ |
495 |
: " AND biblioitems.itemtype = ?" |
526 |
AND ( COALESCE( items.itype, biblioitems.itemtype ) = ? |
496 |
if defined $ruleitemtype; |
527 |
OR reserves.itemtype = ? ) |
|
|
528 |
}; |
529 |
} |
530 |
else { |
531 |
$querycount .= q{ |
532 |
AND ( biblioitems.itemtype = ? |
533 |
OR reserves.itemtype = ? ) |
534 |
}; |
535 |
} |
536 |
} |
497 |
|
537 |
|
498 |
my $sthcount = $dbh->prepare($querycount); |
538 |
my $sthcount = $dbh->prepare($querycount); |
499 |
|
539 |
|
500 |
if ( defined $ruleitemtype ) { |
540 |
if ( defined $ruleitemtype ) { |
501 |
$sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype ); |
541 |
$sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype, $ruleitemtype ); |
502 |
} |
542 |
} |
503 |
else { |
543 |
else { |
504 |
$sthcount->execute( $borrowernumber, $branchcode ); |
544 |
$sthcount->execute( $borrowernumber, $branchcode ); |