Bug 9943: activate "Pay selected" button only when at least one fine is selected
authorOwen Leonard <oleonard@myacpl.org>
Fri, 9 Aug 2013 17:43:21 +0000 (13:43 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 8 Sep 2013 07:10:42 +0000 (07:10 +0000)
If you select no fines but click the "pay selected" button the resulting
screen offers to let you pay against all fines, which is confusing. To
simplify things this patch disables the "pay selected" button if no
lines are selected.

To test, apply the patch and find a patron with outstanding fines. From
the "pay fines" page (members/pay.pl) try selecting and deselecting
checkboxes and using the "select all" and "clear all" links. When no
item is selected the "Pay selected" button should become disabled.
Confirm that the form submits correctly when one or more fines is
selected.

Signed-off-by: Melia Meggs <melia@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Works nicely in my tests.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt

index 9b50924..91f1609 100644 (file)
@@ -4,6 +4,15 @@
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type= "text/javascript">
 //<![CDATA[
+function enableCheckboxActions(){
+    // Enable/disable controls if checkboxes are checked
+    var checkedBoxes = $("input.cb:checked");
+    if ($(checkedBoxes).size()) {
+      $("#payselected").prop("disabled",false);
+    } else {
+      $("#payselected").prop("disabled",true);
+    }
+}
     $(document).ready(function(){
  $('#pay-fines-form').preventDoubleFormSubmit();
         $("#woall").click(function(event){
                     event.preventDefault();
                 }
         });
-        $('#CheckAll').click(function(){ $("#finest").checkCheckboxes(); return false;});
-        $('#CheckNone').click(function(){ $("#finest").unCheckCheckboxes(); return false;});
+        $('#CheckAll').click(function(){
+            $("#finest").checkCheckboxes();
+            enableCheckboxActions();
+            return false;
+        });
+        $('#CheckNone').click(function(){
+            $("#finest").unCheckCheckboxes();
+            enableCheckboxActions();
+            return false;
+        });
+        $(".cb").change(function(){
+            enableCheckboxActions();
+        });
+        enableCheckboxActions();
     });
 //]]>
 </script>
@@ -71,7 +92,7 @@
 <tr>
     <td>
     [% IF ( line.amountoutstanding > 0 ) %]
-        <input type="checkbox" checked="checked" name="incl_par_[% line.accountno %]" />
+        <input class="cb" type="checkbox" checked="checked" name="incl_par_[% line.accountno %]" />
     [% END %]
     </td>
     <td>
 </tbody>
 </table>
 <fieldset class="action">
-<input type="submit" name="paycollect"  value="Pay amount" class="submit" />
+<input type="submit" id="paycollect" name="paycollect"  value="Pay amount" class="submit" />
 <input type="submit" name="woall"  id="woall" value="Write off all" class="submit" />
-<input type="submit" name="payselected"  value="Pay selected" class="submit" />
+<input type="submit" id="payselected" name="payselected"  value="Pay selected" class="submit" />
 <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
 </fieldset>
 </form>