file:///home/developper/svn/phpcompta/branches/rel510
........
r3236 | danydb | 2010-05-21 20:43:57 +0200 (Fri, 21 May 2010) | 1 line
change place button exit
........
r3237 | danydb | 2010-05-21 20:44:11 +0200 (Fri, 21 May 2010) | 1 line
change place button exit
........
r3238 | danydb | 2010-05-21 20:44:54 +0200 (Fri, 21 May 2010) | 1 line
cosmetic : Button appearance button
........
r3239 | danydb | 2010-05-21 20:46:01 +0200 (Fri, 21 May 2010) | 1 line
Print : add receipt# for cat. of card
........
r3240 | danydb | 2010-05-21 20:46:19 +0200 (Fri, 21 May 2010) | 1 line
Update documentation
........
r3241 | danydb | 2010-05-21 21:05:51 +0200 (Fri, 21 May 2010) | 1 line
add function sql_string to protect
........
r3242 | danydb | 2010-05-22 00:50:31 +0200 (Sat, 22 May 2010) | 1 line
bug in sql_string function : typo
........
r3243 | danydb | 2010-05-22 12:03:49 +0200 (Sat, 22 May 2010) | 1 line
Fix problem with quote for the TMP_PCMN function (ajax search accounting + add / remove and modify accounting)
........
r3244 | danydb | 2010-05-22 12:27:19 +0200 (Sat, 22 May 2010) | 2 lines
Bug in ajax_poste : change set_value(pcm_val,pcm_lib) by set_value(pcm_val,g('lib').innerHTML)
........
r3245 | danydb | 2010-05-24 21:33:53 +0200 (Mon, 24 May 2010) | 2 lines
Fix bug card cannot move due to a typo in Fiche::move_to function
........
156 lines
No EOL
5 KiB
PHP
156 lines
No EOL
5 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
|
|
*/
|
|
/* $Revision$ */
|
|
|
|
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
|
|
|
/*!\file
|
|
* \brief Called by impress->category, export in PDF the history of a category
|
|
* of card
|
|
*/
|
|
|
|
// Security we check if user does exist and his privilege
|
|
require_once('class_user.php');
|
|
require_once('class_database.php');
|
|
require_once('class_pdf.php');
|
|
require_once('class_lettering.php');
|
|
require_once('class_dossier.php');
|
|
require_once('ac_common.php');
|
|
|
|
/* Security */
|
|
$gDossier=dossier::id();
|
|
$cn=new Database($gDossier);
|
|
$User=new User($cn);
|
|
$User->Check();
|
|
$User->check_dossier($gDossier);
|
|
$User->can_request(IMPFIC,0);
|
|
|
|
$pdf=new PDF($cn);
|
|
$pdf->setDossierInfo(" Periode : ".$_GET['start']." - ".$_GET['end']);
|
|
$pdf->AliasNbPages();
|
|
$pdf->AddPage();
|
|
$array=Fiche::get_fiche_def($cn,$_GET['cat']);
|
|
$name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',array($_GET['cat']));
|
|
$pdf->SetFont('DejaVu','BI',14);
|
|
$pdf->Cell(0,8,$name,0,1,'C');
|
|
$pdf->SetTitle($name,1);
|
|
$pdf->SetAuthor('Phpcompta');
|
|
/*
|
|
* You show now the result
|
|
*/
|
|
if ($array == null ) {
|
|
/**
|
|
* @todo if no data send an empty PDF
|
|
*/
|
|
// echo '<h2 class="info2"> Aucune fiche trouvée</h2>';
|
|
exit();
|
|
}
|
|
$tab=array(13,25,55,20,20,12,20);
|
|
$align=array('L','L','L','R','R','R','R');
|
|
|
|
foreach($array as $row) {
|
|
$letter=new Lettering_Card($cn);
|
|
$letter->set_parameter('quick_code',$row->strAttribut(ATTR_DEF_QUICKCODE));
|
|
$letter->set_parameter('start',$_GET['start']);
|
|
$letter->set_parameter('end',$_GET['end']);
|
|
// all
|
|
if ( $_GET['histo'] == 0 ) {
|
|
$letter->get_all();
|
|
}
|
|
|
|
// lettered
|
|
if ( $_GET['histo'] == 1 ) {
|
|
$letter->get_letter();
|
|
}
|
|
// unlettered
|
|
if ( $_GET['histo'] == 2 ) {
|
|
$letter->get_unletter();
|
|
}
|
|
/* skip if nothing to display */
|
|
if (count($letter->content) == 0 ) continue;
|
|
$pdf->SetFont('DejaVu','',10);
|
|
|
|
$pdf->Cell(0,7,$row->strAttribut(ATTR_DEF_NAME),1,1,'C');
|
|
|
|
|
|
$pdf->Cell($tab[0],7,'Date');
|
|
$pdf->Cell($tab[1],7,'ref');
|
|
$pdf->Cell($tab[1],7,'Int.');
|
|
$pdf->Cell($tab[2],7,'Comm');
|
|
$pdf->Cell(40,7,'Montant',0,0,'C');
|
|
$pdf->Cell($tab[5],7,'Let.',0,0,'R');
|
|
$pdf->Cell($tab[6],7,'Som. Let.',0,0,'R');
|
|
$pdf->ln();
|
|
|
|
$amount_deb=0;$amount_cred=0;
|
|
for ($i=0;$i<count($letter->content);$i++){
|
|
if ( $i % 2 == 0 ) {
|
|
$pdf->SetFillColor(220,221,255);
|
|
$fill=1;
|
|
} else {
|
|
$pdf->SetFillColor(0,0,0);
|
|
$fill=0;
|
|
}
|
|
$pdf->SetFont('DejaVuCond','',8);
|
|
$row=$letter->content[$i];
|
|
$str_date=shrink_date($row['j_date_fmt']);
|
|
|
|
$pdf->Cell($tab[0],4,$str_date,0,0,$align[0],$fill);
|
|
$pdf->Cell($tab[1],4,$row['jr_pj_number'],0,0,$align[1],$fill);
|
|
$pdf->Cell($tab[1],4,$row['jr_internal'],0,0,$align[1],$fill);
|
|
$pdf->Cell($tab[2],4,$row['jr_comment'],0,0,$align[2],$fill);
|
|
if ( $row['j_debit'] == 't') {
|
|
$pdf->Cell($tab[3],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
|
|
$amount_deb+=$row['j_montant'];
|
|
$pdf->Cell($tab[4],4,"",0,0,'C',$fill);
|
|
} else {
|
|
$pdf->Cell($tab[3],4,"",0,0,'C',$fill);
|
|
$pdf->Cell($tab[4],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
|
|
$amount_cred+=$row['j_montant'];
|
|
}
|
|
if ($row['letter'] != -1 ) {
|
|
$pdf->Cell($tab[5],4,$row['letter'],0,0,$align[5],$fill);
|
|
// get sum for this lettering
|
|
$sql="select sum(j_montant) from jrnx where j_debit=$1 and j_id in ".
|
|
" (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union ".
|
|
" select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)";
|
|
$sum=$cn->get_value($sql,array($row['j_debit'],$row['letter'],$row['letter']));
|
|
$pdf->Cell($tab[6],4,sprintf('%.2f',$sum),'0','0','R',$fill);
|
|
}
|
|
else
|
|
$pdf->Cell($tab[5],4,"",0,0,'R',$fill);
|
|
$pdf->Ln();
|
|
}
|
|
$pdf->SetFillColor(0,0,0);
|
|
$pdf->SetFont('DejaVuCond','B',8);
|
|
$debit =sprintf('Debit : % 12.2f',$amount_deb);
|
|
$credit=sprintf('Credit : % 12.2f',$amount_cred);
|
|
if ( $amount_deb>$amount_cred) $s='solde débiteur'; else $s='solde crediteur';
|
|
$solde =sprintf('%s : % 12.2f',$s,(abs(round($amount_cred-$amount_deb,2))));
|
|
|
|
$pdf->Cell(0,6,$debit,0,0,'R');$pdf->ln(4);
|
|
$pdf->Cell(0,6,$credit,0,0,'R');$pdf->ln(4);
|
|
$pdf->Cell(0,6,$solde,0,0,'R');$pdf->ln(4);
|
|
|
|
$pdf->Ln();
|
|
}
|
|
|
|
//Save PDF to file
|
|
$fDate=date('dmy-Hi');
|
|
$pdf->Output("category-$fDate.pdf", 'I');exit; |