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