noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_pdf.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
00024  */
00025 
00026 require_once('tfpdf/tfpdf.php');
00027 
00028 class PDF extends TFPDF
00029 {
00030 
00031     var $cn  = null;
00032     var $own = null;
00033     var $soc = "";
00034     var $dossier =  "n/a";
00035     var $date = "";
00036 
00037     public function __construct ($p_cn = null, $orientation = 'P', $unit = 'mm', $format = 'A4')
00038     {
00039                 $this->bigger=0;
00040         if($p_cn == null) die("No database connection. Abort.");
00041 
00042         parent::TFPDF($orientation, $unit, $format);
00043         $this->AddFont('DejaVu','','DejaVuSans.ttf',true);
00044         $this->AddFont('DejaVu','B','DejaVuSans-Bold.ttf',true);
00045         $this->AddFont('DejaVu','BI','DejaVuSans-BoldOblique.ttf',true);
00046         $this->AddFont('DejaVuCond','','DejaVuSansCondensed.ttf',true);
00047         $this->AddFont('DejaVuCond','B','DejaVuSansCondensed-Bold.ttf',true);
00048         $this->AddFont('DejaVuCond','I','DejaVuSansCondensed-Oblique.ttf',true);
00049         date_default_timezone_set ('Europe/Paris');
00050 
00051         $this->cn  = $p_cn;
00052         $this->own = new own($this->cn);
00053         $this->soc = $this->own->MY_NAME;
00054         $this->date = date('d.m.Y');
00055     }
00056 
00057     function setDossierInfo($dossier = "n/a")
00058     {
00059         $this->dossier = dossier::name()." ".$dossier;
00060     }
00061 
00062     function Header()
00063     {
00064         //Arial bold 12
00065         $this->SetFont('DejaVu', 'B', 12);
00066         //Title
00067         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00068         //Line break
00069         $this->Ln(20);
00070     }
00071     function Footer()
00072     {
00073         //Position at 2 cm from bottom
00074         $this->SetY(-20);
00075         //Arial italic 8
00076         $this->SetFont('Arial', '', 8);
00077         //Page number
00078         $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
00079         $this->Ln(3);
00080         // Created by NOALYSS
00081         $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'C',false,'http://www.aevalys.eu');
00082     }
00083     function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00084     {
00085         $txt = str_replace("\\", "", $txt);
00086         return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00087                 }
00088         function LongLine($w,$h,$txt,$border=0,$align='',$fill=false)
00089         {
00090                 $x_m=$this->GetX();
00091                 $y_m=$this->GetY();
00092                 $txt = str_replace("\\", "", $txt);
00093                 if ( $y_m > ($this->h-$this->bMargin-10 ))              {
00094                         $this->AddPage ();
00095                         $y_m=$this->GetY();
00096 
00097                 }
00098                 $this->MultiCell($w,$h,$txt,$border,$align,$fill);
00099                 $x_m=$x_m+$w;
00100                 $tmp=$this->GetY()-$y_m;
00101                 if ( $tmp > $this->bigger) $this->bigger=$tmp;
00102                 $this->SetXY($x_m,$y_m);
00103         }
00104         function Ln($p_step=null){
00105                 if ( $this->bigger==0) parent::Ln($p_step);
00106                 parent::Ln($this->bigger);
00107                 $this->bigger=0;
00108         }
00109     /**
00110      *@brief retrieve the client name and quick_code
00111      *@param $p_jr_id jrn.jr_id
00112      *@param $p_jrn_type ledger type ACH VEN FIN
00113      *@return array (0=>qcode,1=>name) or for FIN 0=>customer qc 1=>customer name 2=>bank qc 3=>bank name
00114      *@see class_print_ledger_simple, class_print_ledger_simple_without_vat
00115      */
00116     function get_tiers($p_jr_id,$p_jrn_type)
00117     {
00118         if ( $p_jrn_type=='ACH' )
00119         {
00120             $array=$this->cn->get_array('SELECT
00121                                         jrnx.j_grpt,
00122                                         quant_purchase.qp_supplier,
00123                                         quant_purchase.qp_internal,
00124                                         jrn.jr_internal
00125                                         FROM
00126                                         public.quant_purchase,
00127                                         public.jrnx,
00128                                         public.jrn
00129                                         WHERE
00130                                         quant_purchase.j_id = jrnx.j_id AND
00131                                         jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1',array($p_jr_id));
00132             if (count($array)==0) return array("ERREUR $p_jr_id",'');
00133             $customer_id=$array[0]['qp_supplier'];
00134             $fiche=new Fiche($this->cn,$customer_id);
00135             $customer_qc=$fiche->get_quick_code($customer_id);
00136             $customer_name=$fiche->getName();
00137             return array($customer_qc,$customer_name);
00138         }
00139         if ( $p_jrn_type=='VEN' )
00140         {
00141             $array=$this->cn->get_array('SELECT
00142                                         quant_sold.qs_client
00143                                         FROM
00144                                         public.quant_sold,
00145                                         public.jrnx,
00146                                         public.jrn
00147                                         WHERE
00148                                         quant_sold.j_id = jrnx.j_id AND
00149                                         jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1',array($p_jr_id));
00150             if (count($array)==0) return array("ERREUR $p_jr_id",'');
00151             $customer_id=$array[0]['qs_client'];
00152             $fiche=new Fiche($this->cn,$customer_id);
00153             $customer_qc=$fiche->get_quick_code($customer_id);
00154             $customer_name=$fiche->getName();
00155             return array($customer_qc,$customer_name);
00156         }
00157         if ( $p_jrn_type=='FIN' )
00158         {
00159             $array=$this->cn->get_array('SELECT
00160                                         qf_other,qf_bank
00161                                         FROM
00162                                         public.quant_fin
00163                                         WHERE
00164                                         quant_fin.jr_id =$1',array($p_jr_id));
00165             if (count($array)==0) return array("ERREUR $p_jr_id",'','','');
00166             $customer_id=$array[0]['qf_other'];
00167             $fiche=new Fiche($this->cn,$customer_id);
00168             $customer_qc=$fiche->get_quick_code($customer_id);
00169             $customer_name=$fiche->getName();
00170 
00171             $bank_id=$array[0]['qf_bank'];
00172             $fiche=new Fiche($this->cn,$bank_id);
00173             $bank_qc=$fiche->get_quick_code($bank_id);
00174             $bank_name=$fiche->getName();
00175 
00176             return array($customer_qc,$customer_name,$bank_qc,$bank_name);
00177         }
00178     }
00179 
00180 
00181 }
00182 
00183 class PDFLand extends PDF
00184 {
00185 
00186     public function __construct ($p_cn = null, $orientation = 'P', $unit = 'mm', $format = 'A4')
00187     {
00188 
00189         if($p_cn == null) die("No database connection. Abort.");
00190         $this->bigger=0;
00191 
00192         parent::TFPDF('L', $unit, $format);
00193         date_default_timezone_set ('Europe/Paris');
00194         $this->AddFont('DejaVu','','DejaVuSans.ttf',true);
00195         $this->AddFont('DejaVu','B','DejaVuSans-Bold.ttf',true);
00196         $this->AddFont('DejaVu','BI','DejaVuSans-BoldOblique.ttf',true);
00197         $this->AddFont('DejaVuCond','','DejaVuSansCondensed.ttf',true);
00198         $this->AddFont('DejaVuCond','B','DejaVuSansCondensed-Bold.ttf',true);
00199         $this->AddFont('DejaVuCond','I','DejaVuSansCondensed-Oblique.ttf',true);
00200 
00201         $this->cn  = $p_cn;
00202         $this->own = new own($this->cn);
00203         $this->soc = $this->own->MY_NAME;
00204         $this->date = date('d.m.Y');
00205     }
00206     function Header()
00207     {
00208         //Arial bold 12
00209         $this->SetFont('DejaVu', 'B', 10);
00210         //Title
00211         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00212         //Line break
00213         $this->Ln(20);
00214     }
00215     function Footer()
00216     {
00217         //Position at 2 cm from bottom
00218         $this->SetY(-20);
00219         //Arial italic 8
00220         $this->SetFont('DejaVuCond', 'I', 8);
00221         //Page number
00222         $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
00223         $this->Ln(3);
00224         // Created by NOALYSS
00225         $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'C',false,'http://www.aevalys.eu');
00226 
00227     }
00228 }
00229 
00230 class PDFBalance_simple extends PDF
00231 {
00232     /**
00233      *@brief set_info(dossier,from poste,to poste, from periode, to periode)
00234      *@param $p_from_poste start = poste
00235      *@param $p_to_poste   end   = poste
00236      *@param $p_from       periode start
00237      *@param $p_to         periode end
00238      */
00239     function set_info($p_from_poste,$to_poste,$p_from,$p_to)
00240     {
00241         $this->dossier='Balance simple '.dossier::name();
00242         $this->from_poste=$p_from_poste;
00243         $this->to_poste=$to_poste;
00244         $this->from=$p_from;
00245         $this->to=$p_to;
00246     }
00247     function Header()
00248     {
00249         parent::Header();
00250         $this->SetFont('DejaVu','B',8);
00251         $titre=sprintf("Balance simple poste %s %s date %s %s",
00252                        $this->from_poste,
00253                        $this->to_poste,
00254                        $this->from,
00255                        $this->to);
00256         $this->Cell(0,7,$titre,1,0,'C');
00257 
00258         $this->Ln();
00259         $this->SetFont('DejaVu','',6);
00260         $this->Cell(20,7,'id','B');
00261         $this->Cell(90,7,'Poste Comptable','B');
00262         $this->Cell(20,7,'Débit','B',0,'L');
00263         $this->Cell(20,7,'Crédit','B',0,'L');
00264         $this->Cell(20,7,'Solde','B',0,'L');
00265         $this->Cell(20,7,'D/C','B',0,'L');
00266         $this->Ln();
00267 
00268     }
00269 }
 All Data Structures Namespaces Files Functions Variables Enumerations