From 9f3dc9fe29cd7dc5ec4f338c8946a48cbc92da1e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 1 Nov 2011 03:57:17 +0000 Subject: [PATCH] =?UTF-8?q?433:=20am=C3=A9lioration=20Compta=20Analytique?= =?UTF-8?q?=20:=20montant=20v=C3=A9rifi=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/anc_script.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/html/js/anc_script.js b/html/js/anc_script.js index 6c36e465d..b0b9f7334 100644 --- a/html/js/anc_script.js +++ b/html/js/anc_script.js @@ -29,17 +29,25 @@ function add_row(p_table,p_seq) { var mytable=g(p_table).tBodies[0]; - + var max=parseFloat(g('amount_t'+p_seq).value); if ( ! mytable ) { return; } var new_value=mytable.rows.length+1; + + if ( mytable.rows.length > 5 ) { alert("Maximum 5 lignes "); return; } + amount=compute_total_table(p_table,p_seq); + if ( max < amount ) + { + alert('Montant incorrect : max = '+max+" calculé="+amount); + return; + } // For the detail view (modify_op) there is several form and then several time the // element var rowToCopy=mytable.rows[1]; @@ -52,8 +60,33 @@ function add_row(p_table,p_seq) // txt=txt.replace(/row_1/g,"row_"+new_value); cell.innerHTML=txt; } + var col=document.getElementsByName("val["+p_seq+"][]"); + col[col.length-1].value=max-amount; } +/** + *@bug cannot compute total for ANC_TABLE + *@todo fix this bug + */ +function compute_total_table(p_table,seq) +{ + try{ + + var i=0;var tot=0; + var col=document.getElementsByName("val["+seq+"][]"); + for (i=0;i