00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00058 if ($User->CheckAction($cn,IMP) == 0 ||
00059 $User->AccessJrn($cn,$_GET['jrn_id']) == false){
00060
00061 NoAccess();
00062 }
00063
00064 $ret="";
00065 $pdf=& new Cezpdf("A4");
00066 $pdf->selectFont('./addon/fonts/Helvetica.afm');
00067
00068
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
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
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
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
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 ?>