Bug 14048: Add a refund rules setting form in smart-rules

This patch introduces the CRUD UI for managing the refund lost item fee
rules on the general 'Circulation and fines rules' page.

Verify that rules can be added and changed.

Rules are correctly associated to the chosen branch (or the
general default rule).

To test:
- Apply the patch
- Open smart-rules.pl
=> SUCCESS: The text and refund rules section correctly refers to default global rules.
   The policy can be set to Yes and No, and works as expected.
- Pick a specific branch
=> SUCCESS: The rule refers to the specific branch
=> SUCCESS: It detects the default rule is picked
=> SUCCESS: On changing the rules values are correctly retrieved if entering
   again to the page.
=> SUCCESS: The 'Use default' text is suffixed with the correct value set by the user
   in the 'All libraries' scenario.
=> Sign off :-D

Sponsored-by: DoverNet
Sponsored-by: South-East Kansas Library System
Sponsored-by: SWITCH Library Consortium

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Jennifer Schmidt <jschmidt@switchinc.org>
Signed-off-by: Margaret Thrasher <p.thrasher@dover.nh.gov>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2016-06-03 11:26:11 -03:00 committed by Jesse Weaver
parent 262b9344cd
commit e85b2e4f94
2 changed files with 115 additions and 0 deletions

View file

@ -30,6 +30,9 @@ use Koha::DateUtils;
use Koha::Database;
use Koha::IssuingRule;
use Koha::IssuingRules;
use Koha::Logger;
use Koha::RefundLostItemFeeRule;
use Koha::RefundLostItemFeeRules;
use Koha::Libraries;
my $input = CGI->new;
@ -423,6 +426,37 @@ elsif ($op eq "add-branch-item") {
}
}
}
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
my $refund = $input->param('refund');
if ( $refund eq '*' ) {
if ( $branch ne '*' ) {
# only do something for $refund eq '*' if branch-specific
eval {
# Delete it so it picks the default
Koha::RefundLostItemFeeRules->find({
branchcode => $branch
})->delete;
};
}
} else {
my $refundRule =
Koha::RefundLostItemFeeRules->find({
branchcode => $branch
}) // Koha::RefundLostItemFeeRule->new;
$refundRule->set({
branchcode => $branch,
refund => $refund
})->store;
}
}
my $refundLostItemFeeRule = Koha::RefundLostItemFeeRules->find({ branchcode => $branch });
$template->param(
refundLostItemFeeRule => $refundLostItemFeeRule,
defaultRefundRule => Koha::RefundLostItemFeeRules->_default_rule
);
my $branches = GetBranches();
my @branchloop;

View file

@ -2,6 +2,7 @@
<title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
[% USE Branches %]
<script type="text/javascript">
//<![CDATA[
@ -557,6 +558,86 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
</form>
</div>
[% END %]
<div id="refund-lost-item-fee-on-return" class="container">
[% IF current_branch == '*' %]
<h3>Default lost item fee refund on return policy</h3>
[% ELSE %]
<h3>Lost item fee refund on return policy for [% Branches.GetName(current_branch) %]</h3>
[% END %]
<p>Specify the default policy for lost item fees on return.
</p>
<form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
<input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
<input type="hidden" name="branch" value="[% current_branch %]" />
<table>
<tr>
<th>Refund lost item fee</th>
<th>&nbsp;</th>
</tr>
<tr>
<td>
<select name="refund">
[#% Default branch %#]
[% IF ( current_branch == '*' ) %]
[% IF ( refundLostItemFeeRule.refund ) %]
<option value="1" selected="selected">
[% ELSE %]
<option value="1">
[% END %]
Yes
</option>
[% IF ( not refundLostItemFeeRule.refund ) %]
<option value="0" selected="selected">
[% ELSE %]
<option value="0">
[% END %]
No
</option>
[% ELSE %]
[#% Branch-specific %#]
[% IF ( not refundLostItemFeeRule ) %]
<option value="*" selected="selected">
[% ELSE %]
<option value="*">
[% END %]
[% IF defaultRefundRule %]
Use default (Yes)
[% ELSE %]
Use default (No)
[% END %]
</option>
[% IF ( not refundLostItemFeeRule ) %]
<option value="1">Yes</option>
<option value="0">No</option>
[% ELSE %]
[% IF ( refundLostItemFeeRule.refund ) %]
<option value="1" selected="selected">
[% ELSE %]
<option value="1">
[% END %]
Yes
</option>
[% IF ( not refundLostItemFeeRule.refund ) %]
<option value="0" selected="selected">
[% ELSE %]
<option value="0">
[% END %]
No
</option>
[% END %]
[% END %]
</select>
</td>
<td class="actions">
<button type="submit" class="btn btn-mini"><i class="fa fa-save"></i> Save</button>
</td>
</td>
</tr>
</table>
</form>
</div>
<div id="holds-policy-by-item-type" class="container">
<h3>[% IF humanbranch %]Holds policy by item type for [% humanbranch %][% ELSE %]Default holds policy by item type[% END %]</h3>
<p>