84 |
} |
} |
85 |
return $this->name; |
return $this->name; |
86 |
} |
} |
87 |
|
/* function GetSolde |
88 |
|
* Purpose : give the balance of an account |
89 |
|
* |
90 |
|
* parm : |
91 |
|
* - cond |
92 |
|
* gen : |
93 |
|
* - none |
94 |
|
* return: |
95 |
|
* - balance of the account |
96 |
|
* |
97 |
|
*/ |
98 |
|
function GetSolde($p_cond="") { |
99 |
|
$Res=ExecSql($this->db,"select sum(deb) as sum_deb, sum(cred) as sum_cred from |
100 |
|
( select j_poste, |
101 |
|
case when j_debit='t' then j_montant else 0 end as deb, |
102 |
|
case when j_debit='f' then j_montant else 0 end as cred |
103 |
|
from jrnx join tmp_pcmn on j_poste=pcm_val |
104 |
|
where |
105 |
|
j_poste like ('$this->id'::text) and |
106 |
|
$p_cond |
107 |
|
) as m "); |
108 |
|
$Max=pg_NumRows($Res); |
109 |
|
if ($Max==0) return 0; |
110 |
|
$r=pg_fetch_array($Res,0); |
111 |
|
|
112 |
|
return abs($r['sum_deb']-$r['sum_cred']); |
113 |
|
} |
114 |
|
|
115 |
} |
} |