noalyss Version-9
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/* !\file
24 * \brief respond ajax request, the get contains
25 * the value :
26 * - l for ledger
27 * - gDossier
28 * Must return at least tva, htva and tvac
29
30 */
31
32/* !\file
33 * \brief get the saldo of a account
34 * the get variable are :
35 * - l the jrn id
36 * - ctl the ctl where to get the quick_code
37 */
38if (!defined('ALLOWED'))
39 die('Appel direct ne sont pas permis');
40/* check the parameters */
41foreach (array('j', 'ctl') as $a)
42{
43 if (!isset(${$a}))
44 {
45 echo "missing $a";
46 return;
47 }
48}
50try
51{
52 $ledger_id=$http->get('j', "number");
53
54 if ($g_user->check_jrn($ledger_id)=='X')
55 return '{"saldo":"0"}';
56
57 $id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($ledger_id));
58 if ($id=='')
59 {
60 echo '{"saldo":"ERR"}';
61 return;
62 }
63
64 $acc=new Fiche($cn, $id);
65
67 $ledger->load();
68 // Is ledger in Default currency
69 if ($ledger->currency_id==0)
70 {
71 /* make a filter on the exercice */
72
73 $filter_year=" j_tech_per in (select p_id from parm_periode ".
74 "where p_exercice='".$g_user->get_exercice()."')";
75
76
77
78
79
80 $res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)");
81
82
83 if (empty($res))
84 return '{"saldo":"0"}';
85 $solde=$res['solde'];
86 if ($res['debit']<$res['credit'])
87 $solde=$solde*(-1);
88
89 echo '{"saldo":"'.$solde.'"}';
90 } else
91 {
92 $solde=$acc->get_bk_balance_currency();
93 echo '{"saldo":"'.$solde.'"}';
94 }
95}
96catch (Exception $e)
97{
98 record_log(__FILE__.":".__LINE__);
99 record_log($e->getMessage());
100 echo '{"saldo":"ERR"}';
101}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
global $g_user
if no group available , then stop
foreach(array('j', 'ctl') as $a) $http
$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...
Definition: fiche.class.php:38
manage the http input (get , post, request) and extract from an array