View | Details | Raw Unified | Return to bug 28529
Collapse All | Expand All

(-)a/C4/Reserves.pm (-9 / +55 lines)
Lines 331-336 sub CanBookBeReserved{ Link Here
331
        return { status =>'alreadypossession' };
331
        return { status =>'alreadypossession' };
332
    }
332
    }
333
333
334
    if ( $params->{itemtype}
335
        and C4::Context->preference('BiblioHoldItemTypeUseForRules') )
336
    {
337
        # biblio-level, item type-contrained
338
        my $patron          = Koha::Patrons->find($borrowernumber);
339
        my $reservesallowed = Koha::CirculationRules->get_effective_rule(
340
            {
341
                itemtype     => $params->{itemtype},
342
                categorycode => $patron->categorycode,
343
                branchcode   => $pickup_branchcode,
344
                rule_name    => 'reservesallowed',
345
            }
346
        )->rule_value;
347
        my $count = $patron->holds->search(
348
            {
349
                '-or' => [
350
                    { 'me.itemtype' => $params->{itemtype} },
351
                    { 'item.itype'  => $params->{itemtype} }
352
                ]
353
            },
354
            {
355
                join => ['item']
356
            }
357
        )->count;
358
359
        return { status => '' }
360
          unless $reservesallowed > $count;
361
    }
362
334
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
363
    my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber");
335
    #get items linked via host records
364
    #get items linked via host records
336
    my @hostitems = get_hostitemnumbers_of($biblionumber);
365
    my @hostitems = get_hostitemnumbers_of($biblionumber);
Lines 485-501 sub CanItemBeReserved { Link Here
485
514
486
    $querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )";
515
    $querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )";
487
516
488
    # If using item-level itypes, fall back to the record
517
    if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) {
489
    # level itemtype if the hold has no associated item
518
        if ( C4::Context->preference('item-level_itypes') ) {
490
    $querycount .=
519
            $querycount .= q{
491
      C4::Context->preference('item-level_itypes')
520
                AND ( COALESCE( items.itype, biblioitems.itemtype ) = ?
492
      ? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?"
521
                   OR reserves.itemtype = ? )
493
      : " AND biblioitems.itemtype = ?"
522
            };
494
      if defined $ruleitemtype;
523
        }
524
        else {
525
            $querycount .= q{
526
                AND ( biblioitems.itemtype = ?
527
                   OR reserves.itemtype = ? )
528
            };
529
        }
530
    }
531
    elsif ( defined $ruleitemtype ) {
532
        # If using item-level itypes, fall back to the record
533
        # level itemtype if the hold has no associated item
534
        $querycount .=
535
        C4::Context->preference('item-level_itypes')
536
        ? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?"
537
        : " AND biblioitems.itemtype = ?";
538
    }
495
539
496
    my $sthcount = $dbh->prepare($querycount);
540
    my $sthcount = $dbh->prepare($querycount);
497
541
498
    if ( defined $ruleitemtype ) {
542
    if ( defined $ruleitemtype and C4::Context->preference('BiblioHoldItemTypeUseForRules') ) {
543
        $sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype, $ruleitemtype );
544
    }
545
    elsif ( defined $ruleitemtype ) {
499
        $sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype );
546
        $sthcount->execute( $borrowernumber, $branchcode, $ruleitemtype );
500
    }
547
    }
501
    else {
548
    else {
502
- 

Return to bug 28529