noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 05/06: Bug detail operation : analytic doesn'


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 05/06: Bug detail operation : analytic doesn't compute properly
Date: Mon, 15 Nov 2021 11:33:33 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 2214a7abbee969fd558162f0fc3a5462d5e22aa2
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Mon Nov 15 17:24:30 2021 +0100

    Bug detail operation : analytic doesn't compute properly
---
 html/js/anc_script.js                 | 41 +++++++++++++++++++++++++----------
 include/class/anc_operation.class.php | 10 ++++++++-
 2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/html/js/anc_script.js b/html/js/anc_script.js
index dfade17..41015f7 100644
--- a/html/js/anc_script.js
+++ b/html/js/anc_script.js
@@ -31,13 +31,16 @@
 function add_row(p_table, p_seq)
 {
     var mytable = g(p_table).tBodies[0];
-    var max =Math.abs( parseFloat(g('amount_t' + p_seq).value));
-    if (!mytable)
+  if (!mytable)
     {
         return;
     }
-    var new_value = mytable.rows.length + 1;
-
+   var a_amount=document.getElementsByClassName(p_table+'-amount');
+      var max=0;
+      for (var e=0;e<a_amount.length;e++) {
+        max +=Math.abs( parseFloat(a_amount[e].value));
+        e=a_amount.length+1;
+      }
 
     if (mytable.rows.length > 15)
     {
@@ -78,15 +81,16 @@ function compute_total_table(p_table, seq)
 
         var i = 0;
         var tot = 0;
-        var col = document.getElementsByName("val[" + seq + "][]");
+        var col = document.getElementsByClassName(p_table+'-value-'+seq);
         var rounded_value = 0 ;
         for (i = 0; i < col.length; i++)
         {
-            if ( $(p_table).contains(col[i])) {
+          
                 rounded_value = Math.round(parseFloat(col[i].value) *100);
                 tot += rounded_value
-            }
+          
         }
+      console.log(`total computed (compute_total_table) ${p_table} ${tot/100}`)
         return tot/100;
     }
     catch (e)
@@ -102,12 +106,19 @@ function compute_total_table(p_table, seq)
  */
 function anc_refresh_remain(p_table, p_seq)
 {
+
     try
     {
-        var tot_line =Math.abs( parseFloat(g('amount_t' + p_seq).value));
+      var a_amount=document.getElementsByClassName(p_table+'-amount');
+      var tot_line=0;
+      for (var e=0;e<a_amount.length;e++) {
+        tot_line +=Math.abs( parseFloat(a_amount[e].value));
+        e=a_amount.length+1;
+      }
+        
         var tot_table = compute_total_table(p_table, p_seq);
-
         var remain = tot_line - tot_table;
+
         remain = Math.round(remain * 100) / 100;
         $('remain' + p_table).innerHTML = remain;
         if (remain == 0)
@@ -145,7 +156,8 @@ function verify_ca(div)
             {
                 var total_amount = 0;
                 // table is found compute the different val[]
-                var array_value = document.getElementsByName('val[' + idx + 
'][]');
+                  var array_value = 
document.getElementsByClassName(table+'-value-'+idx);
+                
 
                 for (var i = 0; i < array_value.length; i++)
                 {
@@ -156,7 +168,12 @@ function verify_ca(div)
 
                     total_amount += parseFloat(array_value[i].value);
                 }
-                var amount = Math.abs(parseFloat(g('amount_t' + idx).value));
+                var a_amount=document.getElementsByClassName(table+'-amount');
+                var amount=0;
+                for (var e=0;e<a_amount.length;e++) {
+                  amount +=Math.abs( parseFloat(a_amount[e].value));
+                  e=a_amount.length+1;
+                }
                 if (isNaN(amount)) {
                     amount=0;
                 } else {
@@ -617,4 +634,4 @@ function anc_detail_op(p_oa_group,gDossier) {
                             remove_waiting_box();
                         }
                     });
-}
\ No newline at end of file
+}
diff --git a/include/class/anc_operation.class.php 
b/include/class/anc_operation.class.php
index fa2ed83..17ee507 100644
--- a/include/class/anc_operation.class.php
+++ b/include/class/anc_operation.class.php
@@ -557,7 +557,14 @@ class Anc_Operation
 
         if ($p_mode==1)
         {
-            $result.=$hidden->input('amount_'.$table_id,$p_amount);
+           $result .= sprintf('<input type="HIDDEN" id="amount_%s" 
class="%s%s-amount" name="amount_%s" value="%s">',
+                   $table_id,
+                   $this->in_div,
+                   $table_id,
+                   $table_id,
+                   $p_amount
+                   );
+            
             $result.='<table id="'.$p_id.$table_id.'">';
         }
         else
@@ -624,6 +631,7 @@ class Anc_Operation
             $value->size=6;
             
$value->value=(isset($val[$p_seq][$i]))?$val[$p_seq][$i]:abs($p_amount);
             $value->value=round($value->value,2);
+             $value->style='class="inum 
'.$this->in_div.$table_id.'-value-'.$p_seq.'"';
             $value->readOnly=($p_mode==1)?false:true;
             $remain=bcsub($remain,$value->value);
             $result.='<td>'.$value->input().'</td>';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]