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

(-)a/C4/Circulation.pm (-59 / +13 lines)
Lines 1542-1591 Get loan length for an itemtype, a borrower type and a branch Link Here
1542
sub GetLoanLength {
1542
sub GetLoanLength {
1543
    my ( $categorycode, $itemtype, $branchcode ) = @_;
1543
    my ( $categorycode, $itemtype, $branchcode ) = @_;
1544
1544
1545
    # Set search precedences
1546
    my @params = (
1547
        {
1548
            categorycode => $categorycode,
1549
            itemtype     => $itemtype,
1550
            branchcode   => $branchcode,
1551
        },
1552
        {
1553
            categorycode => $categorycode,
1554
            itemtype     => undef,
1555
            branchcode   => $branchcode,
1556
        },
1557
        {
1558
            categorycode => undef,
1559
            itemtype     => $itemtype,
1560
            branchcode   => $branchcode,
1561
        },
1562
        {
1563
            categorycode => undef,
1564
            itemtype     => undef,
1565
            branchcode   => $branchcode,
1566
        },
1567
        {
1568
            categorycode => $categorycode,
1569
            itemtype     => $itemtype,
1570
            branchcode   => undef,
1571
        },
1572
        {
1573
            categorycode => $categorycode,
1574
            itemtype     => undef,
1575
            branchcode   => undef,
1576
        },
1577
        {
1578
            categorycode => undef,
1579
            itemtype     => $itemtype,
1580
            branchcode   => undef,
1581
        },
1582
        {
1583
            categorycode => undef,
1584
            itemtype     => undef,
1585
            branchcode   => undef,
1586
        },
1587
    );
1588
1589
    # Initialize default values
1545
    # Initialize default values
1590
    my $rules = {
1546
    my $rules = {
1591
        issuelength   => 0,
1547
        issuelength   => 0,
Lines 1593-1613 sub GetLoanLength { Link Here
1593
        lengthunit    => 'days',
1549
        lengthunit    => 'days',
1594
    };
1550
    };
1595
1551
1596
    # Search for rules!
1552
    my $found = Koha::CirculationRules->get_effective_rules( {
1597
    foreach my $rule_name (qw( issuelength renewalperiod lengthunit )) {
1553
        branchcode => $branchcode,
1598
        foreach my $params (@params) {
1554
        categorycode => $categorycode,
1599
            my $rule = Koha::CirculationRules->search(
1555
        itemtype => $itemtype,
1600
                {
1556
        rules => [
1601
                    rule_name => $rule_name,
1557
            'issuelength',
1602
                    %$params,
1558
            'renewalperiod',
1603
                }
1559
            'lengthunit'
1604
            )->next();
1560
        ],
1561
    } );
1605
1562
1606
            if ($rule) {
1563
    # Search for rules!
1607
                $rules->{$rule_name} = $rule->rule_value;
1564
    foreach my $rule_name (keys %$found) {
1608
                last;
1565
        $rules->{$rule_name} = $found->{$rule_name};
1609
            }
1610
        }
1611
    }
1566
    }
1612
1567
1613
    return $rules;
1568
    return $rules;
1614
- 

Return to bug 25114