details:   https://code.openbravo.com/erp/devel/pi/rev/aef492f2af94
changeset: 17743:aef492f2af94
user:      Javier Etxarri <javier.echarri <at> openbravo.com>
date:      Wed Aug 22 11:56:44 2012 +0200
summary:   Fixes issue 21402: The addDetails popup on payment
window has performance problems when (un)checking all the rows

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.html
 |  64 +++++++++-
 1 files changed, 60 insertions(+), 4 deletions(-)

diffs (81 lines):

diff -r 465b640a58ea -r aef492f2af94 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.html
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.html
      Wed Aug 22 11:41:34 2012 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.html
      Wed Aug 22 11:56:44 2012 +0200
@@ -366,7 +366,62 @@
   }
   return true;
 }
-function updateData(key, mark, drivenByGrid) {
+
+function updateAll(drivenByGrid) {
+  var frm = document.frmMain;
+  var chk = frm.inpScheduledPaymentDetailId;
+  var recordAmount, i;
+
+  frm.inpExpectedPayment.value = applyFormat('0');
+  if (isGLItemEnabled) {
+    frm.inpExpectedPayment.value = frm.inpGLSumAmount.value || 
applyFormat('0');
+  }
+  if (!chk) {
+    return;
+  } else if (!chk.length) {
+    if (!chk.checked) {
+      recordAmount = frm.elements["inpRecordAmt" + chk.value].value;
+      frm.inpExpectedPayment.value = add(frm.inpExpectedPayment.value, 
recordAmount);
+    }
+    updateData(chk.value, chk.checked, drivenByGrid);
+  } else {
+    var total = chk.length;
+    if (drivenByGrid){
+      if(!document.getElementById('inpTotal') || 
document.getElementById('inpTotal').value !== applyFormat('0')){
+        document.getElementById('inpTotal').value = applyFormat('0');
+        for (i = 0; i < total; i++) {
+          
if(applyFormat(document.frmMain.elements['inpPaymentAmount'+chk[i].value].value)
 !== "" && chk[i].checked){
+            document.getElementById('inpTotal').value = 
add(applyFormat(document.getElementById('inpTotal').value), 
applyFormat(document.frmMain.elements['inpPaymentAmount'+chk[i].value].value));
+          }
+        }
+      }
+    }
+    for (i = 0; i < total; i++) {
+      if (!chk[i].checked) {
+        recordAmount = frm.elements["inpRecordAmt" + chk[i].value].value;
+        frm.inpExpectedPayment.value = add(frm.inpExpectedPayment.value, 
recordAmount);
+      }
+      if (drivenByGrid){
+        if 
(applyFormat(document.frmMain.elements['inpPaymentAmount'+chk[i].value].value) 
=== "" || !chk[i].checked)
+        {
+          updateData(chk[i].value, chk[i].checked, drivenByGrid, true);
+          if (chk[i].checked){
+            document.getElementById('inpTotal').value = 
add(applyFormat(document.getElementById('inpTotal').value), 
applyFormat(document.frmMain.elements['inpPaymentAmount'+chk[i].value].value));
+          }
+        }
+      }
+      else{
+          updateData(chk[i].value, chk[i].checked, drivenByGrid,false);
+      }
+    }
+  }
+  if (drivenByGrid){
+    updateTotal();
+  }
+  return true;
+}
+
+function updateData(key, mark, drivenByGrid, all) {
   if (mark === null) { mark=false; }
   updateReadOnly(key, mark);
   var paymentAmount = document.frmMain.elements['inpPaymentAmount'+key];
@@ -405,9 +460,10 @@
       }
     }
   }
-
-  updateTotal();
-
+  if (!all){
+    updateTotal();
+  }
+      
   return true;
 }
 function validateDate(element){

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to