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