135 lines
4.7 KiB
PHP
135 lines
4.7 KiB
PHP
<?
|
|
|
|
/*
|
|
* This file is part of WCOMPTA.
|
|
*
|
|
* WCOMPTA is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* WCOMPTA is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with WCOMPTA; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
|
|
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
|
|
// $Revision$
|
|
|
|
include_once("jrn.php");
|
|
include_once("ac_common.php");
|
|
include_once("postgres.php");
|
|
include_once("class.ezpdf.php");
|
|
include_once("impress_inc.php");
|
|
include_once("preference.php");
|
|
echo_debug("imp pdf journaux");
|
|
$l_Db=sprintf("dossier%d",$g_dossier);
|
|
$cn=DbConnect($l_Db);
|
|
$l_type="JRN";
|
|
if ( isset ($_POST["central"]) ) {
|
|
$centr=($_POST["central"]=='no')?" Non centralisé":" centralisé ";
|
|
$l_type=$_POST["central"] == 'no'?"GL-NOCENTRAL":"GL-CENTRAL";
|
|
|
|
}
|
|
if ( $_POST["filter"] == YES) {
|
|
$name_jrn=GetJrnName($cn,$_POST["p_id"]);
|
|
} else {
|
|
$name_jrn="Grand livre ".$centr;
|
|
}
|
|
$ret="";
|
|
$pdf=& new Cezpdf("A4");
|
|
$pdf->selectFont('./addon/fonts/Helvetica.afm');
|
|
|
|
$offset=0;$limit=35;$step=35;
|
|
$rap_deb=0;$rap_cred=0;
|
|
while (1) {
|
|
$a=0;
|
|
list ($a_jrn,$tot_deb,$tot_cred)=GetDataJrnPdf($cn,$HTTP_POST_VARS,$limit,$offset);
|
|
echo_debug("Total debit $tot_deb,credit $tot_cred");
|
|
|
|
if ( $a_jrn==null) break;
|
|
$offset+=$step;
|
|
foreach ($a_jrn as $key=>$element) {
|
|
echo_debug("$key => $element");
|
|
foreach ($element as $c1=>$c2)
|
|
echo_debug("Array is $c1 => $c2");
|
|
}
|
|
$first_id=$a_jrn[0]['j_id'];
|
|
$Exercice=GetExercice($cn,$a_jrn[0]['periode']);
|
|
|
|
|
|
list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,$_POST["p_id"],$Exercice,FIRST,$l_type);
|
|
echo_debug("MONTANT $rap_deb,$rap_cred");
|
|
echo_debug(" list($rap_deb,$rap_cred)=GetRappel($cn,$first_id,".$_POST["p_id"].",$Exercice,FIRST)");
|
|
|
|
$pdf->ezText($name_jrn,30);
|
|
$str_debit=sprintf( "report Débit % 10.2f",$rap_deb);
|
|
$str_credit=sprintf("report Crédit % 10.2f",$rap_cred);
|
|
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
|
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
|
|
|
$pdf->ezTable($a_jrn,
|
|
array ('internal'=>'Opération',
|
|
'j_date' => 'Date',
|
|
'poste'=>'Poste',
|
|
'description' => 'Description',
|
|
'deb_montant'=> 'Débit',
|
|
'cred_montant'=>'Crédit')," ",
|
|
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
|
|
'cols'=>array('deb_montant'=> array('justification'=>'right'),
|
|
'cred_montant'=> array('justification'=>'right'))));
|
|
$a=1;
|
|
// Total Page
|
|
$apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred));
|
|
foreach ($apage as $key=>$element) echo_debug ("apage $key => $element");
|
|
$pdf->ezTable($apage,
|
|
array (
|
|
'deb'=> 'Total Débit',
|
|
'cred'=>'Total Crédit')," ",
|
|
array('shaded'=>0,'showHeadings'=>1,'width'=>200,
|
|
'xPos'=>'right','xOrientation'=>'left',
|
|
'cols'=>array('deb'=> array('justification'=>'right'),
|
|
'cred'=> array('justification'=>'right'))));
|
|
|
|
$count=count($a_jrn)-1;
|
|
$last_id=$a_jrn[$count]['j_id'];
|
|
$Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
|
|
|
|
list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$_POST["p_id"],$Exercice,LAST,$l_type);
|
|
$str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb);
|
|
$str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
|
|
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
|
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
|
|
|
//New page
|
|
$pdf->ezNewPage();
|
|
}
|
|
if ( $a == 1 ) {
|
|
$apage=array('deb'=>$tot_deb,'cred'=>$tot_cred);
|
|
$pdf->ezTable($apage,
|
|
array (
|
|
'deb'=> 'Total Débit',
|
|
'cred'=>'Total Crédit')," ",
|
|
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
|
|
'cols'=>array('deb'=> array('justification'=>'right'),
|
|
'cred'=> array('justification'=>'right'))));
|
|
$count=count($a_jrn)-1;
|
|
$last_id=$a_jrn[$count]['j_id'];
|
|
$Exercice=GetExercice($cn,$a_jrn[$count]['periode']);
|
|
|
|
list($rap_deb,$rap_cred)=GetRappel($cn,$last_id,$_POST["p_id"],$Exercice,LAST,$l_type);
|
|
$str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb);
|
|
$str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred);
|
|
$pdf->ezText($str_debit,12,array('justification'=>'right'));
|
|
$pdf->ezText($str_credit,12,array('justification'=>'right'));
|
|
|
|
}
|
|
$pdf->ezStream();
|
|
|
|
?>
|