|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2021 Joe Nilson <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Lesser General Public License as |
|
7
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
8
|
|
|
* License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program 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 Lesser General Public License for more details. |
|
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
15
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
//require_once 'plugins/residentes/extras/fpdf183/fpdf.php'; |
|
19
|
|
|
include 'fpdf.php'; |
|
20
|
|
|
include 'NumberToLetterConverter.php'; |
|
21
|
|
|
//include 'exfpdf.php'; |
|
22
|
|
|
//include 'EasyTable.php'; |
|
23
|
|
|
|
|
24
|
|
|
class ResidentesFpdf extends FPDF |
|
25
|
|
|
{ |
|
26
|
|
|
public $max_lines; |
|
27
|
|
|
public $font; |
|
28
|
|
|
public $logo; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct($orientation = 'P', $unit = 'mm', $size = 'A4', $font = 'Verdana') |
|
31
|
|
|
{ |
|
32
|
|
|
parent::__construct($orientation, $unit, $size); |
|
33
|
|
|
$this->SetFont($font, '', 10); |
|
34
|
|
|
$this->setMaxLines($size); |
|
35
|
|
|
$this->SetAutoPagebreak(false); |
|
36
|
|
|
$this->SetMargins(0, 0, 0); |
|
37
|
|
|
$this->font = $font; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function setMaxLines($pageSize) |
|
41
|
|
|
{ |
|
42
|
|
|
switch ($pageSize) { |
|
43
|
|
|
case 'A4': |
|
44
|
|
|
$this->max_lines = 35; |
|
45
|
|
|
break; |
|
46
|
|
|
case 'letter': |
|
47
|
|
|
default: |
|
48
|
|
|
$this->max_lines = 30; |
|
49
|
|
|
break; |
|
50
|
|
|
case 'A5': |
|
51
|
|
|
$this->max_lines = 7; |
|
52
|
|
|
break; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setPdfLogo() |
|
57
|
|
|
{ |
|
58
|
|
|
if (!file_exists(FS_MYDOCS . 'images') && !mkdir($concurrentDirectory = FS_MYDOCS . 'images', 0777, true) && !is_dir($concurrentDirectory)) { |
|
|
|
|
|
|
59
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Antes se guardaba el logo en el temporal. |
|
64
|
|
|
* Mala decisión, lo movemos. |
|
65
|
|
|
*/ |
|
66
|
|
|
if (file_exists('tmp/' . FS_TMP_NAME . 'logo.png')) { |
|
|
|
|
|
|
67
|
|
|
rename('tmp/' . FS_TMP_NAME . 'logo.png', FS_MYDOCS . 'images/logo.png'); |
|
68
|
|
|
} elseif (file_exists('tmp/' . FS_TMP_NAME . 'logo.jpg')) { |
|
69
|
|
|
rename('tmp/' . FS_TMP_NAME . 'logo.jpg', FS_MYDOCS . 'images/logo.jpg'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$this->logo = false; |
|
73
|
|
|
if (file_exists(FS_MYDOCS . 'images/logo.png')) { |
|
74
|
|
|
$this->logo = FS_MYDOCS . 'images/logo.png'; |
|
75
|
|
|
} elseif (file_exists(FS_MYDOCS . 'images/logo.jpg')) { |
|
76
|
|
|
$this->logo = FS_MYDOCS . 'images/logo.jpg'; |
|
77
|
|
|
} |
|
78
|
|
|
if ($this->logo) { |
|
79
|
|
|
$this->Image($this->logo, 5, 5, 30); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function setDocumentHeaderInfo($documentHeader) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->SetFont($this->font, "B", 8); |
|
86
|
|
|
$this->SetLineWidth(0.1); |
|
87
|
|
|
$localHeight = 8; |
|
88
|
|
|
$localTopLine = 8; |
|
89
|
|
|
$localSpaceBetweenLine = 5; |
|
90
|
|
|
$localLine = 1; |
|
91
|
|
|
$this->SetXY(140, $localTopLine); |
|
92
|
|
|
$this->Cell(60, 8, $documentHeader['codigo'], 0, 0, 'C'); |
|
93
|
|
|
$localHeight += 4; |
|
94
|
|
|
$this->SetXY(140, $localTopLine+($localSpaceBetweenLine*$localLine)); |
|
95
|
|
|
$this->Cell(60, 8, $documentHeader['numero2'], 0, 0, 'C'); |
|
96
|
|
|
$localHeight += 4; |
|
97
|
|
|
$localLine++; |
|
98
|
|
|
$this->SetXY(140, $localTopLine+($localSpaceBetweenLine*$localLine)); |
|
99
|
|
|
if (isset($documentHeader['tiponcf'])) { |
|
100
|
|
|
$this->Cell(60, 8, $documentHeader['tiponcf'], 0, 0, 'C'); |
|
101
|
|
|
$localHeight += 4; |
|
102
|
|
|
$localLine++; |
|
103
|
|
|
$this->SetXY(140, $localTopLine+($localSpaceBetweenLine*$localLine)); |
|
104
|
|
|
if (substr($documentHeader['numero2'], -10, 2) !== '02') { |
|
105
|
|
|
$this->Cell(60, 8, "Valido hasta el: ".$documentHeader['vencimientoncf'], 0, 0, 'C'); |
|
106
|
|
|
$localHeight += 4; |
|
107
|
|
|
$localLine++; |
|
108
|
|
|
$this->SetXY(140, $localTopLine*$localSpaceBetweenLine*$localLine); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
$this->Cell(60, 8, "Fecha: " . $documentHeader['fecha'], 0, 0, 'C'); |
|
112
|
|
|
$localHeight += 4; |
|
113
|
|
|
$this->Rect(140, $localTopLine, 60, $localHeight, "D"); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function setDocumentFooterInfo($documentFooter) |
|
117
|
|
|
{ |
|
118
|
|
|
$x = 10; |
|
119
|
|
|
$y = 104; |
|
120
|
|
|
$this->SetLineWidth(0.1); |
|
121
|
|
|
$this->Rect($x, $y, 95, 6, "D"); |
|
122
|
|
|
// Subtotal, Impuestos y Total |
|
123
|
|
|
$number_to_words = new NumberToLetterConverter(); |
|
124
|
|
|
$words = $number_to_words->to_word($documentFooter['neto'], 'DOP'); |
|
125
|
|
|
$subtotal = "Son: " . $words; |
|
126
|
|
|
$this->SetFont($this->font, '', 8); |
|
127
|
|
|
$this->SetXY($x, $y); |
|
128
|
|
|
$this->Cell(95, 8, $subtotal, 0, 0, 'L'); |
|
129
|
|
|
// el total |
|
130
|
|
|
// |
|
131
|
|
|
// $this->SetXY($x, $y+25); |
|
132
|
|
|
// $this->Cell(24, 6, number_format($documentFooter['total'], FS_NF0, FS_NF1, FS_NF2), 0, 0, 'R'); |
|
133
|
|
|
|
|
134
|
|
|
// trait vertical cadre totaux, 8 de hauteur -> 213 + 8 = 221 |
|
135
|
|
|
$this->SetFont($this->font, 'B', 8); |
|
136
|
|
|
$this->Rect($x, $y+6, 95, 6, "D"); |
|
137
|
|
|
// Forma de Pago |
|
138
|
|
|
$this->SetXY($x, $y+6); |
|
139
|
|
|
$this->Cell(38, 5, "Forma de Pago:", 0, 0, 'L'); |
|
140
|
|
|
$this->Cell(55, 5, utf8_decode($documentFooter['codpago']), 0, 0, 'L'); |
|
141
|
|
|
// Fecha de Vencimiento |
|
142
|
|
|
//$date_ech = date_format($documentFooter['vencimiento'], 'd/m/Y'); |
|
143
|
|
|
|
|
144
|
|
|
$this->Rect($x, $y+12, 95, 6, "D"); |
|
145
|
|
|
$this->SetXY($x, $y+12); |
|
146
|
|
|
$this->Cell(38, 5, "Fecha de Vencimiento:", 0, 0, 'R'); |
|
147
|
|
|
$this->Cell(38, 5, $documentFooter['vencimiento'], 0, 0, 'L'); |
|
148
|
|
|
|
|
149
|
|
|
$this->SetFont($this->font, "BU", 8); |
|
150
|
|
|
$this->SetXY($x, $y+30); |
|
151
|
|
|
$this->Cell($this->GetStringWidth("Observaciones"), 0, "Observaciones", 0, "L"); |
|
152
|
|
|
$this->SetFont($this->font, "", 8); |
|
153
|
|
|
$this->SetXY($x, $y+35); |
|
154
|
|
|
$this->MultiCell(190, 4, utf8_decode($documentFooter['observaciones']), 0, "L"); |
|
155
|
|
|
//$y += 5; |
|
156
|
|
|
$this->setDocumentFooterTotalsBase($x, $y); |
|
157
|
|
|
$this->setDocumentFooterTotalsData($documentFooter, $x, $y); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function setDocumentFooterCompanyText($companyText = 'Por definir') |
|
161
|
|
|
{ |
|
162
|
|
|
$this->SetLineWidth(0.1); |
|
163
|
|
|
$this->Rect(5, 260, 200, 6, "D"); |
|
164
|
|
|
$this->SetXY(1, 260); |
|
165
|
|
|
$this->SetFont($this->font, '', 7); |
|
166
|
|
|
$this->Cell($this->GetPageWidth(), 7, $companyText, 0, 0, 'C'); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function setDocumentFooterTotalsBase($x, $y) |
|
170
|
|
|
{ |
|
171
|
|
|
$x += 130; |
|
172
|
|
|
$this->SetLineWidth(0.1); |
|
173
|
|
|
$this->Rect($x, $y, 60, (5*5), "D"); |
|
174
|
|
|
// // Lineas Verticales |
|
175
|
|
|
// $this->Line(147, 221, 147, 245); |
|
176
|
|
|
// $this->Line(164, 221, 164, 245); |
|
177
|
|
|
// $this->Line(181, 221, 181, 245); |
|
178
|
|
|
// // Lineas Horizontales |
|
179
|
|
|
// $this->Line(130, 227, 205, 227); |
|
180
|
|
|
// $this->Line(130, 233, 205, 233); |
|
181
|
|
|
// $this->Line(130, 239, 205, 239); |
|
182
|
|
|
// La tabla de información de subototal y total |
|
183
|
|
|
$this->SetFont($this->font, 'B', 8); |
|
184
|
|
|
$this->SetXY($x, $y); |
|
185
|
|
|
$this->Cell(30, 6, "Importe", 0, 0, 'R'); |
|
186
|
|
|
$this->SetXY($x, $y+5); |
|
187
|
|
|
$this->Cell(30, 6, "Descuento", 0, 0, 'R'); |
|
188
|
|
|
$this->SetXY($x, $y+10); |
|
189
|
|
|
$this->Cell(30, 6, "Subtotal", 0, 0, 'R'); |
|
190
|
|
|
$this->SetXY($x, $y+15); |
|
191
|
|
|
$this->Cell(30, 6, FS_IVA, 0, 0, 'R'); |
|
|
|
|
|
|
192
|
|
|
$this->SetXY($x, $y+20); |
|
193
|
|
|
$this->Cell(30, 6, "Total", 0, 0, 'R'); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function setDocumentFooterTotalsData($documentFooter, $x, $y) |
|
197
|
|
|
{ |
|
198
|
|
|
$x += 160; |
|
199
|
|
|
$this->SetXY($x, $y); |
|
200
|
|
|
//var_dump($documentFooter); |
|
201
|
|
|
$this->Cell(30, 6, number_format($documentFooter['total_antes_descuento'], FS_NF0, FS_NF1, FS_NF2), 0, 0, 'R'); |
|
|
|
|
|
|
202
|
|
|
$taux = $documentFooter['neto']; |
|
203
|
|
|
|
|
204
|
|
|
$totalDescuento = number_format($documentFooter['total_descuento'], FS_NF0, FS_NF1, FS_NF2); |
|
205
|
|
|
$this->SetXY($x, $y+5); |
|
206
|
|
|
$this->Cell(30, 6, $totalDescuento, 0, 0, 'R'); |
|
207
|
|
|
|
|
208
|
|
|
$col_ht = $documentFooter['totaliva']; |
|
209
|
|
|
$col_tva = $col_ht - ($col_ht * (1-($taux/100))); |
|
210
|
|
|
$totalImpuesto = number_format($col_tva, FS_NF0, FS_NF1, FS_NF2); |
|
211
|
|
|
$totalNeto = number_format($documentFooter['neto'], FS_NF0, FS_NF1, FS_NF2); |
|
212
|
|
|
$this->SetXY($x, $y+10); |
|
213
|
|
|
$this->Cell(30, 6, $totalNeto, 0, 0, 'R'); |
|
214
|
|
|
$this->SetXY($x, $y+15); |
|
215
|
|
|
$this->Cell(30, 6, $totalImpuesto, 0, 0, 'R'); |
|
216
|
|
|
|
|
217
|
|
|
$col_ttc = $documentFooter['total']; |
|
218
|
|
|
$totalGeneral = number_format($col_ttc, 2, ',', ' '); |
|
219
|
|
|
$this->SetXY($x, $y+20); |
|
220
|
|
|
$this->Cell(30, 6, $totalGeneral, 0, 0, 'R'); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public function setPdfCustomerHeader($x, $y, $tipoDocumentoFiscal) |
|
224
|
|
|
{ |
|
225
|
|
|
//var_dump($customerInfo); |
|
226
|
|
|
$this->SetFont($this->font, 'B', 8); |
|
227
|
|
|
$this->SetXY($x, $y); |
|
228
|
|
|
$this->Cell(25, 8, utf8_decode("Residente:"), 0, 0, 'R'); |
|
229
|
|
|
$this->SetXY($x+100, $y); |
|
230
|
|
|
$this->Cell(25, 8, utf8_decode($tipoDocumentoFiscal.":"), 0, 0, 'R'); |
|
231
|
|
|
$y += 4; |
|
232
|
|
|
$this->SetXY($x, $y); |
|
233
|
|
|
$this->Cell(25, 8, utf8_decode("Dirección:"), 0, 0, 'R'); |
|
234
|
|
|
$this->SetXY($x+100, $y); |
|
235
|
|
|
$this->Cell(25, 8, utf8_decode("Teléfono:"), 0, 0, 'R'); |
|
236
|
|
|
$y += 4; |
|
237
|
|
|
$this->SetXY($x, $y); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function setPdfCustomerInfo($customerInfo) |
|
241
|
|
|
{ |
|
242
|
|
|
//var_dump($customerInfo); |
|
243
|
|
|
$x = 30; |
|
244
|
|
|
$y = 40; |
|
245
|
|
|
$this->Line(10, $y, $this->GetPageWidth() - 10, $y); |
|
246
|
|
|
$this->setPdfCustomerHeader(5, $y, $customerInfo['tipoidfiscal']); |
|
247
|
|
|
$this->SetFont($this->font, '', 8); |
|
248
|
|
|
$this->SetXY($x, $y); |
|
249
|
|
|
$this->Cell(100, 8, utf8_decode($customerInfo['nombre']), 0, 0, ''); |
|
250
|
|
|
$this->Cell(100, 8, utf8_decode($customerInfo['cifnif']), 0, 0, ''); |
|
251
|
|
|
$y += 4; |
|
252
|
|
|
$this->SetXY($x, $y); |
|
253
|
|
|
$this->Cell(100, 8, utf8_decode($customerInfo['direccion']), 0, 0, ''); |
|
254
|
|
|
$this->Cell(100, 8, $customerInfo['telefono1'], 0, 0, ''); |
|
255
|
|
|
$y += 4; |
|
256
|
|
|
$y += 4; |
|
257
|
|
|
$this->SetXY($x, $y); |
|
258
|
|
|
//$y += 4; |
|
259
|
|
|
$this->Line(10, $y, $this->GetPageWidth() - 10, $y); |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function setPdfSubHeaderCompany($pdf) |
|
263
|
|
|
{ |
|
264
|
|
|
$pdf->SetLineWidth(0.1); |
|
265
|
|
|
$pdf->Rect(5, 95, 200, 118, "D"); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
public function setDocumentLinesHeader($x, $y) |
|
269
|
|
|
{ |
|
270
|
|
|
$this->SetLineWidth(0.1); |
|
271
|
|
|
$this->Rect(10, $y, 190, ($this->max_lines*7), "D"); |
|
272
|
|
|
$this->Line(10, $y+5, 200, $y+5); |
|
273
|
|
|
//Lineas Verticales |
|
274
|
|
|
$arrayLineas = [105, 120, 140, 160, 180]; |
|
275
|
|
|
foreach ($arrayLineas as $lineaX) { |
|
276
|
|
|
$this->Line($lineaX, $y, $lineaX, $y+($this->max_lines*7)); |
|
277
|
|
|
} |
|
278
|
|
|
$arrayDatosLineas = ["Descripción", "Cantidad", "Precio", "Descuento", FS_IVA, "Importe"]; |
|
|
|
|
|
|
279
|
|
|
$arrayAnchoLineas = [95, 15, 20, 20, 20, 20]; |
|
280
|
|
|
//Cabeceras |
|
281
|
|
|
$this->SetXY($x, $y); |
|
282
|
|
|
$this->SetFont($this->font, 'B', 8); |
|
283
|
|
|
$cantidadLineas = count($arrayDatosLineas); |
|
284
|
|
|
for ($i = 0; $i < $cantidadLineas; $i++) { |
|
285
|
|
|
$this->Cell($arrayAnchoLineas[$i], 5, utf8_decode($arrayDatosLineas[$i]), 0, 0, 'C'); |
|
286
|
|
|
if (isset($arrayLineas[$i])) { |
|
287
|
|
|
$this->SetXY($arrayLineas[$i], $y); |
|
288
|
|
|
} |
|
289
|
|
|
} |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
public function setDocumentLinesInfo($documentLines, $pageNumber, $numberOfPages) |
|
293
|
|
|
{ |
|
294
|
|
|
$x = 10; |
|
295
|
|
|
$y = 55; |
|
296
|
|
|
$this->setDocumentLinesHeader($x, $y); |
|
297
|
|
|
$this->SetFont($this->font, '', 8); |
|
298
|
|
|
//We calculate where the FOR function must start |
|
299
|
|
|
$i = ($pageNumber * $this->max_lines) - ($this->max_lines); |
|
300
|
|
|
$linesSubtotal = 0; |
|
301
|
|
|
for ($i; $i < ($pageNumber * $this->max_lines); $i++) { |
|
302
|
|
|
if (isset($documentLines[$i])) { |
|
303
|
|
|
$this->SetXY($x, $y+5); |
|
304
|
|
|
$line = $documentLines[$i]; |
|
305
|
|
|
$linesSubtotal += $line['pvptotal']; |
|
306
|
|
|
$this->Cell(95, 5, utf8_decode($line['descripcion']), 0, 0, 'L'); |
|
307
|
|
|
// qte |
|
308
|
|
|
$this->SetXY(105, $y+6); |
|
309
|
|
|
$this->Cell(15, 5, strrev(wordwrap(strrev($line['cantidad']), 3, ' ', true)), 0, 0, 'R'); |
|
310
|
|
|
// PU |
|
311
|
|
|
$numero_formateado = number_format($line['pvpunitario'], FS_NF0, FS_NF1, FS_NF2); |
|
|
|
|
|
|
312
|
|
|
$this->SetXY(120, $y+6); |
|
313
|
|
|
$this->Cell(20, 5, $numero_formateado, 0, 0, 'R'); |
|
314
|
|
|
//Descuento |
|
315
|
|
|
$numero_formateado = number_format(($line['pvpsindto'] - $line['pvptotal']), FS_NF0, FS_NF1, FS_NF2); |
|
316
|
|
|
$this->SetXY(140, $y+6); |
|
317
|
|
|
$this->Cell(20, 5, $numero_formateado, 0, 0, 'R'); |
|
318
|
|
|
// Impuesto |
|
319
|
|
|
$numero_formateado = number_format($line['iva'], FS_NF0, FS_NF1, FS_NF2); |
|
320
|
|
|
$this->SetXY(160, $y+6); |
|
321
|
|
|
$this->Cell(20, 5, $numero_formateado, 0, 0, 'R'); |
|
322
|
|
|
// total |
|
323
|
|
|
$numero_formateado = number_format($line['pvptotal'], FS_NF0, FS_NF1, FS_NF2); |
|
324
|
|
|
$this->SetXY(180, $y+6); |
|
325
|
|
|
$this->Cell(20, 5, $numero_formateado, 0, 0, 'R'); |
|
326
|
|
|
//$this->Line($x, $y+13, 200, $y+13); |
|
327
|
|
|
$y += 6; |
|
328
|
|
|
} |
|
329
|
|
|
} |
|
330
|
|
|
$this->setDocumentLinesSubtotal($linesSubtotal, $pageNumber, $numberOfPages, $x, ($y+($this->max_lines))); |
|
331
|
|
|
$this->setDocumentPageNumber($pageNumber, $numberOfPages); |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
public function setDocumentLinesSubtotal($linesSubtotal, $pageNumber, $numberOfPages, $x, $y) |
|
335
|
|
|
{ |
|
336
|
|
|
if ($pageNumber !== $numberOfPages) { |
|
337
|
|
|
$x += 130; |
|
338
|
|
|
$this->SetLineWidth(0.1); |
|
339
|
|
|
$this->Rect($x, $y, 60, 6, "D"); |
|
340
|
|
|
$this->SetFont($this->font, '', 8); |
|
341
|
|
|
$this->SetXY($x, $y); |
|
342
|
|
|
$this->Cell(30, 6, utf8_decode("Subtotal página: "), 0, 0, 'R'); |
|
343
|
|
|
$this->SetXY($x+30, $y); |
|
344
|
|
|
$this->Cell(30, 6, number_format($linesSubtotal, FS_NF0, FS_NF1, FS_NF2), 0, 0, 'R'); |
|
|
|
|
|
|
345
|
|
|
} |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
public function setDocumentPageNumber($pageNumber, $numberOfPages) |
|
349
|
|
|
{ |
|
350
|
|
|
$x = $this->GetPageHeight(); |
|
351
|
|
|
$y = $this->GetPageWidth()-70; |
|
352
|
|
|
//print_r($x); |
|
353
|
|
|
$this->SetXY($x, $y); |
|
354
|
|
|
$this->SetFont($this->font, 'B', 7); |
|
355
|
|
|
$this->Cell(52, 5, utf8_decode("Página " . $pageNumber . " de " . $numberOfPages), 0, 0, 'R'); |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
public function setCompanyInfo($companyInfo) |
|
359
|
|
|
{ |
|
360
|
|
|
$y1 = 8; |
|
361
|
|
|
$x1 = ($this->logo) ? 35 : 1; |
|
362
|
|
|
$localLineHeight = 4; |
|
363
|
|
|
//var_dump($companyInfo); |
|
364
|
|
|
$this->SetXY($x1, $y1); |
|
365
|
|
|
$this->SetFont($this->font, 'B', 9); |
|
366
|
|
|
$this->Cell($this->GetPageWidth(), 5, utf8_decode($companyInfo['nombre']), 0, 0, 'L'); |
|
367
|
|
|
$this->SetFont($this->font, '', 7); |
|
368
|
|
|
$this->SetXY($x1, $y1 + $localLineHeight); |
|
369
|
|
|
$this->Cell($this->GetPageWidth(), 5, utf8_decode($companyInfo['cifnif']), 0, 0, 'L'); |
|
370
|
|
|
$localLineHeight += 4; |
|
371
|
|
|
$this->SetXY($x1, $y1 + $localLineHeight); |
|
372
|
|
|
$this->Cell($this->GetPageWidth(), 5, utf8_decode($companyInfo['direccion']), 0, 0, 'L'); |
|
373
|
|
|
$localLineHeight += 4; |
|
374
|
|
|
$this->SetXY($x1, $y1 + $localLineHeight); |
|
375
|
|
|
$this->Cell($this->GetPageWidth(), 5, utf8_decode($companyInfo['telefono']), 0, 0, 'L'); |
|
376
|
|
|
$localLineHeight += 4; |
|
377
|
|
|
$this->SetXY($x1, $y1 + $localLineHeight); |
|
378
|
|
|
$this->Cell($this->GetPageWidth(), 5, utf8_decode($companyInfo['web']) . ' - ' . |
|
379
|
|
|
utf8_decode($companyInfo['email']), 0, 0, 'L'); |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
public function createDocument($companyInformation, $documentHeader, $documentLines, $customerInfo) |
|
383
|
|
|
{ |
|
384
|
|
|
$numberOfPages = (int) ceil(count($documentLines)/$this->max_lines); |
|
385
|
|
|
// var_dump($this->max_lines); |
|
386
|
|
|
// var_dump(count($documentLines)); |
|
387
|
|
|
// var_dump($numberOfPages); |
|
388
|
|
|
for ($pageNumber=0; $pageNumber < $numberOfPages; $pageNumber++) { |
|
389
|
|
|
$this->AddPage(); |
|
390
|
|
|
$this->setPdfLogo(); |
|
391
|
|
|
$this->setCompanyInfo($companyInformation); |
|
392
|
|
|
$this->setPdfCustomerInfo($customerInfo); |
|
393
|
|
|
$this->setDocumentHeaderInfo($documentHeader); |
|
394
|
|
|
$this->setDocumentLinesInfo($documentLines, $pageNumber+1, $numberOfPages); |
|
395
|
|
|
if ($pageNumber === ($numberOfPages-1)) { |
|
396
|
|
|
$this->setDocumentFooterInfo($documentHeader); |
|
397
|
|
|
$this->setDocumentFooterCompanyText($companyInformation['pie_factura']); |
|
398
|
|
|
} |
|
399
|
|
|
} |
|
400
|
|
|
} |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
//class PDF_MC_Table extends FPDF |
|
404
|
|
|
//{ |
|
405
|
|
|
// public $datoscab; |
|
406
|
|
|
// public $widths; |
|
407
|
|
|
// public $aligns; |
|
408
|
|
|
// public $colores; |
|
409
|
|
|
// public $extgstates = array(); |
|
410
|
|
|
// public $angle=0; |
|
411
|
|
|
// public $lineaactual = 0; |
|
412
|
|
|
// public $piepagina = false; |
|
413
|
|
|
// public $logo; |
|
414
|
|
|
// //Adición de grupos de páginas |
|
415
|
|
|
// //Origen: http://fpdf.de/downloads/addons/57/ |
|
416
|
|
|
// public $NewPageGroup; // variable indicating whether a new group was requested |
|
417
|
|
|
// public $PageGroups; // variable containing the number of pages of the groups |
|
418
|
|
|
// public $CurrPageGroup; // variable containing the alias of the current page group |
|
419
|
|
|
// |
|
420
|
|
|
// /** |
|
421
|
|
|
// * Ver marca de agua en la factura |
|
422
|
|
|
// * @var string 1|0 |
|
423
|
|
|
// */ |
|
424
|
|
|
// public $fdf_vermarcaagua; |
|
425
|
|
|
// public function Setdatoscab($v) |
|
426
|
|
|
// { |
|
427
|
|
|
// //Set the array |
|
428
|
|
|
// $this->datoscab=$v; |
|
429
|
|
|
// } |
|
430
|
|
|
// |
|
431
|
|
|
// public function SetWidths($w) |
|
432
|
|
|
// { |
|
433
|
|
|
// //Set the array |
|
434
|
|
|
// $this->widths=$w; |
|
435
|
|
|
// } |
|
436
|
|
|
// |
|
437
|
|
|
// public function SetAligns($a) |
|
438
|
|
|
// { |
|
439
|
|
|
// //Set the array |
|
440
|
|
|
// $this->aligns=$a; |
|
441
|
|
|
// } |
|
442
|
|
|
// |
|
443
|
|
|
// public function SetColors($a) |
|
444
|
|
|
// { |
|
445
|
|
|
// $contador = count($a); |
|
446
|
|
|
// for ($i=0; $i<$contador; $i++) |
|
447
|
|
|
// { |
|
448
|
|
|
// $datos = explode('|', $a[$i]); |
|
449
|
|
|
// $this->colores[$i][0] = $datos[0]; |
|
450
|
|
|
// $this->colores[$i][1] = $datos[1]; |
|
451
|
|
|
// $this->colores[$i][2] = $datos[2]; |
|
452
|
|
|
// } |
|
453
|
|
|
// } |
|
454
|
|
|
// |
|
455
|
|
|
// public function SetColorRelleno($a) |
|
456
|
|
|
// { |
|
457
|
|
|
// switch ($a) { |
|
458
|
|
|
// case 'rojo': |
|
459
|
|
|
// $this->SetFillColor(253, 120, 120); |
|
460
|
|
|
// break; |
|
461
|
|
|
// case 'verde': |
|
462
|
|
|
// $this->SetFillColor(120, 253, 165); |
|
463
|
|
|
// break; |
|
464
|
|
|
// case 'azul': |
|
465
|
|
|
// $this->SetFillColor(120, 158, 253); |
|
466
|
|
|
// break; |
|
467
|
|
|
// case 'blanco': |
|
468
|
|
|
// $this->SetFillColor(255, 255, 255); |
|
469
|
|
|
// break; |
|
470
|
|
|
// default: |
|
471
|
|
|
// if (substr($a, 0, 1)==='#') { |
|
472
|
|
|
// $rgb = $this->htmlColor2Hex($a); |
|
473
|
|
|
// $this->SetFillColor($rgb[0], $rgb[1], $rgb[2]); |
|
474
|
|
|
// } else { |
|
475
|
|
|
// $this->SetFillColor(192); |
|
476
|
|
|
// } |
|
477
|
|
|
// break; |
|
478
|
|
|
// } |
|
479
|
|
|
// } |
|
480
|
|
|
// |
|
481
|
|
|
// //Cabecera de pagina |
|
482
|
|
|
// public function Header() |
|
483
|
|
|
// { |
|
484
|
|
|
// // Datos de la empresa |
|
485
|
|
|
// $direccion = $this->fde_FS_CIFNIF . ": " . utf8_decode($this->fde_cifnif) . "\n" . $this->fde_direccion; |
|
486
|
|
|
// |
|
487
|
|
|
// if ($this->fde_codpostal && $this->fde_ciudad) { |
|
488
|
|
|
// $direccion .= ' - ' .$this->fde_codpostal . ' - ' . $this->fde_ciudad; |
|
489
|
|
|
// } else { |
|
490
|
|
|
// if ($this->fde_codpostal) { |
|
491
|
|
|
// $direccion .= "\n" . $this->fde_codpostal; |
|
492
|
|
|
// } |
|
493
|
|
|
// if ($this->fde_ciudad) { |
|
494
|
|
|
// $direccion .= "\n" . $this->fde_ciudad; |
|
495
|
|
|
// } |
|
496
|
|
|
// } |
|
497
|
|
|
// if ($this->fde_provincia) { |
|
498
|
|
|
// $direccion .= ' (' . $this->fde_provincia . ')'; |
|
499
|
|
|
// } |
|
500
|
|
|
// if ($this->fde_telefono) { |
|
501
|
|
|
// $direccion .= "\n" . $this->fde_telefono; |
|
502
|
|
|
// } |
|
503
|
|
|
// if ($this->fde_fax) { |
|
504
|
|
|
// $direccion .= " - " . $this->fde_fax; |
|
505
|
|
|
// } |
|
506
|
|
|
// |
|
507
|
|
|
// $this->addSociete(utf8_decode($this->fde_nombre), utf8_decode($direccion), utf8_decode($this->fde_email), utf8_decode($this->fde_web)); |
|
508
|
|
|
// |
|
509
|
|
|
// //Logotipo |
|
510
|
|
|
// $this->logo = false; |
|
511
|
|
|
// if ($this->fdf_verlogotipo == '1') { |
|
512
|
|
|
// if (!file_exists(FS_MYDOCS.'images')) { |
|
513
|
|
|
// @mkdir(FS_MYDOCS.'images', 0777, true); |
|
514
|
|
|
// } |
|
515
|
|
|
// |
|
516
|
|
|
// /** |
|
517
|
|
|
// * Antes se guardaba el logo en el temporal. |
|
518
|
|
|
// * Mala decisión, lo movemos. |
|
519
|
|
|
// */ |
|
520
|
|
|
// if (file_exists('tmp/'.FS_TMP_NAME.'logo.png')) { |
|
521
|
|
|
// rename('tmp/'.FS_TMP_NAME.'logo.png', FS_MYDOCS.'images/logo.png'); |
|
522
|
|
|
// } elseif (file_exists('tmp/'.FS_TMP_NAME.'logo.jpg')) { |
|
523
|
|
|
// rename('tmp/'.FS_TMP_NAME.'logo.jpg', FS_MYDOCS.'images/logo.jpg'); |
|
524
|
|
|
// } |
|
525
|
|
|
// |
|
526
|
|
|
// |
|
527
|
|
|
// if (file_exists(FS_MYDOCS.'images/logo.png')) { |
|
528
|
|
|
// $this->logo = FS_MYDOCS.'images/logo.png'; |
|
529
|
|
|
// } elseif (file_exists(FS_MYDOCS.'images/logo.jpg')) { |
|
530
|
|
|
// $this->logo = FS_MYDOCS.'images/logo.jpg'; |
|
531
|
|
|
// } |
|
532
|
|
|
// if($this->logo !== false){ |
|
533
|
|
|
// $this->Image($this->logo, $this->fdf_Xlogotipo, $this->fdf_Ylogotipo, 35); |
|
534
|
|
|
// $this->Ln(0); |
|
535
|
|
|
// } |
|
536
|
|
|
// } |
|
537
|
|
|
// |
|
538
|
|
|
// //Marca de agua |
|
539
|
|
|
// if ($this->fdf_vermarcaagua == '1' && $this->logo !== false) { |
|
540
|
|
|
// // set alpha to semi-transparency |
|
541
|
|
|
// $this->SetAlpha(0.05); |
|
542
|
|
|
// // draw png image |
|
543
|
|
|
// $this->Image($this->logo, $this->fdf_Xmarcaagua, $this->fdf_Ymarcaagua, 160); |
|
544
|
|
|
// // restore full opacity |
|
545
|
|
|
// $this->SetAlpha(1); |
|
546
|
|
|
// $this->Ln(0); |
|
547
|
|
|
// } |
|
548
|
|
|
// |
|
549
|
|
|
// if ($this->fdf_verSelloPagado == '1') { |
|
550
|
|
|
// $this->sello_pagado = false; |
|
551
|
|
|
// if (file_exists(FS_PATH.'plugins/republica_dominicana/extras/images/sello_pagado.png')) { |
|
552
|
|
|
// $this->sello_pagado = FS_PATH.'plugins/republica_dominicana/extras/images/sello_pagado.png'; |
|
553
|
|
|
// $this->Image($this->sello_pagado, $this->fdf_Xsellopagado, $this->fdf_Ysellopagado, 80); |
|
554
|
|
|
// $this->Ln(0); |
|
555
|
|
|
// } |
|
556
|
|
|
// } |
|
557
|
|
|
// |
|
558
|
|
|
// // Tipo de Documento y Numero |
|
559
|
|
|
// $this->datos_documento($this->fdf_documento, $this->fdf_tipodocumento, $this->fdf_estado, $this->fdf_tipodocumento_vencimiento); |
|
560
|
|
|
// |
|
561
|
|
|
// // Fecha factura y Codigo Cliente |
|
562
|
|
|
// $this->addDate($this->fdf_fecha); |
|
563
|
|
|
// $this->addPageNumber($this->GroupPageNo().' de '.$this->PageGroupAlias()); |
|
564
|
|
|
// |
|
565
|
|
|
// // Datos del Cliente |
|
566
|
|
|
// $this->addClienteInfo(); |
|
567
|
|
|
// if (!empty($this->fdf_transporte) or !empty($this->fdf_ruta)) { |
|
568
|
|
|
// $this->addTransporte(utf8_decode($this->fdf_transporte), utf8_decode($this->fdf_ruta)); |
|
569
|
|
|
// } |
|
570
|
|
|
// $this->SetFont('Arial', '', 7); |
|
571
|
|
|
// $this->SetY(-8); |
|
572
|
|
|
// $this->SetLineWidth(0.1); |
|
573
|
|
|
// $this->SetTextColor(0); |
|
574
|
|
|
// $this->Cell(0, 4, utf8_decode($this->fde_piefactura), 0, 0, "C"); |
|
575
|
|
|
// |
|
576
|
|
|
// // Cabecera Titulos Columnas |
|
577
|
|
|
// $this->SetXY(10, 75); |
|
578
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
579
|
|
|
// if ($this->fdf_cabecera_tcolor) { |
|
580
|
|
|
// $rgb = $this->htmlColor2Hex($this->fdf_cabecera_tcolor); |
|
581
|
|
|
// $this->SetTextColor($rgb[0], $rgb[1], $rgb[2]); |
|
582
|
|
|
// } |
|
583
|
|
|
// $contador_dc = count($this->datoscab); |
|
584
|
|
|
// for ($i=0;$i<$contador_dc;$i++) { |
|
585
|
|
|
// $this->Cell($this->widths[$i], 5, $this->datoscab[$i], 1, 0, 'C', 1); |
|
586
|
|
|
// } |
|
587
|
|
|
// $this->SetTextColor(0); |
|
588
|
|
|
// // Cuerpo de la Factura |
|
589
|
|
|
// $this->Ln(); |
|
590
|
|
|
// $aquiY = $this->GetY() + 0.6; |
|
591
|
|
|
// $this->SetY($aquiY); |
|
592
|
|
|
// $aquiX = $this->GetX(); |
|
593
|
|
|
// |
|
594
|
|
|
// $this->SetDrawColor(0, 0, 0); |
|
595
|
|
|
// $this->SetTextColor(0); |
|
596
|
|
|
// //El marco que se dibujara de items |
|
597
|
|
|
// $totalItems = 140; |
|
598
|
|
|
// for ($i=0;$i<$contador_dc;$i++) { |
|
599
|
|
|
// if ($this->fdf_detalle_box == '1') { |
|
600
|
|
|
// $this->Rect($aquiX, ($aquiY), $this->widths[$i], $totalItems, 'D'); |
|
601
|
|
|
// } |
|
602
|
|
|
// $aquiX += $this->widths[$i]; |
|
603
|
|
|
// } |
|
604
|
|
|
// } |
|
605
|
|
|
// |
|
606
|
|
|
// public function Firmas() |
|
607
|
|
|
// { |
|
608
|
|
|
// //Posicion: a 3 cm del final |
|
609
|
|
|
// $this->SetY(-40); |
|
610
|
|
|
// $this->SetLineWidth(0.1); |
|
611
|
|
|
// $this->SetTextColor(0); |
|
612
|
|
|
// $this->SetFont('Arial', '', 8); |
|
613
|
|
|
// $length = 80; |
|
614
|
|
|
// $this->Line(10, $this->h - 15, 80, $this->h - 15); |
|
615
|
|
|
// $this->SetXY(10, $this->h - 13); |
|
616
|
|
|
// $this->Cell($length, 4, str_pad("Firma Cliente", $length, " ", STR_PAD_BOTH)); |
|
617
|
|
|
// $this->Line(120, $this->h - 15, 200, $this->h - 15); |
|
618
|
|
|
// $this->SetXY(120, $this->h - 13); |
|
619
|
|
|
// $this->Cell($length, 4, str_pad("Firma Emisor", $length, " ", STR_PAD_BOTH)); |
|
620
|
|
|
// } |
|
621
|
|
|
// //Pie de pagina |
|
622
|
|
|
// public function Footer() |
|
623
|
|
|
// { |
|
624
|
|
|
// $this->Firmas(); |
|
625
|
|
|
// //Posicion: a 3 cm del final |
|
626
|
|
|
// $this->SetY(-30); |
|
627
|
|
|
// $this->SetLineWidth(0.1); |
|
628
|
|
|
// $this->SetTextColor(0); |
|
629
|
|
|
// $this->SetFont('Arial', '', 8); |
|
630
|
|
|
// if ($this->piepagina) { |
|
631
|
|
|
// // Si existen Incluimos las Observaciones |
|
632
|
|
|
// if ($this->fdf_observaciones != '') { |
|
633
|
|
|
// $this->addObservaciones(substr($this->fdf_observaciones, 0, 116)); |
|
634
|
|
|
// } |
|
635
|
|
|
// |
|
636
|
|
|
// // Total factura |
|
637
|
|
|
// $this->addTotal(); |
|
638
|
|
|
// } else { |
|
639
|
|
|
// // Neto por Pagina |
|
640
|
|
|
// $this->addNeto(); |
|
641
|
|
|
// } |
|
642
|
|
|
// } |
|
643
|
|
|
// |
|
644
|
|
|
// public function Row($data, $ultimo='1', $cantidad_lineas = 0) |
|
645
|
|
|
// { |
|
646
|
|
|
// $this->SetFont('Verdana', '', 7); |
|
647
|
|
|
// |
|
648
|
|
|
// // Guardamos la posicion Actual |
|
649
|
|
|
// $x=$this->GetX(); |
|
650
|
|
|
// $y=$this->GetY(); |
|
651
|
|
|
// // Imprimimos solo los campos numericos |
|
652
|
|
|
// $contador_cb = count($this->datoscab); |
|
653
|
|
|
// $contador_data = count($data); |
|
654
|
|
|
// for ($i=0;$i<$contador_data;$i++) { |
|
655
|
|
|
// if ($i != $ultimo) { // La descripcion del articulo la trataremos la ultima. Aqui no. |
|
656
|
|
|
// $w=$this->widths[$i]; |
|
657
|
|
|
// if ($i == ($ultimo-1)) { |
|
658
|
|
|
// $x1 = $x+$w; |
|
659
|
|
|
// $x += $this->widths[$ultimo]+$w; |
|
660
|
|
|
// } else { |
|
661
|
|
|
// $x += $w; |
|
662
|
|
|
// } |
|
663
|
|
|
// // Seleccionar Alineacion |
|
664
|
|
|
// $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; |
|
665
|
|
|
// // Seleccionar color |
|
666
|
|
|
// $this->SetTextColor(0); |
|
667
|
|
|
// if (isset($this->colores[$i][0])) { |
|
668
|
|
|
// $this->SetTextColor($this->colores[$i][0], $this->colores[$i][1], $this->colores[$i][2]); |
|
669
|
|
|
// } |
|
670
|
|
|
// // Escribimos el texto |
|
671
|
|
|
// $this->MultiCell($w, 5, $data[$i], 0, $a); |
|
672
|
|
|
// // Fijamos la posicion a la derecha de la celda |
|
673
|
|
|
// $this->SetXY($x, $y); |
|
674
|
|
|
// } |
|
675
|
|
|
// } |
|
676
|
|
|
// |
|
677
|
|
|
// // En Ultimo lugar escribimos La descripcion del articulo |
|
678
|
|
|
// $this->SetXY($x1, $y); |
|
679
|
|
|
// $w=$this->widths[$ultimo]; |
|
680
|
|
|
// $a=isset($this->aligns[$ultimo]) ? $this->aligns[$ultimo] : 'L'; |
|
681
|
|
|
// |
|
682
|
|
|
// $this->MultiCell($w, 5, $data[$ultimo], 0, $a); |
|
683
|
|
|
// |
|
684
|
|
|
// // Calcular la altura MAXIMA de la fila e ir a la siguiente línea |
|
685
|
|
|
// $nb = 0; |
|
686
|
|
|
// $totalLineas = 28; |
|
687
|
|
|
// for ($i=0;$i<$contador_data;$i++) { |
|
688
|
|
|
// $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i])); |
|
689
|
|
|
// } |
|
690
|
|
|
// if ((($this->lineaactual + $nb) > $totalLineas) and $cantidad_lineas > 1) { // Mas de una Pagina |
|
691
|
|
|
// $this->AddPage($this->CurOrientation); |
|
692
|
|
|
// $this->lineaactual = 0; |
|
693
|
|
|
// } else { |
|
694
|
|
|
// if ((($this->lineaactual + $nb) == $totalLineas) and $cantidad_lineas > 1) { // Pagina completa |
|
695
|
|
|
// $this->AddPage($this->CurOrientation); |
|
696
|
|
|
// $this->lineaactual = 0; |
|
697
|
|
|
// } else { |
|
698
|
|
|
// $this->lineaactual = $this->lineaactual + $nb; // Una sola Pagina |
|
699
|
|
|
// } |
|
700
|
|
|
// } |
|
701
|
|
|
// |
|
702
|
|
|
// $h = 5 * $this->lineaactual; |
|
703
|
|
|
// $this->Ln($h); |
|
704
|
|
|
// $this->SetY(80+$h); // Y=100 en base a la altura de la cabecera |
|
705
|
|
|
// |
|
706
|
|
|
// // Dibujamos una Linea Gris para separar los Articulos |
|
707
|
|
|
// $aquiX=$this->GetX()+0.155; |
|
708
|
|
|
// $aquiY=$this->GetY(); |
|
709
|
|
|
// $this->SetDrawColor(200, 200, 200); |
|
710
|
|
|
// for ($i=0;$i<$contador_cb;$i++) { |
|
711
|
|
|
// $finX = $this->widths[$i]+$aquiX - 0.316; |
|
712
|
|
|
// $this->Line($aquiX, $aquiY, $finX, $aquiY); |
|
713
|
|
|
// $aquiX = $finX + 0.316; |
|
714
|
|
|
// } |
|
715
|
|
|
// $this->SetDrawColor(0, 0, 0); |
|
716
|
|
|
// $this->SetTextColor(0); |
|
717
|
|
|
// } |
|
718
|
|
|
// |
|
719
|
|
|
// public function NbLines($w, $txt) |
|
720
|
|
|
// { |
|
721
|
|
|
// //Computes the number of lines a MultiCell of width w will take |
|
722
|
|
|
// $cw=&$this->CurrentFont['cw']; |
|
723
|
|
|
// if ($w==0) { |
|
724
|
|
|
// $w=$this->w-$this->rMargin-$this->x; |
|
725
|
|
|
// } |
|
726
|
|
|
// $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
727
|
|
|
// $s=str_replace("\r", '', $txt); |
|
728
|
|
|
// $nb=strlen($s); |
|
729
|
|
|
// if ($nb>0 and $s[$nb-1]=="\n") { |
|
730
|
|
|
// $nb--; |
|
731
|
|
|
// } |
|
732
|
|
|
// $sep=-1; |
|
733
|
|
|
// $i=0; |
|
734
|
|
|
// $j=0; |
|
735
|
|
|
// $l=0; |
|
736
|
|
|
// $nl=1; |
|
737
|
|
|
// while ($i < $nb) { |
|
738
|
|
|
// $c = $s[$i]; |
|
739
|
|
|
// if ($c == "\n") { |
|
740
|
|
|
// $i++; |
|
741
|
|
|
// $sep = -1; |
|
742
|
|
|
// $j = $i; |
|
743
|
|
|
// $l = 0; |
|
744
|
|
|
// $nl++; |
|
745
|
|
|
// continue; |
|
746
|
|
|
// } |
|
747
|
|
|
// if ($c == ' ') { |
|
748
|
|
|
// $sep = $i; |
|
749
|
|
|
// } |
|
750
|
|
|
// $l += $cw[$c]; |
|
751
|
|
|
// if ($l > $wmax) { |
|
752
|
|
|
// if ($sep == -1) { |
|
753
|
|
|
// if ($i == $j) { |
|
754
|
|
|
// $i++; |
|
755
|
|
|
// } |
|
756
|
|
|
// } else { |
|
757
|
|
|
// $i = $sep + 1; |
|
758
|
|
|
// } |
|
759
|
|
|
// $sep = -1; |
|
760
|
|
|
// $j = $i; |
|
761
|
|
|
// $l = 0; |
|
762
|
|
|
// $nl++; |
|
763
|
|
|
// } else { |
|
764
|
|
|
// $i++; |
|
765
|
|
|
// } |
|
766
|
|
|
// } |
|
767
|
|
|
// return $nl; |
|
768
|
|
|
// } |
|
769
|
|
|
// |
|
770
|
|
|
// /** |
|
771
|
|
|
// * @deprecated since version 101 |
|
772
|
|
|
// * @param type $x |
|
773
|
|
|
// * @param type $y |
|
774
|
|
|
// * @param type $w |
|
775
|
|
|
// * @param type $h |
|
776
|
|
|
// * @param type $r |
|
777
|
|
|
// * @param type $style |
|
778
|
|
|
// */ |
|
779
|
|
|
// public function RoundedRect($x, $y, $w, $h, $r, $style = '') |
|
780
|
|
|
// { |
|
781
|
|
|
// $k = $this->k; |
|
782
|
|
|
// $hp = $this->h; |
|
783
|
|
|
// if ($style=='F') { |
|
784
|
|
|
// $op='f'; |
|
785
|
|
|
// } elseif ($style=='FD' or $style=='DF') { |
|
786
|
|
|
// $op='B'; |
|
787
|
|
|
// } else { |
|
788
|
|
|
// $op='S'; |
|
789
|
|
|
// } |
|
790
|
|
|
// $MyArc = 4/3 * (sqrt(2) - 1); |
|
791
|
|
|
// $this->_out(sprintf('%.2f %.2f m', ($x+$r)*$k, ($hp-$y)*$k)); |
|
792
|
|
|
// $xc = $x+$w-$r ; |
|
793
|
|
|
// $yc = $y+$r; |
|
794
|
|
|
// $this->_out(sprintf('%.2f %.2f l', $xc*$k, ($hp-$y)*$k)); |
|
795
|
|
|
// |
|
796
|
|
|
// $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); |
|
797
|
|
|
// $xc = $x+$w-$r ; |
|
798
|
|
|
// $yc = $y+$h-$r; |
|
799
|
|
|
// $this->_out(sprintf('%.2f %.2f l', ($x+$w)*$k, ($hp-$yc)*$k)); |
|
800
|
|
|
// $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); |
|
801
|
|
|
// $xc = $x+$r ; |
|
802
|
|
|
// $yc = $y+$h-$r; |
|
803
|
|
|
// $this->_out(sprintf('%.2f %.2f l', $xc*$k, ($hp-($y+$h))*$k)); |
|
804
|
|
|
// $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); |
|
805
|
|
|
// $xc = $x+$r ; |
|
806
|
|
|
// $yc = $y+$r; |
|
807
|
|
|
// $this->_out(sprintf('%.2f %.2f l', ($x)*$k, ($hp-$yc)*$k)); |
|
808
|
|
|
// $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); |
|
809
|
|
|
// $this->_out($op); |
|
810
|
|
|
// } |
|
811
|
|
|
// |
|
812
|
|
|
// public function _Arc($x1, $y1, $x2, $y2, $x3, $y3) |
|
813
|
|
|
// { |
|
814
|
|
|
// $h = $this->h; |
|
815
|
|
|
// $this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k, |
|
816
|
|
|
// $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); |
|
817
|
|
|
// } |
|
818
|
|
|
// |
|
819
|
|
|
// // Uso: |
|
820
|
|
|
// // set alpha to semi-transparency |
|
821
|
|
|
// // $pdf->SetAlpha(0.5, 'Lighten'); |
|
822
|
|
|
// // draw jpeg image |
|
823
|
|
|
// // $pdf->Image('imagen.jpg',30,30,40); |
|
824
|
|
|
// // restore full opacity |
|
825
|
|
|
// // $pdf->SetAlpha(1); |
|
826
|
|
|
// // |
|
827
|
|
|
// // class AlphaPDF |
|
828
|
|
|
// |
|
829
|
|
|
// // alpha: real value from 0 (transparent) to 1 (opaque) |
|
830
|
|
|
// // bm: blend mode, one of the following: |
|
831
|
|
|
// // Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, |
|
832
|
|
|
// // HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity |
|
833
|
|
|
// public function SetAlpha($alpha, $bm='Normal') |
|
834
|
|
|
// { |
|
835
|
|
|
// // set alpha for stroking (CA) and non-stroking (ca) operations |
|
836
|
|
|
// $gs = $this->AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm)); |
|
837
|
|
|
// $this->SetExtGState($gs); |
|
838
|
|
|
// } |
|
839
|
|
|
// |
|
840
|
|
|
// public function AddExtGState($parms) |
|
841
|
|
|
// { |
|
842
|
|
|
// $n = count($this->extgstates)+1; |
|
843
|
|
|
// $this->extgstates[$n]['parms'] = $parms; |
|
844
|
|
|
// return $n; |
|
845
|
|
|
// } |
|
846
|
|
|
// |
|
847
|
|
|
// public function SetExtGState($gs) |
|
848
|
|
|
// { |
|
849
|
|
|
// $this->_out(sprintf('/GS%d gs', $gs)); |
|
850
|
|
|
// } |
|
851
|
|
|
// |
|
852
|
|
|
// public function _enddoc() |
|
853
|
|
|
// { |
|
854
|
|
|
// if (!empty($this->extgstates) && $this->PDFVersion<'1.4') { |
|
855
|
|
|
// $this->PDFVersion='1.4'; |
|
856
|
|
|
// } |
|
857
|
|
|
// parent::_enddoc(); |
|
858
|
|
|
// } |
|
859
|
|
|
// |
|
860
|
|
|
// public function _putextgstates() |
|
861
|
|
|
// { |
|
862
|
|
|
// $counter_extgstates = count($this->extgstates); |
|
863
|
|
|
// for ($i = 1; $i <= $counter_extgstates; $i++) { |
|
864
|
|
|
// $this->_newobj(); |
|
865
|
|
|
// $this->extgstates[$i]['n'] = $this->n; |
|
866
|
|
|
// $this->_out('<</Type /ExtGState'); |
|
867
|
|
|
// $parms = $this->extgstates[$i]['parms']; |
|
868
|
|
|
// $this->_out(sprintf('/ca %.3F', $parms['ca'])); |
|
869
|
|
|
// $this->_out(sprintf('/CA %.3F', $parms['CA'])); |
|
870
|
|
|
// $this->_out('/BM '.$parms['BM']); |
|
871
|
|
|
// $this->_out('>>'); |
|
872
|
|
|
// $this->_out('endobj'); |
|
873
|
|
|
// } |
|
874
|
|
|
// } |
|
875
|
|
|
// |
|
876
|
|
|
// public function _putresourcedict() |
|
877
|
|
|
// { |
|
878
|
|
|
// parent::_putresourcedict(); |
|
879
|
|
|
// $this->_out('/ExtGState <<'); |
|
880
|
|
|
// foreach ($this->extgstates as $k=>$extgstate) { |
|
881
|
|
|
// $this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R'); |
|
882
|
|
|
// } |
|
883
|
|
|
// $this->_out('>>'); |
|
884
|
|
|
// } |
|
885
|
|
|
// |
|
886
|
|
|
// public function _putresources() |
|
887
|
|
|
// { |
|
888
|
|
|
// $this->_putextgstates(); |
|
889
|
|
|
// parent::_putresources(); |
|
890
|
|
|
// } |
|
891
|
|
|
// // END-class AlphaPDF |
|
892
|
|
|
// |
|
893
|
|
|
// // Girar Texto o Imagen |
|
894
|
|
|
// public function RotatedText($x, $y, $txt, $angle) |
|
895
|
|
|
// { |
|
896
|
|
|
// //Text rotated around its origin |
|
897
|
|
|
// $this->Rotate($angle, $x, $y); |
|
898
|
|
|
// $this->Text($x, $y, $txt); |
|
899
|
|
|
// $this->Rotate(0); |
|
900
|
|
|
// } |
|
901
|
|
|
// |
|
902
|
|
|
// public function RotatedImage($file, $x, $y, $w, $h, $angle) |
|
903
|
|
|
// { |
|
904
|
|
|
// //Image rotated around its upper-left corner |
|
905
|
|
|
// $this->Rotate($angle, $x, $y); |
|
906
|
|
|
// $this->Image($file, $x, $y, $w, $h); |
|
907
|
|
|
// $this->Rotate(0); |
|
908
|
|
|
// } |
|
909
|
|
|
// |
|
910
|
|
|
// public function Rotate($angle, $x=-1, $y=-1) |
|
911
|
|
|
// { |
|
912
|
|
|
// if ($x==-1) { |
|
913
|
|
|
// $x=$this->x; |
|
914
|
|
|
// } |
|
915
|
|
|
// if ($y==-1) { |
|
916
|
|
|
// $y=$this->y; |
|
917
|
|
|
// } |
|
918
|
|
|
// if ($this->angle!=0) { |
|
919
|
|
|
// $this->_out('Q'); |
|
920
|
|
|
// } |
|
921
|
|
|
// $this->angle=$angle; |
|
922
|
|
|
// if ($angle!=0) { |
|
923
|
|
|
// $angle*=M_PI/180; |
|
924
|
|
|
// $c=cos($angle); |
|
925
|
|
|
// $s=sin($angle); |
|
926
|
|
|
// $cx=$x*$this->k; |
|
927
|
|
|
// $cy=($this->h-$y)*$this->k; |
|
928
|
|
|
// $this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy)); |
|
929
|
|
|
// } |
|
930
|
|
|
// } |
|
931
|
|
|
// |
|
932
|
|
|
// public function _endpage() |
|
933
|
|
|
// { |
|
934
|
|
|
// if ($this->angle!=0) { |
|
935
|
|
|
// $this->angle=0; |
|
936
|
|
|
// $this->_out('Q'); |
|
937
|
|
|
// } |
|
938
|
|
|
// parent::_endpage(); |
|
939
|
|
|
// } |
|
940
|
|
|
// // END - Girar Texto o Imagen |
|
941
|
|
|
// |
|
942
|
|
|
// // Factura |
|
943
|
|
|
// public function sizeOfText($texte, $largeur) |
|
944
|
|
|
// { |
|
945
|
|
|
// $index = 0; |
|
946
|
|
|
// $nb_lines = 0; |
|
947
|
|
|
// $loop = true; |
|
948
|
|
|
// while ($loop) { |
|
949
|
|
|
// $pos = strpos($texte, "\n"); |
|
950
|
|
|
// if (!$pos) { |
|
951
|
|
|
// $loop = false; |
|
952
|
|
|
// $ligne = $texte; |
|
953
|
|
|
// } else { |
|
954
|
|
|
// $ligne = substr($texte, $index, $pos); |
|
955
|
|
|
// $texte = substr($texte, $pos+1); |
|
956
|
|
|
// } |
|
957
|
|
|
// $length = floor($this->GetStringWidth($ligne)); |
|
958
|
|
|
// $res = 1 + floor($length / $largeur) ; |
|
959
|
|
|
// $nb_lines += $res; |
|
960
|
|
|
// } |
|
961
|
|
|
// return $nb_lines; |
|
962
|
|
|
// } |
|
963
|
|
|
// |
|
964
|
|
|
// public function htmlColor2Hex($hex) |
|
965
|
|
|
// { |
|
966
|
|
|
// list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); |
|
967
|
|
|
// return array($r, $g, $b); |
|
968
|
|
|
// } |
|
969
|
|
|
// |
|
970
|
|
|
// // Empresa |
|
971
|
|
|
// public function addSociete($nom, $adresse, $email, $web) |
|
972
|
|
|
// { |
|
973
|
|
|
// $x1 = ($this->fdf_verlogotipo == '1')?45:10; |
|
974
|
|
|
// $r1 = $x1; |
|
975
|
|
|
// $r2 = $r1 + 90; |
|
976
|
|
|
// $y1 = 8; |
|
977
|
|
|
// $this->SetXY($x1, $y1); |
|
978
|
|
|
// $this->SetTextColor(0); |
|
979
|
|
|
// $length1 = $this->GetStringWidth($nom); |
|
980
|
|
|
// $this->SetFont('Arial', 'B', ($length1>($r2 - $r1))?10:9); |
|
981
|
|
|
// $this->MultiCell(($r2 - $r1), 4, $nom, '0', 'L'); |
|
982
|
|
|
// $y1+=($this->getY()-$y1); |
|
983
|
|
|
// $this->SetXY($x1, $y1); |
|
984
|
|
|
// $this->SetFont("Arial", "", 8); |
|
985
|
|
|
// $this->MultiCell(($r2 - $r1), 4, $adresse); |
|
986
|
|
|
// $y1+=($this->getY()-$y1); |
|
987
|
|
|
// $this->SetXY($x1, $y1); |
|
988
|
|
|
// if ($email != '') { |
|
989
|
|
|
// $this->SetFont('Arial', '', 8); |
|
990
|
|
|
// $this->Write(5, 'Email: '); |
|
991
|
|
|
// $this->SetTextColor(0, 0, 255); |
|
992
|
|
|
// $this->Write(5, $email, 'mailto:' . $email); |
|
993
|
|
|
// $this->SetTextColor(0); |
|
994
|
|
|
// $this->SetFont(''); |
|
995
|
|
|
// } |
|
996
|
|
|
// |
|
997
|
|
|
// if ($web != '') { |
|
998
|
|
|
// $this->SetFont('Arial', '', 8); |
|
999
|
|
|
// $this->Write(5, ' - Web: '); |
|
1000
|
|
|
// $this->SetTextColor(0, 0, 255); |
|
1001
|
|
|
// $this->Write(5, $web, $web); |
|
1002
|
|
|
// $this->SetTextColor(0); |
|
1003
|
|
|
// $this->SetFont(''); |
|
1004
|
|
|
// } |
|
1005
|
|
|
// } |
|
1006
|
|
|
// |
|
1007
|
|
|
// public function datos_documento($documento, $tipo_documento, $estado, $fecha_vencimiento) |
|
1008
|
|
|
// { |
|
1009
|
|
|
// $r1 = $this->w - 80; |
|
1010
|
|
|
// $r2 = $r1 + 70; |
|
1011
|
|
|
// $y1 = 6; |
|
1012
|
|
|
// $y2 = $y1 + 20; |
|
1013
|
|
|
// if ($this->fdf_cabecera_tcolor) { |
|
1014
|
|
|
// $rgb = $this->htmlColor2Hex($this->fdf_cabecera_tcolor); |
|
1015
|
|
|
// $this->SetTextColor($rgb[0], $rgb[1], $rgb[2]); |
|
1016
|
|
|
// } |
|
1017
|
|
|
// $codigo = utf8_decode('Factura: ').$documento->codigo; |
|
1018
|
|
|
// $ncf = utf8_decode(ucfirst(FS_NUMERO2)).': '.$documento->ncf; |
|
1019
|
|
|
// $szfont = 9; |
|
1020
|
|
|
// $loop = 0; |
|
1021
|
|
|
// |
|
1022
|
|
|
// while ($loop == 0) { |
|
1023
|
|
|
// $this->SetFont("Arial", "B", $szfont); |
|
1024
|
|
|
// $sz = $this->GetStringWidth($ncf); |
|
1025
|
|
|
// if (($r1+$sz) > $r2) { |
|
1026
|
|
|
// $szfont--; |
|
1027
|
|
|
// } else { |
|
1028
|
|
|
// $loop++; |
|
1029
|
|
|
// } |
|
1030
|
|
|
// } |
|
1031
|
|
|
// |
|
1032
|
|
|
// $this->SetLineWidth(0.1); |
|
1033
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), $y2, 'DF'); |
|
1034
|
|
|
// $y1++; |
|
1035
|
|
|
// $this->SetXY($r1+1, $y1); |
|
1036
|
|
|
// $this->MultiCell($r2-$r1-1, 3, utf8_decode($tipo_documento), 0, "C"); |
|
1037
|
|
|
// $y1++; |
|
1038
|
|
|
// $y1++; |
|
1039
|
|
|
// $this->SetXY($r1+1, $y1+1); |
|
1040
|
|
|
// $this->Cell($r2-$r1 -1, 5, $ncf, 0, 0, "C"); |
|
1041
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1042
|
|
|
// $y1++; |
|
1043
|
|
|
// $y1++; |
|
1044
|
|
|
// $y1++; |
|
1045
|
|
|
// $this->SetXY($r1+1, $y1+2); |
|
1046
|
|
|
// $this->Cell($r2-$r1-1, 5, $codigo, 0, 0, "C"); |
|
1047
|
|
|
// $y1++; |
|
1048
|
|
|
// $y1++; |
|
1049
|
|
|
// $y1++; |
|
1050
|
|
|
// $this->SetXY($r1+1, $y1+4); |
|
1051
|
|
|
// if (empty($estado)) { |
|
1052
|
|
|
// if ($fecha_vencimiento) { |
|
1053
|
|
|
// $this->MultiCell($r2-$r1-1, 3, utf8_decode('Válida hasta: '.$fecha_vencimiento), 0, "C"); |
|
1054
|
|
|
// } |
|
1055
|
|
|
// } else { |
|
1056
|
|
|
// $this->MultiCell($r2-$r1-1, 3, 'Estado: '.$estado, 0, "C"); |
|
1057
|
|
|
// } |
|
1058
|
|
|
// $y1++; |
|
1059
|
|
|
// $y1++; |
|
1060
|
|
|
// $y1++; |
|
1061
|
|
|
// $y1++; |
|
1062
|
|
|
// if ($documento->ncf_afecta) { |
|
1063
|
|
|
// $this->SetXY($r1+1, $y1+3); |
|
1064
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1065
|
|
|
// $this->Cell(30, 5, "Rectifica: ", 0, 0, "R"); |
|
1066
|
|
|
// $this->SetFont("Arial", "", 9); |
|
1067
|
|
|
// $this->Cell(60, 5, $documento->ncf_afecta, 0, 0, "L"); |
|
1068
|
|
|
// } |
|
1069
|
|
|
// $this->SetTextColor(0); |
|
1070
|
|
|
// } |
|
1071
|
|
|
// |
|
1072
|
|
|
// // Nombre, numero y estado de la factura |
|
1073
|
|
|
// public function fact_dev($libelle, $num, $estado) |
|
1074
|
|
|
// { |
|
1075
|
|
|
// $r1 = $this->w - 80; |
|
1076
|
|
|
// $r2 = $r1 + 70; |
|
1077
|
|
|
// $y1 = 6; |
|
1078
|
|
|
// $y2 = $y1 + 7; |
|
1079
|
|
|
// $mid = ($r1 + $r2) / 2; |
|
1080
|
|
|
// |
|
1081
|
|
|
// $texte = 'NCF: ' . $num; |
|
1082
|
|
|
// $tipo_comprobante = $libelle; |
|
1083
|
|
|
// $szfont = 9; |
|
1084
|
|
|
// $loop = 0; |
|
1085
|
|
|
// |
|
1086
|
|
|
// while ($loop == 0) { |
|
1087
|
|
|
// $this->SetFont("Arial", "B", $szfont); |
|
1088
|
|
|
// $sz = $this->GetStringWidth($texte); |
|
1089
|
|
|
// if (($r1+$sz) > $r2) { |
|
1090
|
|
|
// $szfont --; |
|
1091
|
|
|
// } else { |
|
1092
|
|
|
// $loop ++; |
|
1093
|
|
|
// } |
|
1094
|
|
|
// } |
|
1095
|
|
|
// |
|
1096
|
|
|
// $this->SetLineWidth(0.1); |
|
1097
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), $y2, 'DF'); |
|
1098
|
|
|
// $this->SetXY($r1+1, $y1+2); |
|
1099
|
|
|
// $this->Cell($r2-$r1 -1, 5, $texte, 0, 0, "C"); |
|
1100
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1101
|
|
|
// $this->SetXY($r1+1, $y1+7); |
|
1102
|
|
|
// $this->MultiCell($r2-$r1-1, 3, $tipo_comprobante, 0, "C"); |
|
1103
|
|
|
// $this->SetXY($r1+1, $y1+7); |
|
1104
|
|
|
// $this->MultiCell($r2-$r1-1, 3, $estado, 0, "C"); |
|
1105
|
|
|
// } |
|
1106
|
|
|
// |
|
1107
|
|
|
// public function addDate($date) |
|
1108
|
|
|
// { |
|
1109
|
|
|
// $r1 = $this->w - 80; |
|
1110
|
|
|
// $r2 = $r1 + 70; |
|
1111
|
|
|
// $y1 = 27; |
|
1112
|
|
|
// $y2 = $y1+5; |
|
1113
|
|
|
// if ($this->fdf_cabecera_tcolor) { |
|
1114
|
|
|
// $rgb = $this->htmlColor2Hex($this->fdf_cabecera_tcolor); |
|
1115
|
|
|
// $this->SetTextColor($rgb[0], $rgb[1], $rgb[2]); |
|
1116
|
|
|
// } |
|
1117
|
|
|
// $this->SetXY($r1, $y1); |
|
1118
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'DF'); |
|
1119
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1120
|
|
|
// $this->Cell(20, 5, "Fecha: ", 0, 0, "L"); |
|
1121
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1122
|
|
|
// $this->Cell(10, 5, $date, 0, 0, "R"); |
|
1123
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1124
|
|
|
// $this->Cell(20, 5, "F. Pago: ", 0, 0, "L"); |
|
1125
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1126
|
|
|
// $this->Cell(20, 5, utf8_decode($this->fdf_epago), 0, 0, "R"); |
|
1127
|
|
|
// $this->SetTextColor(0); |
|
1128
|
|
|
// } |
|
1129
|
|
|
// |
|
1130
|
|
|
// //Transporte Asociado |
|
1131
|
|
|
// public function addTransporte($transporte, $codruta) |
|
1132
|
|
|
// { |
|
1133
|
|
|
// $r1 = $this->w - 80; |
|
1134
|
|
|
// $r2 = $r1 + 70; |
|
1135
|
|
|
// $y1 = 32; |
|
1136
|
|
|
// $y2 = $y1+5; |
|
1137
|
|
|
// if ($this->fdf_cabecera_tcolor) { |
|
1138
|
|
|
// $rgb = $this->htmlColor2Hex($this->fdf_cabecera_tcolor); |
|
1139
|
|
|
// $this->SetTextColor($rgb[0], $rgb[1], $rgb[2]); |
|
1140
|
|
|
// } |
|
1141
|
|
|
// $this->SetXY($r1, $y1); |
|
1142
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'DF'); |
|
1143
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1144
|
|
|
// $this->Cell(20, 5, "Ruta: ", 0, 0, "L"); |
|
1145
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1146
|
|
|
// $this->Cell(10, 5, $codruta, 0, 0, "R"); |
|
1147
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1148
|
|
|
// $this->Cell(25, 5, "Transporte: ", 0, 0, "L"); |
|
1149
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1150
|
|
|
// $this->Cell(15, 5, $transporte, 0, 0, "R"); |
|
1151
|
|
|
// $this->SetTextColor(0); |
|
1152
|
|
|
// } |
|
1153
|
|
|
// |
|
1154
|
|
|
// |
|
1155
|
|
|
// /** |
|
1156
|
|
|
// * //Ya no se utiliza |
|
1157
|
|
|
// * @deprecated |
|
1158
|
|
|
// * @param type $ref |
|
1159
|
|
|
// */ |
|
1160
|
|
|
// public function addClient($ref) |
|
1161
|
|
|
// { |
|
1162
|
|
|
// $r1 = $this->w - 50; |
|
1163
|
|
|
// $r2 = $r1 + 40; |
|
1164
|
|
|
// $y1 = 30; |
|
1165
|
|
|
// $y2 = $y1; |
|
1166
|
|
|
// $mid = $y1 + ($y2 / 3); |
|
1167
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), $y2-6, 'D'); |
|
1168
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1169
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 - 5, $y1+1); |
|
1170
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1171
|
|
|
// $this->Cell(10, 5, 'N'.chr(176).' de CLIENTE', 0, 0, "C"); |
|
1172
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 - 5, $y1 + 7); |
|
1173
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1174
|
|
|
// $this->Cell(10, 5, $ref, 0, 0, "C"); |
|
1175
|
|
|
// } |
|
1176
|
|
|
// |
|
1177
|
|
|
// public function addPageNumber($page) |
|
1178
|
|
|
// { |
|
1179
|
|
|
// $this->SetXY(($this->w-20)/2, $this->h - 14); |
|
1180
|
|
|
// $this->SetFont("Arial", "", 7); |
|
1181
|
|
|
// $this->Cell(10, 5, "- Pagina ".$page." -", 0, 0, "C"); |
|
1182
|
|
|
// } |
|
1183
|
|
|
// |
|
1184
|
|
|
// public function addClienteInfo() |
|
1185
|
|
|
// { |
|
1186
|
|
|
// $r1 = $this->w - 205; |
|
1187
|
|
|
// $r2 = $this->w - 10; |
|
1188
|
|
|
// $y1 = 45; |
|
1189
|
|
|
// //$y2 = $y1; |
|
1190
|
|
|
// $this->SetXY($r1, $y1); |
|
1191
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1192
|
|
|
// $this->Cell(25, 5, utf8_decode('Cliente:'), 0, 0, "R"); |
|
1193
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1194
|
|
|
// $this->Cell(120, 5, $this->fdf_codcliente. ' - '.utf8_decode($this->fdf_nombrecliente), 0, 0, "L"); |
|
1195
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1196
|
|
|
// $this->Cell(25, 5, utf8_decode($this->fdf_FS_CIFNIF.':'), 0, 0, "R"); |
|
1197
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1198
|
|
|
// $this->Cell(25, 5, $this->fdf_cifnif, 0, 0, "C"); |
|
1199
|
|
|
// $this->SetXY($r1, $y1+4); |
|
1200
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1201
|
|
|
// $this->Cell(25, 5, utf8_decode('Dirección:'), 0, 0, "R"); |
|
1202
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1203
|
|
|
// $this->MultiCell(120, 5, utf8_decode($this->fdf_direccion. " - ".$this->fdf_codpostal . " - ".$this->fdf_ciudad . " (".$this->fdf_provincia.")\n")); |
|
1204
|
|
|
// $y1++; |
|
1205
|
|
|
// $y1++; |
|
1206
|
|
|
// $y1++; |
|
1207
|
|
|
// $y1++; |
|
1208
|
|
|
// $y1++; |
|
1209
|
|
|
// $y1++; |
|
1210
|
|
|
// $y1++; |
|
1211
|
|
|
// $y1++; |
|
1212
|
|
|
// $y1++; |
|
1213
|
|
|
// $this->SetXY($r1, $y1+4); |
|
1214
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1215
|
|
|
// $this->Cell(25, 5, utf8_decode('Teléfonos:'), 0, 0, "R"); |
|
1216
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1217
|
|
|
// $telefonos = ''; |
|
1218
|
|
|
// if ($this->fdc_telefono1) { |
|
1219
|
|
|
// $telefonos.= $this->fdc_telefono1; |
|
1220
|
|
|
// } |
|
1221
|
|
|
// if ($this->fdc_telefono2) { |
|
1222
|
|
|
// $telefonos.= $this->fdc_telefono2; |
|
1223
|
|
|
// } |
|
1224
|
|
|
// $this->Cell(120, 5, $telefonos, 0, 0, "L"); |
|
1225
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1226
|
|
|
// $this->Cell(25, 5, utf8_decode('Fax:'), 0, 0, "R"); |
|
1227
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1228
|
|
|
// $this->Cell(30, 5, $this->fdc_fax, 0, 0, "L"); |
|
1229
|
|
|
// $y1++; |
|
1230
|
|
|
// $y1++; |
|
1231
|
|
|
// $y1++; |
|
1232
|
|
|
// $y1++; |
|
1233
|
|
|
// $this->SetXY($r1, $y1+4); |
|
1234
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1235
|
|
|
// $this->Cell(25, 5, utf8_decode('Email:'), 0, 0, "R"); |
|
1236
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1237
|
|
|
// $this->Cell(30, 5, $this->fdc_email, 0, 0, "L"); |
|
1238
|
|
|
// $y1++; |
|
1239
|
|
|
// $y1++; |
|
1240
|
|
|
// $y1++; |
|
1241
|
|
|
// $y1++; |
|
1242
|
|
|
// $this->SetXY($r1, $y1+4); |
|
1243
|
|
|
// $this->SetFont('Arial', 'B', 8); |
|
1244
|
|
|
// $this->Cell(25, 5, utf8_decode('Vendedor:'), 0, 0, "R"); |
|
1245
|
|
|
// $this->SetFont('Arial', '', 9); |
|
1246
|
|
|
// $this->Cell(120, 5, utf8_decode($this->fde_vendedor), 0, 0, "L"); |
|
1247
|
|
|
// if ($this->fdf_cliente_box =='1') { |
|
1248
|
|
|
// $this->Rect($r1-1, 43, ($r2 - ($r1-1)), 30, 'D'); |
|
1249
|
|
|
// } |
|
1250
|
|
|
// } |
|
1251
|
|
|
// |
|
1252
|
|
|
// // Cliente |
|
1253
|
|
|
// public function addClientAdresse($adresse) |
|
1254
|
|
|
// { |
|
1255
|
|
|
// $r1 = $this->w - 205; |
|
1256
|
|
|
// $y1 = 40; |
|
1257
|
|
|
// $this->SetXY($r1, $y1); |
|
1258
|
|
|
// $this->AddFont('Verdana'); |
|
1259
|
|
|
// $this->SetFont('Verdana', '', 8); |
|
1260
|
|
|
// $this->MultiCell(87, 4, $adresse); |
|
1261
|
|
|
// } |
|
1262
|
|
|
// |
|
1263
|
|
|
// |
|
1264
|
|
|
// |
|
1265
|
|
|
// // Ruta asociada si es que se va utilizar distribucion |
|
1266
|
|
|
// public function addRuta($ruta) |
|
1267
|
|
|
// { |
|
1268
|
|
|
// $r1 = 120; |
|
1269
|
|
|
// $r2 = $r1 + 30; |
|
1270
|
|
|
// $y1 = 65; |
|
1271
|
|
|
// $y2 = $y1+10; |
|
1272
|
|
|
// $mid = $y1 + (($y2-$y1) / 2); |
|
1273
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1274
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1275
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1+1); |
|
1276
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1277
|
|
|
// $this->Cell(10, 4, "RUTA", 0, 0, "C"); |
|
1278
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1 + 5); |
|
1279
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1280
|
|
|
// $this->Cell(10, 5, $ruta, 0, 0, "C"); |
|
1281
|
|
|
// } |
|
1282
|
|
|
// |
|
1283
|
|
|
// // Transporte Asociado |
|
1284
|
|
|
// public function addDocumentoRectifica($mode) |
|
1285
|
|
|
// { |
|
1286
|
|
|
// $r1 = 150; |
|
1287
|
|
|
// $r2 = $r1 + 50; |
|
1288
|
|
|
// $y1 = 65; |
|
1289
|
|
|
// $y2 = $y1+10; |
|
1290
|
|
|
// $mid = $y1 + (($y2-$y1) / 2); |
|
1291
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1292
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1293
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1+1); |
|
1294
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1295
|
|
|
// $this->Cell(10, 4, "AFECTA AL DOCUMENTO", 0, 0, "C"); |
|
1296
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1 + 5); |
|
1297
|
|
|
// $this->SetFont("Arial", "", 9); |
|
1298
|
|
|
// $this->Cell(10, 5, $mode, 0, 0, "C"); |
|
1299
|
|
|
// } |
|
1300
|
|
|
// |
|
1301
|
|
|
// // Forma de Pago |
|
1302
|
|
|
// public function addPago($mode) |
|
1303
|
|
|
// { |
|
1304
|
|
|
// $r1 = 150; |
|
1305
|
|
|
// $r2 = $r1 + 50; |
|
1306
|
|
|
// $y1 = 80; |
|
1307
|
|
|
// $y2 = $y1+10; |
|
1308
|
|
|
// $mid = $y1 + (($y2-$y1) / 2); |
|
1309
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1310
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1311
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1+1); |
|
1312
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1313
|
|
|
// $this->Cell(10, 4, "FORMA DE PAGO", 0, 0, "C"); |
|
1314
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 -5, $y1 + 5); |
|
1315
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1316
|
|
|
// $this->Cell(10, 5, $mode, 0, 0, "C"); |
|
1317
|
|
|
// } |
|
1318
|
|
|
// |
|
1319
|
|
|
// // Divisa |
|
1320
|
|
|
// public function addDivisa($divisa) |
|
1321
|
|
|
// { |
|
1322
|
|
|
// $r1 = 140; |
|
1323
|
|
|
// $r2 = $r1 + 30; |
|
1324
|
|
|
// $y1 = 80; |
|
1325
|
|
|
// $y2 = $y1+10; |
|
1326
|
|
|
// $mid = $y1 + (($y2-$y1) / 2); |
|
1327
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1328
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1329
|
|
|
// $this->SetXY($r1 + ($r2 - $r1)/2 - 5, $y1+1); |
|
1330
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1331
|
|
|
// $this->Cell(10, 4, "DIVISA", 0, 0, "C"); |
|
1332
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 - 5, $y1 + 5); |
|
1333
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1334
|
|
|
// $this->Cell(10, 5, $divisa, 0, 0, "C"); |
|
1335
|
|
|
// } |
|
1336
|
|
|
// |
|
1337
|
|
|
// // Pais |
|
1338
|
|
|
// public function addPais($pais) |
|
1339
|
|
|
// { |
|
1340
|
|
|
// $r1 = 170; |
|
1341
|
|
|
// $r2 = $r1 + 30; |
|
1342
|
|
|
// $y1 = 80; |
|
1343
|
|
|
// $y2 = $y1+10; |
|
1344
|
|
|
// $mid = $y1 + (($y2-$y1) / 2); |
|
1345
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1346
|
|
|
// $this->Line($r1, $mid, $r2, $mid); |
|
1347
|
|
|
// $this->SetXY($r1 + ($r2 - $r1)/2 - 5, $y1+1); |
|
1348
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1349
|
|
|
// $this->Cell(10, 4, "PAIS", '', '', "C"); |
|
1350
|
|
|
// $this->SetXY($r1 + ($r2-$r1)/2 - 5, $y1 + 5); |
|
1351
|
|
|
// $this->SetFont("Arial", "", 9); |
|
1352
|
|
|
// $this->Cell(10, 5, $pais, '', '', "C"); |
|
1353
|
|
|
// } |
|
1354
|
|
|
// |
|
1355
|
|
|
// // Incluir Observaciones |
|
1356
|
|
|
// public function addObservaciones($observa) |
|
1357
|
|
|
// { |
|
1358
|
|
|
// $this->SetFont("Arial", "I", 8); |
|
1359
|
|
|
// $length = $this->GetStringWidth("Observaciones: " . $observa); |
|
1360
|
|
|
// $this->SetXY(10, $this->h - 57.5); |
|
1361
|
|
|
// $this->Cell($length, 4, "Observaciones: " . $observa); |
|
1362
|
|
|
// } |
|
1363
|
|
|
// |
|
1364
|
|
|
// // Incluir Lineas de Iva |
|
1365
|
|
|
// public function addLineasIva($datos) |
|
1366
|
|
|
// { |
|
1367
|
|
|
// $r1 = 10; |
|
1368
|
|
|
// $y1 = $this->h - 50; |
|
1369
|
|
|
// $cantidad_datos = count($datos); |
|
1370
|
|
|
// if ($datos) { |
|
1371
|
|
|
// if ($cantidad_datos > 3) { |
|
1372
|
|
|
// // Comentar o eliminar las siguientes 5 lineas para NO mostrar el error. |
|
1373
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1374
|
|
|
// $this->SetXY($r1, $y1 + 8); |
|
1375
|
|
|
// $this->Cell(8, 4, "ERROR: Localizadas ".count($datos)." lineas de ".FS_IVA."... ", 0, '', "L"); |
|
1376
|
|
|
// $this->SetXY($r1, $y1 + 12); |
|
1377
|
|
|
// $this->Cell(8, 4, chr(161).chr(161).chr(161)." Esta plantilla SOLO puede detallar TRES lineas de ".FS_IVA." !!!", 0, '', "L"); |
|
1378
|
|
|
// } else { |
|
1379
|
|
|
// for ($i=1; $i <= $cantidad_datos; $i++) { |
|
1380
|
|
|
// $datos[$i][1]=($datos[$i][1]>0)?$datos[$i][1]*-1:$datos[$i][1]; |
|
1381
|
|
|
// if ($i == 1) { |
|
1382
|
|
|
// $y2 = $y1 + 6; |
|
1383
|
|
|
// } |
|
1384
|
|
|
// if ($i == 2) { |
|
1385
|
|
|
// $y2 = $y1 + 10; |
|
1386
|
|
|
// } |
|
1387
|
|
|
// if ($i == 3) { |
|
1388
|
|
|
// $y2 = $y1 + 14; |
|
1389
|
|
|
// } |
|
1390
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1391
|
|
|
// $this->SetXY($r1, $y2); |
|
1392
|
|
|
// $this->Cell(8, 4, $datos[$i][0], 0, '', "L"); |
|
1393
|
|
|
// $this->Cell(18, 4, $datos[$i][1], 0, '', "R"); |
|
1394
|
|
|
// $this->Cell(7, 4, $datos[$i][2], 0, '', "R"); |
|
1395
|
|
|
// $this->Cell(18, 4, $datos[$i][3], 0, '', "R"); |
|
1396
|
|
|
// $this->Cell(7, 4, $datos[$i][4], 0, '', "R"); |
|
1397
|
|
|
// $this->Cell(18, 4, $datos[$i][5], 0, '', "R"); |
|
1398
|
|
|
// $this->Cell(7, 4, $datos[$i][6], 0, '', "R"); |
|
1399
|
|
|
// $this->Cell(18, 4, $datos[$i][7], 0, '', "R"); |
|
1400
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1401
|
|
|
// $this->Cell(24, 4, $datos[$i][8], 0, '', "R"); |
|
1402
|
|
|
// } |
|
1403
|
|
|
// } |
|
1404
|
|
|
// } |
|
1405
|
|
|
// } |
|
1406
|
|
|
// |
|
1407
|
|
|
// public function addNeto() |
|
1408
|
|
|
// { |
|
1409
|
|
|
// $r1 = $this->w - 70; |
|
1410
|
|
|
// $r2 = $r1 + 60; |
|
1411
|
|
|
// $y1 = $this->h - 50; |
|
1412
|
|
|
// $y2 = $y1+20; |
|
1413
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 1.5, 'D'); |
|
1414
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1415
|
|
|
// $this->SetXY($r1, $y1); |
|
1416
|
|
|
// $this->Cell(60, 4, $this->fdf_divisa, 1, 0, "C"); |
|
1417
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1418
|
|
|
// $this->SetXY($r1, $y1+7); |
|
1419
|
|
|
// $this->Cell(15, 4, "NETO", 0, 0, "C"); |
|
1420
|
|
|
// |
|
1421
|
|
|
// // Total Neto de la pagina |
|
1422
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1423
|
|
|
// $this->SetXY($r1+16, $y1+6.5); |
|
1424
|
|
|
// $this->Cell(43, 4, $this->neto, 0, 0, "C"); |
|
1425
|
|
|
// |
|
1426
|
|
|
// // Suma y Sigue |
|
1427
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1428
|
|
|
// $this->SetXY($r1+16, $y1+13); |
|
1429
|
|
|
// $this->MultiCell(43, 3, '(SUMA y SIGUE)', 0, 'C'); |
|
1430
|
|
|
// } |
|
1431
|
|
|
// |
|
1432
|
|
|
// public function addTotal() |
|
1433
|
|
|
// { |
|
1434
|
|
|
// $this->SetFont("Arial", "B", 9); |
|
1435
|
|
|
// $rr1 = 10; |
|
1436
|
|
|
// $rr2 = $rr1 + 125; |
|
1437
|
|
|
// $yy1 = $this->h - 50; |
|
1438
|
|
|
// $yy2 = $yy1+20; |
|
1439
|
|
|
// $this->Rect($rr1, $yy1, ($rr2 - $rr1), ($yy2-$yy1), 'D'); |
|
1440
|
|
|
// $r1 = $this->w - 70; |
|
1441
|
|
|
// $r2 = $r1 + 60; |
|
1442
|
|
|
// $y1 = $this->h - 50; |
|
1443
|
|
|
// $y2 = $y1+22; |
|
1444
|
|
|
// $this->SetLineWidth(0.15); |
|
1445
|
|
|
// $this->Rect($r1, $y1, ($r2 - $r1), ($y2-$y1), 'D'); |
|
1446
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1447
|
|
|
// $this->SetXY($r1, $y1); |
|
1448
|
|
|
// $this->Cell(60, 4, $this->fdf_divisa, 1, 0, "C"); |
|
1449
|
|
|
// $this->SetXY($r1, $y1+5); |
|
1450
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1451
|
|
|
// $this->Cell(15, 4, "NETO", 0, 0, "R"); |
|
1452
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1453
|
|
|
// $this->Cell(43, 4, $this->fdf_documento_neto, 0, 0, "R"); |
|
1454
|
|
|
// $this->SetXY($r1, $y1+9); |
|
1455
|
|
|
// //$this->SetFont( "Arial", "B", 9); |
|
1456
|
|
|
// //$this->Cell(15,4, "DSCTO", 0, 0, "R"); |
|
1457
|
|
|
// //$this->SetFont( "Arial", "", 8); |
|
1458
|
|
|
// //$this->Cell(43,4, $this->fdf_documento_descuentos, 0, 0, "R"); |
|
1459
|
|
|
// $this->SetXY($r1, $y1+13); |
|
1460
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1461
|
|
|
// $this->Cell(15, 4, FS_IVA, 0, 0, "R"); |
|
1462
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1463
|
|
|
// $this->Cell(43, 4, $this->fdf_documento_totaliva, 0, 0, "R"); |
|
1464
|
|
|
// $this->SetXY($r1, $y1+17); |
|
1465
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1466
|
|
|
// $this->Cell(15, 4, "TOTAL", 0, 0, "R"); |
|
1467
|
|
|
// $this->SetFont("Arial", "", 8); |
|
1468
|
|
|
// $this->Cell(43, 4, $this->fdf_numtotal, 0, 0, "R"); |
|
1469
|
|
|
// $this->SetLineWidth(0.1); |
|
1470
|
|
|
// // Total factura en texto |
|
1471
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1472
|
|
|
// $this->SetXY(12, $y1+4); |
|
1473
|
|
|
// $texto = $this->numtoletras($this->fdf_textotal); |
|
1474
|
|
|
// $this->MultiCell(120, 3, "SON: ".$texto, 0, 'L'); |
|
1475
|
|
|
// $this->SetXY(10, $this->h - 33.5); |
|
1476
|
|
|
// $this->SetFont("Arial", "B", 8); |
|
1477
|
|
|
// $this->SetXY(10, $this->h - 33.5); |
|
1478
|
|
|
// if($this->fdf_pagada){ |
|
1479
|
|
|
// $this->Cell(120, 3, 'FACTURA PAGADA EL: '.$this->fdf_fecha_pagada, 0, 0, "R"); |
|
1480
|
|
|
// }else{ |
|
1481
|
|
|
// $this->Cell(120, 3, 'FACTURA VENCE EL: '.$this->fdf_vencimiento, 0, 0, "R"); |
|
1482
|
|
|
// } |
|
1483
|
|
|
// |
|
1484
|
|
|
// } |
|
1485
|
|
|
// |
|
1486
|
|
|
// //------ CONVERTIR NUMEROS A LETRAS --------------- |
|
1487
|
|
|
// //------ Máxima cifra soportada: 18 dígitos con 2 decimales |
|
1488
|
|
|
// //------ 999,999,999,999,999,999.99 |
|
1489
|
|
|
// // NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE con 99/100 |
|
1490
|
|
|
// public function numtoletras($xcifra1) |
|
1491
|
|
|
// { |
|
1492
|
|
|
// $xarray = array(0 => "Cero", |
|
1493
|
|
|
// 1 => "UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE", |
|
1494
|
|
|
// "DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISEIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE", |
|
1495
|
|
|
// "VEINTI", 30 => "TREINTA", 40 => "CUARENTA", 50 => "CINCUENTA", 60 => "SESENTA", 70 => "SETENTA", 80 => "OCHENTA", 90 => "NOVENTA", |
|
1496
|
|
|
// 100 => "CIENTO", 200 => "DOSCIENTOS", 300 => "TRESCIENTOS", 400 => "CUATROCIENTOS", 500 => "QUINIENTOS", 600 => "SEISCIENTOS", 700 => "SETECIENTOS", 800 => "OCHOCIENTOS", 900 => "NOVECIENTOS" |
|
1497
|
|
|
// ); |
|
1498
|
|
|
// // |
|
1499
|
|
|
// $xcifra2 = ($xcifra1<0)?($xcifra1*-1):$xcifra1; |
|
1500
|
|
|
// $xcifra = trim($xcifra2); |
|
1501
|
|
|
// $xlength = strlen($xcifra); |
|
1502
|
|
|
// $xpos_punto = strpos($xcifra, "."); |
|
1503
|
|
|
// $xaux_int = $xcifra; |
|
1504
|
|
|
// $xdecimales = "00"; |
|
1505
|
|
|
// if (!($xpos_punto === false)) { |
|
1506
|
|
|
// if ($xpos_punto == 0) { |
|
1507
|
|
|
// $xcifra = "0" . $xcifra; |
|
1508
|
|
|
// $xpos_punto = strpos($xcifra, "."); |
|
1509
|
|
|
// } |
|
1510
|
|
|
// $xaux_int = substr($xcifra, 0, $xpos_punto); // obtengo el entero de la cifra a convertir |
|
1511
|
|
|
// $xdecimales = substr($xcifra . "00", $xpos_punto + 1, 2); // obtengo los valores decimales |
|
1512
|
|
|
// } |
|
1513
|
|
|
// |
|
1514
|
|
|
// $XAUX = str_pad($xaux_int, 18, " ", STR_PAD_LEFT); // ajusto la longitud de la cifra, para que sea divisible por centenas de miles (grupos de 6) |
|
1515
|
|
|
// $xcadena = ""; |
|
1516
|
|
|
// for ($xz = 0; $xz < 3; $xz++) { |
|
1517
|
|
|
// $xaux = substr($XAUX, $xz * 6, 6); |
|
1518
|
|
|
// $xi = 0; |
|
1519
|
|
|
// $xlimite = 6; // inicializo el contador de centenas xi y establezco el límite a 6 dígitos en la parte entera |
|
1520
|
|
|
// $xexit = true; // bandera para controlar el ciclo del While |
|
1521
|
|
|
// while ($xexit) { |
|
1522
|
|
|
// if ($xi == $xlimite) { // si ya ha llegado al límite máximo de enteros |
|
1523
|
|
|
// break; // termina el ciclo |
|
1524
|
|
|
// } |
|
1525
|
|
|
// |
|
1526
|
|
|
// $x3digitos = ($xlimite - $xi) * -1; // comienzo con los tres primeros digitos de la cifra, comenzando por la izquierda |
|
1527
|
|
|
// $xaux = substr($xaux, $x3digitos, abs($x3digitos)); // obtengo la centena (los tres dígitos) |
|
1528
|
|
|
// for ($xy = 1; $xy < 4; $xy++) { // ciclo para revisar centenas, decenas y unidades, en ese orden |
|
1529
|
|
|
// switch ($xy) { |
|
1530
|
|
|
// case 1: // checa las centenas |
|
1531
|
|
|
// if (substr($xaux, 0, 3) < 100) { // si el grupo de tres dígitos es menor a una centena ( < 99) no hace nada y pasa a revisar las decenas |
|
1532
|
|
|
// } else { |
|
1533
|
|
|
// $key = (int) substr($xaux, 0, 3); |
|
1534
|
|
|
// if (true === array_key_exists($key, $xarray)) { // busco si la centena es número redondo (100, 200, 300, 400, etc..) |
|
1535
|
|
|
// $xseek = $xarray[$key]; |
|
1536
|
|
|
// $xsub = $this->subfijo($xaux); // devuelve el subfijo correspondiente (Millón, Millones, Mil o nada) |
|
1537
|
|
|
// if (substr($xaux, 0, 3) == 100) { |
|
1538
|
|
|
// $xcadena = " " . $xcadena . " CIEN " . $xsub; |
|
1539
|
|
|
// } else { |
|
1540
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek . " " . $xsub; |
|
1541
|
|
|
// } |
|
1542
|
|
|
// $xy = 3; // la centena fue redonda, entonces termino el ciclo del for y ya no reviso decenas ni unidades |
|
1543
|
|
|
// } else { // entra aquí si la centena no es numero redondo (101, 253, 120, 980, etc.) |
|
1544
|
|
|
// $key = (int) substr($xaux, 0, 1) * 100; |
|
1545
|
|
|
// $xseek = $xarray[$key]; // toma el primer caracter de la centena y lo multiplica por cien y lo busca en el arreglo (para que busque 100,200,300, etc) |
|
1546
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek; |
|
1547
|
|
|
// } // ENDIF ($xseek) |
|
1548
|
|
|
// } // ENDIF (substr($xaux, 0, 3) < 100) |
|
1549
|
|
|
// break; |
|
1550
|
|
|
// case 2: // Chequear las decenas (con la misma lógica que las centenas) |
|
1551
|
|
|
// if (substr($xaux, 1, 2) < 10) { |
|
1552
|
|
|
// } else { |
|
1553
|
|
|
// $key = (int) substr($xaux, 1, 2); |
|
1554
|
|
|
// if (true === array_key_exists($key, $xarray)) { |
|
1555
|
|
|
// $xseek = $xarray[$key]; |
|
1556
|
|
|
// $xsub = $this->subfijo($xaux); |
|
1557
|
|
|
// if (substr($xaux, 1, 2) == 20) { |
|
1558
|
|
|
// $xcadena = " " . $xcadena . " VEINTE " . $xsub; |
|
1559
|
|
|
// } else { |
|
1560
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek . " " . $xsub; |
|
1561
|
|
|
// } |
|
1562
|
|
|
// $xy = 3; |
|
1563
|
|
|
// } else { |
|
1564
|
|
|
// $key = (int) substr($xaux, 1, 1) * 10; |
|
1565
|
|
|
// $xseek = $xarray[$key]; |
|
1566
|
|
|
// if (20 == substr($xaux, 1, 1) * 10) { |
|
1567
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek; |
|
1568
|
|
|
// } else { |
|
1569
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek . " Y "; |
|
1570
|
|
|
// } |
|
1571
|
|
|
// } // ENDIF ($xseek) |
|
1572
|
|
|
// } // ENDIF (substr($xaux, 1, 2) < 10) |
|
1573
|
|
|
// break; |
|
1574
|
|
|
// case 3: // Chequear las unidades |
|
1575
|
|
|
// if (substr($xaux, 2, 1) < 1) { // si la unidad es cero, ya no hace nada |
|
1576
|
|
|
// } else { |
|
1577
|
|
|
// $key = (int) substr($xaux, 2, 1); |
|
1578
|
|
|
// $xseek = $xarray[$key]; // obtengo directamente el valor de la unidad (del uno al nueve) |
|
1579
|
|
|
// $xsub = $this->subfijo($xaux); |
|
1580
|
|
|
// $xcadena = " " . $xcadena . " " . $xseek . " " . $xsub; |
|
1581
|
|
|
// } // ENDIF (substr($xaux, 2, 1) < 1) |
|
1582
|
|
|
// break; |
|
1583
|
|
|
// } // END SWITCH |
|
1584
|
|
|
// } // END FOR |
|
1585
|
|
|
// $xi = $xi + 3; |
|
1586
|
|
|
// } // ENDDO |
|
1587
|
|
|
// |
|
1588
|
|
|
// if (substr(trim($xcadena), -5, 5) == "ILLON") { // si la cadena obtenida termina en MILLON o BILLON, entonces le agrega al final la conjuncion DE |
|
1589
|
|
|
// $xcadena.= " DE"; |
|
1590
|
|
|
// } |
|
1591
|
|
|
// |
|
1592
|
|
|
// if (substr(trim($xcadena), -7, 7) == "ILLONES") { // si la cadena obtenida en MILLONES o BILLONES, entoncea le agrega al final la conjuncion DE |
|
1593
|
|
|
// $xcadena.= " DE"; |
|
1594
|
|
|
// } |
|
1595
|
|
|
// |
|
1596
|
|
|
// // ----------- esta línea la puedes cambiar de acuerdo a tus necesidades o a tu país ------- |
|
1597
|
|
|
// if (trim($xaux) != "") { |
|
1598
|
|
|
// switch ($xz) { |
|
1599
|
|
|
// case 0: |
|
1600
|
|
|
// if (trim(substr($XAUX, $xz * 6, 6)) == "1") { |
|
1601
|
|
|
// $xcadena.= "UN BILLON "; |
|
1602
|
|
|
// } else { |
|
1603
|
|
|
// $xcadena.= " BILLONES "; |
|
1604
|
|
|
// } |
|
1605
|
|
|
// break; |
|
1606
|
|
|
// case 1: |
|
1607
|
|
|
// if (trim(substr($XAUX, $xz * 6, 6)) == "1") { |
|
1608
|
|
|
// $xcadena.= "UN MILLON "; |
|
1609
|
|
|
// } else { |
|
1610
|
|
|
// $xcadena.= " MILLONES "; |
|
1611
|
|
|
// } |
|
1612
|
|
|
// break; |
|
1613
|
|
|
// case 2: |
|
1614
|
|
|
// if ($xcifra < 1) { |
|
1615
|
|
|
// $xcadena = "CERO con $xdecimales/100"; |
|
1616
|
|
|
// } |
|
1617
|
|
|
// if ($xcifra >= 1 && $xcifra < 2) { |
|
1618
|
|
|
// $xcadena = "UNO con $xdecimales/100"; |
|
1619
|
|
|
// } |
|
1620
|
|
|
// if ($xcifra >= 2) { |
|
1621
|
|
|
// $xcadena.= " con $xdecimales/100"; |
|
1622
|
|
|
// } |
|
1623
|
|
|
// break; |
|
1624
|
|
|
// } // endswitch ($xz) |
|
1625
|
|
|
// } // ENDIF (trim($xaux) != "") |
|
1626
|
|
|
// |
|
1627
|
|
|
// $xcadena = str_replace("VEINTI ", "VEINTI", $xcadena); // quito el espacio para el VEINTI, para que quede: VEINTICUATRO, VEINTIUN, VEINTIDOS, etc |
|
1628
|
|
|
// $xcadena = str_replace(" ", " ", $xcadena); // quito espacios dobles |
|
1629
|
|
|
// $xcadena = str_replace("UN UN", "UN", $xcadena); // quito la duplicidad |
|
1630
|
|
|
// $xcadena = str_replace(" ", " ", $xcadena); // quito espacios dobles |
|
1631
|
|
|
// $xcadena = str_replace("BILLON DE MILLONES", "BILLON DE", $xcadena); // corrigo la leyenda |
|
1632
|
|
|
// $xcadena = str_replace("BILLONES DE MILLONES", "BILLONES DE", $xcadena); // corrigo la leyenda |
|
1633
|
|
|
// $xcadena = str_replace("DE UN", "UN", $xcadena); // corrigo la leyenda |
|
1634
|
|
|
// } // ENDFOR ($xz) |
|
1635
|
|
|
// |
|
1636
|
|
|
// $xcadena = str_replace("UN MIL ", "MIL ", $xcadena); // quito el BUG de UN MIL |
|
1637
|
|
|
// return trim($xcadena); |
|
1638
|
|
|
// } |
|
1639
|
|
|
// |
|
1640
|
|
|
// // END FUNCTION |
|
1641
|
|
|
// |
|
1642
|
|
|
// public function subfijo($xx) |
|
1643
|
|
|
// { // esta función genera un subfijo para la cifra |
|
1644
|
|
|
// $xx = trim($xx); |
|
1645
|
|
|
// $xstrlen = strlen($xx); |
|
1646
|
|
|
// if ($xstrlen == 1 || $xstrlen == 2 || $xstrlen == 3) { |
|
1647
|
|
|
// $xsub = ""; |
|
1648
|
|
|
// } |
|
1649
|
|
|
// // |
|
1650
|
|
|
// if ($xstrlen == 4 || $xstrlen == 5 || $xstrlen == 6) { |
|
1651
|
|
|
// $xsub = "MIL"; |
|
1652
|
|
|
// } |
|
1653
|
|
|
// // |
|
1654
|
|
|
// return $xsub; |
|
1655
|
|
|
// } |
|
1656
|
|
|
// |
|
1657
|
|
|
// // END FUNCTION |
|
1658
|
|
|
// |
|
1659
|
|
|
// // create a new page group; call this before calling AddPage() |
|
1660
|
|
|
// public function StartPageGroup() |
|
1661
|
|
|
// { |
|
1662
|
|
|
// $this->NewPageGroup=true; |
|
1663
|
|
|
// } |
|
1664
|
|
|
// |
|
1665
|
|
|
// // current page in the group |
|
1666
|
|
|
// public function GroupPageNo() |
|
1667
|
|
|
// { |
|
1668
|
|
|
// return $this->PageGroups[$this->CurrPageGroup]; |
|
1669
|
|
|
// } |
|
1670
|
|
|
// |
|
1671
|
|
|
// // alias of the current page group -- will be replaced by the total number of pages in this group |
|
1672
|
|
|
// public function PageGroupAlias() |
|
1673
|
|
|
// { |
|
1674
|
|
|
// return $this->CurrPageGroup; |
|
1675
|
|
|
// } |
|
1676
|
|
|
// |
|
1677
|
|
|
// public function _beginpage($orientation, $size = null, $rotation = 0) |
|
1678
|
|
|
// { |
|
1679
|
|
|
// parent::_beginpage($orientation, $size, $rotation); |
|
1680
|
|
|
// if ($this->NewPageGroup) { |
|
1681
|
|
|
// // start a new group |
|
1682
|
|
|
// $n = 1; |
|
1683
|
|
|
// if (is_array($this->PageGroups) && sizeof($this->PageGroups) <= 0) { |
|
1684
|
|
|
// $n = sizeof($this->PageGroups)+1; |
|
1685
|
|
|
// } |
|
1686
|
|
|
// |
|
1687
|
|
|
// $alias = "{nb$n}"; |
|
1688
|
|
|
// $this->PageGroups[$alias] = 1; |
|
1689
|
|
|
// $this->CurrPageGroup = $alias; |
|
1690
|
|
|
// $this->NewPageGroup=false; |
|
1691
|
|
|
// } elseif ($this->CurrPageGroup) { |
|
1692
|
|
|
// $this->PageGroups[$this->CurrPageGroup]++; |
|
1693
|
|
|
// } |
|
1694
|
|
|
// } |
|
1695
|
|
|
// |
|
1696
|
|
|
// public function _putpages() |
|
1697
|
|
|
// { |
|
1698
|
|
|
// $nb = $this->page; |
|
1699
|
|
|
// if (!empty($this->PageGroups)) { |
|
1700
|
|
|
// // do page number replacement |
|
1701
|
|
|
// foreach ($this->PageGroups as $k => $v) { |
|
1702
|
|
|
// for ($n = 1; $n <= $nb; $n++) { |
|
1703
|
|
|
// $this->pages[$n]=str_replace($k, $v, $this->pages[$n]); |
|
1704
|
|
|
// } |
|
1705
|
|
|
// } |
|
1706
|
|
|
// } |
|
1707
|
|
|
// parent::_putpages(); |
|
1708
|
|
|
// } |
|
1709
|
|
|
//} |