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

(-)a/Koha/IssuingRules.pm (-2 / +19 lines)
Lines 71-76 sub get_effective_issuing_rule { Link Here
71
    return $rule;
71
    return $rule;
72
}
72
}
73
73
74
=head3 get_opacitemholds_policy
75
76
my $can_place_a_hold_at_item_level = Koha::IssuingRules->get_opacitemholds_policy( { patron => $patron, item => $item } );
77
78
Return 'Y' or 'F' if the patron can place a hold on this item according to the issuing rules
79
and the "Item level holds" (opacitemholds).
80
Can be 'N' - Don't allow, 'Y' - Allow, and 'F' - Force
81
82
=cut
83
74
sub get_opacitemholds_policy {
84
sub get_opacitemholds_policy {
75
    my ( $class, $params ) = @_;
85
    my ( $class, $params ) = @_;
76
86
Lines 79-86 sub get_opacitemholds_policy { Link Here
79
89
80
    return unless $item or $patron;
90
    return unless $item or $patron;
81
91
82
    require C4::Reserves;
92
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
83
    return C4::Reserves::OPACItemHoldsAllowed( $item->unblessed, $patron->unblessed );
93
        {
94
            categorycode => $patron->categorycode,
95
            itemtype     => $item->effective_itemtype,
96
            branchcode   => $item->homebranch,
97
        }
98
    );
99
100
    return $issuing_rule ? $issuing_rule->opacitemholds : undef;
84
}
101
}
85
102
86
=head3 type
103
=head3 type
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-1 / +1 lines)
Lines 584-590 function checkMultiHold() { Link Here
584
                    Not on hold
584
                    Not on hold
585
                [% END %]
585
                [% END %]
586
586
587
                [% IF itemloo.item_level_holds == "" %]
587
                [% IF itemloo.item_level_holds == "N" %]
588
                    <br/>Item level hold not allowed from OPAC
588
                    <br/>Item level hold not allowed from OPAC
589
                [% ELSIF itemloo.item_level_holds == "F" %]
589
                [% ELSIF itemloo.item_level_holds == "F" %]
590
                    <br/>Item level hold forced from OPAC
590
                    <br/>Item level hold forced from OPAC
(-)a/opac/opac-reserve.pl (-3 / +5 lines)
Lines 36-41 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::Items;
40
use Koha::Items;
40
use Koha::ItemTypes;
41
use Koha::ItemTypes;
41
use Koha::Checkouts;
42
use Koha::Checkouts;
Lines 446-451 foreach my $biblioNum (@biblionumbers) { Link Here
446
    my $numCopiesOPACAvailable = 0;
447
    my $numCopiesOPACAvailable = 0;
447
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
448
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
448
        my $itemNum = $itemInfo->{itemnumber};
449
        my $itemNum = $itemInfo->{itemnumber};
450
        my $item = Koha::Items->find( $itemNum );
449
        my $itemLoopIter = {};
451
        my $itemLoopIter = {};
450
452
451
        $itemLoopIter->{itemnumber} = $itemNum;
453
        $itemLoopIter->{itemnumber} = $itemNum;
Lines 475-481 foreach my $biblioNum (@biblionumbers) { Link Here
475
        }
477
        }
476
478
477
        # checking reserve
479
        # checking reserve
478
        my $item = Koha::Items->find( $itemNum );
479
        my $holds = $item->current_holds;
480
        my $holds = $item->current_holds;
480
481
481
        if ( my $first_hold = $holds->next ) {
482
        if ( my $first_hold = $holds->next ) {
Lines 539-548 foreach my $biblioNum (@biblionumbers) { Link Here
539
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
540
            CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
540
541
541
        if ($policy_holdallowed) {
542
        if ($policy_holdallowed) {
542
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $patron_unblessed ) ) {
543
            my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
544
            if ( $opac_hold_policy ne 'N' ) { # If Y or F
543
                $itemLoopIter->{available} = 1;
545
                $itemLoopIter->{available} = 1;
544
                $numCopiesOPACAvailable++;
546
                $numCopiesOPACAvailable++;
545
                $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
547
                $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
546
            }
548
            }
547
            $numCopiesAvailable++;
549
            $numCopiesAvailable++;
548
550
(-)a/reserve/request.pl (-2 / +4 lines)
Lines 47-52 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::Items;
51
use Koha::Items;
51
use Koha::ItemTypes;
52
use Koha::ItemTypes;
52
use Koha::Libraries;
53
use Koha::Libraries;
Lines 396-402 foreach my $biblionumber (@biblionumbers) { Link Here
396
            }
397
            }
397
398
398
            # checking reserve
399
            # checking reserve
399
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
400
            my $item_object = Koha::Items->find( $itemnumber );
401
            my $holds = $item_object->current_holds;
400
            if ( my $first_hold = $holds->next ) {
402
            if ( my $first_hold = $holds->next ) {
401
                my $p = Koha::Patrons->find( $first_hold->borrowernumber );
403
                my $p = Koha::Patrons->find( $first_hold->borrowernumber );
402
404
Lines 468-474 foreach my $biblionumber (@biblionumbers) { Link Here
468
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
470
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
469
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
471
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
470
472
471
                $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed);
473
                $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
472
474
473
                if (
475
                if (
474
                       !$item->{cantreserve}
476
                       !$item->{cantreserve}
(-)a/t/db_dependent/Koha/IssuingRules.t (-3 / +2 lines)
Lines 274-280 subtest 'get_opacitemholds_policy' => sub { Link Here
274
    is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itype');
274
    is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itype');
275
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
275
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
276
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
276
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
277
    is ( $opacitemholds, '', 'Patrons cannot place a hold on this itemtype');
277
    is ( $opacitemholds, 'N', 'Patrons cannot place a hold on this itemtype');
278
278
279
    Koha::IssuingRules->delete;
279
    Koha::IssuingRules->delete;
280
    Koha::IssuingRule->new({categorycode => '*', itemtype => '*',                 branchcode => '*', opacitemholds => "N"})->store;
280
    Koha::IssuingRule->new({categorycode => '*', itemtype => '*',                 branchcode => '*', opacitemholds => "N"})->store;
Lines 282-288 subtest 'get_opacitemholds_policy' => sub { Link Here
282
    Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "Y"})->store;
282
    Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "Y"})->store;
283
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
283
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
284
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
284
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
285
    is ( $opacitemholds, '', 'Patrons cannot place a hold on this itype');
285
    is ( $opacitemholds, 'N', 'Patrons cannot place a hold on this itype');
286
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
286
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
287
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
287
    $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
288
    is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itemtype');
288
    is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itemtype');
289
- 

Return to bug 19300