Bug 18925: Fix 'Default checkout, hold policy by patron category' block

We want ->Search to return undef if the rule does not exist.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2019-03-02 14:14:11 -03:00 committed by Nick Clemens
parent 13faff1250
commit cf207a07a1
2 changed files with 25 additions and 6 deletions

View File

@ -42,4 +42,24 @@ sub Get {
return $rule->rule_value if $rule;
}
sub Search {
my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
$branchcode = undef if $branchcode eq q{};
$categorycode = undef if $categorycode eq q{};
$itemtype = undef if $itemtype eq q{};
my $rule = Koha::CirculationRules->search(
{
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => $rule_name,
}
)->next;
return $rule->rule_value if $rule;
}
1;

View File

@ -533,9 +533,9 @@
<th>&nbsp;</th>
</tr>
[% FOREACH c IN categorycodes %]
[% SET patron_maxissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxissueqty' ) %]
[% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
[% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
[% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
[% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
[% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
[% IF patron_maxissueqty || patron_maxonsiteissueqty || max_holds %]
<tr>
@ -561,9 +561,8 @@
[% END %]
</td>
<td>
[% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode || '*', branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %]
[% IF rule_value.defined && rule_value != '' %]
[% rule_value | html %]
[% IF max_holds.defined && max_holds != '' %]
[% max_holds | html %]
[% ELSE %]
<span>Unlimited</span>
[% END %]