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

(-)a/C4/Circulation.pm (-47 / +28 lines)
Lines 1722-1779 Neither C<$branchcode> nor C<$itemtype> should be '*'. Link Here
1722
sub GetBranchItemRule {
1722
sub GetBranchItemRule {
1723
    my ( $branchcode, $itemtype ) = @_;
1723
    my ( $branchcode, $itemtype ) = @_;
1724
1724
1725
    # Set search precedences
1725
    # Search for rules!
1726
    my @params = (
1726
    my $holdallowed_rule = Koha::CirculationRules->get_effective_rule(
1727
        {
1728
            branchcode   => $branchcode,
1729
            categorycode => undef,
1730
            itemtype     => $itemtype,
1731
        },
1732
        {
1733
            branchcode   => $branchcode,
1734
            categorycode => undef,
1735
            itemtype     => undef,
1736
        },
1737
        {
1727
        {
1738
            branchcode   => undef,
1728
            branchcode => $branchcode,
1739
            categorycode => undef,
1729
            itemtype => $itemtype,
1740
            itemtype     => $itemtype,
1730
            rule_name => 'holdallowed',
1741
        },
1731
        }
1732
    );
1733
    my $hold_fulfillment_policy_rule = Koha::CirculationRules->get_effective_rule(
1742
        {
1734
        {
1743
            branchcode   => undef,
1735
            branchcode => $branchcode,
1744
            categorycode => undef,
1736
            itemtype => $itemtype,
1745
            itemtype     => undef,
1737
            rule_name => 'hold_fulfillment_policy',
1746
        },
1738
        }
1747
    );
1739
    );
1748
1740
    my $returnbranch_rule = Koha::CirculationRules->get_effective_rule(
1749
    # Initialize default values
1741
        {
1750
    my $rules = {
1742
            branchcode => $branchcode,
1751
        holdallowed             => undef,
1743
            itemtype => $itemtype,
1752
        hold_fulfillment_policy => undef,
1744
            rule_name => 'returnbranch',
1753
        returnbranch            => undef,
1754
    };
1755
1756
    # Search for rules!
1757
    foreach my $rule_name (qw( holdallowed hold_fulfillment_policy returnbranch )) {
1758
        foreach my $params (@params) {
1759
            my $rule = Koha::CirculationRules->search(
1760
                {
1761
                    rule_name => $rule_name,
1762
                    %$params,
1763
                }
1764
            )->next();
1765
1766
            if ( $rule ) {
1767
                $rules->{$rule_name} = $rule->rule_value;
1768
                last;
1769
            }
1770
        }
1745
        }
1771
    }
1746
    );
1772
1747
1773
    # built-in default circulation rule
1748
    # built-in default circulation rule
1774
    $rules->{holdallowed} = 2                 unless ( defined $rules->{holdallowed} );
1749
    my $rules;
1775
    $rules->{hold_fulfillment_policy} = 'any' unless ( defined $rules->{hold_fulfillment_policy} );
1750
    $rules->{holdallowed} = defined $holdallowed_rule
1776
    $rules->{returnbranch} = 'homebranch'     unless ( defined $rules->{returnbranch} );
1751
        ? $holdallowed_rule->rule_value
1752
        : 2;
1753
    $rules->{hold_fulfillment_policy} = defined $hold_fulfillment_policy_rule
1754
        ? $hold_fulfillment_policy_rule->rule_value
1755
        : 'any';
1756
    $rules->{returnbranch} = defined $returnbranch_rule
1757
        ? $returnbranch_rule->rule_value
1758
        : 'homebranch';
1777
1759
1778
    return $rules;
1760
    return $rules;
1779
}
1761
}
1780
- 

Return to bug 18928