noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_fiche_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("class_fiche.php");
00031 require_once ('header_print.php');
00032 require_once('class_dossier.php');
00033 require_once('class_pdf.php');
00034 $gDossier=dossier::id();
00035 
00036 $cn=new Database($gDossier);
00037 
00038 extract($_GET);
00039 
00040 $ret="";
00041 $pdf= new PDF($cn);
00042 $pdf->setDossierInfo("  Periode : ".$_GET['from_periode']." - ".$_GET['to_periode']);
00043 $pdf->AliasNbPages();
00044 $pdf->AddPage();
00045 $pdf->SetAuthor('NOALYSS');
00046 $pdf->setTitle("Détail fiche",true);
00047 
00048 
00049 $Fiche=new Fiche($cn,$f_id);
00050 
00051 
00052 list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date($from_periode,$to_periode,$_GET['ople']);
00053 // don't print empty account
00054 if ( count($array) == 0 )
00055 {
00056     exit;
00057 }
00058 $size=array(13,25,20,60,12,20,20,20);
00059 $align=array('L','C','C','L','R','R','R','R');
00060 
00061 $Libelle=sprintf("(%s) %s [ %s ]",$Fiche->id,$Fiche->getName(),$Fiche->get_quick_code());
00062 $pdf->SetFont('DejaVu','',10);
00063 $pdf->Cell(0,8,$Libelle,1,0,'C');
00064 $pdf->Ln();
00065 
00066 
00067 $pdf->SetFont('DejaVuCond','',8);
00068 $l=0;
00069 $pdf->Cell($size[$l],6,'Date',0,0,'L');
00070 $l++;
00071 $pdf->Cell($size[$l],6,'Ref',0,0,'C');
00072 $l++;
00073 $pdf->Cell($size[$l],6,'Journal',0,0,'C');
00074 $l++;
00075 $pdf->Cell($size[$l],6,'Libellé',0,0,'L');
00076 $l++;
00077 $pdf->Cell($size[$l],6,'Let',0,0,'R');
00078 $l++;
00079 $pdf->Cell($size[$l],6,'Debit',0,0,'R');
00080 $l++;
00081 $pdf->Cell($size[$l],6,'Credit',0,0,'R');
00082 $l++;
00083 $pdf->Cell($size[$l],6,'Prog',0,0,'R');
00084 $l++;
00085 $pdf->ln();
00086 $tot_deb=0;
00087 $tot_cred=0;
00088 $progress=0;
00089 $current_exercice="";
00090 bcscale(2);
00091 for ($e=0;$e<count($array);$e++)
00092 {
00093     $row=$array[$e];
00094     /*
00095      * separation per exercice
00096      */
00097     if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
00098 
00099     if ( $current_exercice != $row['p_exercice']) {
00100             $str_debit=sprintf("% 12.2f €",$tot_deb);
00101             $str_credit=sprintf("% 12.2f €",$tot_cred);
00102             $diff_solde=bcsub($tot_deb,$tot_cred);
00103             if ( $diff_solde < 0 )
00104             {
00105                 $solde=" créditeur ";
00106                 $diff_solde=bcmul($diff_solde,-1);
00107             }
00108             else
00109             {
00110                  $solde=" débiteur ";
00111             }
00112             $str_diff_solde=sprintf("%12.2f €",$diff_solde);
00113 
00114             $pdf->SetFont('DejaVu','B',8);
00115             $pdf->LongLine(15,6,_('totaux'),0,'L');
00116             $pdf->Cell(15,6,$current_exercice,0,0,'L');
00117             $pdf->LongLine(40,6,$solde,0,'L');
00118             $pdf->Cell(40,6,$str_debit,0,0,'R');
00119             $pdf->Cell(40,6,$str_credit,0,0,'R');
00120             $pdf->Cell(40,6,$str_diff_solde,0,0,'R');
00121             $pdf->Ln();
00122             /*
00123             * reset total and current_exercice
00124             */
00125             $prog=0;
00126             $current_exercice=$row['p_exercice'];
00127             $tot_deb=0;$tot_cred=0;    
00128             $pdf->SetFont('DejaVuCond','',8);
00129     }
00130     $l=0;
00131     $progress=bcsub($row['deb_montant'],$row['cred_montant']);
00132 
00133 
00134     $date=shrink_date($row['j_date_fmt']);
00135     $pdf->LongLine($size[$l],6,$date,0,$align[$l]);
00136     $l++;
00137     if ( $row['jr_pj_number'] == '')
00138       $pdf->Cell($size[$l],6,"",0,0,$align[$l]);
00139     else
00140       $pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
00141 
00142     $l++;
00143     $pdf->LongLine($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,$align[$l]);
00144     $l++;
00145     $pdf->LongLine($size[$l],6,($row['description'].'('.$row['jr_internal'].")"),0,$align[$l]);
00146 
00147     $l++;
00148     $pdf->LongLine($size[$l],6,(($row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
00149     $l++;
00150     $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,$align[$l]);
00151     $l++;
00152     $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,$align[$l]);
00153     $l++;
00154     $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,$align[$l]);
00155     $l++;
00156     $pdf->ln();
00157     $tot_deb=bcadd($tot_deb,$row['deb_montant']);
00158     $tot_cred=bcadd($tot_cred,$row['cred_montant']);
00159     /* -------------------------------------- */
00160     /* if details are asked we show them here */
00161     /* -------------------------------------- */
00162     if ( isset($_GET['oper_detail']))
00163     {
00164         $detail=new Acc_Operation($cn);
00165         $detail->jr_id=$row['jr_id'];
00166         $a_detail=$detail->get_jrnx_detail();
00167         for ($f=0;$f<count($a_detail);$f++)
00168         {
00169             $l=0;
00170             $pdf->Cell($size[$l],6,'',0,0,$align[$l]);
00171             $l++;
00172             $pdf->Cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,'L');
00173             $l++;
00174             $pdf->Cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,'R');
00175             $l++;
00176             if ( $a_detail[$f]['j_qcode']=='')
00177                 $lib=$a_detail[$f]['pcm_lib'];
00178             else
00179             {
00180                 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
00181                 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
00182                                     array(ATTR_DEF_NAME,$f_id));
00183             }
00184             $pdf->Cell($size[$l],6,$lib,0,0,$align[$l]);
00185             $l++;
00186             $pdf->Cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
00187             $l++;
00188 
00189             $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
00190             $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
00191 
00192             $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
00193             $l++;
00194             $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
00195             $l++;
00196             $pdf->ln();
00197         }
00198     }
00199 
00200 }
00201 $str_debit=sprintf("% 12.2f €",$tot_deb);
00202 $str_credit=sprintf("% 12.2f €",$tot_cred);
00203 $diff_solde=$tot_deb-$tot_cred;
00204 if ( $diff_solde < 0 )
00205 {
00206     $solde=" créditeur ";
00207     $diff_solde*=-1;
00208 }
00209 else
00210 {
00211     $solde=" débiteur ";
00212 }
00213 $str_diff_solde=sprintf("%12.2f €",$diff_solde);
00214 
00215 $pdf->SetFont('DejaVu','B',8);
00216 
00217 $pdf->Cell(160,5,'Débit',0,0,'R');
00218 $pdf->Cell(30,5,$str_debit,0,0,'R');
00219 $pdf->Ln();
00220 $pdf->Cell(160,5,'Crédit',0,0,'R');
00221 $pdf->Cell(30,5,$str_credit,0,0,'R');
00222 $pdf->Ln();
00223 $pdf->Cell(160,5,'Solde '.$solde,0,0,'R');
00224 $pdf->Cell(30,5,$str_diff_solde,0,0,'R');
00225 $pdf->Ln();
00226 
00227 $fDate=date('dmy-Hi');
00228 $pdf->Output('fiche-'.$fDate.'.pdf','D');
00229 
00230 
00231 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations