noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
pdf.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@noalyss.eu
21
22/*!\file pdf.class.php
23 * \brief API for creating PDF, unicode, based on tfpdf
24 *@see TFPDF
25 */
26/*!
27 * \class PDF
28 * \brief API for creating PDF, unicode, based on tfpdf
29 *@see TFPDF
30 */
31
32
33class PDF extends PDF_Core
34{
35 var $cn = null;
36 var $own = null;
37 var $soc = "";
38 var $dossier = "n/a";
39 var $date = "";
40
41 function __construct(Database $p_cn , $orientation = 'P', $unit = 'mm', $format = 'A4')
42 {
43 $this->cn = $p_cn;
44
45 $this->own = new Noalyss_Parameter_Folder($this->cn);
46 $this->soc = $this->own->MY_NAME;
47 $this->date = date('d.m.Y');
48 parent::__construct($orientation,$unit,$format);
49 date_default_timezone_set ('Europe/Paris');
50 $this->SetCreator("Noalyss");
51 }
52 function setDossierInfo($dossier = "n/a")
53 {
54 $this->dossier = dossier::name()." ".$dossier;
55 }
56 function Header()
57 {
58 //Arial bold 12
59 $this->SetFont('DejaVu', 'B', 12);
60 //Title
61 parent::Cell(0,10,$this->dossier, 'B', 0, 'C');
62 //Line break
63 parent::Ln(20);
64 }
65 function Footer()
66 {
67 //Position at 2 cm from bottom
68 $this->SetY(-20);
69 //Arial italic 8
70 $this->SetFont('Arial', '', 8);
71 //Page number
72 parent::Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
73 parent::Ln(3);
74 // Created by NOALYSS
75 parent::Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
76 }
77 /**
78 *@brief retrieve the client name and quick_code
79 *@param $p_jr_id jrn.jr_id
80 *@param $p_jrn_type ledger type ACH VEN FIN
81 *@return array (0=>qcode,1=>name) or for FIN 0=>customer qc 1=>customer name 2=>bank qc 3=>bank name
82 *@see class_print_ledger_simple, class_print_ledger_simple_without_vat
83 */
84 function get_tiers($p_jr_id,$p_jrn_type)
85 {
86 if ( $p_jrn_type=='ACH' )
87 {
88 $array=$this->cn->get_array('SELECT
89 jrnx.j_grpt,
90 quant_purchase.qp_supplier,
91 quant_purchase.qp_internal,
92 jrn.jr_internal
93 FROM
94 public.quant_purchase,
95 public.jrnx,
96 public.jrn
97 WHERE
98 quant_purchase.j_id = jrnx.j_id AND
99 jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1',array($p_jr_id));
100 if (count($array)==0) return array("ERREUR $p_jr_id",'');
101 $customer_id=$array[0]['qp_supplier'];
102 $fiche=new Fiche($this->cn,$customer_id);
103 $customer_qc=$fiche->get_quick_code($customer_id);
104 $customer_name=$fiche->getName();
105 return array($customer_qc,$customer_name);
106 }
107 if ( $p_jrn_type=='VEN' )
108 {
109 $array=$this->cn->get_array('SELECT
110 quant_sold.qs_client
111 FROM
112 public.quant_sold,
113 public.jrnx,
114 public.jrn
115 WHERE
116 quant_sold.j_id = jrnx.j_id AND
117 jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1',array($p_jr_id));
118 if (count($array)==0) return array("ERREUR $p_jr_id",'');
119 $customer_id=$array[0]['qs_client'];
120 $fiche=new Fiche($this->cn,$customer_id);
121 $customer_qc=$fiche->get_quick_code($customer_id);
122 $customer_name=$fiche->getName();
123 return array($customer_qc,$customer_name);
124 }
125 if ( $p_jrn_type=='FIN' )
126 {
127 $array=$this->cn->get_array('SELECT
128 qf_other,qf_bank
129 FROM
130 public.quant_fin
131 WHERE
132 quant_fin.jr_id =$1',array($p_jr_id));
133 if (count($array)==0) return array("ERREUR $p_jr_id",'','','');
134 $customer_id=$array[0]['qf_other'];
135 $fiche=new Fiche($this->cn,$customer_id);
136 $customer_qc=$fiche->get_quick_code($customer_id);
137 $customer_name=$fiche->getName();
138
139 $bank_id=$array[0]['qf_bank'];
140 $fiche=new Fiche($this->cn,$bank_id);
141 $bank_qc=$fiche->get_quick_code($bank_id);
142 $bank_name=$fiche->getName();
143
144 return array($customer_qc,$customer_name,$bank_qc,$bank_name);
145 }
146 }
147
149 {
150 if (in_array($filter_operation, ['all', 'paid', 'unpaid']))
151 {
152 $this->filter_operation=$filter_operation;
153 return $this;
154 }
155 throw new Exception(_("Filter invalide ".$filter_operation), 5);
156 }
157
158 /**
159 * @brief test the class
160 * @return void
161 */
162 static function test_me()
163 {
164 $cn=Dossier::connect();
165 $pdf=new PDF($cn);
166 $pdf->AddPage();
167 $pdf->SetFont('DejaVu', '', 8);
168 for ($i=0;$i <10;$i++){
169 $ln = $i*2+8;
170 $pdf->write_cell("50",$ln," heigh $ln ln $i",'1',$i);
171 $pdf->line_new();
172
173 }
174
175 $pdf->AddPage();
176 for ($i=0;$i <10;$i++){
177 $ln = $i*2+8;
178 $pdf->LongLine("100",3,"
179 Contrairement à une opinion répandue le Lorem Ipsum n'est pas simplement du texte aléatoire. Il trouve ses racines dans une oeuvre de la littérature latine classique datant de 45 av. J.-C., le rendant vieux de 2000 ans. Un professeur du Hampden-Sydney College, en Virginie, s'est intéressé à un des mots latins les plus obscurs, consectetur, extrait d'un passage du Lorem Ipsum, et en étudiant tous les usages de ce mot dans la littérature classique, découvrit la source incontestable du Lorem Ipsum. Il provient en fait des sections 1.10.32 et 1.10.33 du De Finibus Bonorum et Malorum (Des Suprêmes Biens et des Suprêmes Maux) de Cicéron. Cet ouvrage, très populaire pendant la Renaissance, est un traité sur la théorie de l'éthique. Les premières lignes du Lorem Ipsum, Lorem ipsum dolor sit amet.., proviennent de la section 1.10.32 heigh $ln ln $i",'1',$i);
180
181 $pdf->write_cell("50",$ln," heigh $ln ln $i",'1',$i,align:'C');
182 $pdf->line_new();
183
184 }
185
186
187 $pdf->Output('F','/tmp/a.pdf');
188 }
189
190}
$input_from cn
_("actif, passif,charge,...")
contains the class for connecting to Noalyss
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Class to manage the company parameter (address, name...)
API for creating PDF, unicode, based on tfpdf.
API for creating PDF, unicode, based on tfpdf.
Definition pdf.class.php:34
Header()
Definition pdf.class.php:56
get_tiers($p_jr_id, $p_jrn_type)
retrieve the client name and quick_code
Definition pdf.class.php:84
Footer()
Definition pdf.class.php:65
static test_me()
test the class
set_filter_operation($filter_operation)
$dossier
Definition pdf.class.php:38
setDossierInfo($dossier="n/a")
Definition pdf.class.php:52
__construct(Database $p_cn, $orientation='P', $unit='mm', $format='A4')
Definition pdf.class.php:41
$filter_operation