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

(-)a/C4/Reserves.pm (-1 / +16 lines)
Lines 340-345 sub CanBookBeReserved{ Link Here
340
  if ($canReserve->{status} eq 'OK') { #We can reserve this Item! }
340
  if ($canReserve->{status} eq 'OK') { #We can reserve this Item! }
341
341
342
@RETURNS { status => OK },              if the Item can be reserved.
342
@RETURNS { status => OK },              if the Item can be reserved.
343
         { status => onShelfHoldsNotAllowed },  if onShelfHoldsAllowed parameter and item availability combination doesn't allow holds.
343
         { status => ageRestricted },   if the Item is age restricted for this borrower.
344
         { status => ageRestricted },   if the Item is age restricted for this borrower.
344
         { status => damaged },         if the Item is damaged.
345
         { status => damaged },         if the Item is damaged.
345
         { status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK.
346
         { status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK.
Lines 362-373 sub CanItemBeReserved { Link Here
362
    my $holds_per_record = 1; # Total number of holds allowed for this one given record
363
    my $holds_per_record = 1; # Total number of holds allowed for this one given record
363
    my $holds_per_day;        # Default to unlimited
364
    my $holds_per_day;        # Default to unlimited
364
    my $opacitemholds = 'Y';  # Itemlevel holds default to allowed
365
    my $opacitemholds = 'Y';  # Itemlevel holds default to allowed
366
    my $on_shelf_holds = 0;   # Default to "if any unavailable"
365
367
366
    # Get calling context
368
    # Get calling context
367
    my $caller = (caller(1))[3];
369
    my $caller = (caller(1))[3];
368
370
369
    # we retrieve borrowers and items informations #
371
    # we retrieve borrowers and items informations #
370
    # item->{itype} will come for biblioitems if necessery
372
    # item->{itype} will come for biblioitems if necessery
373
371
    my $item       = Koha::Items->find($itemnumber);
374
    my $item       = Koha::Items->find($itemnumber);
372
    my $biblio     = $item->biblio;
375
    my $biblio     = $item->biblio;
373
    my $patron = Koha::Patrons->find( $borrowernumber );
376
    my $patron = Koha::Patrons->find( $borrowernumber );
Lines 417-422 sub CanItemBeReserved { Link Here
417
        $holds_per_record = $rights->{holds_per_record} // $holds_per_record;
420
        $holds_per_record = $rights->{holds_per_record} // $holds_per_record;
418
        $holds_per_day    = $rights->{holds_per_day};
421
        $holds_per_day    = $rights->{holds_per_day};
419
        $opacitemholds    = $rights->{opacitemholds};
422
        $opacitemholds    = $rights->{opacitemholds};
423
        $on_shelf_holds   = $rights->{onshelfholds};
420
    }
424
    }
421
    else {
425
    else {
422
        $ruleitemtype = undef;
426
        $ruleitemtype = undef;
Lines 426-431 sub CanItemBeReserved { Link Here
426
        return { status => "notReservable" };
430
        return { status => "notReservable" };
427
    }
431
    }
428
432
433
    # Check for item on shelves and OnShelfHoldsAllowed
434
    return { status => 'onShelfHoldsNotAllowed' }
435
     if ( 0 == (
436
        $item->{'notforloan'} or
437
        $item->{'onloan'} or
438
        $item->{'itemlost'} or
439
        $item->{'withdrawn'} or
440
        $item->{'damaged'} )
441
        && ($on_shelf_holds != "1"));
442
429
    $item = Koha::Items->find( $itemnumber );
443
    $item = Koha::Items->find( $itemnumber );
430
444
431
    my $holds = Koha::Holds->search(
445
    my $holds = Koha::Holds->search(
Lines 2268-2274 sub GetHoldRule { Link Here
2268
            itemtype     => $itemtype,
2282
            itemtype     => $itemtype,
2269
            categorycode => $categorycode,
2283
            categorycode => $categorycode,
2270
            branchcode   => $branchcode,
2284
            branchcode   => $branchcode,
2271
            rules        => ['holds_per_record', 'holds_per_day', 'opacitemholds'],
2285
            rules        => ['holds_per_record', 'holds_per_day', 'opacitemholds', 'onshelfholds'],
2272
            order_by     => {
2286
            order_by     => {
2273
                -desc => [ 'categorycode', 'itemtype', 'branchcode' ]
2287
                -desc => [ 'categorycode', 'itemtype', 'branchcode' ]
2274
            }
2288
            }
Lines 2277-2282 sub GetHoldRule { Link Here
2277
    $rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record};
2291
    $rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record};
2278
    $rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day};
2292
    $rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day};
2279
    $rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds};
2293
    $rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds};
2294
    $rules->{onshelfholds}  = $holds_per_x_rules->{onshelfholds};
2280
2295
2281
    return $rules;
2296
    return $rules;
2282
}
2297
}
(-)a/t/db_dependent/Reserves.t (-1 / +4 lines)
Lines 190-195 Koha::CirculationRules->set_rules( Link Here
190
        rules        => {
190
        rules        => {
191
            reservesallowed => 25,
191
            reservesallowed => 25,
192
            holds_per_record => 1,
192
            holds_per_record => 1,
193
            onshelfholds => 1,
193
        }
194
        }
194
    }
195
    }
195
);
196
);
Lines 1000-1005 subtest 'reserves.item_level_hold' => sub { Link Here
1000
                rules        => {
1001
                rules        => {
1001
                    reservesallowed => 25,
1002
                    reservesallowed => 25,
1002
                    opacitemholds => 'F',
1003
                    opacitemholds => 'F',
1004
                    onshelfholds => 1,
1003
                }
1005
                }
1004
            }
1006
            }
1005
        );
1007
        );
Lines 1029-1034 subtest 'reserves.item_level_hold' => sub { Link Here
1029
                rules        => {
1031
                rules        => {
1030
                    reservesallowed => 25,
1032
                    reservesallowed => 25,
1031
                    opacitemholds => 'N',
1033
                    opacitemholds => 'N',
1034
                    onshelfholds => 1,
1032
                }
1035
                }
1033
            }
1036
            }
1034
            );
1037
            );
Lines 1057-1062 subtest 'reserves.item_level_hold' => sub { Link Here
1057
                rules        => {
1060
                rules        => {
1058
                    reservesallowed => 25,
1061
                    reservesallowed => 25,
1059
                    opacitemholds => 'Y',
1062
                    opacitemholds => 'Y',
1063
                    onshelfholds => 1,
1060
                }
1064
                }
1061
            }
1065
            }
1062
            );
1066
            );
1063
- 

Return to bug 20985