From 231c4db5493cf211bdc804a322bc88afdfb1f3e2 Mon Sep 17 00:00:00 2001 From: Liz Rea <liz@catalyst.net.nz> Date: Thu, 27 Dec 2012 16:10:26 +1300 Subject: [PATCH] Bug 8054 - double clicking can cause duplicate payments/fines 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) --- .../prog/en/modules/members/mancredit.tt | 3 ++- .../prog/en/modules/members/maninvoice.tt | 3 ++- .../intranet-tmpl/prog/en/modules/members/pay.tt | 3 ++- .../prog/en/modules/members/paycollect.tt | 13 ++++++++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt index 8b71856..52264ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt @@ -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"> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt index 217882e..dc9aac4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt @@ -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> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index 2780c3f..b351d33 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -4,6 +4,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){ @@ -38,7 +39,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 %]" /> <table> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index c558b08..cb1a540 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -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 %]" /> -- 1.7.9.5