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

send_jrn_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 */
00020 
00025 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00026 // $Revision: 1.12 $
00027 
00028 if ( ! isset($g_dossier) ) {
00029   echo "INVALID G_DOSSIER UNKNOWN !!! ";
00030   exit();
00031 }
00032 
00033 include_once("jrn.php");
00034 include_once("ac_common.php");
00035 include_once("postgres.php");
00036 include_once("class.ezpdf.php");
00037 include_once("impress_inc.php");
00038 include_once("preference.php");
00039 echo_debug('send_jrn_pdf.php',__LINE__,"imp pdf journaux");
00040 $l_Db=sprintf("dossier%d",$g_dossier);
00041 $cn=DbConnect($g_dossier);
00042 $l_type="JRN";
00043 $centr=" Non centralisé";
00044 $l_centr=0;
00045 if ( isset ($_POST['central']) ) {
00046   $centr=" centralisé ";
00047   $l_centr=1;
00048 }
00049 
00050 if ( $_GET["filter"] == YES) {
00051   $name_jrn=GetJrnName($cn,$_GET["p_id"]).$centr;
00052 } else {
00053   $name_jrn="Grand livre ".$centr;
00054 }
00055     $ret="";
00056     $pdf=& new Cezpdf("A4");
00057     $pdf->selectFont('./addon/fonts/Helvetica.afm');
00058 
00059 $offset=0;$limit=25;$step=25;
00060 $rap_deb=0;$rap_cred=0;
00061 while (1) {
00062   $a=0;
00063   list ($a_jrn,$tot_deb,$tot_cred)=GetDataJrnPdf($cn,$HTTP_GET_VARS,$limit,$offset);
00064   echo_debug('send_jrn_pdf.php',__LINE__,"Total debit $tot_deb,credit $tot_cred");
00065 
00066   if ( $a_jrn==null) break;
00067   $offset+=$step; 
00068   foreach ($a_jrn as $key=>$element) {
00069     echo_debug('send_jrn_pdf.php',__LINE__,"$key => $element");
00070     foreach ($element as $c1=>$c2) 
00071       echo_debug('send_jrn_pdf.php',__LINE__,"Array is $c1 => $c2");
00072   }
00073   $first_id=$a_jrn[0]['j_id'];
00074    $Exercice=GetExercice($cn,$a_jrn[0]['periode']);
00075 
00076 
00077   list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,$_GET["p_id"],$Exercice,FIRST,
00078                                      $_GET['filter'],
00079                                      $l_centr
00080                                      );
00081   echo_debug('send_jrn_pdf.php',__LINE__,"MONTANT $rap_deb,$rap_cred");
00082   echo_debug('send_jrn_pdf.php',__LINE__,"  list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,".$_GET["p_id"].",$Exercice,FIRST)");
00083   $pdf->ezText($name_jrn,30);
00084 
00085   if (  $l_centr == 1 ) {
00086     // si centralisé montre les montants de rappel
00087   $str_debit=sprintf( "report Débit  % 10.2f",$rap_deb);
00088   $str_credit=sprintf("report Crédit % 10.2f",$rap_cred);
00089   $pdf->ezText($str_debit,12,array('justification'=>'right'));
00090   $pdf->ezText($str_credit,12,array('justification'=>'right'));
00091   }
00092 
00093   $pdf->ezTable($a_jrn,
00094                 array ('internal'=>'Opération',
00095                        'j_date' => 'Date',
00096                        'poste'=>'Poste',
00097                        'description' => 'Description',
00098                        'deb_montant'=> 'Débit',
00099                        'cred_montant'=>'Crédit')," ",
00100                 array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00101                       'cols'=>array('deb_montant'=> array('justification'=>'right'),
00102                       'cred_montant'=> array('justification'=>'right'))));
00103   $a=1;
00104   // Total Page
00105   $apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred));
00106   foreach ($apage as $key=>$element) echo_debug('send_jrn_pdf.php',__LINE__,"apage $key => $element");
00107   $pdf->ezTable($apage,
00108                 array (
00109                        'deb'=> 'Total Débit',
00110                        'cred'=>'Total Crédit')," ",
00111                 array('shaded'=>0,'showHeadings'=>1,'width'=>200,
00112                       'xPos'=>'right','xOrientation'=>'left',
00113                       'cols'=>array('deb'=> array('justification'=>'right'),
00114                       'cred'=> array('justification'=>'right'))));
00115 
00116   $count=count($a_jrn)-1;
00117   $last_id=$a_jrn[$count]['j_id'];
00118   $Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
00119   if ( $l_centr == 1) {
00120     // Montant de rappel si centralisé
00121     list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$_GET['filter'],$l_centr);
00122     $str_debit=sprintf( "à reporter Débit  % 10.2f",$rap_deb);
00123     $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
00124     $pdf->ezText($str_debit,12,array('justification'=>'right'));
00125     $pdf->ezText($str_credit,12,array('justification'=>'right'));
00126   }
00127   //New page
00128   $pdf->ezNewPage();
00129 }    
00130 if ( $a == 1 )   {
00131   $apage=array('deb'=>$tot_deb,'cred'=>$tot_cred);
00132 $pdf->ezTable($apage,
00133                 array (
00134                        'deb'=> 'Total Débit',
00135                        'cred'=>'Total Crédit')," ",
00136                 array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00137                       'cols'=>array('deb'=> array('justification'=>'right'),
00138                       'cred'=> array('justification'=>'right'))));
00139   $count=count($a_jrn)-1;
00140   $last_id=$a_jrn[$count]['j_id'];
00141   $Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
00142 
00143   list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$l_GET['filter'],$l_centr);
00144   $str_debit=sprintf( "à reporter  Débit % 10.2f",$rap_deb);
00145   $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
00146   $pdf->ezText($str_debit,12,array('justification'=>'right'));
00147   $pdf->ezText($str_credit,12,array('justification'=>'right'));
00148 
00149 }
00150 $pdf->ezStream();
00151 
00152 ?>