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=?");
} 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) {
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,
<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> </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> </th>
</tr>
<!-- TMPL_LOOP NAME="rules" -->
<tr>
</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> </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&categorycode=<!-- TMPL_VAR NAME="categorycode" -->&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>