Bug 8054 - double clicking can cause duplicate payments/fines
authorLiz Rea <liz@catalyst.net.nz>
Thu, 27 Dec 2012 03:10:26 +0000 (16:10 +1300)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Mon, 11 Mar 2013 12:14:12 +0000 (08:14 -0400)
Uses preventDoubleForSubmit() to prevent double form submissions in the fines module.

To test:

Create a manual invoice/fine
Create some manual fines, click save like mad - you should get only one fine (without, you will get several if you click madly enough)

Click Pay fines
Pay some fines, clicking save like mad on each. You should only get one payment. (without, you will get several payments)

Create a manual credit
Create a credit, click save like mad. You should only get one credit. (without you will get several if you click madly enough)

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>

koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt

index 8b71856..52264ee 100644 (file)
@@ -5,6 +5,7 @@
 //<![CDATA[
 $(document).ready(function(){
        $("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
+        $('#mancredit').preventDoubleFormSubmit();
 });
 //]]>
 </script>
@@ -32,7 +33,7 @@ $(document).ready(function(){
 </ul>
 <div class="tabs-container">
 
-<form action="/cgi-bin/koha/members/mancredit.pl" method="post">
+<form action="/cgi-bin/koha/members/mancredit.pl" method="post" id="mancredit">
 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
 
 <fieldset class="rows">
index 217882e..dc9aac4 100644 (file)
@@ -5,6 +5,7 @@
 //<![CDATA[
 $(document).ready(function(){
        $("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
+        $('#maninvoice').preventDoubleFormSubmit();
 });
 //]]>
 </script>
@@ -37,7 +38,7 @@ $(document).ready(function(){
   ERROR an invalid itemnumber was entered, please hit back and try again
 [% END %]
 [% ELSE %]
-<form action="/cgi-bin/koha/members/maninvoice.pl" method="post"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
+<form action="/cgi-bin/koha/members/maninvoice.pl" method="post" id="maninvoice"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
        <fieldset class="rows">
        <legend>Manual Invoice</legend>
        <ol>
index 171337d..e575df8 100644 (file)
@@ -5,6 +5,7 @@
 <script type= "text/javascript">
 //<![CDATA[
     $(document).ready(function(){
+ $('#pay-fines-form').preventDoubleFormSubmit();
         $("#woall").click(function(event){
             var answer = confirm(_("Are you sure you want to write off [% total | format('%.2f') %] in outstanding fines? This cannot be undone!"));
                 if (!answer){
@@ -41,7 +42,7 @@
 <div class="tabs-container">
 
 [% IF ( accounts ) %]
-    <form action="/cgi-bin/koha/members/pay.pl" method="post">
+    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
        <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
 <p><span class="checkall"><a id="CheckAll" href="#">Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></p>
 <table id="finest">
index 5b3b2ca..f38d20c 100644 (file)
@@ -3,6 +3,13 @@
 [% INCLUDE 'doc-head-close.inc' %]
 <script type= "text/javascript">
 //<![CDATA[
+$(document).ready(function() {
+    $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
+});
+//]]>
+</script>
+<script type= "text/javascript">
+//<![CDATA[
 function moneyFormat(textObj) {
     var newValue = textObj.value;
     var decAmount = "";
@@ -91,7 +98,7 @@ function moneyFormat(textObj) {
 [% END %]
 
 [% IF ( pay_individual ) %]
-    <form name="payindivfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
+    <form name="payindivfine" id="payindivfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual %]" />
     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber %]" />
@@ -145,7 +152,7 @@ function moneyFormat(textObj) {
         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a></div>
     </form>
 [% ELSIF ( writeoff_individual ) %]
-    <form name="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
+    <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
     <fieldset class="rows">
     <legend>Write off an individual fine</legend>
     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
@@ -185,7 +192,7 @@ function moneyFormat(textObj) {
     </form>
 [% ELSE %]
 
-    <form name="payfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
+    <form name="payfine" id="payfine" onsubmit="return validatePayment(this);" method="post" action="/cgi-bin/koha/members/paycollect.pl">
     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
     <input type="hidden" name="total" id="total" value="[% total %]" />