[Koha-patches] [PATCH] bug 2707 - overdue rules not being deleted
John Beppu
john.beppu at liblime.com
Fri Oct 24 13:59:06 CEST 2008
I added some code to detect the rows which were blank, and
I deleted them upon saving the form.
---
tools/overduerules.pl | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/tools/overduerules.pl b/tools/overduerules.pl
index 8378496..b2ab74e 100755
--- a/tools/overduerules.pl
+++ b/tools/overduerules.pl
@@ -30,6 +30,24 @@ use C4::Members;
my $input = new CGI;
my $dbh = C4::Context->dbh;
+my @category_codes = qw(B HB IL J K L PT SC ST YA);
+my @rule_params = qw(delay letter debarred);
+
+# blank_row($category_code) - return true if the entire row is blank.
+sub blank_row {
+ my ($category_code) = @_;
+ for my $rp (@rule_params) {
+ for my $n (1 .. 3) {
+ my $key = "${rp}${n}-$category_code";
+ my $value = $input->param($key);
+ if ($value) {
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
my $type=$input->param('type');
my $branch = $input->param('branch');
$branch="" unless $branch;
@@ -66,6 +84,10 @@ if ($op eq 'save') {
$temphash{$bor}->{"$type$num"}=$input->param("$key") if (($input->param("$key") ne "") or ($input->param("$key")>0));
}
}
+
+ # figure out which rows need to be deleted
+ my @rows_to_delete = grep { blank_row($_) } @category_codes;
+
foreach my $bor (keys %temphash){
# get category name if we need it for an error message
my $bor_category = GetBorrowercategory($bor);
@@ -133,7 +155,10 @@ if ($op eq 'save') {
}
}
unless ($err) {
- $template->param(datasaved=>1);
+ for my $category_code (@rows_to_delete) {
+ $sth_delete->execute($branch, $category_code);
+ }
+ $template->param(datasaved => 1);
$input_saved = 1;
}
}
--
1.5.2.5
More information about the Koha-patches
mailing list