From c9a7dd5520da81dd3f40969f00c79db42cf4c966 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 20 Jun 2008 08:11:17 -0500 Subject: [PATCH] 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 --- admin/smart-rules.pl | 51 ++++++++++++++++++ .../prog/en/modules/admin/smart-rules.tmpl | 53 +++++++++++++++++-- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 2b6a1bec06..a5572a0236 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -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, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl index 209b0b4203..bf6a0ae907 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl @@ -64,11 +64,11 @@ $(document).ready(function() { Patron Category Item Type - Amount - Grace Period - Charging Interval - Amoun Loanable - Loan time  + Fine Amount + Fine Grace Period + Fine Charging Interval + Current Checkouts Allowed + Loan Period  @@ -121,6 +121,49 @@ $(document).ready(function() { + +
+

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. +

+

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. +

+
+
+
+ + "/> + + + + + + + + + + + + + + + + + + +
Patron CategoryTotal Current Checkouts Allowed 
+ &branch=">Delete +
+ +
+
+
+ -- 2.39.5