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

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

Return to bug 25114