/* * This file is part of NOALYSS. * * NOALYSS is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NOALYSS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NOALYSS; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Revision$ */ // Copyright Author Dany De Bontridder danydb@aevalys.eu /** * @file * javascript for the analytic accountancy */ /** * add a row for the CA * \param p_table_id * \param p_amount amount to reach */ function add_row(p_table, p_seq) { var mytable = id$(p_table).tBodies[0]; if (!mytable) { return; } var a_amount=document.getElementsByClassName(p_table+'-amount'); var max=0; for (var e=0;e 15) { alert_box(content[55]); return; } var amount = compute_total_table(p_table, p_seq); if (max < amount) { alert_box(content[48]+' '+content[56]+ ' '+max + content[57]+' '+ amount); } // For the detail view (modify_op) there is several form and then several time the // element var rowToCopy = mytable.rows[1]; var row = mytable.insertRow(mytable.rows.length); for (var i = 0; i < rowToCopy.cells.length; i++) { var cell = row.insertCell(i); var txt = rowToCopy.cells[i].innerHTML; cell.innerHTML = txt; } var col = document.getElementsByName("val[" + p_seq + "][]"); let tmp_amount=max - amount; col[col.length - 1].value = Math.round(tmp_amount*100)/100; anc_refresh_remain(p_table, p_seq); } /** *Compute total of a form from Anc_Operation::display_form_plan *@param {dom_id} p_table table id *@param {int}seq sequence of the line *@see Anc_Operation::display_form_plan */ function compute_total_table(p_table, seq) { try { var i = 0; var tot = 0; var col = document.getElementsByClassName(p_table+'-value-'+seq); var rounded_value = 0 ; for (i = 0; i < col.length; i++) { rounded_value = Math.round(parseFloat(col[i].value) *100); tot += rounded_value } return tot/100; } catch (e) { alert_box(e.message); } } /** * Refresh remain of account. analytic *@param p_table table id *@param p_seq sequence of the line *@see Anc_Operation::display_form_plan */ function anc_refresh_remain(p_table, p_seq) { try { var a_amount=document.getElementsByClassName(p_table+'-amount'); var tot_line=0; for (var e=0;e 15) { alert_box("Maximum 15 lignes "); return; } var rowToCopy = mytable.rows[1]; var row = mytable.insertRow(table_length); var nb=mytable.rows.length -2; for (var i = 0; i < rowToCopy.cells.length; i++) { var cell = row.insertCell(i); cell.className=rowToCopy.cells[i].className; var txt = rowToCopy.cells[i].innerHTML; if ( i == 0 ) { var change=nb+1; cell.innerHTML =change+''; } else { if (i == rowToCopy.cells.length -1 ) { txt=txt.replace(/value="[0-9]*.{1}[0-9]*"/,'value="0"') } else { txt=txt.replace(/po_id\[0\]/g,'po_id['+nb+']'); } cell.innerHTML = txt; } } id$('total_key').innerHTML="?"; } function anc_key_compute_table() { var tot=0; var i=0; var value=0; var percent=document.getElementsByName('percent[]'); for (i=0;i