Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

send_poste_pdf.php

Go to the documentation of this file.
00001 <?
00002 
00003 /*
00004  *   This file is part of PhpCompta.
00005  *
00006  *   PhpCompta is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   PhpCompta is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with PhpCompta; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00024 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 // $Revision: 1.11 $
00026 
00027     include_once("jrn.php");
00028     include_once("ac_common.php");
00029     include_once("postgres.php");
00030     include_once("class.ezpdf.php");
00031     include_once("impress_inc.php");
00032 include("poste.php");
00033     echo_debug('send_poste_pdf.php',__LINE__,"imp pdf journaux");
00034     $cn=DbConnect($g_dossier);
00035 foreach ($HTTP_POST_VARS as $key=>$element) {
00036   ${"$key"}=$element;
00037 }
00038 if ( isset ( $all_poste) ){ //choisit de voir tous les postes
00039   $r_poste=ExecSql($cn,"select pcm_val from tmp_pcmn where pcm_val = any ".
00040                    " (select j_poste from jrnx) order by pcm_val::text");
00041   $nPoste=pg_numRows($r_poste);
00042   for ( $i=0;$i<$nPoste;$i++) {
00043     $t_poste=pg_fetch_array($r_poste,$i);
00044     $poste[]=$t_poste['pcm_val'];
00045   } 
00046 }      
00047 
00048 
00049     $ret="";
00050     $pdf=& new Cezpdf();
00051     $pdf->selectFont('./addon/fonts/Helvetica.afm');
00052 $cond=CreatePeriodeCond($periode);
00053 //$rap_deb=0;$rap_cred=0;
00054 for ( $i =0;$i<count($poste);$i++) {
00055   
00056     list($array,$tot_deb,$tot_cred)=GetDataPoste($cn,$poste[$i],$cond);
00057     // don't print empty account
00058     if ( count($array) == 0 ) {
00059     continue;
00060     }
00061     $Libelle=sprintf("(%s) %s ",$poste[$i],GetPosteLibelle($cn,$poste[$i],1));
00062     
00063     //  $pdf->ezText($Libelle,30);
00064     $pdf->ezTable($array,
00065                   array ('jr_internal'=>'Opération',
00066                        'j_date' => 'Date',
00067                        'jrn_name'=>'Journal',
00068                          'description'=>'Description',
00069                        'deb_montant'=> 'Montant',
00070                        'cred_montant'=> 'Montant'
00071                        ),$Libelle,
00072                 array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00073                       'cols'=>array('montant'=> array('justification'=>'right'),
00074                                     )));
00075 $str_debit=sprintf("Débit  % 12.2f",$tot_deb);
00076 $str_cred=sprintf("Crédit % 12.2f",$tot_cred);
00077 $diff_solde=$tot_deb-$tot_cred;
00078 if ( $diff_solde < 0 ) {
00079         $solde=" C ";
00080         $diff_solde*=-1;
00081         } else 
00082         {
00083         $solde=" D ";
00084         }
00085 $str_solde=sprintf(" Solde %s %12.2f",$solde,$diff_solde);
00086 
00087  $pdf->ezText($str_debit,10,array('justification'=>'right'));
00088  $pdf->ezText($str_cred,10,array('justification'=>'right'));
00089  $pdf->ezText($str_solde,14,array('justification'=>'right'));
00090 
00091   //New page
00092   //$pdf->ezNewPage();
00093 }    
00094 
00095 $pdf->ezStream();
00096 
00097 ?>