|
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 DateTime; |
|
20
|
|
|
use NFePHP\DA\Legacy\Dom; |
|
21
|
|
|
use NFePHP\DA\Legacy\Common; |
|
22
|
|
|
use NFePHP\DA\Legacy\Pdf; |
|
23
|
|
|
|
|
24
|
|
|
class Damdfe extends Common |
|
25
|
|
|
{ |
|
26
|
|
|
//publicas |
|
27
|
|
|
public $logoAlign = 'L'; //alinhamento do logo |
|
28
|
|
|
public $yDados = 0; |
|
29
|
|
|
public $debugMode = 0; //ativa ou desativa o modo de debug |
|
30
|
|
|
//privadas |
|
31
|
|
|
protected $pdf; // objeto fpdf() |
|
32
|
|
|
protected $xml; // string XML NFe |
|
33
|
|
|
protected $logomarca = ''; // path para logomarca em jpg |
|
34
|
|
|
protected $errMsg = ''; // mesagens de erro |
|
35
|
|
|
protected $errStatus = false;// status de erro TRUE um erro ocorreu false sem erros |
|
36
|
|
|
protected $orientacao = 'P'; //orientação da DANFE P-Retrato ou L-Paisagem |
|
37
|
|
|
protected $papel = 'A4'; //formato do papel |
|
38
|
|
|
//destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local |
|
39
|
|
|
protected $destino = 'I'; |
|
40
|
|
|
protected $pdfDir = ''; //diretorio para salvar o pdf com a opção de destino = F |
|
41
|
|
|
protected $fontePadrao = 'Times'; //Nome da Fonte para gerar o DANFE |
|
42
|
|
|
protected $version = '1.0.0'; |
|
43
|
|
|
protected $wPrint; //largura imprimivel |
|
44
|
|
|
protected $hPrint; //comprimento imprimivel |
|
45
|
|
|
protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
|
46
|
|
|
protected $margemInterna = 2; |
|
47
|
|
|
protected $hMaxLinha = 9; |
|
48
|
|
|
protected $hBoxLinha = 6; |
|
49
|
|
|
protected $hLinha = 3; |
|
50
|
|
|
//variaveis da carta de correção |
|
51
|
|
|
protected $id; |
|
52
|
|
|
protected $chMDFe; |
|
53
|
|
|
protected $tpAmb; |
|
54
|
|
|
protected $cOrgao; |
|
55
|
|
|
protected $xCondUso; |
|
56
|
|
|
protected $dhEvento; |
|
57
|
|
|
protected $cStat; |
|
58
|
|
|
protected $xMotivo; |
|
59
|
|
|
protected $CNPJDest = ''; |
|
60
|
|
|
protected $dhRegEvento; |
|
61
|
|
|
protected $nProt; |
|
62
|
|
|
protected $tpEmis; |
|
63
|
|
|
protected $qrCodMDFe; |
|
64
|
|
|
//objetos |
|
65
|
|
|
private $dom; |
|
66
|
|
|
private $procEventoNFe; |
|
67
|
|
|
private $evento; |
|
68
|
|
|
private $infEvento; |
|
69
|
|
|
private $retEvento; |
|
70
|
|
|
private $rinfEvento; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* __construct |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $xmlfile Arquivo XML da MDFe |
|
76
|
|
|
* @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem |
|
77
|
|
|
* @param string $sPapel Tamanho do papel (Ex. A4) |
|
78
|
|
|
* @param string $sPathLogo Caminho para o arquivo do logo |
|
79
|
|
|
* @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S- |
|
80
|
|
|
* @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF |
|
81
|
|
|
* @param string $fonteDAMDFE Nome da fonte alternativa do DAnfe |
|
|
|
|
|
|
82
|
|
|
* @param integer $mododebug 0-Não 1-Sim e 2-nada (2 default) |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __construct( |
|
85
|
|
|
$xmlfile = '', |
|
86
|
|
|
$sOrientacao = '', |
|
87
|
|
|
$sPapel = '', |
|
88
|
|
|
$sPathLogo = '', |
|
89
|
|
|
$sDestino = 'I', |
|
90
|
|
|
$sDirPDF = '', |
|
91
|
|
|
$fontePDF = '', |
|
92
|
|
|
$mododebug = 2 |
|
93
|
|
|
) { |
|
94
|
|
|
//define o caminho base da instalação do sistema |
|
95
|
|
|
if (!defined('PATH_ROOT')) { |
|
96
|
|
|
define('PATH_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); |
|
97
|
|
|
} |
|
98
|
|
|
//ajuste do tempo limite de resposta do processo |
|
99
|
|
|
set_time_limit(1800); |
|
100
|
|
|
//definição do caminho para o diretorio com as fontes do FDPF |
|
101
|
|
|
if (!defined('FPDF_FONTPATH')) { |
|
102
|
|
|
define('FPDF_FONTPATH', 'font/'); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
if (is_numeric($mododebug)) { |
|
106
|
|
|
$this->debugMode = $mododebug; |
|
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
if ($this->debugMode) { |
|
109
|
|
|
//ativar modo debug |
|
110
|
|
|
error_reporting(E_ALL); |
|
111
|
|
|
ini_set('display_errors', 'On'); |
|
112
|
|
|
} else { |
|
113
|
|
|
//desativar modo debug |
|
114
|
|
|
error_reporting(0); |
|
115
|
|
|
ini_set('display_errors', 'Off'); |
|
116
|
|
|
} |
|
117
|
|
|
$this->orientacao = $sOrientacao; |
|
118
|
|
|
$this->papel = $sPapel; |
|
119
|
|
|
$this->pdf = ''; |
|
120
|
|
|
$this->xml = $xmlfile; |
|
121
|
|
|
$this->logomarca = $sPathLogo; |
|
122
|
|
|
$this->destino = $sDestino; |
|
123
|
|
|
$this->pdfDir = $sDirPDF; |
|
124
|
|
|
// verifica se foi passa a fonte a ser usada |
|
125
|
|
|
if (empty($fontePDF)) { |
|
126
|
|
|
$this->fontePadrao = 'Times'; |
|
127
|
|
|
} else { |
|
128
|
|
|
$this->fontePadrao = $fontePDF; |
|
129
|
|
|
} |
|
130
|
|
|
//se for passado o xml |
|
131
|
|
|
if (empty($xmlfile)) { |
|
132
|
|
|
$this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!'; |
|
133
|
|
|
$this->errStatus = true; |
|
134
|
|
|
} |
|
135
|
|
|
if (!is_file($xmlfile)) { |
|
136
|
|
|
$this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!'; |
|
137
|
|
|
$this->errStatus = true; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
// $docxml = file_get_contents($xmlfile); |
|
141
|
|
|
$this->dom = new Dom(); |
|
142
|
|
|
$this->dom->loadXML($this->xml); |
|
143
|
|
|
$this->mdfeProc = $this->dom->getElementsByTagName("mdfeProc")->item(0); |
|
|
|
|
|
|
144
|
|
|
$this->infMDFe = $this->dom->getElementsByTagName("infMDFe")->item(0); |
|
|
|
|
|
|
145
|
|
|
$this->emit = $this->dom->getElementsByTagName("emit")->item(0); |
|
|
|
|
|
|
146
|
|
|
$this->CNPJ = $this->dom->getElementsByTagName("CNPJ")->item(0)->nodeValue; |
|
|
|
|
|
|
147
|
|
|
$this->IE = $this->dom->getElementsByTagName("IE")->item(0)->nodeValue; |
|
|
|
|
|
|
148
|
|
|
$this->xNome = $this->dom->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
|
|
|
|
|
149
|
|
|
$this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); |
|
|
|
|
|
|
150
|
|
|
$this->xLgr = $this->dom->getElementsByTagName("xLgr")->item(0)->nodeValue; |
|
|
|
|
|
|
151
|
|
|
$this->nro = $this->dom->getElementsByTagName("nro")->item(0)->nodeValue; |
|
|
|
|
|
|
152
|
|
|
$this->xBairro = $this->dom->getElementsByTagName("xBairro")->item(0)->nodeValue; |
|
|
|
|
|
|
153
|
|
|
$this->UF = $this->dom->getElementsByTagName("UF")->item(0)->nodeValue; |
|
|
|
|
|
|
154
|
|
|
$this->xMun = $this->dom->getElementsByTagName("xMun")->item(0)->nodeValue; |
|
|
|
|
|
|
155
|
|
|
$this->CEP = $this->dom->getElementsByTagName("CEP")->item(0)->nodeValue; |
|
|
|
|
|
|
156
|
|
|
$this->ide = $this->dom->getElementsByTagName("ide")->item(0); |
|
|
|
|
|
|
157
|
|
|
$this->tpAmb = $this->dom->getElementsByTagName("tpAmb")->item(0)->nodeValue; |
|
158
|
|
|
$this->mod = $this->dom->getElementsByTagName("mod")->item(0)->nodeValue; |
|
|
|
|
|
|
159
|
|
|
$this->serie = $this->dom->getElementsByTagName("serie")->item(0)->nodeValue; |
|
|
|
|
|
|
160
|
|
|
$this->dhEmi = $this->dom->getElementsByTagName("dhEmi")->item(0)->nodeValue; |
|
|
|
|
|
|
161
|
|
|
$this->UFIni = $this->dom->getElementsByTagName("UFIni")->item(0)->nodeValue; |
|
|
|
|
|
|
162
|
|
|
$this->UFFim = $this->dom->getElementsByTagName("UFFim")->item(0)->nodeValue; |
|
|
|
|
|
|
163
|
|
|
$this->nMDF = $this->dom->getElementsByTagName("nMDF")->item(0)->nodeValue; |
|
|
|
|
|
|
164
|
|
|
$this->tpEmis = $this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue; |
|
165
|
|
|
$this->tot = $this->dom->getElementsByTagName("tot")->item(0); |
|
|
|
|
|
|
166
|
|
|
$this->qNFe = ""; |
|
|
|
|
|
|
167
|
|
|
if ($this->dom->getElementsByTagName("qNFe")->item(0) != "") { |
|
168
|
|
|
$this->qNFe = $this->dom->getElementsByTagName("qNFe")->item(0)->nodeValue; |
|
169
|
|
|
} |
|
170
|
|
|
$this->qNF = ""; |
|
|
|
|
|
|
171
|
|
|
if ($this->dom->getElementsByTagName("qNF")->item(0) != "") { |
|
172
|
|
|
$this->qNF = $this->dom->getElementsByTagName("qNF")->item(0)->nodeValue; |
|
173
|
|
|
} |
|
174
|
|
|
$this->qCTe = ""; |
|
|
|
|
|
|
175
|
|
|
if ($this->dom->getElementsByTagName("qCTe")->item(0) != "") { |
|
176
|
|
|
$this->qCTe = $this->dom->getElementsByTagName("qCTe")->item(0)->nodeValue; |
|
177
|
|
|
} |
|
178
|
|
|
$this->qCT = ""; |
|
|
|
|
|
|
179
|
|
|
if ($this->dom->getElementsByTagName("qCT")->item(0) != "") { |
|
180
|
|
|
$this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue; |
|
181
|
|
|
} |
|
182
|
|
|
$this->qCarga = $this->dom->getElementsByTagName("qCarga")->item(0)->nodeValue; |
|
|
|
|
|
|
183
|
|
|
$this->infModal = $this->dom->getElementsByTagName("infModal")->item(0); |
|
|
|
|
|
|
184
|
|
|
$this->rodo = $this->dom->getElementsByTagName("rodo")->item(0); |
|
|
|
|
|
|
185
|
|
|
$this->ciot = ""; |
|
|
|
|
|
|
186
|
|
|
if ($this->dom->getElementsByTagName('CIOT')->item(0) != "") { |
|
187
|
|
|
$this->ciot = $this->dom->getElementsByTagName('CIOT')->item(0)->nodeValue; |
|
188
|
|
|
} |
|
189
|
|
|
$this->veicTracao = $this->dom->getElementsByTagName("veicTracao")->item(0); |
|
|
|
|
|
|
190
|
|
|
$this->veicReboque = $this->dom->getElementsByTagName("veicReboque"); |
|
|
|
|
|
|
191
|
|
|
$this->valePed = ""; |
|
|
|
|
|
|
192
|
|
|
if ($this->dom->getElementsByTagName("valePed")->item(0) != "") { |
|
193
|
|
|
$this->valePed = $this->dom->getElementsByTagName("valePed")->item(0)->getElementsByTagName("disp"); |
|
194
|
|
|
} |
|
195
|
|
|
$this->infCpl = ($infCpl = $this->dom->getElementsByTagName('infCpl')->item(0)) ? $infCpl->nodeValue : ""; |
|
|
|
|
|
|
196
|
|
|
$this->chMDFe = str_replace( |
|
197
|
|
|
'MDFe', |
|
198
|
|
|
'', |
|
199
|
|
|
$this->infMDFe->getAttribute("Id") |
|
200
|
|
|
); |
|
201
|
|
|
$this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodMDFe')->item(0) ? |
|
202
|
|
|
$this->dom->getElementsByTagName('qrCodMDFe')->item(0)->nodeValue : null; |
|
203
|
|
|
if (is_object($this->mdfeProc)) { |
|
204
|
|
|
$this->nProt = !empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ? |
|
205
|
|
|
$this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : ''; |
|
206
|
|
|
$this->dhRecbto = $this->mdfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue; |
|
|
|
|
|
|
207
|
|
|
} |
|
208
|
|
|
}//fim construct |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
*buildMDFe |
|
212
|
|
|
* |
|
213
|
|
|
*/ |
|
214
|
|
|
public function buildMDFe() |
|
215
|
|
|
{ |
|
216
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
217
|
|
|
if ($this->orientacao == 'P') { |
|
218
|
|
|
// margens do PDF |
|
219
|
|
|
$margSup = 7; |
|
220
|
|
|
$margEsq = 7; |
|
221
|
|
|
$margDir = 7; |
|
222
|
|
|
// posição inicial do relatorio |
|
223
|
|
|
$xInic = 7; |
|
224
|
|
|
$yInic = 7; |
|
225
|
|
|
if ($this->papel == 'A4') { //A4 210x297mm |
|
226
|
|
|
$maxW = 210; |
|
227
|
|
|
$maxH = 297; |
|
228
|
|
|
} |
|
229
|
|
|
} else { |
|
230
|
|
|
// margens do PDF |
|
231
|
|
|
$margSup = 7; |
|
232
|
|
|
$margEsq = 7; |
|
233
|
|
|
$margDir = 7; |
|
234
|
|
|
// posição inicial do relatorio |
|
235
|
|
|
$xInic = 7; |
|
236
|
|
|
$yInic = 7; |
|
237
|
|
|
if ($this->papel == 'A4') { //A4 210x297mm |
|
238
|
|
|
$maxH = 210; |
|
239
|
|
|
$maxW = 297; |
|
240
|
|
|
} |
|
241
|
|
|
}//orientação |
|
242
|
|
|
//largura imprimivel em mm |
|
243
|
|
|
$this->wPrint = $maxW - ($margEsq + $xInic); |
|
|
|
|
|
|
244
|
|
|
//comprimento imprimivel em mm |
|
245
|
|
|
$this->hPrint = $maxH - ($margSup + $yInic); |
|
|
|
|
|
|
246
|
|
|
// estabelece contagem de paginas |
|
247
|
|
|
$this->pdf->AliasNbPages(); |
|
248
|
|
|
// fixa as margens |
|
249
|
|
|
$this->pdf->SetMargins($margEsq, $margSup, $margDir); |
|
250
|
|
|
$this->pdf->SetDrawColor(0, 0, 0); |
|
251
|
|
|
$this->pdf->SetFillColor(255, 255, 255); |
|
252
|
|
|
// inicia o documento |
|
253
|
|
|
$this->pdf->Open(); |
|
254
|
|
|
// adiciona a primeira página |
|
255
|
|
|
$this->pdf->AddPage($this->orientacao, $this->papel); |
|
256
|
|
|
$this->pdf->SetLineWidth(0.1); |
|
257
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
258
|
|
|
//montagem da página |
|
259
|
|
|
$x = $xInic; |
|
260
|
|
|
$y = $yInic; |
|
261
|
|
|
//coloca o cabeçalho Paisagem |
|
262
|
|
|
if ($this->orientacao == 'P') { |
|
263
|
|
|
$y = $this->headerMDFeRetrato($x, $y); |
|
264
|
|
|
} else { |
|
265
|
|
|
$y = $this->headerMDFePaisagem($x, $y); |
|
266
|
|
|
} |
|
267
|
|
|
//coloca os dados da MDFe |
|
268
|
|
|
$y = $this->bodyMDFe($x, $y); |
|
269
|
|
|
//coloca os dados da MDFe |
|
270
|
|
|
$y = $this->footerMDFe($x, $y); |
|
|
|
|
|
|
271
|
|
|
} //fim buildCCe |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* headerMDFePaisagem |
|
275
|
|
|
* @param float $x |
|
276
|
|
|
* @param float $y |
|
277
|
|
|
* @return string |
|
278
|
|
|
*/ |
|
279
|
|
|
private function headerMDFePaisagem($x, $y) |
|
280
|
|
|
{ |
|
281
|
|
|
$oldY = $y; |
|
282
|
|
|
$maxW = $this->wPrint; |
|
283
|
|
|
//#################################################################################### |
|
284
|
|
|
//coluna esquerda identificação do emitente |
|
285
|
|
|
$w = $maxW; //round($maxW*0.41, 0);// 80; |
|
286
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
|
|
|
|
|
|
287
|
|
|
$w1 = $w; |
|
|
|
|
|
|
288
|
|
|
$h = 30; |
|
289
|
|
|
$oldY += $h; |
|
290
|
|
|
$this->pTextBox($x, $y, $w, $h); |
|
291
|
|
|
if (is_file($this->logomarca)) { |
|
292
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
293
|
|
|
//largura da imagem em mm |
|
294
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
295
|
|
|
//altura da imagem em mm |
|
296
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
297
|
|
|
if ($this->logoAlign == 'L') { |
|
298
|
|
|
$nImgW = round($w / 4.5, 0); |
|
299
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
300
|
|
|
$xImg = $x + 1; |
|
301
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
302
|
|
|
//estabelecer posições do texto |
|
303
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
|
304
|
|
|
$y1 = round($y + 2, 0); |
|
305
|
|
|
$tw = round(2 * $w / 3, 0); |
|
306
|
|
|
} |
|
307
|
|
|
if ($this->logoAlign == 'C') { |
|
308
|
|
|
$nImgH = round($h / 3, 0); |
|
309
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
310
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
311
|
|
|
$yImg = $y + 3; |
|
312
|
|
|
$x1 = $x; |
|
313
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
314
|
|
|
$tw = $w; |
|
315
|
|
|
} |
|
316
|
|
|
if ($this->logoAlign == 'R') { |
|
317
|
|
|
$nImgW = round($w / 3, 0); |
|
318
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
319
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
320
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
321
|
|
|
$x1 = $x; |
|
322
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
323
|
|
|
$tw = round(2 * $w / 3, 0); |
|
324
|
|
|
} |
|
325
|
|
|
$this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
326
|
|
|
} else { |
|
327
|
|
|
$x1 = $x; |
|
328
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
329
|
|
|
$tw = $w; |
|
330
|
|
|
} |
|
331
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
332
|
|
|
$razao = $this->xNome; |
|
333
|
|
|
$cnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##"); |
|
334
|
|
|
$ie = 'IE: ' . $this->pFormat($this->IE, '##/########'); |
|
335
|
|
|
$lgr = 'Logradouro: ' . $this->xLgr; |
|
336
|
|
|
$nro = 'Nº: ' . $this->nro; |
|
337
|
|
|
$bairro = 'Bairro: ' . $this->xBairro; |
|
338
|
|
|
$CEP = $this->CEP; |
|
339
|
|
|
$CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###"); |
|
340
|
|
|
$UF = 'UF: ' . $this->UF; |
|
341
|
|
|
$mun = 'Municipio: ' . $this->xMun; |
|
342
|
|
|
|
|
343
|
|
|
$texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n"; |
|
344
|
|
|
$texto .= $lgr . ' - ' . $nro . "\n"; |
|
345
|
|
|
$texto .= $bairro . "\n"; |
|
346
|
|
|
$texto .= $UF . ' - ' . $mun . ' - ' . $CEP; |
|
347
|
|
|
$this->pTextBox($x1, $y1 + 5, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
348
|
|
|
$x = $x + $maxW / 2; |
|
349
|
|
|
$w = $maxW / 2; |
|
350
|
|
|
$this->pTextBox($x, $y, $w, $h); |
|
351
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I'); |
|
352
|
|
|
$this->pTextBox( |
|
353
|
|
|
$x, |
|
354
|
|
|
$y, |
|
355
|
|
|
$w, |
|
356
|
|
|
8, |
|
357
|
|
|
'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais', |
|
358
|
|
|
$aFont, |
|
359
|
|
|
'T', |
|
360
|
|
|
'C', |
|
361
|
|
|
0, |
|
362
|
|
|
'' |
|
363
|
|
|
); |
|
364
|
|
|
$this->pTextBox($x, $y, $w, 6); |
|
365
|
|
|
$bH = 13; |
|
366
|
|
|
$bW = round(($w), 0); |
|
367
|
|
|
$this->pdf->SetFillColor(0, 0, 0); |
|
368
|
|
|
$this->pdf->Code128($x + 5, $y + 7.5, $this->chMDFe, $bW - 10, $bH); |
|
369
|
|
|
$this->pdf->SetFillColor(255, 255, 255); |
|
370
|
|
|
$y = $y + 22; |
|
371
|
|
|
$this->pTextBox($x, $y, $w, 8); |
|
372
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
|
373
|
|
|
$texto = 'CHAVE DE ACESSO'; |
|
374
|
|
|
$this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, ''); |
|
375
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
376
|
|
|
$texto = $this->pFormat($this->chMDFe, $this->formatoChave); |
|
377
|
|
|
$this->pTextBox($x, $y + 3, $w, 6, $texto, $aFont, 'T', 'C', 0, ''); |
|
378
|
|
|
$y = $y + 11; |
|
379
|
|
|
$this->pTextBox($x, $y, $w, 12); |
|
380
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
|
381
|
|
|
$texto = 'PROTOCOLO DE AUTORIZACAO DE USO'; |
|
382
|
|
|
$this->pTextBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
383
|
|
|
|
|
384
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
385
|
|
|
if (is_object($this->mdfeProc)) { |
|
386
|
|
|
$tsHora = $this->pConvertTime($this->dhRecbto); |
|
387
|
|
|
$texto = $this->nProt . ' - ' . date('d/m/Y H:i:s', $tsHora); |
|
388
|
|
|
} else { |
|
389
|
|
|
$texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y H:i:s'); |
|
390
|
|
|
} |
|
391
|
|
|
$this->pTextBox($x, $y + 4, $w, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
392
|
|
|
if ($this->tpAmb != 1) { |
|
393
|
|
|
$x = 10; |
|
394
|
|
|
if ($this->orientacao == 'P') { |
|
395
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
|
396
|
|
|
} else { |
|
397
|
|
|
$yy = round($this->hPrint / 2, 0); |
|
398
|
|
|
} |
|
399
|
|
|
$h = 5; |
|
400
|
|
|
$w = $maxW - (2 * $x); |
|
401
|
|
|
$this->pdf->SetTextColor(90, 90, 90); |
|
402
|
|
|
$texto = "SEM VALOR FISCAL"; |
|
403
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'); |
|
404
|
|
|
$this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
405
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'); |
|
406
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
|
407
|
|
|
$this->pTextBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
408
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
409
|
|
|
} else { |
|
410
|
|
|
$x = 10; |
|
411
|
|
|
if ($this->orientacao == 'P') { |
|
412
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
|
413
|
|
|
} else { |
|
414
|
|
|
$yy = round($this->hPrint / 2, 0); |
|
415
|
|
|
}//fim orientacao |
|
416
|
|
|
$h = 5; |
|
417
|
|
|
$w = $maxW - (2 * $x); |
|
418
|
|
|
$this->pdf->SetTextColor(90, 90, 90); |
|
419
|
|
|
//indicar FALTA DO PROTOCOLO se MDFe não for em contingência |
|
420
|
|
|
if (($this->tpEmis == 2 || $this->tpEmis == 5)) { |
|
421
|
|
|
//Contingência |
|
422
|
|
|
$texto = "DAMDFE Emitido em Contingência"; |
|
423
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'); |
|
424
|
|
|
$this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
425
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'); |
|
426
|
|
|
$texto = "devido à problemas técnicos"; |
|
427
|
|
|
$this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
428
|
|
|
} |
|
429
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
430
|
|
|
} |
|
431
|
|
|
return $y; |
|
432
|
|
|
}// fim headerMDFe |
|
433
|
|
|
|
|
434
|
|
|
/** |
|
435
|
|
|
* headerMDFeRetrato |
|
436
|
|
|
* |
|
437
|
|
|
* @param float $x |
|
438
|
|
|
* @param float $y |
|
439
|
|
|
* @return string |
|
440
|
|
|
*/ |
|
441
|
|
|
private function headerMDFeRetrato($x, $y) |
|
442
|
|
|
{ |
|
443
|
|
|
$oldY = $y; |
|
444
|
|
|
$maxW = $this->wPrint; |
|
445
|
|
|
//#################################################################################### |
|
446
|
|
|
//coluna esquerda identificação do emitente |
|
447
|
|
|
$w = $maxW; //round($maxW*0.41, 0);// 80; |
|
448
|
|
|
$h = 27; |
|
449
|
|
|
$tw = $w; |
|
450
|
|
|
$oldY += $h; |
|
451
|
|
|
$this->pTextBox($x, $y, $w, $h); |
|
452
|
|
|
$x1 = $x; |
|
453
|
|
|
if (is_file($this->logomarca)) { |
|
454
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
455
|
|
|
//largura da imagem em mm |
|
456
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
457
|
|
|
//altura da imagem em mm |
|
458
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
459
|
|
|
switch ($this->logoAlign) { |
|
460
|
|
|
case 'L': |
|
461
|
|
|
$nImgW = round($w / 8, 0); |
|
462
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
463
|
|
|
$xImg = $x + 1; |
|
464
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
465
|
|
|
//estabelecer posições do texto |
|
466
|
|
|
$x = round($xImg + $nImgW + 1, 0); |
|
467
|
|
|
$y = round($y + 2, 0); |
|
468
|
|
|
$tw = round(2 * $w / 3, 0); |
|
469
|
|
|
$x1 = $x - 27; |
|
470
|
|
|
break; |
|
471
|
|
|
|
|
472
|
|
|
case 'C': |
|
473
|
|
|
$nImgH = round($h / 3, 0); |
|
474
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
475
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
476
|
|
|
$yImg = $y + 3; |
|
477
|
|
|
$y = round($yImg + $nImgH + 1, 0); |
|
478
|
|
|
$tw = $w; |
|
479
|
|
|
$x1 = $x - 27; |
|
480
|
|
|
break; |
|
481
|
|
|
|
|
482
|
|
|
case 'R': |
|
483
|
|
|
$nImgW = round($w / 3, 0); |
|
484
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
485
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
486
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
487
|
|
|
$y = round($h / 3 + $y, 0); |
|
488
|
|
|
$tw = round(2 * $w / 3, 0); |
|
489
|
|
|
$x1 = $x - 27; |
|
490
|
|
|
break; |
|
491
|
|
|
default: |
|
492
|
|
|
$x1 = $x; |
|
493
|
|
|
break; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
$this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
if ($this->qrCodMDFe !== null) { |
|
500
|
|
|
$this->pQRDAMDFE($y - 3); |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 11, 'style' => ''); |
|
504
|
|
|
$razao = $this->xNome; |
|
505
|
|
|
$cnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##"); |
|
506
|
|
|
$ie = 'IE: ' . $this->pFormat($this->IE, '##########'); |
|
507
|
|
|
$lgr = 'Logradouro: ' . $this->xLgr; |
|
508
|
|
|
$nro = 'Nº: ' . $this->nro; |
|
509
|
|
|
$bairro = 'Bairro: ' . $this->xBairro; |
|
510
|
|
|
$CEP = $this->CEP; |
|
511
|
|
|
$CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###"); |
|
512
|
|
|
$mun = 'Municipio: ' . $this->xMun; |
|
513
|
|
|
$UF = 'UF: ' . $this->UF; |
|
514
|
|
|
$texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n"; |
|
515
|
|
|
$texto .= $lgr . ' - ' . $nro . "\n"; |
|
516
|
|
|
$texto .= $bairro . "\n"; |
|
517
|
|
|
$texto .= $UF . ' - ' . $mun . ' - ' . $CEP; |
|
518
|
|
|
$this->pTextBox($x, $y, $tw, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
519
|
|
|
|
|
520
|
|
|
//################################################## |
|
521
|
|
|
$y = $h + 8; |
|
522
|
|
|
$this->pTextBox($x1, $y, $maxW, 6); |
|
523
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I'); |
|
524
|
|
|
$this->pTextBox( |
|
525
|
|
|
$x1, |
|
526
|
|
|
$y, |
|
527
|
|
|
$maxW, |
|
528
|
|
|
8, |
|
529
|
|
|
'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais', |
|
530
|
|
|
$aFont, |
|
531
|
|
|
'T', |
|
532
|
|
|
'C', |
|
533
|
|
|
0, |
|
534
|
|
|
'' |
|
535
|
|
|
); |
|
536
|
|
|
$y = $y + 8; |
|
537
|
|
|
$this->pTextBox($x1, $y, $maxW, 20); |
|
538
|
|
|
$bH = 16; |
|
539
|
|
|
$w = $maxW; |
|
|
|
|
|
|
540
|
|
|
$this->pdf->SetFillColor(0, 0, 0); |
|
541
|
|
|
$this->pdf->Code128($x1 + 5, $y + 2, $this->chMDFe, $maxW - 10, $bH); |
|
542
|
|
|
$this->pdf->SetFillColor(255, 255, 255); |
|
543
|
|
|
$y = $y + 27; |
|
544
|
|
|
$this->pTextBox($x1, $y, $maxW, 10); |
|
545
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
|
546
|
|
|
$tsHora = $this->pConvertTime($this->dhEvento); |
|
|
|
|
|
|
547
|
|
|
$texto = 'CHAVE DE ACESSO'; |
|
548
|
|
|
$this->pTextBox($x1, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, ''); |
|
549
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
550
|
|
|
$texto = $this->pFormat($this->chMDFe, $this->formatoChave); |
|
551
|
|
|
$this->pTextBox($x1, $y + 4, $maxW, 6, $texto, $aFont, 'T', 'C', 0, ''); |
|
552
|
|
|
$y = $y + 12; |
|
553
|
|
|
$this->pTextBox($x1, $y, $maxW, 10); |
|
554
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
|
555
|
|
|
$texto = 'PROTOCOLO DE AUTORIZACAO DE USO'; |
|
556
|
|
|
$this->pTextBox($x1, $y, $maxW, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
557
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
558
|
|
|
if (is_object($this->mdfeProc)) { |
|
559
|
|
|
$tsHora = $this->pConvertTime($this->dhRecbto); |
|
560
|
|
|
$texto = $this->nProt . ' - ' . date('d/m/Y H:i:s', $tsHora); |
|
561
|
|
|
} else { |
|
562
|
|
|
$texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y H:i:s'); |
|
563
|
|
|
} |
|
564
|
|
|
$this->pTextBox($x1, $y + 4, $maxW, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
565
|
|
|
if ($this->tpAmb != 1) { |
|
566
|
|
|
$x = 10; |
|
567
|
|
|
if ($this->orientacao == 'P') { |
|
568
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
|
569
|
|
|
} else { |
|
570
|
|
|
$yy = round($this->hPrint / 2, 0); |
|
571
|
|
|
} |
|
572
|
|
|
$h = 5; |
|
573
|
|
|
$w = $maxW - (2 * $x); |
|
574
|
|
|
$this->pdf->SetTextColor(90, 90, 90); |
|
575
|
|
|
$texto = "SEM VALOR FISCAL"; |
|
576
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'); |
|
577
|
|
|
$this->pTextBox($x + 7, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
578
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'); |
|
579
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
|
580
|
|
|
$this->pTextBox($x + 7, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
581
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
582
|
|
|
} else { |
|
583
|
|
|
$x = 10; |
|
584
|
|
|
if ($this->orientacao == 'P') { |
|
585
|
|
|
$yy = round($this->hPrint * 2 / 3, 0); |
|
586
|
|
|
} else { |
|
587
|
|
|
$yy = round($this->hPrint / 2, 0); |
|
588
|
|
|
}//fim orientacao |
|
589
|
|
|
$h = 5; |
|
590
|
|
|
$w = $maxW - (2 * $x); |
|
591
|
|
|
$this->pdf->SetTextColor(90, 90, 90); |
|
592
|
|
|
//indicar FALTA DO PROTOCOLO se MDFe não for em contingência |
|
593
|
|
|
if (($this->tpEmis == 2 || $this->tpEmis == 5)) { |
|
594
|
|
|
//Contingência |
|
595
|
|
|
$texto = "DAMDFE Emitido em Contingência"; |
|
596
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'); |
|
597
|
|
|
$this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
598
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'); |
|
599
|
|
|
$texto = "devido à problemas técnicos"; |
|
600
|
|
|
$this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
601
|
|
|
} |
|
602
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
603
|
|
|
} |
|
604
|
|
|
return $y + 17; |
|
605
|
|
|
}// fim headerMDFe |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* bodyMDFe |
|
609
|
|
|
* |
|
610
|
|
|
* @param float $x |
|
611
|
|
|
* @param float $y |
|
612
|
|
|
* @return void |
|
613
|
|
|
*/ |
|
614
|
|
|
private function bodyMDFe($x, $y) |
|
615
|
|
|
{ |
|
616
|
|
|
if ($this->orientacao == 'P') { |
|
617
|
|
|
$maxW = $this->wPrint; |
|
618
|
|
|
} else { |
|
619
|
|
|
$maxW = $this->wPrint / 2; |
|
620
|
|
|
} |
|
621
|
|
|
$x2 = ($maxW / 6); |
|
622
|
|
|
$x1 = $x2; |
|
|
|
|
|
|
623
|
|
|
$this->pTextBox($x, $y, $x2 - 7, 12); |
|
624
|
|
|
$texto = 'Modelo'; |
|
625
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
626
|
|
|
$this->pTextBox($x, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
627
|
|
|
$texto = $this->mod; |
|
628
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
629
|
|
|
$this->pTextBox($x, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
630
|
|
|
$x1 = $x2; |
|
631
|
|
|
$this->pTextBox($x1, $y, $x2 - 7, 12); |
|
632
|
|
|
$texto = 'Série'; |
|
633
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
634
|
|
|
$this->pTextBox($x1, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
635
|
|
|
$texto = $this->serie; |
|
636
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
637
|
|
|
$this->pTextBox($x1, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
638
|
|
|
$x1 += $x2 - 7; |
|
639
|
|
|
$this->pTextBox($x1, $y, $x2 + 5, 12); |
|
640
|
|
|
$texto = 'Número'; |
|
641
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
642
|
|
|
$this->pTextBox($x1, $y, $x2 + 5, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
643
|
|
|
$texto = $this->pFormat(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###'); |
|
644
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
645
|
|
|
$this->pTextBox($x1, $y + 4, $x2 + 5, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
646
|
|
|
$x1 += $x2 + 5; |
|
647
|
|
|
$this->pTextBox($x1, $y, $x2 - 7, 12); |
|
648
|
|
|
$texto = 'FL'; |
|
649
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
650
|
|
|
$this->pTextBox($x1, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
651
|
|
|
$texto = '1'; |
|
652
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
653
|
|
|
$this->pTextBox($x1, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
654
|
|
|
$x1 += $x2 - 7; |
|
655
|
|
|
$this->pTextBox($x1, $y, $x2 + 11, 12); |
|
656
|
|
|
$texto = 'Data e Hora de Emissão'; |
|
657
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
658
|
|
|
$this->pTextBox($x1, $y, $x2 + 11, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
659
|
|
|
$data = explode('T', $this->dhEmi); |
|
660
|
|
|
$texto = $this->pYmd2dmy($data[0]) . ' - ' . $data[1]; |
|
661
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
662
|
|
|
$this->pTextBox($x1, $y + 4, $x2 + 11, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
663
|
|
|
$x1 += $x2 + 11; |
|
664
|
|
|
$this->pTextBox($x1, $y, $x2 - 15, 12); |
|
665
|
|
|
$texto = 'UF Carreg.'; |
|
666
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
667
|
|
|
$this->pTextBox($x1, $y, $x2 - 15, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
668
|
|
|
$texto = $this->UFIni; |
|
669
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
670
|
|
|
$this->pTextBox($x1, $y + 4, $x2 - 15, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
671
|
|
|
$maxW = $this->wPrint; |
|
|
|
|
|
|
672
|
|
|
|
|
673
|
|
|
$x1 += $x2 - 15; |
|
674
|
|
|
$this->pTextBox($x1, $y, $x2 - 13, 12); |
|
675
|
|
|
$texto = 'UF Descar.'; |
|
676
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
677
|
|
|
$this->pTextBox($x1, $y, $x2 - 13, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
678
|
|
|
$texto = $this->UFFim; |
|
679
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
680
|
|
|
$this->pTextBox($x1, $y + 4, $x2 - 13, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
681
|
|
|
$maxW = $this->wPrint; |
|
682
|
|
|
|
|
683
|
|
|
|
|
684
|
|
|
$x1 = $x; |
|
685
|
|
|
$x2 = $maxW; |
|
686
|
|
|
$y += 14; |
|
687
|
|
|
$this->pTextBox($x1, $y, $x2, 23); |
|
688
|
|
|
$texto = 'Modal Rodoviário de Carga'; |
|
689
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
|
690
|
|
|
$this->pTextBox($x1, $y + 1, $x2, 8, $texto, $aFont, 'T', 'C', 0, '', false); |
|
691
|
|
|
$x1 = $x; |
|
692
|
|
|
$x2 = ($maxW / 6); |
|
693
|
|
|
$y += 6; |
|
694
|
|
|
$this->pTextBox($x1, $y, $x2, 12); |
|
695
|
|
|
$texto = 'Qtd. CT-e'; |
|
696
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
697
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
698
|
|
|
$texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT); |
|
699
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
700
|
|
|
$this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
701
|
|
|
$x1 += $x2; |
|
702
|
|
|
$this->pTextBox($x1, $y, $x2, 12); |
|
703
|
|
|
$texto = 'Qtd. NF-e'; |
|
704
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
705
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
706
|
|
|
$texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT); |
|
707
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
708
|
|
|
$this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
709
|
|
|
$x1 += $x2; |
|
710
|
|
|
$this->pTextBox($x1, $y, $x2, 12); |
|
711
|
|
|
$texto = 'Peso Total (Kg)'; |
|
712
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
713
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
714
|
|
|
$texto = number_format($this->qCarga, 4, ', ', '.'); |
|
715
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
716
|
|
|
$this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
717
|
|
|
$x1 = $x; |
|
718
|
|
|
$y += 12; |
|
719
|
|
|
$yold = $y; |
|
720
|
|
|
$x2 = round($maxW / 2, 0); |
|
721
|
|
|
$texto = 'Veículo'; |
|
722
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
723
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
724
|
|
|
$y += 5; |
|
725
|
|
|
$x2 = round($maxW / 4, 0); |
|
726
|
|
|
$tamanho = 22; |
|
727
|
|
|
$this->pTextBox($x1, $y, $x2, $tamanho); |
|
728
|
|
|
$texto = 'Placa'; |
|
729
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
730
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
731
|
|
|
$texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue; |
|
732
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
733
|
|
|
$this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
734
|
|
|
$altura = $y + 4; |
|
735
|
|
|
/** @var \DOMNodeList $veicReboque */ |
|
736
|
|
|
$veicReboque = $this->veicReboque; |
|
737
|
|
|
foreach ($veicReboque as $item) { |
|
738
|
|
|
/** @var \DOMElement $item */ |
|
739
|
|
|
$altura += 4; |
|
740
|
|
|
$texto = $item->getElementsByTagName('placa')->item(0)->nodeValue; |
|
741
|
|
|
$this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
742
|
|
|
} |
|
743
|
|
|
$x1 += $x2; |
|
744
|
|
|
$this->pTextBox($x1, $y, $x2, $tamanho); |
|
745
|
|
|
$texto = 'RNTRC'; |
|
746
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
747
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
748
|
|
|
// RNTRC Não informado |
|
749
|
|
|
if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) { |
|
750
|
|
|
$texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue; |
|
751
|
|
|
} else { |
|
752
|
|
|
$texto = ""; |
|
753
|
|
|
} |
|
754
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
755
|
|
|
$this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
756
|
|
|
$altura = $y + 4; |
|
757
|
|
|
/** @var \DOMNodeList $veicReboque */ |
|
758
|
|
|
$veicReboque = $this->veicReboque; |
|
759
|
|
|
foreach ($veicReboque as $item) { |
|
760
|
|
|
/** @var \DOMElement $item */ |
|
761
|
|
|
$DOMNodeList = $item->getElementsByTagName('RNTRC'); |
|
762
|
|
|
if ($DOMNodeList->length > 0) { |
|
763
|
|
|
$altura += 4; |
|
764
|
|
|
$texto = $DOMNodeList->item(0)->nodeValue; |
|
765
|
|
|
$this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false); |
|
766
|
|
|
} |
|
767
|
|
|
} |
|
768
|
|
|
$x1 = $x; |
|
769
|
|
|
$y += 22; |
|
770
|
|
|
$x2 = round($maxW / 2, 0); |
|
771
|
|
|
$valesPedagios = 1; |
|
772
|
|
|
$temVales = false; |
|
773
|
|
|
if ($this->valePed != "" && $this->valePed->length > 0) { |
|
774
|
|
|
$valesPedagios = $this->valePed->length; |
|
775
|
|
|
$temVales = true; |
|
776
|
|
|
} |
|
777
|
|
|
$tamanho = ($valesPedagios * 7.5); |
|
778
|
|
|
if (!$temVales) { |
|
779
|
|
|
$valesPedagios = 0; |
|
780
|
|
|
} |
|
781
|
|
|
$this->pTextBox($x1, $y, $x2, 11 + $tamanho / 2); |
|
782
|
|
|
$texto = 'Vale Pedágio'; |
|
783
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
784
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
785
|
|
|
$y += 5; |
|
786
|
|
|
$x2 = ($x2 / 3); |
|
787
|
|
|
$this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2)); |
|
788
|
|
|
$texto = 'Responsável CNPJ'; |
|
789
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
790
|
|
|
$this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
791
|
|
|
$altura = $y; |
|
792
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
|
793
|
|
|
$altura += 4; |
|
794
|
|
|
$texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue; |
|
795
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
796
|
|
|
$this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
797
|
|
|
} |
|
798
|
|
|
$x1 += $x2 - 3; |
|
799
|
|
|
$this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2)); |
|
800
|
|
|
$texto = 'Fornecedora CNPJ'; |
|
801
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
802
|
|
|
$this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
803
|
|
|
$altura = $y; |
|
804
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
|
805
|
|
|
$altura += 4; |
|
806
|
|
|
$texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue; |
|
807
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
808
|
|
|
$this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
809
|
|
|
} |
|
810
|
|
|
$x1 += $x2 - 3; |
|
811
|
|
|
$this->pTextBox($x1, $y, $x2 + 6, 6 + ($tamanho / 2)); |
|
812
|
|
|
$texto = 'Nº Comprovante'; |
|
813
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
814
|
|
|
$this->pTextBox($x1, $y, $x2 + 6, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
815
|
|
|
$altura = $y; |
|
816
|
|
|
for ($i = 0; $i < $valesPedagios; $i++) { |
|
817
|
|
|
$altura += 4; |
|
818
|
|
|
$texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue; |
|
819
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
820
|
|
|
$this->pTextBox($x1 + 1, $altura, $x2 + 5, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
821
|
|
|
} |
|
822
|
|
|
if (!$temVales) { |
|
823
|
|
|
$altura += 4; |
|
824
|
|
|
} |
|
825
|
|
|
$this->condutor = $this->veicTracao->getElementsByTagName('condutor'); |
|
|
|
|
|
|
826
|
|
|
$x1 = round($maxW / 2, 0) + 7; |
|
827
|
|
|
$y = $yold; |
|
828
|
|
|
$x2 = round($maxW / 2, 0); |
|
829
|
|
|
$texto = 'Condutor'; |
|
830
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
831
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
832
|
|
|
$y += 5; |
|
833
|
|
|
$x2 = ($maxW / 4); |
|
834
|
|
|
$this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2)); |
|
835
|
|
|
$texto = 'CPF'; |
|
836
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
837
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
838
|
|
|
$yold = $y; |
|
839
|
|
|
for ($i = 0; $i < $this->condutor->length; $i++) { |
|
840
|
|
|
$y += 4; |
|
841
|
|
|
$texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue; |
|
842
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
843
|
|
|
$this->pTextBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false); |
|
844
|
|
|
} |
|
845
|
|
|
$y = $yold; |
|
846
|
|
|
$x1 += $x2; |
|
847
|
|
|
$this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2)); |
|
848
|
|
|
$texto = 'Nome'; |
|
849
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
850
|
|
|
$this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
851
|
|
|
for ($i = 0; $i < $this->condutor->length; $i++) { |
|
852
|
|
|
$y += 4; |
|
853
|
|
|
$texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue; |
|
854
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
855
|
|
|
$this->pTextBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
856
|
|
|
} |
|
857
|
|
|
return $altura + 7; |
|
858
|
|
|
} |
|
859
|
|
|
|
|
860
|
|
|
|
|
861
|
|
|
protected function pQRDAMDFE($y = 0) |
|
862
|
|
|
{ |
|
863
|
|
|
|
|
864
|
|
|
$margemInterna = $this->margemInterna; |
|
865
|
|
|
$barcode = new Barcode(); |
|
866
|
|
|
$bobj = $barcode->getBarcodeObj( |
|
867
|
|
|
'QRCODE,M', |
|
868
|
|
|
$this->qrCodMDFe, |
|
869
|
|
|
-4, |
|
870
|
|
|
-4, |
|
871
|
|
|
'black', |
|
872
|
|
|
array(-2, -2, -2, -2) |
|
873
|
|
|
)->setBackgroundColor('white'); |
|
874
|
|
|
$qrcode = $bobj->getPngData(); |
|
875
|
|
|
$wQr = 25; |
|
876
|
|
|
$hQr = 25; |
|
877
|
|
|
$yQr = ($y + $margemInterna); |
|
878
|
|
|
$xQr = 170; |
|
879
|
|
|
// prepare a base64 encoded "data url" |
|
880
|
|
|
$pic = 'data://text/plain;base64,' . base64_encode($qrcode); |
|
881
|
|
|
$this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG'); |
|
882
|
|
|
} |
|
883
|
|
|
|
|
884
|
|
|
|
|
885
|
|
|
/** |
|
886
|
|
|
* footerMDFe |
|
887
|
|
|
* |
|
888
|
|
|
* @param float $x |
|
889
|
|
|
* @param float $y |
|
890
|
|
|
*/ |
|
891
|
|
|
private function footerMDFe($x, $y) |
|
892
|
|
|
{ |
|
893
|
|
|
$maxW = $this->wPrint; |
|
894
|
|
|
$x2 = $maxW; |
|
895
|
|
|
$this->pTextBox($x, $y, $x2, 30); |
|
896
|
|
|
$texto = 'Observação |
|
897
|
|
|
' . $this->infCpl; |
|
898
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
899
|
|
|
$this->pTextBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false); |
|
900
|
|
|
$y = $this->hPrint - 4; |
|
901
|
|
|
$texto = "Impresso em " . date('d/m/Y H:i:s'); |
|
902
|
|
|
$w = $this->wPrint - 4; |
|
903
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
|
904
|
|
|
$this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, ''); |
|
905
|
|
|
}//fim footerCCe |
|
906
|
|
|
|
|
907
|
|
|
/** |
|
908
|
|
|
* printMDFe |
|
909
|
|
|
* |
|
910
|
|
|
* @param string $nome |
|
911
|
|
|
* @param string $destino |
|
912
|
|
|
* @param string $printer |
|
913
|
|
|
* @return string |
|
914
|
|
|
*/ |
|
915
|
|
|
public function printMDFe($nome = '', $destino = 'I', $printer = '') |
|
916
|
|
|
{ |
|
917
|
|
|
//monta |
|
918
|
|
|
$command = ''; |
|
919
|
|
|
if ($nome == '') { |
|
920
|
|
|
$file = $this->pdfDir . 'mdfe.pdf'; |
|
921
|
|
|
} else { |
|
922
|
|
|
$file = $this->pdfDir . $nome; |
|
923
|
|
|
} |
|
924
|
|
|
if ($destino != 'I' && $destino != 'S' && $destino != 'F') { |
|
925
|
|
|
$destino = 'I'; |
|
926
|
|
|
} |
|
927
|
|
|
if ($printer != '') { |
|
928
|
|
|
$command = "-P $printer"; |
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
$this->buildMDFe(); |
|
932
|
|
|
$arq = $this->pdf->Output($file, $destino); |
|
933
|
|
|
if ($destino == 'S' && $command != '') { |
|
934
|
|
|
//aqui pode entrar a rotina de impressão direta |
|
935
|
|
|
$command = "lpr $command $file"; |
|
936
|
|
|
system($command, $retorno); |
|
937
|
|
|
} |
|
938
|
|
|
|
|
939
|
|
|
return $arq; |
|
940
|
|
|
}//fim printMDFe |
|
941
|
|
|
|
|
942
|
|
|
/** |
|
943
|
|
|
* Dados brutos do PDF |
|
944
|
|
|
* @return string |
|
945
|
|
|
*/ |
|
946
|
|
|
public function render() |
|
947
|
|
|
{ |
|
948
|
|
|
return $this->pdf->getPdf(); |
|
949
|
|
|
} |
|
950
|
|
|
} |
|
951
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.