/* * This file is part of PhpCompta. * * PhpCompta 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. * * PhpCompta 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 PhpCompta; 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 ddebontridder@yahoo.fr /*!\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) { 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"; g("p_jrn_predef").value=jrn; var action=new Ajax.Request( "ajax_misc.php", { method:'get', parameters:querystring, onFailure:error_get_predef, onSuccess:success_get_predef } ); } /** * @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() { $('jrn_name').innerHTML=$('p_jrn').options[$('p_jrn').selectedIndex].innerHTML; } /** * @brief update the field predef */ function success_get_predef(request,json) { var i=0; var answer=request.responseText.evalJSON(true); obj=g("pre_def"); obj.innerHTML=''; if ( answer.count == 0 ) return; for ( i = 0 ; i < answer.count;i++) { value=answer['value'+i]; label=answer['label'+i]; obj.options[obj.options.length]=new Option(label,value); } } /** * @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 } ); } /** *ask the name, quick_code of the bank for the 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