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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 1133-1139 sub IsAvailableForItemLevelRequest { Link Here
1133
        $item->{withdrawn}        ||
1133
        $item->{withdrawn}        ||
1134
        ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1134
        ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1135
1135
1136
    my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } );
1136
    my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } );
1137
1137
1138
    if ( $on_shelf_holds == 1 ) {
1138
    if ( $on_shelf_holds == 1 ) {
1139
        return 1;
1139
        return 1;
(-)a/Koha/CirculationRules.pm (+22 lines)
Lines 322-327 sub set_rules { Link Here
322
    return $rule_objects;
322
    return $rule_objects;
323
}
323
}
324
324
325
=head3 get_onshelfholds_policy
326
327
    my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy({ item => $item, patron => $patron });
328
329
=cut
330
331
sub get_onshelfholds_policy {
332
    my ( $class, $params ) = @_;
333
    my $item = $params->{item};
334
    my $itemtype = $item->effective_itemtype;
335
    my $patron = $params->{patron};
336
    my $rule = Koha::CirculationRules->get_effective_rule(
337
        {
338
            categorycode => ( $patron ? $patron->categorycode : undef ),
339
            itemtype     => $itemtype,
340
            branchcode   => $item->holdingbranch,
341
            rule_name    => 'onshelfholds',
342
        }
343
    );
344
    return $rule ? $rule->rule_value : undef;
345
}
346
325
=head3 type
347
=head3 type
326
348
327
=cut
349
=cut
(-)a/installer/onboarding.pl (-11 / +10 lines)
Lines 30-37 use Koha::DateUtils; Link Here
30
use Koha::Patron::Categories;
30
use Koha::Patron::Categories;
31
use Koha::Patron::Category;
31
use Koha::Patron::Category;
32
use Koha::ItemTypes;
32
use Koha::ItemTypes;
33
use Koha::IssuingRule;
34
use Koha::IssuingRules;
35
33
36
#Setting variables
34
#Setting variables
37
my $input = new CGI;
35
my $input = new CGI;
Lines 250-265 if ( $step == 5 ) { Link Here
250
            branchcode      => $branchcode,
248
            branchcode      => $branchcode,
251
            categorycode    => $categorycode,
249
            categorycode    => $categorycode,
252
            itemtype        => $itemtype,
250
            itemtype        => $itemtype,
253
            maxissueqty     => $maxissueqty,
251
            rules => {
254
            renewalsallowed => $renewalsallowed,
252
                maxissueqty     => $maxissueqty,
255
            renewalperiod   => $renewalperiod,
253
                renewalsallowed => $renewalsallowed,
256
            issuelength     => $issuelength,
254
                renewalperiod   => $renewalperiod,
257
            lengthunit      => $lengthunit,
255
                issuelength     => $issuelength,
258
            onshelfholds    => $onshelfholds,
256
                lengthunit      => $lengthunit,
257
                onshelfholds    => $onshelfholds,
258
            }
259
        };
259
        };
260
260
261
        my $issuingrule = Koha::IssuingRule->new($params);
261
        eval { Koha::CirculationRules->set_rules( $params ) };
262
        eval { $issuingrule->store; };
263
262
264
        unless ($@) {
263
        unless ($@) {
265
            push @messages, { code => 'success_on_insert_circ_rule' };
264
            push @messages, { code => 'success_on_insert_circ_rule' };
Lines 269-275 if ( $step == 5 ) { Link Here
269
        }
268
        }
270
    }
269
    }
271
270
272
    $step++ if Koha::IssuingRules->count;
271
    $step++ if Koha::CirculationRules->count;
273
}
272
}
274
273
275
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
274
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
(-)a/opac/opac-ISBDdetail.pl (-2 / +2 lines)
Lines 52-58 use C4::Reserves; Link Here
52
use C4::Acquisition;
52
use C4::Acquisition;
53
use C4::Serials;    # uses getsubscriptionfrom biblionumber
53
use C4::Serials;    # uses getsubscriptionfrom biblionumber
54
use C4::Koha;
54
use C4::Koha;
55
use Koha::IssuingRules;
55
use Koha::CirculationRules;
56
use Koha::Items;
56
use Koha::Items;
57
use Koha::ItemTypes;
57
use Koha::ItemTypes;
58
use Koha::Patrons;
58
use Koha::Patrons;
Lines 180-186 for my $itm (@items) { Link Here
180
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
180
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
181
        && $itm->{'itemnumber'};
181
        && $itm->{'itemnumber'};
182
182
183
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
183
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
184
      unless $allow_onshelf_holds;
184
      unless $allow_onshelf_holds;
185
}
185
}
186
186
(-)a/opac/opac-MARCdetail.pl (-2 / +2 lines)
Lines 58-64 use C4::Acquisition; Link Here
58
use C4::Koha;
58
use C4::Koha;
59
use List::MoreUtils qw( any uniq );
59
use List::MoreUtils qw( any uniq );
60
use Koha::Biblios;
60
use Koha::Biblios;
61
use Koha::IssuingRules;
61
use Koha::CirculationRules;
62
use Koha::Items;
62
use Koha::Items;
63
use Koha::Patrons;
63
use Koha::Patrons;
64
use Koha::RecordProcessor;
64
use Koha::RecordProcessor;
Lines 135-141 my $allow_onshelf_holds; Link Here
135
my $patron = Koha::Patrons->find( $loggedinuser );
135
my $patron = Koha::Patrons->find( $loggedinuser );
136
for my $itm (@all_items) {
136
for my $itm (@all_items) {
137
    my $item = Koha::Items->find( $itm->{itemnumber} );
137
    my $item = Koha::Items->find( $itm->{itemnumber} );
138
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
138
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
139
    last if $allow_onshelf_holds;
139
    last if $allow_onshelf_holds;
140
}
140
}
141
141
(-)a/opac/opac-detail.pl (-2 / +2 lines)
Lines 52-58 use C4::CourseReserves qw(GetItemCourseReservesInfo); Link Here
52
use Koha::Biblios;
52
use Koha::Biblios;
53
use Koha::RecordProcessor;
53
use Koha::RecordProcessor;
54
use Koha::AuthorisedValues;
54
use Koha::AuthorisedValues;
55
use Koha::IssuingRules;
55
use Koha::CirculationRules;
56
use Koha::Items;
56
use Koha::Items;
57
use Koha::ItemTypes;
57
use Koha::ItemTypes;
58
use Koha::Acquisition::Orders;
58
use Koha::Acquisition::Orders;
Lines 674-680 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
674
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
674
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
675
        && $itm->{'itemnumber'};
675
        && $itm->{'itemnumber'};
676
676
677
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
677
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
678
      unless $allow_onshelf_holds;
678
      unless $allow_onshelf_holds;
679
679
680
    # get collection code description, too
680
    # get collection code description, too
(-)a/opac/opac-reserve.pl (-2 / +2 lines)
Lines 36-42 use C4::Debug; Link Here
36
use Koha::AuthorisedValues;
36
use Koha::AuthorisedValues;
37
use Koha::Biblios;
37
use Koha::Biblios;
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::IssuingRules;
39
use Koha::CirculationRules;
40
use Koha::Items;
40
use Koha::Items;
41
use Koha::ItemTypes;
41
use Koha::ItemTypes;
42
use Koha::Checkouts;
42
use Koha::Checkouts;
Lines 536-542 foreach my $biblioNum (@biblionumbers) { Link Here
536
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
536
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
537
537
538
        if ($policy_holdallowed) {
538
        if ($policy_holdallowed) {
539
            my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
539
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
540
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
540
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
541
                $itemLoopIter->{available} = 1;
541
                $itemLoopIter->{available} = 1;
542
                $numCopiesOPACAvailable++;
542
                $numCopiesOPACAvailable++;
(-)a/opac/opac-shelves.pl (-2 / +2 lines)
Lines 31-37 use C4::XSLT; Link Here
31
31
32
use Koha::Biblios;
32
use Koha::Biblios;
33
use Koha::Biblioitems;
33
use Koha::Biblioitems;
34
use Koha::IssuingRules;
34
use Koha::CirculationRules;
35
use Koha::Items;
35
use Koha::Items;
36
use Koha::ItemTypes;
36
use Koha::ItemTypes;
37
use Koha::Patrons;
37
use Koha::Patrons;
Lines 320-326 if ( $op eq 'view' ) { Link Here
320
320
321
                my $items = $biblio->items;
321
                my $items = $biblio->items;
322
                while ( my $item = $items->next ) {
322
                while ( my $item = $items->next ) {
323
                    $this_item->{allow_onshelf_holds} = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
323
                    $this_item->{allow_onshelf_holds} = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
324
                    last if $this_item->{allow_onshelf_holds};
324
                    last if $this_item->{allow_onshelf_holds};
325
                }
325
                }
326
326
(-)a/reserve/request.pl (-2 / +2 lines)
Lines 47-53 use Koha::Biblios; Link Here
47
use Koha::DateUtils;
47
use Koha::DateUtils;
48
use Koha::Checkouts;
48
use Koha::Checkouts;
49
use Koha::Holds;
49
use Koha::Holds;
50
use Koha::IssuingRules;
50
use Koha::CirculationRules;
51
use Koha::Items;
51
use Koha::Items;
52
use Koha::ItemTypes;
52
use Koha::ItemTypes;
53
use Koha::Libraries;
53
use Koha::Libraries;
Lines 454-460 foreach my $biblionumber (@biblionumbers) { Link Here
454
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
454
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
455
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
455
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
456
456
457
                $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
457
                $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
458
458
459
                if (
459
                if (
460
                       !$item->{cantreserve}
460
                       !$item->{cantreserve}
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-11 / +8 lines)
Lines 269-288 my $hold = $builder->build({ Link Here
269
    }
269
    }
270
});
270
});
271
271
272
$dbh->do("DELETE FROM issuingrules");
272
Koha::CirculationRules->set_rules(
273
$rule = Koha::IssuingRule->new(
274
    {
273
    {
275
        categorycode => '*',
274
        categorycode => undef,
276
        itemtype     => '*',
275
        itemtype     => undef,
277
        branchcode   => '*',
276
        branchcode   => undef,
278
        maxissueqty  => 99,
277
        rules        => {
279
        issuelength  => 7,
278
            maxissueqty     => 99,
280
        lengthunit   => 8,
279
            onshelfholds    => 2,
281
        reservesallowed => 99,
280
        }
282
        onshelfholds => 0,
283
    }
281
    }
284
);
282
);
285
$rule->store();
286
283
287
$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
284
$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
288
is( $is, 1, "Item can be held, items in transit are not available" );
285
is( $is, 1, "Item can be held, items in transit are not available" );
(-)a/t/db_dependent/Reserves.t (-14 lines)
Lines 563-581 Koha::CirculationRules->set_rules( Link Here
563
    }
563
    }
564
);
564
);
565
565
566
ok( C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() allowed" );
567
Koha::CirculationRules->set_rules(
568
    {
569
        categorycode => $categorycode,
570
        itemtype     => $itype,
571
        branchcode   => $holdingbranch,
572
        rules => {
573
            onshelfholds => 0,
574
        }
575
    }
576
);
577
ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" );
578
579
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
566
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
580
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
567
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
581
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
568
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
582
- 

Return to bug 18936