bug 2000 - add total loan limit to alt. issuing rules

The alternate issuing rules editor can now allow
defining the maximum number of loans that a borrower
of a given category can take out per branch, regardless
of item type.

The form for entering this limit now appears below
the form for setting loan rules per patron category
and item type.  The form only appears if a specific
branch is chosen, not if the default branch is used.

Also, some terminology changes:

* "Amount Loanable" => "Current Checkouts Allowed"
* "Amount" => "Fine Amount"
* "Grace Period" => "Fine Grace Period"
* "Charging Interval" => "Fine Charging Interval"
* "Loan time" => "Loan Period"

Documentation change: new screenshots for the alternate
loan rules form.

squashme terminology

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Galen Charlton 2008-06-20 08:11:17 -05:00 committed by Joshua Ferraro
parent 9f2c77a686
commit c9a7dd5520
2 changed files with 99 additions and 5 deletions

View file

@ -52,6 +52,13 @@ if ($op eq 'delete') {
my $sth_Idelete = $dbh->prepare("delete from issuingrules where branchcode=? and categorycode=? and itemtype=?");
$sth_Idelete->execute($branch, $categorycode, $itemtype);
}
elsif ($op eq 'delete-branch-cat') {
my $sth_delete = $dbh->prepare("DELETE FROM branch_borrower_circ_rules
WHERE branchcode = ?
AND categorycode = ?");
my $categorycode = $input->param('categorycode');
$sth_delete->execute($branch, $categorycode);
}
# save the values entered
elsif ($op eq 'add') {
my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?");
@ -75,7 +82,34 @@ elsif ($op eq 'add') {
} else {
$sth_insert->execute($br,$bor,$cat,$maxissueqty,$issuelength,$fine,$firstremind,$chargeperiod);
}
}
elsif ($op eq "add-branch-cat") {
my $sth_search = $dbh->prepare("SELECT count(*) AS total
FROM branch_borrower_circ_rules
WHERE branchcode = ?
AND categorycode = ?");
my $sth_insert = $dbh->prepare("INSERT INTO branch_borrower_circ_rules
(branchcode, categorycode, maxissueqty)
VALUES (?, ?, ?)");
my $sth_update = $dbh->prepare("UPDATE branch_borrower_circ_rules
SET maxissueqty = ?
WHERE branchcode = ?
AND categorycode = ?");
my $categorycode = $input->param('categorycode');
my $maxissueqty = $input->param('maxissueqty');
$maxissueqty =~ s/\s//g;
$maxissueqty = undef if $maxissueqty !~ /^\d+/;
$sth_search->execute($branch, $categorycode);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
$sth_update->execute($maxissueqty, $branch, $categorycode);
} else {
$sth_insert->execute($branch, $categorycode, $maxissueqty);
}
}
my $branches = GetBranches();
my @branchloop;
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
@ -128,6 +162,23 @@ $sth->finish;
my @sorted_row_loop = sort by_category_and_itemtype @row_loop;
my $sth_branch_cat = $dbh->prepare("
SELECT branch_borrower_circ_rules.*, categories.description AS humancategorycode
FROM branch_borrower_circ_rules
JOIN categories USING (categorycode)
WHERE branch_borrower_circ_rules.branchcode = ?
");
if ($branch ne "*") {
$sth_branch_cat->execute($branch);
my @branch_cat_rules = ();
while (my $row = $sth_branch_cat->fetchrow_hashref) {
push @branch_cat_rules, $row;
}
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humancategorycode'} } @branch_cat_rules;
$template->param(show_branch_cat_rule_form => 1);
$template->param(branch_cat_rule_loop => \@sorted_branch_cat_rules);
}
$template->param(categoryloop => \@category_loop,
itemtypeloop => \@itemtypes,
rules => \@sorted_row_loop,

View file

@ -64,11 +64,11 @@ $(document).ready(function() {
<tr>
<th>Patron Category</th>
<th>Item Type</th>
<th>Amount</th>
<th>Grace Period</th>
<th>Charging Interval</th>
<th>Amoun Loanable</th>
<th>Loan time</th><th>&nbsp;</th>
<th>Fine Amount</th>
<th>Fine Grace Period</th>
<th>Fine Charging Interval</th>
<th>Current Checkouts Allowed</th>
<th>Loan Period</th><th>&nbsp;</th>
</tr>
<!-- TMPL_LOOP NAME="rules" -->
<tr>
@ -121,6 +121,49 @@ $(document).ready(function() {
</table>
</form>
</div>
<!-- TMPL_IF NAME="show_branch_cat_rule_form" -->
<div class="help">
<p>For this library, you can specify the maximum number of loans that
a patron of a given category can make, regardless of the item type.
</p>
<p>If the total amount loanable for a given patron category is left blank,
no limit applies, except possibly for a limit you define for a specific item type.
</p>
</div>
<div>
<form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
<input type="hidden" name="op" value="add-branch-cat" />
<input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/>
<table>
<tr>
<th>Patron Category</th>
<th>Total Current Checkouts Allowed</th>
<th>&nbsp;</th>
</tr>
<!-- TMPL_LOOP NAME="branch_cat_rule_loop" -->
<tr>
<td><!-- TMPL_VAR NAME="humancategorycode" --></td>
<td><!-- TMPL_VAR NAME="maxissueqty" --></td>
<td>
<a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
</td>
</tr>
<!-- /TMPL_LOOP -->
<tr>
<td>
<select name="categorycode">
<!-- TMPL_LOOP NAME="categoryloop" -->
<option value="<!-- TMPL_VAR NAME="categorycode" -->"><!-- TMPL_VAR NAME="description" --></option>
<!-- /TMPL_LOOP -->
</select>
</td>
<td><input name="maxissueqty" size="3" /></td>
<td><input type="submit" value="Add" class="submit" /></td>
</tr>
</table>
</form>
</div>
<!-- /TMPL_IF -->
</div>
</div>