/* * 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 * \brief javascript script for the ledger in accountancy, * compute the sum, add a row at the table.. * */ var layer=1; /** * @brief update the list of available predefined operation when we change the ledger. */ function update_predef(p_type,p_direct,p_ac) { var jrn=g("p_jrn").value; var dossier=g("gDossier").value; var querystring='gDossier='+dossier+'&l='+jrn+'&t='+p_type+'&d='+p_direct+"&op=up_predef&ac="+p_ac; g("p_jrn_predef").value=jrn; var action = new Ajax.Request( "ajax_misc.php", { method: 'get', parameters: querystring, onFailure: error_get_predef, onSuccess: function(req) { try { $('info_div').innerHTML = "ok"; var answer = req.responseXML; var a = answer.getElementsByTagName('code'); var html = answer.getElementsByTagName('value'); if (a.length == 0) { var rec = req.responseText; alert('erreur :' + rec); } var code_html = getNodeText(html[0]); code_html = unescape_xml(code_html); // document.getElementsByName(name_ctl)[0].value = code_html; $('modele_op_div').innerHTML=code_html; } catch (e) { $('info_div').innerHTML = e.getMessage; } } } ); } /** * @brief update the list of payment method when we change the ledger. */ function update_pay_method() { waiting_box(); var jrn=g("p_jrn").value; var dossier=g("gDossier").value; var querystring='gDossier='+dossier+'&l='+jrn+"&op=up_pay_method"; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:querystring, onFailure:error_get_predef, onSuccess:function(req){ remove_waiting_box(); var answer=req.responseText; $('payment').innerHTML=answer; } } ); } /** *@brief update ctl id =jrn_name with the value of p_jrn */ function update_name() { var jrn_id=$('p_jrn').value; var dossier=g("gDossier").value; var querystring='gDossier='+dossier+'&l='+jrn_id+"&op=ledger_description"; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:querystring, onFailure:error_get_pj, onSuccess:function (req){ $('jrn_name_div').innerHTML=req.responseText; } } ); } /** * @brief update the field predef */ function error_get_predef(request,json) { alert ("Erreur mise à jour champs non possible"); } /** * @brief update the list of available predefined operation when we change the ledger. */ function update_pj() { var jrn=g("p_jrn").value; var dossier=g("gDossier").value; var querystring='gDossier='+dossier+'&l='+jrn+"&op=upd_receipt"; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:querystring, onFailure:error_get_pj, onSuccess:success_get_pj } ); } /** *ask the name, quick_code of the bank for the ledger */ function update_bank() { var jrn=g('p_jrn').value; var dossier=g('gDossier').value; var qs='gDossier='+dossier+'&op=bkname&p_jrn='+jrn; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:qs, onFailure:error_get_pj, onSuccess:success_update_bank } ); } /** * Update the number of rows when changing of ledger */ function update_row(ctl) { try { var jrn=g('p_jrn').value; var dossier=g('gDossier').value; var qs='gDossier='+dossier+'&op=minrow&j='+jrn+'&ctl='+ctl; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:qs, onFailure:null, onSuccess:function(request,json) { try { var answer=request.responseText.evalJSON(true); var row=parseFloat(answer.row); var current_row=parseFloat($('nb_item').value); if ( current_row > row ) { // Too many row var delta=$('nb_item').value-row; var idx=$('nb_item').value; for (var i=0;i