00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024
00025
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) ){
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
00054 for ( $i =0;$i<count($poste);$i++) {
00055
00056 list($array,$tot_deb,$tot_cred)=GetDataPoste($cn,$poste[$i],$cond);
00057
00058 if ( count($array) == 0 ) {
00059 continue;
00060 }
00061 $Libelle=sprintf("(%s) %s ",$poste[$i],GetPosteLibelle($cn,$poste[$i],1));
00062
00063
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
00092
00093 }
00094
00095 $pdf->ezStream();
00096
00097 ?>