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