Lines 1604-1653
Get loan length for an itemtype, a borrower type and a branch
Link Here
|
1604 |
sub GetLoanLength { |
1604 |
sub GetLoanLength { |
1605 |
my ( $categorycode, $itemtype, $branchcode ) = @_; |
1605 |
my ( $categorycode, $itemtype, $branchcode ) = @_; |
1606 |
|
1606 |
|
1607 |
# Set search precedences |
|
|
1608 |
my @params = ( |
1609 |
{ |
1610 |
categorycode => $categorycode, |
1611 |
itemtype => $itemtype, |
1612 |
branchcode => $branchcode, |
1613 |
}, |
1614 |
{ |
1615 |
categorycode => $categorycode, |
1616 |
itemtype => undef, |
1617 |
branchcode => $branchcode, |
1618 |
}, |
1619 |
{ |
1620 |
categorycode => undef, |
1621 |
itemtype => $itemtype, |
1622 |
branchcode => $branchcode, |
1623 |
}, |
1624 |
{ |
1625 |
categorycode => undef, |
1626 |
itemtype => undef, |
1627 |
branchcode => $branchcode, |
1628 |
}, |
1629 |
{ |
1630 |
categorycode => $categorycode, |
1631 |
itemtype => $itemtype, |
1632 |
branchcode => undef, |
1633 |
}, |
1634 |
{ |
1635 |
categorycode => $categorycode, |
1636 |
itemtype => undef, |
1637 |
branchcode => undef, |
1638 |
}, |
1639 |
{ |
1640 |
categorycode => undef, |
1641 |
itemtype => $itemtype, |
1642 |
branchcode => undef, |
1643 |
}, |
1644 |
{ |
1645 |
categorycode => undef, |
1646 |
itemtype => undef, |
1647 |
branchcode => undef, |
1648 |
}, |
1649 |
); |
1650 |
|
1651 |
# Initialize default values |
1607 |
# Initialize default values |
1652 |
my $rules = { |
1608 |
my $rules = { |
1653 |
issuelength => 0, |
1609 |
issuelength => 0, |
Lines 1655-1675
sub GetLoanLength {
Link Here
|
1655 |
lengthunit => 'days', |
1611 |
lengthunit => 'days', |
1656 |
}; |
1612 |
}; |
1657 |
|
1613 |
|
1658 |
# Search for rules! |
1614 |
my $found = Koha::CirculationRules->get_effective_rules( { |
1659 |
foreach my $rule_name (qw( issuelength renewalperiod lengthunit )) { |
1615 |
branchcode => $branchcode, |
1660 |
foreach my $params (@params) { |
1616 |
categorycode => $categorycode, |
1661 |
my $rule = Koha::CirculationRules->search( |
1617 |
itemtype => $itemtype, |
1662 |
{ |
1618 |
rules => [ |
1663 |
rule_name => $rule_name, |
1619 |
'issuelength', |
1664 |
%$params, |
1620 |
'renewalperiod', |
1665 |
} |
1621 |
'lengthunit' |
1666 |
)->next(); |
1622 |
], |
|
|
1623 |
} ); |
1667 |
|
1624 |
|
1668 |
if ($rule) { |
1625 |
# Search for rules! |
1669 |
$rules->{$rule_name} = $rule->rule_value; |
1626 |
foreach my $rule_name (keys %$found) { |
1670 |
last; |
1627 |
$rules->{$rule_name} = $found->{$rule_name}; |
1671 |
} |
|
|
1672 |
} |
1673 |
} |
1628 |
} |
1674 |
|
1629 |
|
1675 |
return $rules; |
1630 |
return $rules; |
1676 |
- |
|
|