1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\DA\MDFe; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Esta classe gera do PDF do MDFDe, conforme regras e estruturas |
7
|
|
|
* estabelecidas pela SEFAZ. |
8
|
|
|
* |
9
|
|
|
* @category Library |
10
|
|
|
* @package nfephp-org/sped-da |
11
|
|
|
* @name Damdfe.php |
12
|
|
|
* @copyright 2009-2016 NFePHP |
13
|
|
|
* @license http://www.gnu.org/licenses/lesser.html LGPL v3 |
14
|
|
|
* @link http://github.com/nfephp-org/sped-da for the canonical source repository |
15
|
|
|
* @author Leandro C. Lopez <leandro dot castoldi at gmail dot com> |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use Com\Tecnick\Barcode\Barcode; |
19
|
|
|
use NFePHP\DA\Legacy\Dom; |
20
|
|
|
use NFePHP\DA\Legacy\Pdf; |
21
|
|
|
use NFePHP\DA\Common\DaCommon; |
22
|
|
|
|
23
|
|
|
class Damdfe extends DaCommon |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
protected $yDados = 0; |
27
|
|
|
protected $xml; // string XML NFe |
28
|
|
|
protected $errMsg = ''; // mesagens de erro |
29
|
|
|
protected $errStatus = false;// status de erro TRUE um erro ocorreu false sem erros |
30
|
|
|
protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
31
|
|
|
protected $margemInterna = 2; |
32
|
|
|
protected $id; |
33
|
|
|
protected $chMDFe; |
34
|
|
|
protected $tpAmb; |
35
|
|
|
protected $ide; |
36
|
|
|
protected $xCondUso; |
37
|
|
|
protected $dhEvento; |
38
|
|
|
protected $cStat; |
39
|
|
|
protected $xMotivo; |
40
|
|
|
protected $CNPJDest = ''; |
41
|
|
|
protected $mdfeProc; |
42
|
|
|
protected $nProt; |
43
|
|
|
protected $tpEmis; |
44
|
|
|
protected $qrCodMDFe; |
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $logoAlign = 'L'; |
49
|
|
|
private $dom; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* __construct |
53
|
|
|
* |
54
|
|
|
* @param string $xml Arquivo XML da MDFe |
55
|
|
|
*/ |
56
|
|
|
public function __construct( |
57
|
|
|
$xml |
58
|
|
|
) { |
59
|
|
|
$this->loadDoc($xml); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
private function loadDoc($xml) |
63
|
|
|
{ |
64
|
|
|
$this->xml = $xml; |
65
|
|
|
if (!empty($xml)) { |
66
|
|
|
$this->dom = new Dom(); |
67
|
|
|
$this->dom->loadXML($this->xml); |
68
|
|
|
$this->mdfeProc = $this->dom->getElementsByTagName("mdfeProc")->item(0); |
69
|
|
|
if (empty($this->dom->getElementsByTagName("infMDFe")->item(0))) { |
70
|
|
|
throw new \Exception('Isso não é um MDF-e.'); |
71
|
|
|
} |
72
|
|
|
$this->infMDFe = $this->dom->getElementsByTagName("infMDFe")->item(0); |
|
|
|
|
73
|
|
|
$this->ide = $this->dom->getElementsByTagName("ide")->item(0); |
74
|
|
|
if ($this->getTagValue($this->ide, "mod") != '58') { |
75
|
|
|
throw new \Exception("O xml deve ser MDF-e modelo 58."); |
76
|
|
|
} |
77
|
|
|
$this->emit = $this->dom->getElementsByTagName("emit")->item(0); |
|
|
|
|
78
|
|
|
if ($this->emit->getElementsByTagName("CPF")->item(0)) { |
79
|
|
|
$this->CPF = $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue; |
|
|
|
|
80
|
|
|
} else { |
81
|
|
|
$this->CNPJ = $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue; |
|
|
|
|
82
|
|
|
} |
83
|
|
|
$this->IE = $this->dom->getElementsByTagName("IE")->item(0)->nodeValue; |
|
|
|
|
84
|
|
|
$this->xNome = $this->dom->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
|
|
|
85
|
|
|
$this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); |
|
|
|
|
86
|
|
|
$this->xLgr = $this->dom->getElementsByTagName("xLgr")->item(0)->nodeValue; |
|
|
|
|
87
|
|
|
$this->nro = $this->dom->getElementsByTagName("nro")->item(0)->nodeValue; |
|
|
|
|
88
|
|
|
$this->xBairro = $this->dom->getElementsByTagName("xBairro")->item(0)->nodeValue; |
|
|
|
|
89
|
|
|
$this->UF = $this->dom->getElementsByTagName("UF")->item(0)->nodeValue; |
|
|
|
|
90
|
|
|
$this->xMun = $this->dom->getElementsByTagName("xMun")->item(0)->nodeValue; |
|
|
|
|
91
|
|
|
$this->CEP = $this->dom->getElementsByTagName("CEP")->item(0)->nodeValue; |
|
|
|
|
92
|
|
|
$this->tpAmb = $this->dom->getElementsByTagName("tpAmb")->item(0)->nodeValue; |
93
|
|
|
$this->mod = $this->dom->getElementsByTagName("mod")->item(0)->nodeValue; |
|
|
|
|
94
|
|
|
$this->serie = $this->dom->getElementsByTagName("serie")->item(0)->nodeValue; |
|
|
|
|
95
|
|
|
$this->dhEmi = $this->dom->getElementsByTagName("dhEmi")->item(0)->nodeValue; |
|
|
|
|
96
|
|
|
$this->UFIni = $this->dom->getElementsByTagName("UFIni")->item(0)->nodeValue; |
|
|
|
|
97
|
|
|
$this->UFFim = $this->dom->getElementsByTagName("UFFim")->item(0)->nodeValue; |
|
|
|
|
98
|
|
|
$this->nMDF = $this->dom->getElementsByTagName("nMDF")->item(0)->nodeValue; |
|
|
|
|
99
|
|
|
$this->tpEmis = $this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue; |
100
|
|
|
$this->tot = $this->dom->getElementsByTagName("tot")->item(0); |
|
|
|
|
101
|
|
|
$this->qMDFe = ""; |
|
|
|
|
102
|
|
|
if ($this->dom->getElementsByTagName("qMDFe")->item(0) != "") { |
103
|
|
|
$this->qMDFe = $this->dom->getElementsByTagName("qMDFe")->item(0)->nodeValue; |
104
|
|
|
} |
105
|
|
|
$this->qNFe = ""; |
|
|
|
|
106
|
|
|
if ($this->dom->getElementsByTagName("qNFe")->item(0) != "") { |
107
|
|
|
$this->qNFe = $this->dom->getElementsByTagName("qNFe")->item(0)->nodeValue; |
108
|
|
|
} |
109
|
|
|
$this->qNF = ""; |
|
|
|
|
110
|
|
|
if ($this->dom->getElementsByTagName("qNF")->item(0) != "") { |
111
|
|
|
$this->qNF = $this->dom->getElementsByTagName("qNF")->item(0)->nodeValue; |
112
|
|
|
} |
113
|
|
|
$this->qCTe = ""; |
|
|
|
|
114
|
|
|
if ($this->dom->getElementsByTagName("qCTe")->item(0) != "") { |
115
|
|
|
$this->qCTe = $this->dom->getElementsByTagName("qCTe")->item(0)->nodeValue; |
116
|
|
|
} |
117
|
|
|
$this->qCT = ""; |
|
|
|
|
118
|
|
|
if ($this->dom->getElementsByTagName("qCT")->item(0) != "") { |
119
|
|
|
$this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue; |
120
|
|
|
} |
121
|
|
|
$this->qCarga = $this->dom->getElementsByTagName("qCarga")->item(0)->nodeValue; |
|
|
|
|
122
|
|
|
$this->cUnid = $this->dom->getElementsByTagName("cUnid")->item(0)->nodeValue; |
|
|
|
|
123
|
|
|
$this->infModal = $this->dom->getElementsByTagName("infModal")->item(0); |
|
|
|
|
124
|
|
|
$this->rodo = $this->dom->getElementsByTagName("rodo")->item(0); |
|
|
|
|
125
|
|
|
$this->aereo = $this->dom->getElementsByTagName("aereo")->item(0); |
|
|
|
|
126
|
|
|
$this->aquav = $this->dom->getElementsByTagName("aquav")->item(0); |
|
|
|
|
127
|
|
|
$this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0); |
|
|
|
|
128
|
|
|
if (!empty($this->rodo)) { |
129
|
|
|
$infANTT = $this->rodo->getElementsByTagName("infANTT")->item(0); |
130
|
|
|
$this->RNTRC = empty($infANTT) ? null : $infANTT->getElementsByTagName("RNTRC")->item(0)->nodeValue; |
|
|
|
|
131
|
|
|
} |
132
|
|
|
$this->ciot = ""; |
|
|
|
|
133
|
|
|
if ($this->dom->getElementsByTagName('CIOT')->item(0) != "") { |
134
|
|
|
$this->ciot = $this->dom->getElementsByTagName('CIOT')->item(0)->nodeValue; |
135
|
|
|
} |
136
|
|
|
$this->veicTracao = $this->dom->getElementsByTagName("veicTracao")->item(0); |
|
|
|
|
137
|
|
|
$this->veicReboque = $this->dom->getElementsByTagName("veicReboque"); |
|
|
|
|
138
|
|
|
$this->valePed = ""; |
|
|
|
|
139
|
|
|
if ($this->dom->getElementsByTagName("valePed")->item(0) != "") { |
140
|
|
|
$this->valePed = $this->dom->getElementsByTagName("valePed")->item(0)->getElementsByTagName("disp"); |
141
|
|
|
} |
142
|
|
|
$this->infCpl = ($infCpl = $this->dom->getElementsByTagName('infCpl')->item(0)) ? $infCpl->nodeValue : ""; |
|
|
|
|
143
|
|
|
$this->chMDFe = str_replace( |
144
|
|
|
'MDFe', |
145
|
|
|
'', |
146
|
|
|
$this->infMDFe->getAttribute("Id") |
147
|
|
|
); |
148
|
|
|
$this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodMDFe')->item(0) ? |
149
|
|
|
$this->dom->getElementsByTagName('qrCodMDFe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE'; |
150
|
|
|
if (is_object($this->mdfeProc)) { |
151
|
|
|
$this->nProt = !empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ? |
152
|
|
|
$this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : ''; |
153
|
|
|
$this->dhRecbto = $this->mdfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue; |
|
|
|
|
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
protected function monta( |
159
|
|
|
$logo = '' |
160
|
|
|
) { |
161
|
|
|
$this->pdf = ''; |
|
|
|
|
162
|
|
|
if (!empty($logo)) { |
163
|
|
|
$this->logomarca = $this->adjustImage($logo); |
164
|
|
|
} |
165
|
|
|
//pega o orientação do documento |
166
|
|
|
if (empty($this->orientacao)) { |
167
|
|
|
$this->orientacao = 'P'; |
168
|
|
|
} |
169
|
|
|
$this->buildMDFe(); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* buildMDFe |
175
|
|
|
*/ |
176
|
|
|
public function buildMDFe() |
177
|
|
|
{ |
178
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
|
|
|
179
|
|
|
if ($this->orientacao == 'P') { |
180
|
|
|
// margens do PDF |
181
|
|
|
$margSup = 7; |
182
|
|
|
$margEsq = 7; |
183
|
|
|
$margDir = 7; |
184
|
|
|
// posição inicial do relatorio |
185
|
|
|
$xInic = 7; |
186
|
|
|
$yInic = 7; |
187
|
|
|
if ($this->papel == 'A4') { //A4 210x297mm |
188
|
|
|
$maxW = 210; |
189
|
|
|
$maxH = 297; |
190
|
|
|
} |
191
|
|
|
} else { |
192
|
|
|
// margens do PDF |
193
|
|
|
$margSup = 7; |
194
|
|
|
$margEsq = 7; |
195
|
|
|
$margDir = 7; |
196
|
|
|
// posição inicial do relatorio |
197
|
|
|
$xInic = 7; |
198
|
|
|
$yInic = 7; |
199
|
|
|
if ($this->papel == 'A4') { //A4 210x297mm |
200
|
|
|
$maxH = 210; |
201
|
|
|
$maxW = 297; |
202
|
|
|
} |
203
|
|
|
}//orientação |
204
|
|
|
//largura imprimivel em mm |
205
|
|
|
$this->wPrint = $maxW - ($margEsq + $xInic); |
|
|
|
|
206
|
|
|
//comprimento imprimivel em mm |
207
|
|
|
$this->hPrint = $maxH - ($margSup + $yInic); |
|
|
|
|
208
|
|
|
// estabelece contagem de paginas |
209
|
|
|
$this->pdf->aliasNbPages(); |
210
|
|
|
// fixa as margens |
211
|
|
|
$this->pdf->setMargins($margEsq, $margSup, $margDir); |
212
|
|
|
$this->pdf->setDrawColor(0, 0, 0); |
213
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
214
|
|
|
// inicia o documento |
215
|
|
|
$this->pdf->open(); |
216
|
|
|
// adiciona a primeira página |
217
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
|
|
|
218
|
|
|
$this->pdf->setLineWidth(0.1); |
219
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
220
|
|
|
//montagem da página |
221
|
|
|
$pag = 1; |
222
|
|
|
$x = $xInic; |
223
|
|
|
$y = $yInic; |
224
|
|
|
//coloca o cabeçalho Paisagem |
225
|
|
|
if ($this->orientacao == 'P') { |
226
|
|
|
$y = $this->headerMDFeRetrato($x, $y, $pag); |
227
|
|
|
} else { |
228
|
|
|
$y = $this->headerMDFePaisagem($x, $y, $pag); |
229
|
|
|
} |
230
|
|
|
//coloca os dados da MDFe |
231
|
|
|
$y = $this->bodyMDFe($x, $y); |
232
|
|
|
//coloca os dados da MDFe |
233
|
|
|
$y = $this->footerMDFe($x, $y); |
|
|
|
|
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* headerMDFePaisagem |
238
|
|
|
* |
239
|
|
|
* @param float $x |
240
|
|
|
* @param float $y |
241
|
|
|
* @param integer $pag |
242
|
|
|
* @return string |
243
|
|
|
*/ |
244
|
|
|
private function headerMDFePaisagem($x, $y, $pag) |
|
|
|
|
245
|
|
|
{ |
246
|
|
|
$oldX = $x; |
|
|
|
|
247
|
|
|
$oldY = $y; |
248
|
|
|
$maxW = $this->wPrint; |
249
|
|
|
//#################################################################################### |
250
|
|
|
//coluna esquerda identificação do emitente |
251
|
|
|
//$w = $maxW; //round($maxW*0.41, 0);// 80; |
252
|
|
|
$w = round($maxW * 0.70, 0); |
253
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
|
|
|
|
254
|
|
|
$w1 = $w; |
|
|
|
|
255
|
|
|
$h = 30; |
256
|
|
|
$oldY += $h; |
257
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
258
|
|
|
if (is_file($this->logomarca)) { |
259
|
|
|
$logoInfo = getimagesize($this->logomarca); |
260
|
|
|
//largura da imagem em mm |
261
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
262
|
|
|
//altura da imagem em mm |
263
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
264
|
|
|
if ($this->logoAlign == 'L') { |
265
|
|
|
$nImgW = round($w / 3, 0); |
266
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
267
|
|
|
$xImg = $x + 1; |
268
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
269
|
|
|
//estabelecer posições do texto |
270
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
271
|
|
|
$y1 = round($y + 2, 0); |
272
|
|
|
$tw = round(2 * $w / 3, 0); |
273
|
|
|
} |
274
|
|
|
if ($this->logoAlign == 'C') { |
275
|
|
|
$nImgH = round($h / 3, 0); |
276
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
277
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
278
|
|
|
$yImg = $y + 3; |
279
|
|
|
$x1 = $x; |
280
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
281
|
|
|
$tw = $w; |
282
|
|
|
} |
283
|
|
|
if ($this->logoAlign == 'R') { |
284
|
|
|
$nImgW = round($w / 3, 0); |
285
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
286
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
287
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
288
|
|
|
$x1 = $x; |
289
|
|
|
$y1 = round($h / 3 + $y, 0); |
290
|
|
|
$tw = round(2 * $w / 3, 0); |
291
|
|
|
} |
292
|
|
|
$this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
293
|
|
|
} else { |
294
|
|
|
$x1 = $x; |
295
|
|
|
$y1 = round($h / 3 + $y, 0); |
296
|
|
|
$tw = $w; |
297
|
|
|
} |
298
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
|
|
|
299
|
|
|
$razao = $this->xNome; |
|
|
|
|
300
|
|
|
if (isset($this->CPF)) { |
301
|
|
|
$cpfcnpj = 'CPF: ' . $this->formatField($this->CPF, "###.###.###-##"); |
302
|
|
|
} else { |
303
|
|
|
$cpfcnpj = 'CNPJ: ' . $this->formatField($this->CNPJ, "###.###.###/####-##"); |
304
|
|
|
} |
305
|
|
|
$ie = 'IE: ' . (strlen($this->IE) == 9 |
306
|
|
|
? $this->formatField($this->IE, '###/#######') |
307
|
|
|
: $this->formatField($this->IE, '###.###.###.###')); |
308
|
|
|
$rntrc = empty($this->RNTRC) ? '' : ' - RNTRC: ' . $this->RNTRC; |
309
|
|
|
$lgr = 'Logradouro: ' . $this->xLgr; |
310
|
|
|
$nro = 'Nº: ' . $this->nro; |
311
|
|
|
$bairro = 'Bairro: ' . $this->xBairro; |
312
|
|
|
$CEP = $this->CEP; |
313
|
|
|
$CEP = 'CEP: ' . $this->formatField($CEP, "##.###-###"); |
314
|
|
|
$UF = 'UF: ' . $this->UF; |
315
|
|
|
$mun = 'Municipio: ' . $this->xMun; |
316
|
|
|
|
317
|
|
|
$texto = $cpfcnpj . ' - ' . $ie . $rntrc ."\n"; |
318
|
|
|
$texto .= $lgr . ' - ' . $nro . "\n"; |
319
|
|
|
$texto .= $bairro . "\n"; |
320
|
|
|
$texto .= $UF . ' - ' . $mun . ' - ' . $CEP; |
321
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
322
|
|
|
$this->pdf->textBox($x1, $y1 + 6, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
323
|
|
|
//################################################## |
324
|
|
|
$w = round($maxW * 0.70, 0); |
325
|
|
|
$y = $h + 9; |
326
|
|
|
$this->pdf->textBox($x, $y, $w, 6); |
327
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'I']; |
328
|
|
|
$this->pdf->textBox( |
329
|
|
|
$x, |
330
|
|
|
$y, |
331
|
|
|
$w, |
332
|
|
|
8, |
333
|
|
|
'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais', |
334
|
|
|
$aFont, |
335
|
|
|
'T', |
336
|
|
|
'C', |
337
|
|
|
0, |
|
|
|
|
338
|
|
|
'' |
339
|
|
|
); |
340
|
|
|
|
341
|
|
|
if ($this->tpAmb != 1) { |
342
|
|
|
$x = 10; |
343
|
|
|
if ($this->orientacao == 'P') { |
344
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
345
|
|
|
} else { |
346
|
|
|
$yy = round($this->hPrint / 2, 0); |
347
|
|
|
} |
348
|
|
|
$h = 5; |
349
|
|
|
$w = $maxW - (2 * $x); |
350
|
|
|
$this->pdf->setTextColor(90, 90, 90); |
351
|
|
|
$texto = "SEM VALOR FISCAL"; |
352
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
353
|
|
|
$this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
354
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 30, 'style' => 'B']; |
355
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
356
|
|
|
$this->pdf->textBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
357
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
358
|
|
|
} else { |
359
|
|
|
$x = 10; |
360
|
|
|
if ($this->orientacao == 'P') { |
361
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
362
|
|
|
} else { |
363
|
|
|
$yy = round($this->hPrint / 2, 0); |
364
|
|
|
} |
365
|
|
|
$h = 5; |
366
|
|
|
$w = $maxW - (2 * $x); |
367
|
|
|
$this->pdf->setTextColor(90, 90, 90); |
368
|
|
|
//indicar FALTA DO PROTOCOLO se MDFe não for em contingência |
369
|
|
|
if (($this->tpEmis == 2 || $this->tpEmis == 5)) { |
370
|
|
|
//Contingência |
371
|
|
|
$texto = "DAMDFE Emitido em Contingência"; |
372
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
373
|
|
|
$this->pdf->textBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
374
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 30, 'style' => 'B']; |
375
|
|
|
$texto = "devido à problemas técnicos"; |
376
|
|
|
$this->pdf->textBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
377
|
|
|
} |
378
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
379
|
|
|
} |
380
|
|
|
return $y + 8; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* Verifica o status da MDFe |
385
|
|
|
* |
386
|
|
|
* @return array |
387
|
|
|
*/ |
388
|
|
|
protected function statusMDFe() |
389
|
|
|
{ |
390
|
|
|
$resp = [ |
391
|
|
|
'status' => true, |
392
|
|
|
'valida' => true, |
393
|
|
|
'message' => [], |
394
|
|
|
'submessage' => '' |
395
|
|
|
]; |
396
|
|
|
if (!isset($this->mdfeProc)) { |
397
|
|
|
$resp['status'] = false; |
398
|
|
|
$resp['message'][] = 'MDFe NÃO PROTOCOLADA'; |
399
|
|
|
} else { |
400
|
|
|
if ($this->getTagValue($this->ide, "tpAmb") == '2') { |
401
|
|
|
$resp['status'] = false; |
402
|
|
|
$resp['valida'] = false; |
403
|
|
|
$resp['message'][] = "MDFe EMITIDA EM HOMOLOGAÇÃO"; |
404
|
|
|
} |
405
|
|
|
$retEvento = $this->mdfeProc->getElementsByTagName('retEventoMDFe')->item(0); |
406
|
|
|
$cStat = $this->getTagValue($this->mdfeProc, "cStat"); |
407
|
|
|
$tpEvento = $this->getTagValue($this->mdfeProc, "tpEvento"); |
408
|
|
|
if ($cStat == '101' |
409
|
|
|
|| $cStat == '151' |
410
|
|
|
|| $cStat == '135' |
411
|
|
|
|| $cStat == '155' |
412
|
|
|
|| $this->cancelFlag === true |
413
|
|
|
) { |
414
|
|
|
$resp['status'] = false; |
415
|
|
|
$resp['valida'] = false; |
416
|
|
|
$resp['message'][] = "MDFe CANCELADA"; |
417
|
|
|
} elseif (($cStat == '103' |
418
|
|
|
|| $cStat == '136' |
419
|
|
|
|| $cStat == '135' |
420
|
|
|
|| $cStat == '155' |
421
|
|
|
|| $tpEvento === '110112') |
422
|
|
|
and empty($retEvento) |
423
|
|
|
) { |
424
|
|
|
$resp['status'] = false; |
425
|
|
|
$resp['message'][] = "MDFe ENCERRADA"; |
426
|
|
|
} elseif (!empty($retEvento)) { |
427
|
|
|
$infEvento = $retEvento->getElementsByTagName('infEvento')->item(0); |
428
|
|
|
$cStat = $this->getTagValue($infEvento, "cStat"); |
429
|
|
|
$tpEvento = $this->getTagValue($infEvento, "tpEvento"); |
430
|
|
|
$dhEvento = date("d/m/Y H:i:s", $this->toTimestamp($this->getTagValue($infEvento, "dhRegEvento"))); |
431
|
|
|
$nProt = $this->getTagValue($infEvento, "nProt"); |
432
|
|
|
if ($tpEvento == '110111' |
433
|
|
|
&& ($cStat == '101' |
434
|
|
|
|| $cStat == '151' |
435
|
|
|
|| $cStat == '135' |
436
|
|
|
|| $cStat == '155' |
437
|
|
|
)) { |
438
|
|
|
$resp['status'] = false; |
439
|
|
|
$resp['valida'] = false; |
440
|
|
|
$resp['message'][] = "MDFe CANCELADA"; |
441
|
|
|
$resp['submessage'] = "{$dhEvento} - {$nProt}"; |
442
|
|
|
} elseif ($tpEvento == '110112' && ($cStat == '136' || $cStat == '135' || $cStat == '155')) { |
443
|
|
|
$resp['status'] = false; |
444
|
|
|
$resp['message'][] = "MDFe ENCERRADA"; |
445
|
|
|
$resp['submessage'] = "{$dhEvento} - {$nProt}"; |
446
|
|
|
} |
447
|
|
|
} elseif (($this->tpEmis == 2 || $this->tpEmis == 5) and empty($this->nProt)) { |
448
|
|
|
$resp['status'] = false; |
449
|
|
|
$resp['message'][] = "MDFE Emitido em Contingência"; |
450
|
|
|
$resp['message'][] = "devido à problemas técnicos"; |
451
|
|
|
} |
452
|
|
|
} |
453
|
|
|
return $resp; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* headerMDFeRetrato |
458
|
|
|
* |
459
|
|
|
* @param float $x |
460
|
|
|
* @param float $y |
461
|
|
|
* @param integer $pag |
462
|
|
|
* @return string |
463
|
|
|
*/ |
464
|
|
|
private function headerMDFeRetrato($x, $y, $pag) |
|
|
|
|
465
|
|
|
{ |
466
|
|
|
$oldX = $x; |
|
|
|
|
467
|
|
|
$oldY = $y; |
468
|
|
|
$maxW = $this->wPrint; |
469
|
|
|
//#################################################################################### |
470
|
|
|
//coluna esquerda identificação do emitente |
471
|
|
|
//$w = $maxW; //round($maxW*0.41, 0);// 80; |
472
|
|
|
$w = round($maxW * 0.70, 0); |
473
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
|
|
|
|
474
|
|
|
$w1 = $w; |
|
|
|
|
475
|
|
|
$h = 20; |
476
|
|
|
$oldY += $h; |
477
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
478
|
|
|
if (!empty($this->logomarca)) { |
479
|
|
|
$logoInfo = getimagesize($this->logomarca); |
480
|
|
|
//largura da imagem em mm |
481
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
482
|
|
|
//altura da imagem em mm |
483
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
484
|
|
|
if ($this->logoAlign == 'L') { |
485
|
|
|
// ajusta a dimensão do logo |
486
|
|
|
$nImgW = round((round($maxW * 0.50, 0)) / 3, 0); |
487
|
|
|
$nImgH = round(($h - $y) - 2, 0) + $y; |
488
|
|
|
$xImg = $x + 1; |
489
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
490
|
|
|
//estabelecer posições do texto |
491
|
|
|
$x1 = round($xImg + $nImgW + 4, 0); |
492
|
|
|
$y1 = round($y + 2, 0); |
493
|
|
|
$tw = round(2 * $w / 3, 0); |
494
|
|
|
} |
495
|
|
|
if ($this->logoAlign == 'C') { |
496
|
|
|
$nImgH = round($h / 3, 0); |
497
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
498
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
499
|
|
|
$yImg = $y + 3; |
500
|
|
|
$x1 = $x; |
501
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
502
|
|
|
$tw = $w; |
503
|
|
|
} |
504
|
|
|
if ($this->logoAlign == 'R') { |
505
|
|
|
$nImgW = round($w / 3, 0); |
506
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
507
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
508
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
509
|
|
|
$x1 = $x; |
510
|
|
|
$y1 = round($h / 3 + $y, 0); |
511
|
|
|
$tw = round(2 * $w / 3, 0); |
512
|
|
|
} |
513
|
|
|
$this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
514
|
|
|
} else { |
515
|
|
|
$x1 = $x; |
516
|
|
|
$y1 = $y; |
517
|
|
|
$tw = $w; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
if ($this->qrCodMDFe !== null) { |
521
|
|
|
$this->qrCodeDamdfe($y - 3); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
525
|
|
|
$texto = $this->xNome; |
526
|
|
|
$this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
527
|
|
|
if (isset($this->CPF)) { |
528
|
|
|
$cpfcnpj = 'CPF: ' . $this->formatField($this->CPF, "###.###.###-##"); |
529
|
|
|
} else { |
530
|
|
|
$cpfcnpj = 'CNPJ: ' . $this->formatField($this->CNPJ, "###.###.###/####-##"); |
531
|
|
|
} |
532
|
|
|
$ie = 'IE: ' . (strlen($this->IE) == 9 |
533
|
|
|
? $this->formatField($this->IE, '###/#######') |
534
|
|
|
: $this->formatField($this->IE, '###.###.###.###')); |
535
|
|
|
$rntrc = empty($this->RNTRC) ? '' : ' - RNTRC: ' . $this->RNTRC; |
536
|
|
|
$lgr = 'Logradouro: ' . $this->xLgr; |
537
|
|
|
$nro = 'Nº: ' . $this->nro; |
538
|
|
|
$bairro = 'Bairro: ' . $this->xBairro; |
539
|
|
|
$CEP = $this->CEP; |
540
|
|
|
$CEP = 'CEP: ' . $this->formatField($CEP, "##.###-###"); |
541
|
|
|
$mun = 'Municipio: ' . $this->xMun; |
542
|
|
|
$UF = 'UF: ' . $this->UF; |
543
|
|
|
$texto = $cpfcnpj . ' - ' . $ie . $rntrc . "\n"; |
544
|
|
|
$texto .= $lgr . ' - ' . $nro . "\n"; |
545
|
|
|
$texto .= $bairro . "\n"; |
546
|
|
|
$texto .= $UF . ' - ' . $mun . ' - ' . $CEP; |
547
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
548
|
|
|
$this->pdf->textBox($x1, $y1 + 4, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
549
|
|
|
//################################################## |
550
|
|
|
$w = round($maxW * 0.70, 0); |
551
|
|
|
$y = $h + 9; |
552
|
|
|
$this->pdf->textBox($x, $y, $w, 6); |
553
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I'); |
554
|
|
|
$this->pdf->textBox( |
555
|
|
|
$x, |
556
|
|
|
$y, |
557
|
|
|
$w, |
558
|
|
|
8, |
559
|
|
|
'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais', |
560
|
|
|
$aFont, |
561
|
|
|
'T', |
562
|
|
|
'C', |
563
|
|
|
0, |
|
|
|
|
564
|
|
|
'' |
565
|
|
|
); |
566
|
|
|
$resp = $this->statusMDFe(); |
567
|
|
|
if (!$resp['status']) { |
568
|
|
|
$n = count($resp['message']); |
569
|
|
|
$alttot = $n * 15; |
570
|
|
|
$x = 10; |
571
|
|
|
$y = $this->hPrint/2 - $alttot/2; |
572
|
|
|
$h = 15; |
573
|
|
|
$w = $maxW - (2 * $x); |
574
|
|
|
$this->pdf->settextcolor(90, 90, 90); |
575
|
|
|
foreach ($resp['message'] as $msg) { |
|
|
|
|
576
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
577
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $msg, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
578
|
|
|
$y += $h; |
579
|
|
|
} |
580
|
|
|
$texto = $resp['submessage']; |
581
|
|
|
if (!empty($texto)) { |
582
|
|
|
$y += 3; |
583
|
|
|
$h = 5; |
584
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 20, 'style' => 'B']; |
585
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
586
|
|
|
$y += $h; |
587
|
|
|
} |
588
|
|
|
if (!$resp['valida']) { |
589
|
|
|
$y += 5; |
590
|
|
|
$w = $maxW - (2 * $x); |
591
|
|
|
$texto = "SEM VALOR FISCAL"; |
592
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
593
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
594
|
|
|
$this->pdf->settextcolor(0, 0, 0); |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
return $oldY + 8; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* bodyMDFe |
602
|
|
|
* |
603
|
|
|
* @param float $x |
604
|
|
|
* @param float $y |
605
|
|
|
* @return void |
606
|
|
|
*/ |
607
|
|
|
private function bodyMDFe($x, $y) |
608
|
|
|
{ |
609
|
|
|
if ($this->orientacao == 'P') { |
610
|
|
|
$maxW = $this->wPrint; |
611
|
|
|
} else { |
612
|
|
|
//$maxW = $this->wPrint / 2; |
613
|
|
|
$maxW = $this->wPrint * 0.9; |
614
|
|
|
} |
615
|
|
|
$x2 = ($maxW / 6); |
616
|
|
|
$x1 = $x2; |
617
|
|
|
$this->pdf->textBox($x, $y, $x2 - 22, 12); |
618
|
|
|
$texto = 'Modelo'; |
619
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
620
|
|
|
$this->pdf->textBox($x, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
621
|
|
|
$texto = $this->mod; |
622
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
623
|
|
|
$this->pdf->textBox($x, $y + 4, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
624
|
|
|
|
625
|
|
|
if ($this->orientacao == 'P') { |
626
|
|
|
$x1 += $x2 - 47.5; |
627
|
|
|
} else { |
628
|
|
|
$x1 += $x2 - 57.5; |
629
|
|
|
} |
630
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 22, 12); |
631
|
|
|
$texto = 'Série'; |
632
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
633
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
634
|
|
|
$texto = $this->serie; |
635
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
636
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
637
|
|
|
|
638
|
|
|
$x1 += $x2 - 22; |
639
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 5, 12); |
640
|
|
|
$texto = 'Número'; |
641
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
642
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 5, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
643
|
|
|
$texto = $this->formatField(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###'); |
644
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
645
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2 - 5, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
646
|
|
|
$x1 += $x2 - 5; |
647
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 22, 12); |
648
|
|
|
$texto = 'FL'; |
649
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
650
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
651
|
|
|
$texto = '1'; |
652
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
653
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
654
|
|
|
$x1 += $x2 - 22; |
655
|
|
|
if ($this->orientacao == 'P') { |
656
|
|
|
$x3 = $x2 + 10.5; |
657
|
|
|
} else { |
658
|
|
|
$x3 = $x2 + 3; |
659
|
|
|
} |
660
|
|
|
$this->pdf->textBox($x1, $y, $x3, 12); |
661
|
|
|
$texto = 'Data e Hora de Emissão'; |
662
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
663
|
|
|
$this->pdf->textBox($x1, $y, $x3, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
664
|
|
|
$data = explode('T', $this->dhEmi); |
665
|
|
|
$texto = $this->ymdTodmy($data[0]) . ' - ' . $data[1]; |
666
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
667
|
|
|
$this->pdf->textBox($x1, $y + 4, $x3, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
668
|
|
|
$x1 += $x3; |
669
|
|
|
|
670
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 15, 12); |
671
|
|
|
$texto = 'UF Carreg.'; |
672
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
673
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 15, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
674
|
|
|
$texto = $this->UFIni; |
675
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
676
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2 - 15, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
677
|
|
|
$maxW = $this->wPrint; |
|
|
|
|
678
|
|
|
|
679
|
|
|
$x1 += $x2 - 15; |
680
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 16, 12); |
681
|
|
|
$texto = 'UF Descar.'; |
682
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
683
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 16, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
684
|
|
|
$texto = $this->UFFim; |
685
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
686
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2 - 16, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
687
|
|
|
$maxW = $this->wPrint; |
688
|
|
|
|
689
|
|
|
if ($this->aquav) { |
690
|
|
|
$x1 = $x; |
691
|
|
|
$x2 = $maxW; |
692
|
|
|
$y += 14; |
693
|
|
|
$this->pdf->textBox($x1, $y, $x2, 10); |
694
|
|
|
$texto = 'Embarcação'; |
695
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
696
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
697
|
|
|
$texto = $this->aquav->getElementsByTagName('cEmbar')->item(0)->nodeValue; |
698
|
|
|
$texto .= ' - '; |
699
|
|
|
$texto .= $this->aquav->getElementsByTagName('xEmbar')->item(0)->nodeValue; |
700
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
701
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
$x1 = $x; |
705
|
|
|
$x2 = $maxW; |
706
|
|
|
$y += 13; |
707
|
|
|
$this->pdf->textBox($x1, $y, $x2, 43); |
708
|
|
|
if ($this->rodo) { |
709
|
|
|
$texto = 'Modal Rodoviário de Carga'; |
710
|
|
|
} |
711
|
|
|
if ($this->aereo) { |
712
|
|
|
$texto = 'Modal Aéreo de Carga'; |
713
|
|
|
} |
714
|
|
|
if ($this->aquav) { |
715
|
|
|
$texto = 'Modal Aquaviário de Carga'; |
716
|
|
|
} |
717
|
|
|
if ($this->ferrov) { |
718
|
|
|
$texto = 'Modal Ferroviário de Carga'; |
719
|
|
|
} |
720
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'); |
721
|
|
|
$this->pdf->textBox($x1, $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
722
|
|
|
$texto = 'CONTROLE DO FISCO'; |
723
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
724
|
|
|
$this->pdf->textBox($x1 + ($x2 / 2), $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
725
|
|
|
|
726
|
|
|
$x1 = $x; |
727
|
|
|
$x2 = ($maxW / 6); |
728
|
|
|
$y += 6; |
729
|
|
|
$this->pdf->textBox($x1, $y, $x2, 12); |
730
|
|
|
$texto = 'Qtd. CT-e'; |
731
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
732
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
733
|
|
|
$texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT); |
734
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
735
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
736
|
|
|
$x1 += $x2; |
737
|
|
|
$this->pdf->textBox($x1, $y, $x2, 12); |
738
|
|
|
$texto = 'Qtd. NF-e'; |
739
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
740
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
741
|
|
|
$texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT); |
742
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
743
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
744
|
|
|
$x1 += $x2; |
745
|
|
|
$this->pdf->textBox($x1, $y, $x2, 12); |
746
|
|
|
|
747
|
|
|
if ($this->rodo |
748
|
|
|
|| $this->aereo |
749
|
|
|
|| $this->ferrov |
750
|
|
|
) { |
751
|
|
|
if ($this->cUnid == 01) { |
752
|
|
|
$texto = 'Peso Total (Kg)'; |
753
|
|
|
} else { |
754
|
|
|
$texto = 'Peso Total (Ton)'; |
755
|
|
|
} |
756
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
757
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
758
|
|
|
$texto = number_format($this->qCarga, 4, ',', '.'); |
759
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
760
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
if ($this->aquav) { |
764
|
|
|
$texto = 'Qtd. MDF-e Ref.'; |
765
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
766
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
767
|
|
|
$texto = str_pad($this->qMDFe, 3, '0', STR_PAD_LEFT); |
768
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
769
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
770
|
|
|
|
771
|
|
|
$ya = $y + 12; |
772
|
|
|
$this->pdf->textBox($x, $ya, $maxW / 2, 12); |
773
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
774
|
|
|
if ($this->cUnid == 01) { |
775
|
|
|
$texto = 'Peso Total (Kg)'; |
776
|
|
|
} else { |
777
|
|
|
$texto = 'Peso Total (Ton)'; |
778
|
|
|
} |
779
|
|
|
$this->pdf->textBox($x, $ya, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
780
|
|
|
$texto = number_format($this->qCarga, 4, ',', '.'); |
781
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
782
|
|
|
$this->pdf->textBox($x, $ya + 4, $x2, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
// codigo de barras da chave |
786
|
|
|
$x1 += $x2; |
787
|
|
|
//$y = $y + 8; |
788
|
|
|
$this->pdf->textBox($x1, $y, $maxW / 2, 20); |
789
|
|
|
$bH = 16; |
790
|
|
|
$w = $maxW; |
|
|
|
|
791
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
792
|
|
|
$this->pdf->code128($x1 + 5, $y + 2, $this->chMDFe, ($maxW / 2) - 10, $bH); |
793
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
794
|
|
|
|
795
|
|
|
// protocolo de autorização |
796
|
|
|
$y = $y + 24; |
797
|
|
|
$this->pdf->textBox($x, $y, $maxW / 2, 13); |
798
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
799
|
|
|
$texto = 'Protocolo de Autorização'; |
800
|
|
|
$this->pdf->textBox($x, $y, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
801
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
802
|
|
|
if (is_object($this->mdfeProc)) { |
803
|
|
|
$tsHora = $this->toTimestamp($this->dhRecbto); |
804
|
|
|
$texto = $this->nProt . ' - ' . date('d/m/Y H:i:s', $tsHora); |
805
|
|
|
} else { |
806
|
|
|
$texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y H:i:s'); |
807
|
|
|
} |
808
|
|
|
$this->pdf->textBox($x, $y + 4, $maxW / 2, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
809
|
|
|
|
810
|
|
|
$y -= 4; |
811
|
|
|
|
812
|
|
|
// chave de acesso |
813
|
|
|
$this->pdf->textBox($x + $maxW / 2, $y, $maxW / 2, 17); |
814
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
815
|
|
|
$tsHora = $this->toTimestamp($this->dhEvento); |
|
|
|
|
816
|
|
|
$texto = 'Chave de Acesso'; |
817
|
|
|
$this->pdf->textBox($x + $maxW / 2, $y, $maxW / 2, 6, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
818
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
819
|
|
|
$texto = $this->formatField($this->chMDFe, $this->formatoChave); |
820
|
|
|
$this->pdf->textBox($x + $maxW / 2, $y + 4, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
821
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
822
|
|
|
$texto = 'Consulte em https://dfe-portal.sefazvirtual.rs.gov.br/MDFe/consulta'; |
823
|
|
|
$this->pdf->textBox($x + $maxW / 2, $y + 10, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
824
|
|
|
|
825
|
|
|
$x1 = $x; |
826
|
|
|
$y += 20; |
827
|
|
|
$yold = $y; |
828
|
|
|
$x2 = round($maxW / 2, 0); |
829
|
|
|
|
830
|
|
|
if ($this->rodo) { |
831
|
|
|
$texto = 'Veículo'; |
832
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
833
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
834
|
|
|
$y += 5; |
835
|
|
|
$x2 = round($maxW / 4, 0); |
836
|
|
|
$tamanho = 22; |
837
|
|
|
$this->pdf->textBox($x1, $y, $x2, $tamanho); |
838
|
|
|
$texto = 'Placa'; |
839
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
840
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
841
|
|
|
$texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue; |
842
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
843
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
844
|
|
|
$altura = $y + 4; |
845
|
|
|
/** |
846
|
|
|
* |
847
|
|
|
* |
848
|
|
|
* @var \DOMNodeList $veicReboque |
849
|
|
|
*/ |
850
|
|
|
$veicReboque = $this->veicReboque; |
851
|
|
|
foreach ($veicReboque as $item) { |
852
|
|
|
/** |
853
|
|
|
* |
854
|
|
|
* |
855
|
|
|
* @var \DOMElement $item |
856
|
|
|
*/ |
857
|
|
|
$altura += 4; |
858
|
|
|
$texto = $item->getElementsByTagName('placa')->item(0)->nodeValue; |
859
|
|
|
$this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
860
|
|
|
} |
861
|
|
|
$x1 += $x2; |
862
|
|
|
$this->pdf->textBox($x1, $y, $x2, $tamanho); |
863
|
|
|
$texto = 'RNTRC'; |
864
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
865
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
866
|
|
|
$prop = $this->veicTracao->getElementsByTagName("prop")->item(0); |
867
|
|
|
if (!empty($prop)) { |
868
|
|
|
$texto = $prop->getElementsByTagName("RNTRC")->item(0)->nodeValue ?? ''; |
869
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
870
|
|
|
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
871
|
|
|
$altura = $y + 4; |
872
|
|
|
} |
873
|
|
|
/* |
874
|
|
|
// RNTRC Não informado |
875
|
|
|
if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) { |
876
|
|
|
$texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue; |
877
|
|
|
} else { |
878
|
|
|
$texto = ""; |
879
|
|
|
}*/ |
880
|
|
|
//$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
881
|
|
|
//$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
882
|
|
|
//$altura = $y + 4; |
883
|
|
|
/** |
884
|
|
|
* @var \DOMNodeList $veicTracao |
885
|
|
|
*/ |
886
|
|
|
/* |
887
|
|
|
$veicTracao = $this->veicTracao->getElementsByTagName('prop'); |
888
|
|
|
foreach ($veicTracao as $item) { |
889
|
|
|
$DOMNodeList = $item->getElementsByTagName('RNTRC'); |
890
|
|
|
if ($DOMNodeList->length > 0) { |
891
|
|
|
$texto = $DOMNodeList->item(0)->nodeValue; |
892
|
|
|
$this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
893
|
|
|
$altura += 4; |
894
|
|
|
} |
895
|
|
|
}*/ |
896
|
|
|
$veicReboque = $this->veicReboque; |
897
|
|
|
foreach ($veicReboque as $item) { |
898
|
|
|
/** |
899
|
|
|
* |
900
|
|
|
* |
901
|
|
|
* @var \DOMElement $item |
902
|
|
|
*/ |
903
|
|
|
$DOMNodeList = $item->getElementsByTagName('RNTRC'); |
904
|
|
|
if ($DOMNodeList->length > 0) { |
905
|
|
|
$altura += 4; |
906
|
|
|
$texto = $DOMNodeList->item(0)->nodeValue ?? ''; |
907
|
|
|
$this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
908
|
|
|
} |
909
|
|
|
} |
910
|
|
|
$x1 = $x; |
911
|
|
|
$y += 22; |
912
|
|
|
$x2 = round($maxW / 2, 0); |
913
|
|
|
$valesPedagios = 1; |
914
|
|
|
$temVales = false; |
915
|
|
|
if ($this->valePed != "" && $this->valePed->length > 0) { |
916
|
|
|
$valesPedagios = $this->valePed->length; |
917
|
|
|
$temVales = true; |
918
|
|
|
} |
919
|
|
|
$tamanho = ($valesPedagios * 7.5); |
920
|
|
|
if (!$temVales) { |
921
|
|
|
$valesPedagios = 0; |
922
|
|
|
} |
923
|
|
|
$this->pdf->textBox($x1, $y, $x2, 11 + $tamanho / 2); |
924
|
|
|
$texto = 'Vale Pedágio'; |
925
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
926
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
927
|
|
|
$y += 5; |
928
|
|
|
$x2 = ($x2 / 3); |
929
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2)); |
930
|
|
|
$texto = 'Responsável CNPJ'; |
931
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
932
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
933
|
|
|
$altura = $y; |
934
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
935
|
|
|
$altura += 4; |
936
|
|
|
$pgNode = $this->valePed->item($i)->getElementsByTagName('CNPJPg'); |
937
|
|
|
$texto = $pgNode->length == 0 ? '' : $pgNode->item(0)->nodeValue; |
938
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
939
|
|
|
$this->pdf->textBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
940
|
|
|
} |
941
|
|
|
$x1 += $x2 - 3; |
942
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2)); |
943
|
|
|
$texto = 'Fornecedora CNPJ'; |
944
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
945
|
|
|
$this->pdf->textBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
946
|
|
|
$altura = $y; |
947
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
948
|
|
|
$altura += 4; |
949
|
|
|
$pgNode = $this->valePed->item($i)->getElementsByTagName('CNPJForn'); |
950
|
|
|
$texto = $pgNode->length == 0 ? '' : $pgNode->item(0)->nodeValue; |
951
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
952
|
|
|
$this->pdf->textBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
953
|
|
|
} |
954
|
|
|
$x1 += $x2 - 3; |
955
|
|
|
$this->pdf->textBox($x1, $y, $x2 + 6, 6 + ($tamanho / 2)); |
956
|
|
|
$texto = 'Nº Comprovante'; |
957
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
958
|
|
|
$this->pdf->textBox($x1, $y, $x2 + 6, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
959
|
|
|
$altura = $y; |
960
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
961
|
|
|
$altura += 4; |
962
|
|
|
$texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue; |
963
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
964
|
|
|
$this->pdf->textBox($x1 + 1, $altura, $x2 + 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
965
|
|
|
} |
966
|
|
|
if (!$temVales) { |
967
|
|
|
$altura += 4; |
968
|
|
|
} |
969
|
|
|
$this->condutor = $this->veicTracao->getElementsByTagName('condutor'); |
|
|
|
|
970
|
|
|
$x1 = round($maxW / 2, 0) + 7; |
971
|
|
|
$y = $yold; |
972
|
|
|
$x2 = round($maxW / 2, 0); |
973
|
|
|
$texto = 'Condutor'; |
974
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
975
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
976
|
|
|
$y += 5; |
977
|
|
|
$x2 = ($maxW / 6); |
978
|
|
|
$this->pdf->textBox($x1, $y, $x2, 33 + ($tamanho / 2)); |
979
|
|
|
$texto = 'CPF'; |
980
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
981
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
982
|
|
|
$yold = $y; |
983
|
|
|
for ($i = 0; $i < $this->condutor->length; $i++) { |
984
|
|
|
$y += 4; |
985
|
|
|
$texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue; |
986
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
987
|
|
|
$this->pdf->textBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
988
|
|
|
} |
989
|
|
|
$y = $yold; |
990
|
|
|
$x1 += $x2; |
991
|
|
|
$x2 = $x2 * 2; |
992
|
|
|
$this->pdf->textBox($x1, $y, $x2, 33 + ($tamanho / 2)); |
993
|
|
|
$texto = 'Nome'; |
994
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
995
|
|
|
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
996
|
|
|
for ($i = 0; $i < $this->condutor->length; $i++) { |
997
|
|
|
$y += 4; |
998
|
|
|
$texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue; |
999
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1000
|
|
|
$this->pdf->textBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1001
|
|
|
} |
1002
|
|
|
} |
1003
|
|
|
|
1004
|
|
|
if ($this->aereo) { |
1005
|
|
|
$altura = $y + 4; |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
if ($this->aquav) { |
1009
|
|
|
$x1 = $x; |
1010
|
|
|
$x2 = $maxW; |
1011
|
|
|
|
1012
|
|
|
$initial = $y; |
1013
|
|
|
$initialA = $y + 2; |
1014
|
|
|
$initialB = $y + 2; |
1015
|
|
|
|
1016
|
|
|
$texto = 'Carregamento'; |
1017
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1018
|
|
|
$this->pdf->textBox($x, $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1019
|
|
|
foreach ($this->aquav->getElementsByTagName('infTermCarreg') as $item) { |
1020
|
|
|
$initialA += 4.5; |
1021
|
|
|
|
1022
|
|
|
$texto = $item->getElementsByTagName('cTermCarreg')->item(0)->nodeValue; |
1023
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1024
|
|
|
$this->pdf->textBox($x1 + 1, $initialA, ($x2 / 2) - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1025
|
|
|
|
1026
|
|
|
$texto = $item->getElementsByTagName('xTermCarreg')->item(0)->nodeValue; |
1027
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1028
|
|
|
$this->pdf->textBox($x1 + 25, $initialA, ($x2 / 2) - 25, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1029
|
|
|
|
1030
|
|
|
if (strlen($texto) > 50) { |
1031
|
|
|
$initialA += 2; |
1032
|
|
|
} |
1033
|
|
|
} |
1034
|
|
|
if ($this->aquav->getElementsByTagName('infTermCarreg')->item(0) != null) { |
1035
|
|
|
$this->pdf->textBox($x1, $initial + 6, ($x2 / 2), $initialA - $y); |
1036
|
|
|
} |
1037
|
|
|
|
1038
|
|
|
$texto = 'Descarregamento'; |
1039
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1040
|
|
|
$this->pdf->textBox($x1 + ($x2 / 2), $initial + 2, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1041
|
|
|
foreach ($this->aquav->getElementsByTagName('infTermDescarreg') as $item) { |
1042
|
|
|
$initialB += 4.5; |
1043
|
|
|
|
1044
|
|
|
$texto = $item->getElementsByTagName('cTermDescarreg')->item(0)->nodeValue; |
1045
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1046
|
|
|
$this->pdf->textBox( |
1047
|
|
|
($x1 + ($x2 / 2)) + 1, |
1048
|
|
|
$initialB, |
1049
|
|
|
($x2 / 2) - 1, |
1050
|
|
|
10, |
1051
|
|
|
$texto, |
1052
|
|
|
$aFont, |
1053
|
|
|
'T', |
1054
|
|
|
'L', |
1055
|
|
|
0, |
|
|
|
|
1056
|
|
|
'', |
1057
|
|
|
false |
1058
|
|
|
); |
1059
|
|
|
|
1060
|
|
|
$texto = $item->getElementsByTagName('xTermDescarreg')->item(0)->nodeValue; |
1061
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1062
|
|
|
|
1063
|
|
|
$this->pdf->textBox( |
1064
|
|
|
($x1 + ($x2 / 2)) + 25, |
1065
|
|
|
$initialB, |
1066
|
|
|
($x2 / 2) - 25, |
1067
|
|
|
10, |
1068
|
|
|
$texto, |
1069
|
|
|
$aFont, |
1070
|
|
|
'T', |
1071
|
|
|
'L', |
1072
|
|
|
0, |
|
|
|
|
1073
|
|
|
'', |
1074
|
|
|
false |
1075
|
|
|
); |
1076
|
|
|
|
1077
|
|
|
if (strlen($texto) > 50) { |
1078
|
|
|
$initialB += 2; |
1079
|
|
|
} |
1080
|
|
|
} |
1081
|
|
|
if ($this->aquav->getElementsByTagName('infTermDescarreg')->item(0) != null) { |
1082
|
|
|
$this->pdf->textBox(($x1 + ($x2 / 2)), $initial + 6, ($x2 / 2), $initialB - $y); |
1083
|
|
|
} |
1084
|
|
|
|
1085
|
|
|
$altura = $initialA > $initialB ? $initialA : $initialB; |
1086
|
|
|
$altura += 6; |
1087
|
|
|
|
1088
|
|
|
$y = $altura + 3; |
1089
|
|
|
|
1090
|
|
|
$initial = $y; |
1091
|
|
|
$initialA = $y + 2; |
1092
|
|
|
$initialB = $y + 2; |
1093
|
|
|
|
1094
|
|
|
$texto = 'Unidade de Transporte'; |
1095
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1096
|
|
|
$this->pdf->textBox($x, $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1097
|
|
|
|
1098
|
|
|
$texto = 'Unidade de Carga'; |
1099
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1100
|
|
|
$this->pdf->textBox($x1 + ($x2 / 4), $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1101
|
|
|
|
1102
|
|
|
foreach ($this->aquav->getElementsByTagName('infUnidCargaVazia') as $item) { |
1103
|
|
|
$initialA += 4.5; |
1104
|
|
|
|
1105
|
|
|
$texto = $item->getElementsByTagName('idUnidCargaVazia')->item(0)->nodeValue; |
1106
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1107
|
|
|
$this->pdf->textBox($x1 + 1, $initialA, ($x2 / 2) - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1108
|
|
|
|
1109
|
|
|
$texto = $item->getElementsByTagName('tpUnidCargaVazia')->item(0)->nodeValue; |
1110
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1111
|
|
|
$this->pdf->textBox( |
1112
|
|
|
$x1 + ($x2 / 4), |
1113
|
|
|
$initialA, |
1114
|
|
|
($x2 / 2) - 25, |
1115
|
|
|
10, |
1116
|
|
|
$texto, |
1117
|
|
|
$aFont, |
1118
|
|
|
'T', |
1119
|
|
|
'L', |
1120
|
|
|
0, |
|
|
|
|
1121
|
|
|
'', |
1122
|
|
|
false |
1123
|
|
|
); |
1124
|
|
|
|
1125
|
|
|
if (strlen($texto) > 50) { |
1126
|
|
|
$initialA += 2; |
1127
|
|
|
} |
1128
|
|
|
} |
1129
|
|
|
if ($this->aquav->getElementsByTagName('infUnidCargaVazia')->item(0) != null) { |
1130
|
|
|
$this->pdf->textBox($x1, $initial + 6, ($x2 / 2), $initialA - $y); |
1131
|
|
|
} |
1132
|
|
|
|
1133
|
|
|
$texto = 'Unidade de Transporte'; |
1134
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1135
|
|
|
$this->pdf->textBox($x1 + ($x2 / 2), $initial + 2, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1136
|
|
|
|
1137
|
|
|
$texto = 'Unidade de Carga'; |
1138
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
1139
|
|
|
$this->pdf->textBox($x1 + ($x2 / 1.33), $initial + 2, ($x2 / 2), 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1140
|
|
|
|
1141
|
|
|
foreach ($this->aquav->getElementsByTagName('infUnidTranspVazia') as $item) { |
1142
|
|
|
$initialB += 4.5; |
1143
|
|
|
|
1144
|
|
|
$texto = $item->getElementsByTagName('idUnidTranspVazia')->item(0)->nodeValue; |
1145
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1146
|
|
|
|
1147
|
|
|
$this->pdf->textBox( |
1148
|
|
|
($x1 + ($x2 / 2)) + 1, |
1149
|
|
|
$initialB, |
1150
|
|
|
($x2 / 2) - 1, |
1151
|
|
|
10, |
1152
|
|
|
$texto, |
1153
|
|
|
$aFont, |
1154
|
|
|
'T', |
1155
|
|
|
'L', |
1156
|
|
|
0, |
|
|
|
|
1157
|
|
|
'', |
1158
|
|
|
false |
1159
|
|
|
); |
1160
|
|
|
|
1161
|
|
|
$texto = $item->getElementsByTagName('tpUnidTranspVazia')->item(0)->nodeValue; |
1162
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1163
|
|
|
$this->pdf->textBox( |
1164
|
|
|
($x1 + ($x2 / 1.33)), |
1165
|
|
|
$initialB, |
1166
|
|
|
($x2 / 2) - 25, |
1167
|
|
|
10, |
1168
|
|
|
$texto, |
1169
|
|
|
$aFont, |
1170
|
|
|
'T', |
1171
|
|
|
'L', |
1172
|
|
|
0, |
|
|
|
|
1173
|
|
|
'', |
1174
|
|
|
false |
1175
|
|
|
); |
1176
|
|
|
|
1177
|
|
|
if (strlen($texto) > 50) { |
1178
|
|
|
$initialB += 2; |
1179
|
|
|
} |
1180
|
|
|
} |
1181
|
|
|
if ($this->aquav->getElementsByTagName('infUnidTranspVazia')->item(0) != null) { |
1182
|
|
|
$this->pdf->textBox(($x1 + ($x2 / 2)), $initial + 6, ($x2 / 2), $initialB - $y); |
1183
|
|
|
} |
1184
|
|
|
|
1185
|
|
|
$altura = $initialA > $initialB ? $initialA : $initialB; |
1186
|
|
|
$altura += 6; |
1187
|
|
|
} |
1188
|
|
|
|
1189
|
|
|
if ($this->ferrov) { |
1190
|
|
|
$altura = $y + 4; |
1191
|
|
|
} |
1192
|
|
|
|
1193
|
|
|
return $altura + 10; |
|
|
|
|
1194
|
|
|
} |
1195
|
|
|
|
1196
|
|
|
|
1197
|
|
|
protected function qrCodeDamdfe($y = 0) |
1198
|
|
|
{ |
1199
|
|
|
$margemInterna = $this->margemInterna; |
1200
|
|
|
$barcode = new Barcode(); |
1201
|
|
|
$bobj = $barcode->getBarcodeObj( |
1202
|
|
|
'QRCODE,M', |
1203
|
|
|
$this->qrCodMDFe, |
1204
|
|
|
-4, |
1205
|
|
|
-4, |
1206
|
|
|
'black', |
1207
|
|
|
array(-2, -2, -2, -2) |
1208
|
|
|
)->setBackgroundColor('white'); |
1209
|
|
|
$qrcode = $bobj->getPngData(); |
1210
|
|
|
$wQr = 35; |
1211
|
|
|
$hQr = 35; |
1212
|
|
|
$yQr = ($y + $margemInterna); |
1213
|
|
|
if ($this->orientacao == 'P') { |
1214
|
|
|
$xQr = 160; |
1215
|
|
|
} else { |
1216
|
|
|
$xQr = 235; |
1217
|
|
|
} |
1218
|
|
|
// prepare a base64 encoded "data url" |
1219
|
|
|
$pic = 'data://text/plain;base64,' . base64_encode($qrcode); |
1220
|
|
|
$this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG'); |
1221
|
|
|
} |
1222
|
|
|
|
1223
|
|
|
|
1224
|
|
|
/** |
1225
|
|
|
* footerMDFe |
1226
|
|
|
* |
1227
|
|
|
* @param float $x |
1228
|
|
|
* @param float $y |
1229
|
|
|
*/ |
1230
|
|
|
private function footerMDFe($x, $y) |
1231
|
|
|
{ |
1232
|
|
|
$maxW = $this->wPrint; |
1233
|
|
|
$x2 = $maxW; |
1234
|
|
|
if ($this->orientacao == 'P') { |
1235
|
|
|
$h = 145; |
1236
|
|
|
} else { |
1237
|
|
|
$h = 45; |
1238
|
|
|
} |
1239
|
|
|
$this->pdf->textBox($x, $y, $x2, $h); |
1240
|
|
|
$texto = 'Observação |
1241
|
|
|
' . $this->infCpl; |
1242
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
1243
|
|
|
$this->pdf->textBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
1244
|
|
|
//$y = $this->hPrint - 4; |
1245
|
|
|
$y = $this->hPrint+8; |
1246
|
|
|
$texto = "Impresso em " . date('d/m/Y H:i:s') . ' ' . $this->creditos; |
1247
|
|
|
$w = $this->wPrint - 4; |
1248
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
1249
|
|
|
$this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
1250
|
|
|
$texto = ''; |
1251
|
|
|
if ($this->powered) { |
1252
|
|
|
$texto = "Powered by NFePHP®"; |
1253
|
|
|
} |
1254
|
|
|
$this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, ''); |
1255
|
|
|
} |
1256
|
|
|
} |
1257
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: