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

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 
00021 
00022 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00023 // $Revision: 1.9 $
00028 if ( ! isset($_SESSION['g_dossier']) ) {
00029   echo "INVALID G_DOSSIER UNKNOWN !!! ";
00030   exit();
00031 }
00032 include_once('class_user.php');
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 include_once("class_jrn.php");
00040 include_once("check_priv.php");
00041 
00042 echo_debug('jrn_pdf.php',__LINE__,"imp pdf journaux");
00043 $cn=DbConnect($_SESSION['g_dossier']);
00044 $l_type="JRN";
00045 $centr=" Non centralisé";
00046 $l_centr=0;
00047 if ($_GET['central'] == 'on' ) {
00048   $centr=" centralisé ";
00049   $l_centr=1;
00050 }
00051 $Jrn=new jrn($cn,$_GET['jrn_id']);
00052 
00053 $Jrn->GetName();
00054 $User=new cl_user(DbConnect());
00055 $User->Check();
00056 
00057 // Security
00058 if ($User->CheckAction($cn,IMP) == 0 ||
00059     $User->AccessJrn($cn,$_GET['jrn_id']) == false){
00060     /* Cannot Access */
00061     NoAccess();
00062  }
00063 
00064 $ret="";
00065 $pdf=& new Cezpdf("A4");
00066 $pdf->selectFont('./addon/fonts/Helvetica.afm');
00067 
00068 // filter : 0 for Grand Livre otherwise 1
00069 $filter=( $Jrn->id == 0)?0:1;
00070 
00071 $offset=0;$limit=22;$step=22;
00072 $rap_deb=0;$rap_cred=0;
00073 while (1) {
00074   $a=0;
00075   list ($a_jrn,$tot_deb,$tot_cred)=$Jrn->GetRow($_GET['from_periode'],
00076                                           $_GET['to_periode'],
00077                                           $_GET['central'],
00078                                           $limit,$offset);
00079   echo_debug('jrn_pdf.php',__LINE__,"Total debit $tot_deb,credit $tot_cred");
00080 
00081   if ( $a_jrn==null) break;
00082   $offset+=$step; 
00083   $first_id=$a_jrn[0]['int_j_id'];
00084   $Exercice=GetExercice($cn,$a_jrn[0]['periode']);
00085 
00086 
00087   list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,$Jrn->id,$Exercice,FIRST,
00088                                      $filter,
00089                                      $l_centr
00090                                      );
00091   echo_debug('jrn_pdf.php',__LINE__,"MONTANT $rap_deb,$rap_cred");
00092   echo_debug('jrn_pdf.php',__LINE__,"  list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,".$Jrn->id.",$Exercice,FIRST)");
00093   $pdf->ezText($Jrn->name,30);
00094 
00095   if (  $l_centr == 1 ) {
00096     // si centralisé montre les montants de rappel
00097   $str_debit=sprintf( "report Débit  % 10.2f",$rap_deb);
00098   $str_credit=sprintf("report Crédit % 10.2f",$rap_cred);
00099   $pdf->ezText($str_debit,12,array('justification'=>'right'));
00100   $pdf->ezText($str_credit,12,array('justification'=>'right'));
00101   }
00102 
00103   $pdf->ezTable($a_jrn,
00104                 array ('j_id'=>' Numéro',
00105                        'j_date' => 'Date',
00106                        'poste'=>'Poste',
00107                        'description' => 'Description',
00108                        'deb_montant'=> 'Débit',
00109                        'cred_montant'=>'Crédit')," ",
00110                 array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00111                       'cols'=>array('deb_montant'=> array('justification'=>'right'),
00112                       'cred_montant'=> array('justification'=>'right'))));
00113   $a=1;
00114   // Total Page
00115   $apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred));
00116   foreach ($apage as $key=>$element) echo_debug('jrn_pdf.php',__LINE__,"apage $key => $element");
00117   $pdf->ezTable($apage,
00118                 array (
00119                        'deb'=> 'Total Débit',
00120                        'cred'=>'Total Crédit')," ",
00121                 array('shaded'=>0,'showHeadings'=>1,'width'=>200,
00122                       'xPos'=>'right','xOrientation'=>'left',
00123                       'cols'=>array('deb'=> array('justification'=>'right'),
00124                       'cred'=> array('justification'=>'right'))));
00125 
00126   $count=count($a_jrn)-1;
00127   $last_id=$a_jrn[$count]['int_j_id'];
00128   $Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
00129   if ( $l_centr == 1) {
00130     // Montant de rappel si centralisé
00131     list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$Jrn->id,$Exercice,LAST,$filter,$l_centr);
00132     $str_debit=sprintf( "à reporter Débit  % 10.2f",$rap_deb);
00133     $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
00134     $pdf->ezText($str_debit,12,array('justification'=>'right'));
00135     $pdf->ezText($str_credit,12,array('justification'=>'right'));
00136   }
00137   //New page
00138   $pdf->ezNewPage();
00139 }    
00140 if ( $a == 1 )   {
00141   $apage=array('deb'=>$tot_deb,'cred'=>$tot_cred);
00142 $pdf->ezTable($apage,
00143                 array (
00144                        'deb'=> 'Total Débit',
00145                        'cred'=>'Total Crédit')," ",
00146                 array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00147                       'cols'=>array('deb'=> array('justification'=>'right'),
00148                       'cred'=> array('justification'=>'right'))));
00149   $count=count($a_jrn)-1;
00150   $last_id=$a_jrn[$count]['int_j_id'];
00151   $Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
00152 
00153   list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$Jrn->id,$Exercice,LAST,$filter,$l_centr);
00154   $str_debit=sprintf( "à reporter  Débit % 10.2f",$rap_deb);
00155   $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
00156   $pdf->ezText($str_debit,12,array('justification'=>'right'));
00157   $pdf->ezText($str_credit,12,array('justification'=>'right'));
00158 
00159 }
00160 $pdf->ezStream();
00161 
00162 ?>