From a99f52f9c50e2457454b800f774c028484902c64 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Wed, 4 Oct 2017 16:50:26 -0600 Subject: [PATCH] Bug 18887: (follow-up) Fix behavior for default branch/category Also, fix a couple small QA issues. --- Koha/CirculationRules.pm | 5 ++++- admin/smart-rules.pl | 16 ++++++++++++++-- .../intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 5 +++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 8004e95196..054eb00858 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -136,7 +136,6 @@ sub set_rule { sub set_rules { my ( $self, $params ) = @_; - warn Data::Dumper::Dumper( $params ); my $branchcode = $params->{branchcode}; my $categorycode = $params->{categorycode}; @@ -164,6 +163,10 @@ sub _type { return 'CirculationRule'; } +=head3 object_class + +=cut + sub object_class { return 'Koha::CirculationRule'; } diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index b1ce8c24ca..c5dcc30abb 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -219,12 +219,15 @@ elsif ($op eq "set-branch-defaults") { my $holdallowed = $input->param('holdallowed'); my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); my $returnbranch = $input->param('returnbranch'); + my $max_holds = $input->param('max_holds'); $maxissueqty =~ s/\s//g; $maxissueqty = undef if $maxissueqty !~ /^\d+/; $maxonsiteissueqty =~ s/\s//g; $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; $holdallowed =~ s/\s//g; $holdallowed = undef if $holdallowed !~ /^\d+/; + $max_holds =~ s/\s//g; + $max_holds = undef if $max_holds !~ /^\d+/; if ($branch eq "*") { my $sth_search = $dbh->prepare("SELECT count(*) AS total @@ -260,6 +263,15 @@ elsif ($op eq "set-branch-defaults") { $sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); } } + Koha::CirculationRules->set_rule( + { + branchcode => $branch, + categorycode => '*', + itemtype => undef, + rule_name => 'max_holds', + rule_value => $max_holds, + } + ); } elsif ($op eq "add-branch-cat") { my $categorycode = $input->param('categorycode'); @@ -312,7 +324,7 @@ elsif ($op eq "add-branch-cat") { my $sth_insert = $dbh->prepare(q| INSERT INTO default_borrower_circ_rules (categorycode, maxissueqty, maxonsiteissueqty) - VALUES (?, ?, ?, ?) + VALUES (?, ?, ?) |); my $sth_update = $dbh->prepare(q| UPDATE default_borrower_circ_rules @@ -330,7 +342,7 @@ elsif ($op eq "add-branch-cat") { Koha::CirculationRules->set_rule( { - branchcode => undef, + branchcode => '*', categorycode => $categorycode, itemtype => undef, rule_name => 'max_holds', diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 7fe6ee9bde..593fcf9bd4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -452,6 +452,7 @@ $(document).ready(function() {   Total current checkouts allowed Total current on-site checkouts allowed + Maximum total holds allowed (count) Hold policy Hold pickup library match Return policy @@ -462,6 +463,10 @@ $(document).ready(function() { + [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %] + + +