noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_poste_detail_pdf.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 /*! \file
00023  * \brief send the account list in PDF
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 include_once("class_acc_account_ledger.php");
00027 include_once("ac_common.php");
00028 require_once('class_database.php');
00029 include_once("class_impress.php");
00030 require_once ('header_print.php');
00031 require_once('class_dossier.php');
00032 require_once('class_user.php');
00033 require_once('class_pdf.php');
00034 
00035 $gDossier=dossier::id();
00036 
00037 /* Security */
00038 $cn=new Database($gDossier);
00039 extract($_GET);
00040 
00041 if ( isset ( $poste_fille) )
00042 { //choisit de voir tous les postes
00043     $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '$poste_id%' order by pcm_val");
00044 }
00045 else
00046     $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text = '$poste_id'");
00047 
00048 
00049 $ret="";
00050 
00051 $pdf=new PDF($cn);
00052 $pdf->setDossierInfo("  Periode : ".$_GET['from_periode']." - ".$_GET['to_periode']);
00053 $pdf->AliasNbPages();
00054 $pdf->AddPage();
00055 $pdf->SetAuthor('NOALYSS');
00056 $pdf->setTitle("Détail poste comptable",true);
00057 
00058 
00059 if ( count($a_poste) == 0 )
00060 {
00061     $pdf->Output('poste.pdf','D');
00062     exit;
00063 }
00064 $size=array(13,25,20,60,12,20,20,20);
00065 $align=array('L','C','C','L','R','R','R','R');
00066 
00067 foreach ($a_poste as $poste)
00068 {
00069     $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
00070     list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode,$_GET['ople']);
00071     // don't print empty account
00072     if ( count($array) == 0 )
00073     {
00074         continue;
00075     }
00076     $Libelle=sprintf("(%s) %s ",$Poste->id,$Poste->get_name());
00077     $pdf->SetFont('DejaVuCond','',10);
00078     $pdf->Cell(0,8,$Libelle,1,0,'C');
00079     $pdf->Ln();
00080 
00081     $pdf->SetFont('DejaVuCond','',8);
00082     $l=0;
00083     $pdf->Cell($size[$l],6,'Date',0,0,'L');
00084     $l++;
00085     $pdf->Cell($size[$l],6,'Ref',0,0,'C');
00086     $l++;
00087     $pdf->Cell($size[$l],6,'Journal',0,0,'C');
00088     $l++;
00089     $pdf->LongLine($size[$l],6,'Libellé',0,'L');
00090     $l++;
00091     $pdf->Cell($size[$l],6,'Let',0,0,'R');
00092     $l++;
00093     $pdf->Cell($size[$l],6,'Debit',0,0,'R');
00094     $l++;
00095     $pdf->Cell($size[$l],6,'Credit',0,0,'R');
00096     $l++;
00097     $pdf->Cell($size[$l],6,'Prog',0,0,'R');
00098     $l++;
00099     $pdf->ln();
00100     $tot_deb=0;
00101     $tot_cred=0;
00102     $prog=0;
00103     for ($e=0;$e<count($array);$e++)
00104     {
00105         $l=0;
00106         $row=$array[$e];
00107         $prog+=$row['deb_montant']-$row['cred_montant'];
00108 
00109         $date=shrink_date($row['j_date_fmt']);
00110         $pdf->Cell($size[$l],6,$date,0,0,$align[$l]);
00111         $l++;
00112         if ( $row['jr_pj_number'] == '')
00113           $pdf->Cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]);
00114         else
00115           $pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
00116         $l++;
00117         $pdf->Cell($size[$l],6,mb_substr($row['jrn_name'],0,14),0,0,$align[$l]);
00118         $l++;
00119         $pdf->LongLine($size[$l],6,  $row['description'],0,$align[$l]);
00120         $l++;
00121         $pdf->Cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]);
00122         $l++;
00123         $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);
00124         $l++;
00125         $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);
00126         $l++;
00127         $pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($prog))),0,0,$align[$l]);
00128         $l++;
00129         $pdf->ln();
00130         $tot_deb+=$row['deb_montant'];
00131         $tot_cred+=$row['cred_montant'];
00132         /* -------------------------------------- */
00133         /* if details are asked we show them here */
00134         /* -------------------------------------- */
00135         if ( isset($_GET['oper_detail']))
00136         {
00137             $detail=new Acc_Operation($cn);
00138             $detail->jr_id=$row['jr_id'];
00139             $a_detail=$detail->get_jrnx_detail();
00140             for ($f=0;$f<count($a_detail);$f++)
00141             {
00142                 $l=0;
00143                 $pdf->Cell($size[$l],6,'',0,0,$align[$l]);
00144                 $l++;
00145                 $pdf->Cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,$align[$l]);
00146                 $l++;
00147                 $pdf->Cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,$align[$l]);
00148                 $l++;
00149                 if ( $a_detail[$f]['j_qcode']=='')
00150                     $lib=$a_detail[$f]['pcm_lib'];
00151                 else
00152                 {
00153                     $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
00154                     $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
00155                                         array(ATTR_DEF_NAME,$f_id));
00156                 }
00157                 $pdf->Cell($size[$l],6,$lib,0,0,$align[$l]);
00158                 $l++;
00159                 $pdf->Cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
00160                 $l++;
00161 
00162                 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
00163                 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
00164 
00165                 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
00166                 $l++;
00167                 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
00168                 $l++;
00169                 $pdf->ln();
00170             }
00171         }
00172     }
00173     $str_debit=sprintf("% 12.2f €",$tot_deb);
00174     $str_credit=sprintf("% 12.2f €",$tot_cred);
00175     $diff_solde=$tot_deb-$tot_cred;
00176     if ( $diff_solde < 0 )
00177     {
00178         $solde=" créditeur ";
00179         $diff_solde*=-1;
00180     }
00181     else
00182     {
00183         $solde=" débiteur ";
00184     }
00185     $str_diff_solde=sprintf("%12.2f €",$diff_solde);
00186 
00187     $pdf->SetFont('DejaVu','B',8);
00188 
00189     $pdf->Cell(160,5,'Débit',0,0,'R');
00190     $pdf->Cell(30,5,$str_debit,0,0,'R');
00191     $pdf->Ln();
00192     $pdf->Cell(160,5,'Crédit',0,0,'R');
00193     $pdf->Cell(30,5,$str_credit,0,0,'R');
00194     $pdf->Ln();
00195     $pdf->Cell(160,5,'Solde '.$solde,0,0,'R');
00196     $pdf->Cell(30,5,$str_diff_solde,0,0,'R');
00197     $pdf->Ln();
00198 
00199 }
00200 $fDate=date('dmy-Hi');
00201 $pdf->Output('poste-'.$fDate.'-'.$poste_id.'.pdf','D');
00202 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations