60 function get_row($p_from_periode,$p_to_periode,$p_previous_exc=0)
64 $per_sql=
sql_filter_per($this->
db,$p_from_periode,$p_to_periode,
'p_id',
'j_tech_per');
72 if ( !empty($this->
jrn) )
80 $jrn=
" j_jrn_def in (";
84 $jrn.=$comma.$this->jrn[
$e];
93 $from_poste=
" $and j_poste::text >= '".$this->from_poste.
"'";
98 $to_poste=
" $and j_poste::text <= '".$this->to_poste.
"'";
101 $filter_sql=
$g_user->get_ledger_sql(
'ALL',3);
103 switch ($p_previous_exc)
107 $sql=
"select j_poste as poste,
109 sum(cred) as sum_cred,
110 sum(deb_op) as sum_deb_ope ,
111 sum(cred_op) as sum_cred_ope
114 case when j_debit='t' then j_montant else 0 end as deb,
115 case when j_debit='f' then j_montant else 0 end as cred,
116 case when j_debit='t' and jr_optype='OPE' then j_montant else 0 end as deb_op,
117 case when j_debit='f' and jr_optype='OPE' then j_montant else 0 end as cred_op
118 from jrnx join tmp_pcmn on (j_poste=pcm_val)
119 left join parm_periode on (j_tech_per = p_id)
120 join jrn_def on (j_jrn_def=jrn_def_id)
121 join jrn on (j_grpt=jr_grpt_id)
123 $jrn $from_poste $to_poste
126 $per_sql ) as m group by 1 order by 1";
137 $per_sql_previous=
sql_filter_per($this->
db,$previous_start->p_id,$previous_end->p_id,
'p_id',
'j_tech_per');
140 ( select j_poste,sum(deb) as sdeb,sum(cred) as scred,
141 sum(deb_op) as sum_deb_ope ,
142 sum(cred_op) as sum_cred_ope
145 case when j_debit='t' then j_montant else 0 end as deb,
146 case when j_debit='f' then j_montant else 0 end as cred ,
147 case when j_debit='t' and jr_optype='OPE' then j_montant else 0 end as deb_op,
148 case when j_debit='f' and jr_optype='OPE' then j_montant else 0 end as cred_op
150 join jrn on (j_grpt=jr_grpt_id)
151 join tmp_pcmn on (j_poste=pcm_val)
152 left join parm_periode on (j_tech_per = p_id)
153 join jrn_def on (j_jrn_def=jrn_def_id)
155 $jrn $from_poste $to_poste
156 $and $filter_sql and $per_sql
157 ) as sub_m group by j_poste order by j_poste ) ,
158 p as ( select j_poste,sum(deb) as sdeb,
162 case when j_debit='t' then j_montant else 0 end as deb,
163 case when j_debit='f' then j_montant else 0 end as cred
164 from jrnx join tmp_pcmn on (j_poste=pcm_val)
165 left join parm_periode on (j_tech_per = p_id)
166 join jrn_def on (j_jrn_def=jrn_def_id)
167 join jrn on (j_grpt=jr_grpt_id)
169 $jrn $from_poste $to_poste
170 $and $filter_sql and $per_sql_previous) as sub_p group by j_poste order by j_poste)
171 select coalesce(m.j_poste,p.j_poste) as poste
172 ,coalesce(m.sdeb,0) as sum_deb
173 , coalesce(m.scred,0) as sum_cred
174 ,coalesce(p.sdeb,0) as sum_deb_previous
175 , coalesce(p.scred,0) as sum_cred_previous
176 ,coalesce(sum_deb_ope,0) as sum_deb_ope
177 ,coalesce(sum_cred_ope,0) as sum_cred_ope
178 from m full join p on (p.j_poste=m.j_poste)
181 }
catch (Exception $exc) {
186 $sql=
"select j_poste as poste,
188 sum(cred) as sum_cred,
189 sum(deb_op) as sum_deb_ope ,
190 sum(cred_op) as sum_cred_ope
193 case when j_debit='t' then j_montant else 0 end as deb,
194 case when j_debit='f' then j_montant else 0 end as cred,
195 case when j_debit='t' and jr_optype='OPE' then j_montant else 0 end as deb_op,
196 case when j_debit='f' and jr_optype='OPE' then j_montant else 0 end as cred_op
197 from jrnx join tmp_pcmn on (j_poste=pcm_val)
198 left join parm_periode on (j_tech_per = p_id)
199 join jrn_def on (j_jrn_def=jrn_def_id)
200 join jrn on (j_grpt=jr_grpt_id)
202 $jrn $from_poste $to_poste
205 $per_sql ) as m group by poste order by poste";
218 $tot_deb_saldo_ope=0.0;
219 $tot_cred_saldo_ope=0.0;
220 $tot_cred_previous= 0.0;
221 $tot_deb_previous= 0.0;
222 $tot_deb_saldo_previous=0.0;
223 $tot_cred_saldo_previous=0.0;
224 $M=$this->db->size();
229 $r=$this->db->fetch(
$i);
232 $a[
'poste']=
$r[
'poste'];
233 $a[
'label']=mb_substr(
$poste->get_lib(),0,40);
234 $a[
'type']=
$poste->get_parameter(
"pcm_type");
235 $a[
'sum_deb']=round(
$r[
'sum_deb'],2);
236 $a[
'sum_cred']=round(
$r[
'sum_cred'],2);
237 $a[
'solde_deb']=round((
$a[
'sum_deb'] >=
$a[
'sum_cred'] )?
$a[
'sum_deb']-
$a[
'sum_cred']:0,2);
238 $a[
'solde_cred']=round((
$a[
'sum_deb'] <=
$a[
'sum_cred'] )?
$a[
'sum_cred']-
$a[
'sum_deb']:0,2);
240 $a[
'sum_deb_ope']=round(
$r[
'sum_deb_ope'],2);
241 $a[
'sum_cred_ope']=round(
$r[
'sum_cred_ope'],2);
242 $a[
'solde_deb_ope']=round((
$a[
'sum_deb_ope'] >=
$a[
'sum_cred_ope'] )?
$a[
'sum_deb_ope']-
$a[
'sum_cred_ope']:0,2);
243 $a[
'solde_cred_ope']=round((
$a[
'sum_deb_ope'] <=
$a[
'sum_cred_ope'] )?
$a[
'sum_cred_ope']-
$a[
'sum_deb_ope']:0,2);
246 if ($p_previous_exc==1)
248 $a[
'sum_deb_previous']=round(
$r[
'sum_deb_previous'],2);
249 $a[
'sum_cred_previous']=round(
$r[
'sum_cred_previous'],2);
250 $a[
'solde_deb_previous']=round((
$a[
'sum_deb_previous'] >=
$a[
'sum_cred_previous'] )?
$a[
'sum_deb_previous']-
$a[
'sum_cred_previous']:0,2);
251 $a[
'solde_cred_previous']=round((
$a[
'sum_deb_previous'] <=
$a[
'sum_cred_previous'] )?
$a[
'sum_cred_previous']-
$a[
'sum_deb_previous']:0,2);
252 $tot_cred_previous = bcadd ($tot_cred_previous,
$a[
'sum_cred_previous']);
253 $tot_deb_previous = bcadd( $tot_deb_previous,
$a[
'sum_deb_previous']);
254 $tot_deb_saldo_previous = bcadd ($tot_deb_saldo_previous ,
$a[
'solde_deb_previous']);
255 $tot_cred_saldo_previous = bcadd ($tot_cred_saldo_previous,
$a[
'solde_cred_previous']);
257 if ($p_previous_exc==0 && $this->unsold==
true &&
$a[
'solde_cred']==0 &&
$a[
'solde_deb']==0)
continue;
258 if ($p_previous_exc==1 && $this->unsold==
true &&
$a[
'solde_cred']==0 &&
$a[
'solde_deb']==0 &&
$a[
'solde_cred_previous']==0 &&
$a[
'solde_deb_previous']==0)
continue;
263 $tot_deb_saldo= bcadd($tot_deb_saldo,
$a[
'solde_deb']);
264 $tot_cred_saldo= bcadd($tot_cred_saldo,
$a[
'solde_cred']);
266 $tot_cred_ope= bcadd ($tot_cred_ope,
$a[
'sum_cred_ope']);
267 $tot_deb_ope= bcadd($tot_deb_ope,
$a[
'sum_deb_ope']);
268 $tot_deb_saldo_ope= bcadd($tot_deb_saldo_ope,
$a[
'solde_deb_ope']);
269 $tot_cred_saldo_ope= bcadd($tot_cred_saldo_ope,
$a[
'solde_cred_ope']);
279 $a[
'label']=sprintf(_(
"Totaux delta %s %s"),
nbm(abs(
$delta)),$side_delta);
282 $a[
'solde_deb']=$tot_deb_saldo;
283 $a[
'solde_cred']=$tot_cred_saldo;
284 $a[
'sum_deb_ope']=$tot_deb_ope;
285 $a[
'sum_cred_ope']=$tot_cred_ope;
286 $a[
'solde_deb_ope']=$tot_deb_saldo_ope;
287 $a[
'solde_cred_ope']=$tot_cred_saldo_ope;
288 if ($p_previous_exc==1) {
289 $a[
'sum_deb_previous']=$tot_deb_previous;
290 $a[
'sum_cred_previous']=$tot_cred_previous;
291 $a[
'solde_deb_previous']=$tot_deb_saldo_previous;
292 $a[
'solde_cred_previous']=$tot_cred_saldo_previous;
319 $t_a=$this->db->get_array(
'select jrn_def_id from jrn_def where jrn_def_type=$1',array(
$array[
$e][
'cat']));
320 for (
$f=0;
$f < count($t_a);
$f++) $this->
jrn[]=$t_a[
$f][
'jrn_def_id'];
331 $array[
"1_5"]=[
"deb"=>0,
"cred"=>0];
332 $array[
"6"]=[
"deb"=>0,
"cred"=>0];
333 $array[
"7"]=[
"deb"=>0,
"cred"=>0];
349 if (trim($p_accounting)==
"")
return $p_array;
351 $first_digit=trim($p_accounting);
352 $first_digit_trim=$first_digit[0];
353 if ( $first_digit_trim >0 && $first_digit_trim < 6) {
357 elseif ($first_digit_trim ==
"6") {
361 elseif ($first_digit_trim==
"7") {
377 echo
td(_(
"Class 1-5"));
385 echo
td(_(
"Class 6"));
387 echo
td(
nbm(abs($diff6),2),
' class="num"');
388 $side=($diff6 < 0)?
"C":
"D";
393 echo
td(_(
"Class 7"));
395 echo
td(
nbm(abs($diff7),2),
' class="num"');
396 $side=($diff7 < 0)?
"C":
"D";
401 echo
td(_(
"Solde 6/7"));
402 $diff=bcadd($diff6,$diff7);
418 $p_pdf->write_cell(30,6,_(
"Class 1-5"));
420 $p_pdf->write_cell(50,6,
424 $p_pdf->write_cell(10,6,
$side);
427 $p_pdf->write_cell(30,6,_(
"Class 6"));
429 $p_pdf->write_cell(50,6,
nbm(abs($diff6),2),0,0,
'R');
430 $side=($diff6 < 0)?
"C":
"D";
432 $p_pdf->write_cell(10,6,
$side);
435 $p_pdf->write_cell(30,6,_(
"Class 7"));
437 $p_pdf->write_cell(50,6,
nbm(abs($diff7),2),0,0,
'R');
438 $side=($diff7 < 0)?
"C":
"D";
440 $p_pdf->write_cell(10,6,
$side);
443 $p_pdf->write_cell(30,6,_(
"Solde 6/7"));
444 $diff=bcadd($diff6,$diff7);
445 $p_pdf->write_cell(50,6,
nbm(abs(
$diff),2),0,0,
'R');
448 $p_pdf->write_cell(10,6,
$side);
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
findSide($p_number)
return D if the number is smaller than 0 , C if bigger and an empty string if equal to 0.
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$anc_grandlivre from_poste
Manage the account from the table tmp_pcmn.
Class for manipulating data to print the balance of account.
summary_add($p_array, $p_accounting, $p_deb, $p_cred)
Add the current amount (d /c) to the right item in the array, in order to compute a summary (1 to 5 ,...
summary_display_pdf($p_array, $p_pdf)
Display the summary of result in PDF.
filter_cat($p_array)
set the $this->jrn to the cat, filter the ledger thanks the type (key in the array)
summary_init()
create an empty array for computing the summary
summary_display($p_array)
Display the summary of result in HTML.
static array_cat()
create an array of the existing cat, to be used in a checkbox form
For the periode tables parm_periode and jrn_periode.
if( $delta< 0) elseif( $delta==0)