altocompta/html/poste_pdf.php
Dany De Bontridder 002d4ce01a Merged revisions 3280-3284 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel510

........
  r3280 | danydb | 2010-06-11 14:50:28 +0200 (Fri, 11 Jun 2010) | 2 lines
  
  Print the accounting in PDF in the right order
........
  r3281 | danydb | 2010-06-11 17:37:07 +0200 (Fri, 11 Jun 2010) | 2 lines
  
  Improve cosmetic
........
  r3282 | danydb | 2010-06-11 17:38:09 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Add check for restore of folder or template
........
  r3283 | danydb | 2010-06-11 17:46:21 +0200 (Fri, 11 Jun 2010) | 2 lines
  
  truncate table quant_*
........
  r3284 | danydb | 2010-06-11 17:55:18 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Cosmetic : anchorbutton style
........
2010-06-11 20:01:43 +00:00

130 lines
No EOL
4.1 KiB
PHP

<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
// $Revision$
/*! \file
* \brief send the account list in PDF
*/
include_once("class_acc_account_ledger.php");
include_once("ac_common.php");
require_once('class_database.php');
include_once("impress_inc.php");
require_once ('header_print.php');
require_once('class_dossier.php');
require_once('class_user.php');
require_once('class_pdf.php');
$gDossier=dossier::id();
/* Security */
$cn=new Database($gDossier);
$User=new User($cn);
$User->Check();
$User->check_dossier($gDossier);
$User->can_request(IMPPOSTE,0);
extract($_GET);
if ( isset ( $poste_fille) ){ //choisit de voir tous les postes
$a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '$poste_id%' order by pcm_val");
} else
$a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text = '$poste_id'");
$ret="";
$pdf=new PDF($cn);
$pdf->setDossierInfo(" Periode : ".$_GET['from_periode']." - ".$_GET['to_periode']);
$pdf->AliasNbPages();
$pdf->AddPage();
if ( count($a_poste) == 0 ) {
$pdf->Output('poste.pdf','I');
exit;
}
$size=array(13,25,20,80,12,20,20);
$align=array('L','C','C','L','R','R','R');
foreach ($a_poste as $poste)
{
$Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode);
// don't print empty account
if ( count($array) == 0 ) {
continue;
}
$Libelle=sprintf("(%s) %s ",$Poste->id,$Poste->get_name());
$pdf->SetFont('DejaVuCond','',10);
$pdf->Cell(0,8,$Libelle,1,0,'C');
$pdf->Ln();
$pdf->SetFont('DejaVuCond','',8);
$l=0;
$pdf->Cell($size[$l],6,'Date',0,0,'L');$l++;
$pdf->Cell($size[$l],6,'Ref',0,0,'C');$l++;
$pdf->Cell($size[$l],6,'Journal',0,0,'C');$l++;
$pdf->Cell($size[$l],6,'Libellé',0,0,'L');$l++;
$pdf->Cell($size[$l],6,'Let',0,0,'R');$l++;
$pdf->Cell($size[$l],6,'Debit',0,0,'R');$l++;
$pdf->Cell($size[$l],6,'Credit',0,0,'R');$l++;
$pdf->ln();
$tot_deb=0;$tot_cred=0;
for ($e=0;$e<count($array);$e++) {
$l=0;
$row=$array[$e];
$date=shrink_date($row['j_date_fmt']);
$pdf->Cell($size[$l],6,$date,0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,substr($row['jrn_name'],0,14),0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,$row['description'],0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);$l++;
$pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);$l++;
$pdf->ln();
$tot_deb+=$row['deb_montant'];
$tot_cred+=$row['cred_montant'];
}
$str_debit=sprintf("% 12.2f €",$tot_deb);
$str_credit=sprintf("% 12.2f €",$tot_cred);
$diff_solde=$tot_deb-$tot_cred;
if ( $diff_solde < 0 ) {
$solde=" créditeur ";
$diff_solde*=-1;
} else
{
$solde=" débiteur ";
}
$str_diff_solde=sprintf("%12.2f €",$diff_solde);
$pdf->SetFont('DejaVu','B',8);
$pdf->Cell(160,5,'Débit',0,0,'R');
$pdf->Cell(30,5,$str_debit,0,0,'R');$pdf->Ln();
$pdf->Cell(160,5,'Crédit',0,0,'R');
$pdf->Cell(30,5,$str_credit,0,0,'R');$pdf->Ln();
$pdf->Cell(160,5,'Solde '.$solde,0,0,'R');
$pdf->Cell(30,5,$str_diff_solde,0,0,'R');$pdf->Ln();
}
$fDate=date('dmy-Hi');
$pdf->Output('poste-'.$fDate.'.pdf','I');
?>