noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_print_ledger_detail.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief this class extends PDF and let you export the detailled printing
00024  *  of any ledgers
00025  */
00026 require_once('class_pdf.php');
00027 
00028 class Print_Ledger_Detail extends PDF
00029 {
00030     public function __construct ($p_cn = null, Acc_Ledger $ledger)
00031     {
00032 
00033         if($p_cn == null) die("No database connection. Abort.");
00034         
00035         parent::__construct($p_cn,'L', 'mm', 'A4');
00036         $this->ledger=$ledger;
00037         date_default_timezone_set ('Europe/Paris');
00038 
00039     }
00040 
00041     function setDossierInfo($dossier = "n/a")
00042     {
00043         $this->dossier = dossier::name()." ".$dossier;
00044     }
00045 
00046     function Header()
00047     {
00048         //Arial bold 12
00049         $this->SetFont('DejaVu', 'B', 12);
00050         //Title
00051         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00052         //Line break
00053         $this->Ln(20);
00054     }
00055     function Footer()
00056     {
00057         //Position at 2 cm from bottom
00058         $this->SetY(-20);
00059         //Arial italic 8
00060         $this->SetFont('Arial', 'I', 8);
00061         //Page number
00062         $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
00063         // Created by NOALYSS
00064         $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
00065 
00066     }
00067     function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00068     {
00069         $txt = str_replace("\\", "", $txt);
00070         return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00071     }
00072 
00073     function export()
00074     {
00075         
00076         // detailled printing
00077         $rap_deb=0;
00078         $rap_cred=0;
00079         // take all operations from jrn
00080         $array=$this->ledger->get_operation($_GET['from_periode'],$_GET['to_periode']);
00081 
00082         $this->SetFont('DejaVu','BI',7);
00083         $this->Cell(215,7,'report Débit',0,0,'R');
00084         $this->Cell(30,7,nbm($rap_deb),0,0,'R');
00085         $this->Ln(4);
00086         $this->Cell(215,7,'report Crédit',0,0,'R');
00087         $this->Cell(30,7,nbm($rap_cred),0,0,'R');
00088         $this->Ln(4);
00089 
00090         // print all operation
00091         for ($i=0;$i< count($array);$i++)
00092         {
00093             $this->SetFont('DejaVuCond','B',7);
00094             $row=$array[$i];
00095 
00096             $this->LongLine(20,7,$row['pj']);
00097             $this->Cell(15,7,$row['date_fmt']);
00098             $this->Cell(20,7,$row['internal']);
00099             $this->LongLine(170,7,$row['comment']);
00100             $this->Cell(20,7,nbm($row['montant']),0,0,'R');
00101 
00102             $this->Ln();
00103             // get the entries
00104             $aEntry=$this->cn->get_array("select j_id,j_poste,j_qcode,j_montant,j_debit, j_text,".
00105                                                                                  " case when j_text='' or j_text is null then pcm_lib else j_text end as desc,".
00106                                          " pcm_lib ".
00107                                          " from jrnx join tmp_pcmn on (j_poste=pcm_val) where j_grpt = $1".
00108                                          " order by j_debit desc,j_id",
00109                                          array($row['jr_grpt_id']));
00110             for ($j=0;$j<count($aEntry);$j++)
00111             {
00112                 $this->SetFont('DejaVuCond','',7);
00113                 $entry=$aEntry[$j];
00114                 // $this->Cell(15,6,$entry['j_id'],0,0,'R');
00115                 $this->Cell(32,6,$entry['j_qcode'],0,0,'R');
00116                 $this->Cell(23,6,$entry['j_poste'],0,0,'R');
00117 
00118                 // if j_qcode is not empty retrieve name
00119                 if ( $entry['j_text'] =='' && $entry['j_qcode'] != '')
00120                 {
00121                     $f_id=$this->cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($entry['j_qcode']));
00122                     if ($f_id != '')
00123                         $name=$this->cn->get_value('select ad_value from fiche_detail where f_id=$1 and ad_id=1',
00124                                                    array($f_id));
00125                     else
00126                         $name=$entry['pcm_lib'];
00127                 }
00128                 else
00129                     $name=$entry['desc'];
00130                 $this->Cell(150,6,$name,0,0,'L');
00131 
00132                 // print amount
00133                 $str_amount=nbm($entry['j_montant']);
00134                 if ( $entry['j_debit']=='t')
00135                 {
00136                     $this->Cell(20,6,$str_amount,0,0,'R');
00137                     $this->Cell(20,6,'',0,0,'R');
00138                 }
00139                 else
00140                 {
00141                     $this->Cell(20,6,'',0,0,'R');
00142                     $this->Cell(20,6,$str_amount,0,0,'R');
00143                 }
00144                 $this->Ln(4);
00145             }
00146         }
00147     }
00148 }
 All Data Structures Namespaces Files Functions Variables Enumerations