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

(-)a/Koha/CirculationRules.pm (+21 lines)
Lines 342-348 sub delete { Link Here
342
    while ( my $rule = $self->next ){
342
    while ( my $rule = $self->next ){
343
        $rule->delete;
343
        $rule->delete;
344
    }
344
    }
345
}
346
347
=head3 get_onshelfholds_policy
348
349
    my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy({ item => $item, patron => $patron });
350
351
=cut
345
352
353
sub get_onshelfholds_policy {
354
    my ( $class, $params ) = @_;
355
    my $item = $params->{item};
356
    my $itemtype = $item->effective_itemtype;
357
    my $patron = $params->{patron};
358
    my $rule = Koha::CirculationRules->get_effective_rule(
359
        {
360
            categorycode => ( $patron ? $patron->categorycode : undef ),
361
            itemtype     => $itemtype,
362
            branchcode   => $item->holdingbranch,
363
            rule_name    => 'onshelfholds',
364
        }
365
    );
366
    return $rule ? $rule->rule_value : undef;
346
}
367
}
347
368
348
=head3 type
369
=head3 type
(-)a/installer/onboarding.pl (-9 / +9 lines)
Lines 30-36 use Koha::DateUtils; Link Here
30
use Koha::Patrons;
30
use Koha::Patrons;
31
use Koha::Patron::Categories;
31
use Koha::Patron::Categories;
32
use Koha::ItemTypes;
32
use Koha::ItemTypes;
33
use Koha::IssuingRules;
34
33
35
#Setting variables
34
#Setting variables
36
my $input = new CGI;
35
my $input = new CGI;
Lines 251-265 if ( $step == 5 ) { Link Here
251
            branchcode      => $branchcode,
250
            branchcode      => $branchcode,
252
            categorycode    => $categorycode,
251
            categorycode    => $categorycode,
253
            itemtype        => $itemtype,
252
            itemtype        => $itemtype,
254
            renewalsallowed => $renewalsallowed,
253
            rules => {
255
            renewalperiod   => $renewalperiod,
254
                renewalsallowed => $renewalsallowed,
256
            issuelength     => $issuelength,
255
                renewalperiod   => $renewalperiod,
257
            lengthunit      => $lengthunit,
256
                issuelength     => $issuelength,
258
            onshelfholds    => $onshelfholds,
257
                lengthunit      => $lengthunit,
258
                onshelfholds    => $onshelfholds,
259
            }
259
        };
260
        };
260
261
261
        my $issuingrule = Koha::IssuingRule->new($params);
262
        eval { Koha::CirculationRules->set_rules( $params ) };
262
        eval { $issuingrule->store; };
263
263
264
        if ($@) {
264
        if ($@) {
265
            push @messages, { code => 'error_on_insert_circ_rule' };
265
            push @messages, { code => 'error_on_insert_circ_rule' };
Lines 287-293 if ( $step == 5 ) { Link Here
287
        }
287
        }
288
    }
288
    }
289
289
290
    $step++ if Koha::IssuingRules->count;
290
    $step++ if Koha::CirculationRules->count;
291
}
291
}
292
292
293
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
293
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
(-)a/opac/opac-ISBDdetail.pl (-2 / +2 lines)
Lines 51-57 use C4::Reserves; Link Here
51
use C4::Acquisition;
51
use C4::Acquisition;
52
use C4::Serials;    # uses getsubscriptionfrom biblionumber
52
use C4::Serials;    # uses getsubscriptionfrom biblionumber
53
use C4::Koha;
53
use C4::Koha;
54
use Koha::IssuingRules;
54
use Koha::CirculationRules;
55
use Koha::ItemTypes;
55
use Koha::ItemTypes;
56
use Koha::Patrons;
56
use Koha::Patrons;
57
use Koha::RecordProcessor;
57
use Koha::RecordProcessor;
Lines 178-184 while ( my $item = $items->next ) { Link Here
178
        && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
178
        && !Koha::ItemTypes->find($item->effective_itemtype)->notforloan
179
        && $item->itemnumber;
179
        && $item->itemnumber;
180
180
181
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
181
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
182
      unless $allow_onshelf_holds;
182
      unless $allow_onshelf_holds;
183
}
183
}
184
184
(-)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::ItemTypes;
63
use Koha::ItemTypes;
64
use Koha::Patrons;
64
use Koha::Patrons;
Lines 138-144 $template->param( Link Here
138
my $allow_onshelf_holds;
138
my $allow_onshelf_holds;
139
for my $itm (@all_items) {
139
for my $itm (@all_items) {
140
    my $item = Koha::Items->find( $itm->{itemnumber} );
140
    my $item = Koha::Items->find( $itm->{itemnumber} );
141
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
141
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
142
    last if $allow_onshelf_holds;
142
    last if $allow_onshelf_holds;
143
}
143
}
144
144
(-)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 689-695 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
689
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
689
        && !$itemtypes->{$itm->{'itype'}}->{notforloan}
690
        && $itm->{'itemnumber'};
690
        && $itm->{'itemnumber'};
691
691
692
    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
692
    $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
693
      unless $allow_onshelf_holds;
693
      unless $allow_onshelf_holds;
694
694
695
    # get collection code description, too
695
    # 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 548-554 foreach my $biblioNum (@biblionumbers) { Link Here
548
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
548
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
549
549
550
        if ($policy_holdallowed) {
550
        if ($policy_holdallowed) {
551
            my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
551
            my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
552
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
552
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
553
                $itemLoopIter->{available} = 1;
553
                $itemLoopIter->{available} = 1;
554
                $numCopiesOPACAvailable++;
554
                $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 337-343 if ( $op eq 'view' ) { Link Here
337
337
338
                my $items = $biblio->items;
338
                my $items = $biblio->items;
339
                while ( my $item = $items->next ) {
339
                while ( my $item = $items->next ) {
340
                    $this_item->{allow_onshelf_holds} = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
340
                    $this_item->{allow_onshelf_holds} = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
341
                    last if $this_item->{allow_onshelf_holds};
341
                    last if $this_item->{allow_onshelf_holds};
342
                }
342
                }
343
343
(-)a/reserve/request.pl (-2 / +2 lines)
Lines 48-54 use Koha::Biblios; Link Here
48
use Koha::DateUtils;
48
use Koha::DateUtils;
49
use Koha::Checkouts;
49
use Koha::Checkouts;
50
use Koha::Holds;
50
use Koha::Holds;
51
use Koha::IssuingRules;
51
use Koha::CirculationRules;
52
use Koha::Items;
52
use Koha::Items;
53
use Koha::ItemTypes;
53
use Koha::ItemTypes;
54
use Koha::Libraries;
54
use Koha::Libraries;
Lines 551-557 foreach my $biblionumber (@biblionumbers) { Link Here
551
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
551
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
552
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
552
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
553
553
554
                $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
554
                $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
555
555
556
                if (
556
                if (
557
                       !$item->{cantreserve}
557
                       !$item->{cantreserve}
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-8 / +8 lines)
Lines 216-232 my $hold = $builder->build({ Link Here
216
    }
216
    }
217
});
217
});
218
218
219
Koha::IssuingRule->new(
219
Koha::CirculationRules->set_rules(
220
    {
220
    {
221
        categorycode => '*',
221
        categorycode => undef,
222
        itemtype     => $itemtype2,
222
        itemtype     => $itemtype2,
223
        branchcode   => '*',
223
        branchcode   => undef,
224
        issuelength  => 7,
224
        rules        => {
225
        lengthunit   => 8,
225
            maxissueqty     => 99,
226
        reservesallowed => 99,
226
            onshelfholds    => 2,
227
        onshelfholds => 0,
227
        }
228
    }
228
    }
229
)->store();
229
);
230
230
231
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
231
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
232
is( $is, 1, "Item can be held, items in transit are not available" );
232
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