Bug 15486: Make circ rules UI handle holds_per_day
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 7 Feb 2018 19:10:28 +0000 (16:10 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 24 Oct 2018 13:24:05 +0000 (13:24 +0000)
This patch makes the staff UI correctly handle the holds_per_day
configuration.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

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

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

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

index 854dcde..4975254 100755 (executable)
@@ -164,7 +164,10 @@ elsif ($op eq 'add') {
     $no_auto_renewal_after_hard_limit = eval { dt_from_string( $input->param('no_auto_renewal_after_hard_limit') ) } if ( $no_auto_renewal_after_hard_limit );
     $no_auto_renewal_after_hard_limit = output_pref( { dt => $no_auto_renewal_after_hard_limit, dateonly => 1, dateformat => 'iso' } ) if ( $no_auto_renewal_after_hard_limit );
     my $reservesallowed  = $input->param('reservesallowed');
-    my $holds_per_record  = $input->param('holds_per_record');
+    my $holds_per_record = $input->param('holds_per_record');
+    my $holds_per_day    = $input->param('holds_per_day');
+    $holds_per_day =~ s/\s//g;
+    $holds_per_day = undef if $holds_per_day !~ /^\d+/;
     my $onshelfholds     = $input->param('onshelfholds') || 0;
     $maxissueqty =~ s/\s//g;
     $maxissueqty = undef if $maxissueqty !~ /^\d+/;
@@ -205,6 +208,7 @@ elsif ($op eq 'add') {
         no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
         reservesallowed               => $reservesallowed,
         holds_per_record              => $holds_per_record,
+        holds_per_day                 => $holds_per_day,
         issuelength                   => $issuelength,
         lengthunit                    => $lengthunit,
         hardduedate                   => $hardduedate,
@@ -613,9 +617,10 @@ my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humanca
 
 # note undef maxissueqty so that template can deal with them
 foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) {
-    $entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty});
+    $entry->{unlimited_maxissueqty}       = 1 unless defined($entry->{maxissueqty});
     $entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty});
-    $entry->{unlimited_max_holds} = 1 unless defined($entry->{max_holds});
+    $entry->{unlimited_max_holds}         = 1 unless defined($entry->{max_holds});
+    $entry->{unlimited_holds_per_day}     = 1 unless defined($entry->{holds_per_day});
 }
 
 @sorted_row_loop = sort by_category_and_itemtype @row_loop;
index 849ad73..672a55f 100644 (file)
@@ -90,7 +90,8 @@
                 <th>Automatic renewal</th>
                 <th>No automatic renewal after</th>
                 <th>No automatic renewal after (hard limit)</th>
-                <th>Holds allowed (count)</th>
+                <th>Holds allowed (total)</th>
+                <th>Holds allowed (daily)</th>
                 <th>Holds per record (count)</th>
                 <th>On shelf holds allowed</th>
                 <th>Item level holds</th>
                             <td>[% rule.no_auto_renewal_after | html %]</td>
                             <td>[% rule.no_auto_renewal_after_hard_limit | html %]</td>
                                                        <td>[% rule.reservesallowed | html %]</td>
-                                                        <td>[% rule.holds_per_record | html %]</td>
+                            <td>[% IF rule.unlimited_holds_per_day %]
+                                    <span>Unlimited</span>
+                                [% ELSE %]
+                                    [% rule.holds_per_day | html %]
+                                [% END %]
+                            </td>
+                            <td>[% rule.holds_per_record | html %]</td>
                                                         <td>
                                                             [% IF rule.onshelfholds == 1 %]
                                                                 <span>Yes</span>
                         <input type="text" size="10" name="no_auto_renewal_after_hard_limit" id="no_auto_renewal_after_hard_limit" value="[% no_auto_renewal_after_hard_limit | html %]" class="datepicker"/>
                         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                     </td>
-                    <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
+                    <td><input type="text" name="reservesallowed"  id="reservesallowed"  size="2" /></td>
+                    <td><input type="text" name="holds_per_day"    id="holds_per_day"    size="2" /></td>
                     <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
                     <td>
                         <select name="onshelfholds" id="onshelfholds">
                       <th>No renewal before</th>
                       <th>Automatic renewal</th>
                       <th>No automatic renewal after</th>
-                       <th>No automatic renewal after (hard limit)</th>
-                      <th>Holds allowed (count)</th>
+                      <th>No automatic renewal after (hard limit)</th>
+                      <th>Holds allowed (total)</th>
+                      <th>Holds allowed (daily)</th>
                       <th>Holds per record (count)</th>
                       <th>On shelf holds allowed</th>
                       <th>Item level holds</th>
                             // Remove potential previous input added
                             $(current_column).find("input").remove();
                             $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
-                        } else if ( i == 3 || i == 4 ) {
-                            // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
+                        } else if ( i == 3 || i == 4 || i == 24 ) {
+                            // If the value is not an integer for
+                            //     - "Current checkouts allowed"
+                            //     - "Current on-site checkouts allowed"
+                            //     - "Holds allowed (daily)"
                             // The value is "Unlimited" (or an equivalent translated string)
                             // an it should be set to an empty string
                             if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {