phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r5379 - phpcompta/trunk/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5379 - phpcompta/trunk/include
Date: Thu, 5 Sep 2013 22:35:06 +0200 (CEST)

Author: danydb
Date: 2013-09-05 22:35:06 +0200 (Thu, 05 Sep 2013)
New Revision: 5379

Modified:
   phpcompta/trunk/include/balance.inc.php
   phpcompta/trunk/include/class_acc_balance.php
   phpcompta/trunk/include/export_balance_csv.php
   phpcompta/trunk/include/export_balance_pdf.php
Log:
Allow balance on 2 years : the choosen one and the previous one

Modified: phpcompta/trunk/include/balance.inc.php
===================================================================
--- phpcompta/trunk/include/balance.inc.php     2013-09-05 20:34:31 UTC (rev 
5378)
+++ phpcompta/trunk/include/balance.inc.php     2013-09-05 20:35:06 UTC (rev 
5379)
@@ -132,7 +132,12 @@
 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";
 $from_poste->set_attribute('ipopup','ipop_account');
@@ -158,7 +163,12 @@
 echo $to_span->input();
 echo "</div>";
 echo '<div>';
+echo '<p>';
 echo "Uniquement comptes non soldés ".$unsold->input();
+echo '</p>';
+echo '<p>';
+echo "Avec la balance de l'année précédente".$previous_exc->input();
+echo '</p>';
 echo '</div>';
 echo HtmlInput::submit("view","Visualisation");
 echo '</form>';
@@ -193,7 +203,7 @@
 
     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 "</form></TD>";
 
@@ -214,7 +224,7 @@
 
     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 "</form></TD>";
        echo '<td style="vertical-align:top">';
@@ -248,10 +258,14 @@
     }
     $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 @@
     echo '<table id="t_balance" width="100%">';
     echo '<th>Poste Comptable</th>';
     echo '<th>Libell&eacute;</th>';
+    if ( $previous == 1 ){
+        echo '<th>D&eacute;bit N-1</th>';
+        echo '<th>Cr&eacute;dit N-1</th>';
+        echo '<th>Solde D&eacute;biteur N-1</th>';
+        echo '<th>Solde Cr&eacute;diteur N-1</th>';
+    }
     echo '<th>D&eacute;bit</th>';
     echo '<th>Cr&eacute;dit</th>';
     echo '<th>Solde D&eacute;biteur </th>';
     echo '<th>Solde Cr&eacute;diteur</th>';
-
     $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 @@
                echo '<tr style="font-size:12px;font-height:bold">';
                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 @@
                  }
              }
          }
-         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 @@
         echo '<TR class="'.$tr.'">';
         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"');

Modified: phpcompta/trunk/include/class_acc_balance.php
===================================================================
--- phpcompta/trunk/include/class_acc_balance.php       2013-09-05 20:34:31 UTC 
(rev 5378)
+++ phpcompta/trunk/include/class_acc_balance.php       2013-09-05 20:35:06 UTC 
(rev 5379)
@@ -48,6 +48,7 @@
      * \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 @@
      *         - $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 @@
             $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 @@
         $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 @@
         }
 
     }
+    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);
+    }
 }

Modified: phpcompta/trunk/include/export_balance_csv.php
===================================================================
--- phpcompta/trunk/include/export_balance_csv.php      2013-09-05 20:34:31 UTC 
(rev 5378)
+++ phpcompta/trunk/include/export_balance_csv.php      2013-09-05 20:35:06 UTC 
(rev 5379)
@@ -35,8 +35,7 @@
 
 
 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 @@
 $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']);

Modified: phpcompta/trunk/include/export_balance_pdf.php
===================================================================
--- phpcompta/trunk/include/export_balance_pdf.php      2013-09-05 20:34:31 UTC 
(rev 5378)
+++ phpcompta/trunk/include/export_balance_pdf.php      2013-09-05 20:35:06 UTC 
(rev 5379)
@@ -73,9 +73,13 @@
 $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);
 
-$array=$bal->get_row($from_periode,$to_periode);
+$previous= (isset ($array[0]['sum_cred_previous']))?1:0;
 
+
 if ( sizeof($array)  == 0 )
 {
     exit();
@@ -86,7 +90,11 @@
 $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->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_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 ( ${'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 @@
            $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 @@
          {
            $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 @@
 
     // 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 */
 



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]