From f1ffe5cb97e13f8895f2a94dd64ba691dea4effb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 5 Sep 2013 20:35:06 +0000 Subject: [PATCH] Allow balance on 2 years : the choosen one and the previous one --- include/balance.inc.php | 54 +++++++++++-- include/class_acc_balance.php | 138 ++++++++++++++++++++++++++++----- include/export_balance_csv.php | 23 ++++-- include/export_balance_pdf.php | 118 ++++++++++++++++++++-------- 4 files changed, 268 insertions(+), 65 deletions(-) diff --git a/include/balance.inc.php b/include/balance.inc.php index dc799afb4..c0366473a 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -132,6 +132,11 @@ $unsold=new ICheckBox('unsold'); if (HtmlInput::default_value('unsold',false,$_GET) !== false) $unsold->selected=true; +// previous exercice if checked +$previous_exc=new ICheckBox('previous_exc'); +if (HtmlInput::default_value('previous_exc',false,$_GET) !== false) + $previous_exc->selected=true; + $from_poste=new IPoste(); $from_poste->name="from_poste"; @@ -158,7 +163,12 @@ echo " jusque :".$to_poste->input(); echo $to_span->input(); echo ""; echo '
'; +echo '

'; echo "Uniquement comptes non soldés ".$unsold->input(); +echo '

'; +echo '

'; +echo "Avec la balance de l'année précédente".$previous_exc->input(); +echo '

'; echo '
'; echo HtmlInput::submit("view","Visualisation"); echo ''; @@ -193,7 +203,7 @@ if ( isset ($_GET['view'] ) ) echo HtmlInput::hidden("from_poste",$_GET['from_poste']). HtmlInput::hidden("to_poste",$_GET['to_poste']); - echo HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3','unsold')); + echo HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3','unsold','previous_exc')); echo ""; @@ -214,7 +224,7 @@ if ( isset ($_GET['view'] ) ) echo HtmlInput::hidden("from_poste",$_GET['from_poste']). HtmlInput::hidden("to_poste",$_GET['to_poste']); - echo HtmlInput::get_to_hidden(array('unsold')); + echo HtmlInput::get_to_hidden(array('unsold','previous_exc')); echo ""; echo ''; @@ -248,10 +258,14 @@ if ( isset($_GET['view'] ) ) } $bal->from_poste=$_GET['from_poste']; $bal->to_poste=$_GET['to_poste']; - if ( isset($_GET['unsold'])) - $bal->unsold=true; + if ( isset($_GET['unsold'])) $bal->unsold=true; + $previous=(isset($_GET['previous_exc']))?1:0; + $row=$bal->get_row($_GET['from_periode'], - $_GET['to_periode']); + $_GET['to_periode'], + $previous); + $previous= (isset ($row[0]['sum_cred_previous']))?1:0; + $periode=new Periode($cn); $a=$periode->get_date_limit($_GET['from_periode']); $b=$periode->get_date_limit($_GET['to_periode']); @@ -263,13 +277,24 @@ if ( isset($_GET['view'] ) ) echo ''; echo ''; echo ''; + if ( $previous == 1 ){ + echo ''; + echo ''; + echo ''; + echo ''; + } echo ''; echo ''; echo ''; echo ''; - $i=0; - foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + if ( $previous == 1) { + $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_previous','sum_deb_previous','solde_deb_previous','solde_cred_previous'); + } + else { + $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred') ; + } + foreach($a_sum as $a) { $lvl1[$a]=0; $lvl2[$a]=0; @@ -303,6 +328,12 @@ if ( isset($_GET['view'] ) ) echo ''; echo td("Total niveau ".$ind); echo td(${'lvl'.$ind.'_old'}); + if ($previous==1) { + echo td(nbm(${'lvl'.$ind}['sum_deb_previous']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['sum_cred_previous']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['solde_deb_previous']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['solde_cred_previous']),'style="text-align:right"'); + } echo td(nbm(${'lvl'.$ind}['sum_deb']),'style="text-align:right"'); echo td(nbm(${'lvl'.$ind}['sum_cred']),'style="text-align:right"'); echo td(nbm(${'lvl'.$ind}['solde_deb']),'style="text-align:right"'); @@ -316,7 +347,8 @@ if ( isset($_GET['view'] ) ) } } } - foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + + foreach($a_sum as $a) { $lvl1[$a]=bcadd($lvl1[$a],$r[$a]); $lvl2[$a]=bcadd($lvl2[$a],$r[$a]); @@ -325,6 +357,12 @@ if ( isset($_GET['view'] ) ) echo ''; echo td($view_history); echo td(h($r['label'])); + if ($previous == 1 ) { + echo td(nbm($r['sum_deb_previous']),'style="text-align:right"'); + echo td(nbm($r['sum_cred_previous']),'style="text-align:right"'); + echo td(nbm($r['solde_deb_previous']),'style="text-align:right"'); + echo td(nbm($r['solde_cred_previous']),'style="text-align:right"'); + } echo td(nbm($r['sum_deb']),'style="text-align:right"'); echo td(nbm($r['sum_cred']),'style="text-align:right"'); echo td(nbm($r['solde_deb']),'style="text-align:right"'); diff --git a/include/class_acc_balance.php b/include/class_acc_balance.php index ae4d59bf1..4cd00fe48 100644 --- a/include/class_acc_balance.php +++ b/include/class_acc_balance.php @@ -48,6 +48,7 @@ class Acc_Balance * \brief retrieve all the row from the ledger in the range of a periode * \param $p_from_periode start periode (p_id) * \param $p_to_periode end periode (p_id) + * \param $p_previous_exc previous exercice 1= yes default =0 * * \return a double array * array of @@ -58,7 +59,7 @@ class Acc_Balance * - $a['solde_deb'] * - $a['solde_cred'] */ - function get_row($p_from_periode,$p_to_periode) + function get_row($p_from_periode,$p_to_periode,$p_previous_exc=0) { global $g_user; // filter on requested periode @@ -100,42 +101,125 @@ class Acc_Balance $and=" and "; } $filter_sql=$g_user->get_ledger_sql('ALL',3); - - // build query - $sql="select j_poste,sum(deb) as sum_deb, sum(cred) as sum_cred from - ( select j_poste, - case when j_debit='t' then j_montant else 0 end as deb, - case when j_debit='f' then j_montant else 0 end as cred - from jrnx join tmp_pcmn on (j_poste=pcm_val) - left join parm_periode on (j_tech_per = p_id) - join jrn_def on (j_jrn_def=jrn_def_id) - where - $jrn $from_poste $to_poste - $and $filter_sql - and - $per_sql ) as m group by j_poste order by j_poste::text"; + + switch ($p_previous_exc) + { + case 0: + // build query + $sql="select j_poste as poste,sum(deb) as sum_deb, sum(cred) as sum_cred from + ( select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx join tmp_pcmn on (j_poste=pcm_val) + left join parm_periode on (j_tech_per = p_id) + join jrn_def on (j_jrn_def=jrn_def_id) + where + $jrn $from_poste $to_poste + $and $filter_sql + and + $per_sql ) as m group by 1 order by 1"; + break; + case 1: + /* + * retrieve balance previous exercice + */ + $periode=new Periode($this->db); + $previous_exc=$periode->get_exercice($p_from_periode)-1; + try { + list($previous_start,$previous_end)=$periode->get_limit($previous_exc); + + $per_sql_previous=sql_filter_per($this->db,$previous_start->p_id,$previous_end->p_id,'p_id','j_tech_per'); + $sql=" + with m as + ( select j_poste,sum(deb) as sdeb,sum(cred) as scred + from + (select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx + join tmp_pcmn on (j_poste=pcm_val) + left join parm_periode on (j_tech_per = p_id) + join jrn_def on (j_jrn_def=jrn_def_id) + where + $jrn $from_poste $to_poste + $and $filter_sql and $per_sql + ) as sub_m group by j_poste order by j_poste ) , + p as ( select j_poste,sum(deb) as sdeb,sum(cred) as scred + from + (select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx join tmp_pcmn on (j_poste=pcm_val) + left join parm_periode on (j_tech_per = p_id) + join jrn_def on (j_jrn_def=jrn_def_id) + where + $jrn $from_poste $to_poste + $and $filter_sql and $per_sql_previous) as sub_p group by j_poste order by j_poste) + select coalesce(m.j_poste,p.j_poste) as poste + ,coalesce(m.sdeb,0) as sum_deb + , coalesce(m.scred,0) as sum_cred + ,coalesce(p.sdeb,0) as sum_deb_previous + , coalesce(p.scred,0) as sum_cred_previous from m join p on (p.j_poste=m.j_poste) + order by poste"; + + } catch (Exception $exc) { + $p_previous_exc=0; + /* + * no previous exercice + */ + $sql="select upper(j_poste::text) as poste,sum(deb) as sum_deb, sum(cred) as sum_cred from + ( select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx join tmp_pcmn on (j_poste=pcm_val) + left join parm_periode on (j_tech_per = p_id) + join jrn_def on (j_jrn_def=jrn_def_id) + where + $jrn $from_poste $to_poste + $and $filter_sql + and + $per_sql ) as m group by poste order by poste"; + } + break; + + } $cn=clone $this->db; $Res=$this->db->exec_sql($sql); - $tot_cred= 0.0; $tot_deb= 0.0; $tot_deb_saldo=0.0; $tot_cred_saldo=0.0; + $tot_cred_previous= 0.0; + $tot_deb_previous= 0.0; + $tot_deb_saldo_previous=0.0; + $tot_cred_saldo_previous=0.0; $M=$this->db->size(); // Load the array for ($i=0; $i <$M;$i++) { $r=$this->db->fetch($i); - $poste=new Acc_Account($cn,$r['j_poste']); + $poste=new Acc_Account($cn,$r['poste']); - $a['poste']=$r['j_poste']; + $a['poste']=$r['poste']; $a['label']=mb_substr($poste->get_lib(),0,40); $a['sum_deb']=round($r['sum_deb'],2); $a['sum_cred']=round($r['sum_cred'],2); $a['solde_deb']=round(( $a['sum_deb'] >= $a['sum_cred'] )? $a['sum_deb']- $a['sum_cred']:0,2); $a['solde_cred']=round(( $a['sum_deb'] <= $a['sum_cred'] )?$a['sum_cred']-$a['sum_deb']:0,2); - if ($this->unsold==true && $a['solde_cred']==0 && $a['solde_deb']==0) continue; + if ($p_previous_exc==1) + { + $a['sum_deb_previous']=round($r['sum_deb_previous'],2); + $a['sum_cred_previous']=round($r['sum_cred_previous'],2); + $a['solde_deb_previous']=round(( $a['sum_deb_previous'] >= $a['sum_cred_previous'] )? $a['sum_deb_previous']- $a['sum_cred_previous']:0,2); + $a['solde_cred_previous']=round(( $a['sum_deb_previous'] <= $a['sum_cred_previous'] )?$a['sum_cred_previous']-$a['sum_deb_previous']:0,2); + $tot_cred_previous+= $a['sum_cred_previous']; + $tot_deb_previous+= $a['sum_deb_previous']; + $tot_deb_saldo_previous+= $a['solde_deb_previous']; + $tot_cred_saldo_previous+= $a['solde_cred_previous']; + } + if ($p_previous_exc==0 && $this->unsold==true && $a['solde_cred']==0 && $a['solde_deb']==0) continue; + 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; $array[$i]=$a; $tot_cred+= $a['sum_cred']; $tot_deb+= $a['sum_deb']; @@ -152,6 +236,12 @@ class Acc_Balance $a['sum_cred']=$tot_cred; $a['solde_deb']=$tot_deb_saldo; $a['solde_cred']=$tot_cred_saldo; + if ($p_previous_exc==1) { + $a['sum_deb_previous']=$tot_deb_previous; + $a['sum_cred_previous']=$tot_cred_previous; + $a['solde_deb_previous']=$tot_deb_saldo_previous; + $a['solde_cred_previous']=$tot_cred_saldo_previous; + } $array[$i]=$a; $this->row=$array; return $array; @@ -181,4 +271,14 @@ class Acc_Balance } } + static function test_me () + { + require 'class_user.php'; + global $g_user; + $cn=new Database(dossier::id()); + $g_user=new User($cn); + $a=new Acc_Balance($cn); + $a->get_row(163, 175, 1); + var_dump($a); + } } diff --git a/include/export_balance_csv.php b/include/export_balance_csv.php index bd6e9d910..fe6c87254 100644 --- a/include/export_balance_csv.php +++ b/include/export_balance_csv.php @@ -35,8 +35,7 @@ $cn=new Database($gDossier); require_once ('class_user.php'); -echo 'poste;libelle;deb;cred;solde deb;solde cred'; -printf("\n"); + $bal=new Acc_Balance($cn); $bal->jrn=null; switch( $_GET['p_filter']) @@ -64,14 +63,28 @@ case 2: $bal->from_poste=$_GET['from_poste']; $bal->to_poste=$_GET['to_poste']; if (isset($_GET['unsold'])) $bal->unsold=true; +$prev = (isset($_GET['previous_exc'])) ? 1: 0; $row=$bal->get_row($_GET['from_periode'], - $_GET['to_periode']); + $_GET['to_periode'], + $prev); +$prev = ( isset ($row[0]['sum_cred_previous'])) ?1:0; +echo 'poste;libelle;'; +if ($prev == 1 ) echo 'deb n-1;cred n-1;solde deb n-1;solde cred n-1;'; +echo 'deb;cred;solde deb;solde cred'; +printf("\n"); foreach ($row as $r) { echo $r['poste'].';'. - $r['label'].';'. - nb($r['sum_deb']).';'. + $r['label'].';'; + if ( $prev == 1 ) + { + echo nb($r['sum_deb_previous']).';'. + nb($r['sum_cred_previous']).';'. + nb($r['solde_deb_previous']).';'. + nb($r['solde_cred_previous']).';'; + } + echo nb($r['sum_deb']).';'. nb($r['sum_cred']).';'. nb($r['solde_deb']).';'. nb($r['solde_cred']); diff --git a/include/export_balance_pdf.php b/include/export_balance_pdf.php index 972141e71..056ff3657 100644 --- a/include/export_balance_pdf.php +++ b/include/export_balance_pdf.php @@ -73,8 +73,12 @@ case 2: $bal->from_poste=$_GET['from_poste']; $bal->to_poste=$_GET['to_poste']; if (isset($_GET['unsold'])) $bal->unsold=true; +$previous=(isset($_GET['previous_exc']))?1:0; + +$array=$bal->get_row($from_periode,$to_periode,$previous); + +$previous= (isset ($array[0]['sum_cred_previous']))?1:0; -$array=$bal->get_row($from_periode,$to_periode); if ( sizeof($array) == 0 ) { @@ -86,7 +90,11 @@ $pPeriode=new Periode($cn); $a=$pPeriode->get_date_limit($from_periode); $b=$pPeriode->get_date_limit($to_periode); $per_text=" du ".$a['p_start']." au ".$b['p_end']; -$pdf= new PDF($cn); +if ($previous == 1 ) { + $pdf=new PDFLand($cn); +} else { + $pdf= new PDF($cn); +} $pdf->setDossierInfo(" Balance ".$per_text); $pdf->AliasNbPages(); $pdf->AddPage(); @@ -94,11 +102,17 @@ $pdf->SetAuthor('Phpcompta'); $pdf->SetFont('DejaVuCond','',7); $pdf->setTitle("Balance comptable",true); $pdf->Cell(30,6,'poste'); -$pdf->Cell(80,6,'Libellé'); -$pdf->Cell(20,6,'Total Débit',0,0,'R'); -$pdf->Cell(20,6,'Total Crédit',0,0,'R'); -$pdf->Cell(20,6,'Solde Débiteur',0,0,'R'); -$pdf->Cell(20,6,'Solde Créditeur',0,0,'R'); +$pdf->LongLine(60,6,'Libellé'); +if ($previous == 1 ){ + $pdf->Cell(20,6,'Débit N-1',0,0,'R'); + $pdf->Cell(20,6,'Crédit N-1',0,0,'R'); + $pdf->Cell(20,6,'Débiteur N-1',0,0,'R'); + $pdf->Cell(20,6,'Créditeur N-1',0,0,'R'); +} +$pdf->Cell(25,6,'Total Débit',0,0,'R'); +$pdf->Cell(25,6,'Total Crédit',0,0,'R'); +$pdf->Cell(25,6,'Solde Débiteur',0,0,'R'); +$pdf->Cell(25,6,'Solde Créditeur',0,0,'R'); $pdf->Ln(); $pdf->SetFont('DejaVuCond','',8); @@ -106,7 +120,17 @@ $tp_deb=0; $tp_cred=0; $tp_sold=0; $tp_solc=0; -foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) +$tp_deb_previous=0; +$tp_cred_previous=0; +$tp_sold_previous=0; +$tp_solc_previous=0; +if ( $previous == 1) { + $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_previous','sum_deb_previous','solde_deb_previous','solde_cred_previous'); +} +else { + $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred') ; +} +foreach($a_sum as $a) { $nlvl1[$a]=0; $nlvl2[$a]=0; @@ -136,22 +160,28 @@ if (! empty($array)) if ( ${'lvl'.$ind.'_old'} != substr($r['poste'],0,$ind)) { $pdf->SetFont('DejaVu','B',7); - $pdf->Cell(30,6,"Totaux ".$ind); - $pdf->Cell(80,6,${'lvl'.$ind.'_old'}); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_deb']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_cred']),0,0,'R'); + $pdf->LongLine(30,6,"Totaux ".$ind); + $pdf->LongLine(60,6,${'lvl'.$ind.'_old'}); + if ($previous == 1 ) { + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['sum_deb_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['sum_cred_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['solde_deb_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['solde_cred_previous']),0,0,'R'); + } + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['solde_deb']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['solde_cred']),0,0,'R'); $pdf->Ln(); $pdf->SetFont('DejaVuCond','',7); ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + foreach($a_sum as $a) { ${'nlvl'.$ind}[$a]=0; } } } - foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + foreach($a_sum as $a) { $nlvl1[$a]=bcadd($nlvl1[$a],$r[$a]); $nlvl2[$a]=bcadd($nlvl2[$a],$r[$a]); @@ -169,12 +199,22 @@ if (! empty($array)) $fill=0; } - $pdf->Cell(30,6,$value['poste'],0,0,'L',$fill); - $pdf->Cell(80,6,$value['label'],0,0,'L',$fill); - $pdf->Cell(20,6,nbm($value['sum_deb']),0,0,'R',$fill); - $pdf->Cell(20,6,nbm($value['sum_cred']),0,0,'R',$fill); - $pdf->Cell(20,6,nbm($value['solde_deb']),0,0,'R',$fill); - $pdf->Cell(20,6,nbm($value['solde_cred']),0,0,'R',$fill); + $pdf->LongLine(30,6,$value['poste'],0,'L',$fill); + $pdf->LongLine(60,6,$value['label'],0,'L',$fill); + if ($previous == 1 ) { + $pdf->Cell(22,6,nbm($value['sum_deb_previous']),0,0,'R',$fill); + $pdf->Cell(22,6,nbm($value['sum_cred_previous']),0,0,'R',$fill); + $pdf->Cell(22,6,nbm($value['solde_deb_previous']),0,0,'R',$fill); + $pdf->Cell(22,6,nbm($value['solde_cred_previous']),0,0,'R',$fill); + $tp_deb_previous=bcadd($tp_deb_previous,$value['sum_deb_previous']); + $tp_cred_previous=bcadd($tp_cred_previous,$value['sum_cred_previous']); + $tp_sold_previous=bcadd($tp_sold_previous,$value['solde_deb_previous']); + $tp_solc_previous=bcadd($tp_solc_previous,$value['solde_cred_previous']); + } + $pdf->Cell(25,6,nbm($value['sum_deb']),0,0,'R',$fill); + $pdf->Cell(25,6,nbm($value['sum_cred']),0,0,'R',$fill); + $pdf->Cell(25,6,nbm($value['solde_deb']),0,0,'R',$fill); + $pdf->Cell(25,6,nbm($value['solde_cred']),0,0,'R',$fill); $pdf->Ln(); $tp_deb=bcadd($tp_deb,$value['sum_deb']); $tp_cred=bcadd($tp_cred,$value['sum_cred']); @@ -192,15 +232,21 @@ if (! empty($array)) { $pdf->SetFont('DejaVu','B',7); $pdf->Cell(30,6,"Totaux ".$ind); - $pdf->Cell(80,6,${'lvl'.$ind.'_old'}); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_deb']),0,0,'R'); - $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_cred']),0,0,'R'); + $pdf->Cell(60,6,${'lvl'.$ind.'_old'}); + if ($previous == 1 ) { + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['sum_deb_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['sum_cred_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['solde_deb_previous']),0,0,'R'); + $pdf->Cell(22,6,nbm(${'nlvl'.$ind}['solde_cred_previous']),0,0,'R'); + } + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['solde_deb']),0,0,'R'); + $pdf->Cell(25,6,nbm(${'nlvl'.$ind}['solde_cred']),0,0,'R'); $pdf->Ln(); $pdf->SetFont('DejaVuCond','',7); ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + foreach($a_sum as $a) { ${'nlvl'.$ind}[$a]=0; } @@ -209,11 +255,17 @@ if (! empty($array)) // Totaux $pdf->SetFont('DejaVuCond','B',8); - $pdf->Cell(110,6,'Totaux'); - $pdf->Cell(20,6,nbm($tp_deb),'T',0,'R',0); - $pdf->Cell(20,6,nbm($tp_cred),'T',0,'R',0); - $pdf->Cell(20,6,nbm($tp_sold),'T',0,'R',0); - $pdf->Cell(20,6,nbm($tp_solc),'T',0,'R',0); + $pdf->Cell(90,6,'Totaux'); + if ($previous == 1 ) { + $pdf->Cell(22,6,nbm($tp_deb_previous),'T',0,'R',0); + $pdf->Cell(22,6,nbm($tp_cred_previous),'T',0,'R',0); + $pdf->Cell(22,6,nbm($tp_sold_previous),'T',0,'R',0); + $pdf->Cell(22,6,nbm($tp_solc_previous),'T',0,'R',0); + } + $pdf->Cell(25,6,nbm($tp_deb),'T',0,'R',0); + $pdf->Cell(25,6,nbm($tp_cred),'T',0,'R',0); + $pdf->Cell(25,6,nbm($tp_sold),'T',0,'R',0); + $pdf->Cell(25,6,nbm($tp_solc),'T',0,'R',0); $pdf->Ln(); } /** empty */
Poste ComptableLibelléDébit N-1Crédit N-1Solde Débiteur N-1Solde Créditeur N-1DébitCréditSolde Débiteur Solde Créditeur