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

(-)a/C4/Reserves.pm (-6 / +55 lines)
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 {
(-)a/opac/opac-reserve.pl (-5 / +5 lines)
Lines 274-286 if ( $query->param('place_reserve') ) { Link Here
274
274
275
        my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
275
        my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
276
276
277
        my $itemtype = $query->param('itemtype') || undef;
278
        $itemtype = undef if $itemNum;
279
277
        my $rank = $biblioData->{rank};
280
        my $rank = $biblioData->{rank};
278
        my $patron = Koha::Patrons->find( $borrowernumber );
281
        my $patron = Koha::Patrons->find( $borrowernumber );
279
        if ( $item ) {
282
        if ( $item ) {
280
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
283
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
281
        }
284
        }
282
        else {
285
        else {
283
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $branch )->{status} eq 'OK';
286
            $canreserve = 1
287
              if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
284
288
285
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
289
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
286
            $itemNum = undef;
290
            $itemNum = undef;
Lines 302-310 if ( $query->param('place_reserve') ) { Link Here
302
            }
306
            }
303
        }
307
        }
304
308
305
        my $itemtype = $query->param('itemtype') || undef;
306
        $itemtype = undef if $itemNum;
307
308
        # Here we actually do the reserveration. Stage 3.
309
        # Here we actually do the reserveration. Stage 3.
309
        if ($canreserve) {
310
        if ($canreserve) {
310
            my $reserve_id = AddReserve(
311
            my $reserve_id = AddReserve(
311
- 

Return to bug 28529