Bug 18887: (follow-up) Fix behavior for default branch/category
authorJesse Weaver <pianohacker@gmail.com>
Wed, 4 Oct 2017 22:50:26 +0000 (16:50 -0600)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 3 Oct 2018 17:58:13 +0000 (17:58 +0000)
Also, fix a couple small QA issues.

Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>

Signed-off-by: Jesse Maseto <jesse@bywatersolution.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/CirculationRules.pm
admin/smart-rules.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt

index 8004e95..054eb00 100644 (file)
@@ -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';
 }
index ae14a8e..4ff96fc 100755 (executable)
@@ -224,12 +224,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
@@ -265,6 +268,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');
@@ -337,7 +349,7 @@ elsif ($op eq "add-branch-cat") {
 
             Koha::CirculationRules->set_rule(
                 {
-                    branchcode   => undef,
+                    branchcode   => '*',
                     categorycode => $categorycode,
                     itemtype     => undef,
                     rule_name    => 'max_holds',
index 5ddf97a..509f0db 100644 (file)
                     <th>&nbsp;</th>
                     <th>Total current checkouts allowed</th>
                     <th>Total current on-site checkouts allowed</th>
+                    <th>Maximum total holds allowed (count)</th>
                     <th>Hold policy</th>
                     <th>Hold pickup library match</th>
                     <th>Return policy</th>
                     <td><input type="text" name="maxissueqty" size="3" value="[% default_maxissueqty | html %]"/></td>
                     <td><input type="text" name="maxonsiteissueqty" size="3" value="[% default_maxonsiteissueqty | html %]"/></td>
                     <td>
+                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
+                        <input name="max_holds" size="3" value="[% rule_value %]" />
+                    </td>
+                    <td>
                         <select name="holdallowed">
                             [% IF ( default_holdallowed_any ) %]
                             <option value="2" selected="selected">