noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
ajax_bank_saldo.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief respond ajax request, the get contains
00024  *  the value :
00025  * - l for ledger
00026  * - gDossier
00027  * Must return at least tva, htva and tvac
00028 
00029  */
00030 
00031 /*!\file
00032  * \brief get the saldo of a account
00033  * the get variable are :
00034  *  - l the jrn id
00035  *  - ctl the ctl where to get the quick_code
00036  */
00037 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00038 require_once('class_user.php');
00039 require_once('class_dossier.php');
00040 require_once('class_fiche.php');
00041 extract($_GET);
00042 /* check the parameters */
00043 foreach ( array('j','ctl') as $a )
00044 {
00045     if ( ! isset(${$a}) )
00046     {
00047         echo "missing $a";
00048         return;
00049     }
00050 }
00051 
00052 if ( $g_user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}';
00053 /*  make a filter on the exercice */
00054 
00055 $filter_year="  j_tech_per in (select p_id from parm_periode ".
00056              "where p_exercice='".$g_user->get_exercice()."')";
00057 
00058 
00059 $id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1',array($_GET['j']));
00060 $acc=new Fiche($cn,$id);
00061 
00062 $res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)" );
00063 
00064 
00065 if ( empty($res) ) return '{"saldo":"0"}';
00066 $solde=$res['solde'];
00067 if ( $res['debit'] < $res['credit'] ) $solde=$solde*(-1);
00068 
00069 //header("Content-type: text/html; charset: utf8",true);
00070 echo '{"saldo":"'.$solde.'"}';
00071 
00072 
00073 
00074 ?>
00075 
 All Data Structures Namespaces Files Functions Variables Enumerations