00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025
00026
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
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
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
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
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 ?>