noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ajax_bank_saldo.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/*!
24 * \file
25 * \brief respond ajax request, the get contains
26 * the value :
27 * - l for ledger
28 * - gDossier
29 * Must return at least tva, htva and tvac
30
31 */
32
33/*!
34 * \file
35 * \brief get the saldo of a account
36 * the get variable are :
37 * - l the jrn id
38 * - ctl the ctl where to get the quick_code
39 */
40if (!defined('ALLOWED'))
41 die('Appel direct ne sont pas permis');
42/* check the parameters */
43foreach (array('j', 'ctl') as $a)
44{
45 if (!isset(${$a}))
46 {
47 echo "missing $a";
48 return;
49 }
50}
52try
53{
54 $ledger_id=$http->get('j', "number");
55
56 if ($g_user->check_jrn($ledger_id)=='X')
57 return '{"saldo":"0"}';
58
59 $id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($ledger_id));
60 if ($id=='')
61 {
62 echo '{"saldo":"ERR"}';
63 return;
64 }
65
66 $acc=new Fiche($cn, $id);
67
69 $ledger->load();
70 // Is ledger in Default currency
71 if ($ledger->currency_id==0)
72 {
73 /* make a filter on the exercice */
74
75 $filter_year=" j_tech_per in (select p_id from parm_periode ".
76 "where p_exercice='".$g_user->get_exercice()."')";
77
78
79
80
81
82 $res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)");
83
84
85 if (empty($res))
86 return '{"saldo":"0"}';
87 $solde=$res['solde'];
88 if ($res['debit']<$res['credit'])
89 $solde=$solde*(-1);
90
91 echo '{"saldo":"'.$solde.'"}';
92 } else
93 {
94 $solde=$acc->get_bk_balance_currency();
95 echo '{"saldo":"'.$solde.'"}';
96 }
97}
98catch (Exception $e)
99{
100 record_log(__FILE__.":".__LINE__);
101 record_log($e->getMessage());
102 echo '{"saldo":"ERR"}';
103}
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
global $g_user
if no group available , then stop
if(isNumber($jr_id)==0) $ledger_id
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
manage the http input (get , post, request) and extract from an array