Complex classes like Danfe often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Danfe, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
10 | class Danfe extends Common |
||
11 | { |
||
12 | const FPDF_FONTPATH = 'font/'; |
||
13 | const SIT_CANCELADA = 1; |
||
14 | const SIT_DENEGADA = 2; |
||
15 | const SIT_DPEC = 3; |
||
16 | const SIT_NONE = 0; |
||
17 | |||
18 | /** |
||
19 | * alinhamento padrão do logo (C-Center) |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | public $logoAlign = 'C'; |
||
24 | /** |
||
25 | * Posição |
||
26 | * @var float |
||
27 | */ |
||
28 | public $yDados = 0; |
||
29 | /** |
||
30 | * Situação |
||
31 | * @var integer |
||
32 | */ |
||
33 | public $situacaoExterna = 0; |
||
34 | /** |
||
35 | * Numero DPEC |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | public $numero_registro_dpec = ''; |
||
40 | /** |
||
41 | * quantidade de canhotos a serem montados, geralmente 1 ou 2 |
||
42 | * |
||
43 | * @var integer |
||
44 | */ |
||
45 | public $qCanhoto = 1; |
||
46 | |||
47 | //########################################################### |
||
48 | // INÍCIO ATRIBUTOS DE PARÂMETROS DE EXIBIÇÃO |
||
49 | //########################################################### |
||
50 | |||
51 | /** |
||
52 | * Parâmetro para exibir ou ocultar os valores do PIS/COFINS. |
||
53 | * @var boolean |
||
54 | */ |
||
55 | public $exibirPIS = true; |
||
56 | /** |
||
57 | * Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos. |
||
58 | * @var boolean |
||
59 | */ |
||
60 | public $exibirIcmsInterestadual = true; |
||
61 | /** |
||
62 | * Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos. |
||
63 | * @var boolean |
||
64 | */ |
||
65 | public $exibirValorTributos = true; |
||
66 | /** |
||
67 | * Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento |
||
68 | * e as informações de fatura/duplicata. |
||
69 | * @var boolean |
||
70 | */ |
||
71 | public $exibirTextoFatura = false; |
||
72 | /** |
||
73 | * Parâmetro do controle se deve concatenar automaticamente informações complementares |
||
74 | * na descrição do produto, como por exemplo, informações sobre impostos. |
||
75 | * @var boolean |
||
76 | */ |
||
77 | public $descProdInfoComplemento = true; |
||
78 | /** |
||
79 | * Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto. |
||
80 | * @var boolean |
||
81 | */ |
||
82 | public $descProdQuebraLinha = true; |
||
83 | |||
84 | //########################################################### |
||
85 | //PROPRIEDADES DA CLASSE |
||
86 | //########################################################### |
||
87 | |||
88 | /** |
||
89 | * objeto fpdf() |
||
90 | * @var object |
||
91 | */ |
||
92 | protected $pdf; |
||
93 | /** |
||
94 | * XML NFe |
||
95 | * @var string |
||
96 | */ |
||
97 | protected $xml; |
||
98 | /** |
||
99 | * path para logomarca em jpg |
||
100 | * @var string |
||
101 | */ |
||
102 | protected $logomarca = ''; |
||
103 | /** |
||
104 | * mesagens de erro |
||
105 | * @var string |
||
106 | */ |
||
107 | protected $errMsg = ''; |
||
108 | /** |
||
109 | * status de erro true um erro ocorreu false sem erros |
||
110 | * @var boolean |
||
111 | */ |
||
112 | protected $errStatus = false; |
||
113 | /** |
||
114 | * orientação da DANFE |
||
115 | * P-Retrato ou L-Paisagem |
||
116 | * @var string |
||
117 | */ |
||
118 | protected $orientacao = 'P'; |
||
119 | /** |
||
120 | * formato do papel |
||
121 | * @var string |
||
122 | */ |
||
123 | protected $papel = 'A4'; |
||
124 | /** |
||
125 | * destino do arquivo pdf |
||
126 | * I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local |
||
127 | * @var string |
||
128 | */ |
||
129 | protected $destino = 'I'; |
||
130 | /** |
||
131 | * diretorio para salvar o pdf com a opção de destino = F |
||
132 | * @var string |
||
133 | */ |
||
134 | protected $pdfDir = ''; |
||
135 | /** |
||
136 | * Nome da Fonte para gerar o DANFE |
||
137 | * @var string |
||
138 | */ |
||
139 | protected $fontePadrao = 'Times'; |
||
140 | /** |
||
141 | * versão |
||
142 | * @var string |
||
143 | */ |
||
144 | protected $version = '2.2.8'; |
||
145 | /** |
||
146 | * Texto |
||
147 | * @var string |
||
148 | */ |
||
149 | protected $textoAdic = ''; |
||
150 | /** |
||
151 | * Largura |
||
152 | * @var float |
||
153 | */ |
||
154 | protected $wAdic = 0; |
||
155 | /** |
||
156 | * largura imprimivel, em milímetros |
||
157 | * @var float |
||
158 | */ |
||
159 | protected $wPrint; |
||
160 | /** |
||
161 | * Comprimento (altura) imprimivel, em milímetros |
||
162 | * @var float |
||
163 | */ |
||
164 | protected $hPrint; |
||
165 | /** |
||
166 | * largura do canhoto (25mm) apenas para a formatação paisagem |
||
167 | * @var float |
||
168 | */ |
||
169 | protected $wCanhoto = 25; |
||
170 | /** |
||
171 | * Formato chave |
||
172 | * @var string |
||
173 | */ |
||
174 | protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
||
175 | /** |
||
176 | * quantidade de itens já processados na montagem do DANFE |
||
177 | * @var integer |
||
178 | */ |
||
179 | protected $qtdeItensProc; |
||
180 | |||
181 | /** |
||
182 | * Document |
||
183 | * @var DOMDocument |
||
184 | */ |
||
185 | protected $dom; |
||
186 | /** |
||
187 | * Node |
||
188 | * @var DOMNode |
||
189 | */ |
||
190 | protected $infNFe; |
||
191 | /** |
||
192 | * Node |
||
193 | * @var DOMNode |
||
194 | */ |
||
195 | protected $ide; |
||
196 | /** |
||
197 | * Node |
||
198 | * @var DOMNode |
||
199 | */ |
||
200 | protected $entrega; |
||
201 | /** |
||
202 | * Node |
||
203 | * @var DOMNode |
||
204 | */ |
||
205 | protected $retirada; |
||
206 | /** |
||
207 | * Node |
||
208 | * @var DOMNode |
||
209 | */ |
||
210 | protected $emit; |
||
211 | /** |
||
212 | * Node |
||
213 | * @var DOMNode |
||
214 | */ |
||
215 | protected $dest; |
||
216 | /** |
||
217 | * Node |
||
218 | * @var DOMNode |
||
219 | */ |
||
220 | protected $enderEmit; |
||
221 | /** |
||
222 | * Node |
||
223 | * @var DOMNode |
||
224 | */ |
||
225 | protected $enderDest; |
||
226 | /** |
||
227 | * Node |
||
228 | * @var DOMNode |
||
229 | */ |
||
230 | protected $det; |
||
231 | /** |
||
232 | * Node |
||
233 | * @var DOMNode |
||
234 | */ |
||
235 | protected $cobr; |
||
236 | /** |
||
237 | * Node |
||
238 | * @var DOMNode |
||
239 | */ |
||
240 | protected $dup; |
||
241 | /** |
||
242 | * Node |
||
243 | * @var DOMNode |
||
244 | */ |
||
245 | protected $ICMSTot; |
||
246 | /** |
||
247 | * Node |
||
248 | * @var DOMNode |
||
249 | */ |
||
250 | protected $ISSQNtot; |
||
251 | /** |
||
252 | * Node |
||
253 | * @var DOMNode |
||
254 | */ |
||
255 | protected $transp; |
||
256 | /** |
||
257 | * Node |
||
258 | * @var DOMNode |
||
259 | */ |
||
260 | protected $transporta; |
||
261 | /** |
||
262 | * Node |
||
263 | * @var DOMNode |
||
264 | */ |
||
265 | protected $veicTransp; |
||
266 | /** |
||
267 | * Node reboque |
||
268 | * @var DOMNode |
||
269 | */ |
||
270 | protected $reboque; |
||
271 | /** |
||
272 | * Node infAdic |
||
273 | * @var DOMNode |
||
274 | */ |
||
275 | protected $infAdic; |
||
276 | /** |
||
277 | * Tipo de emissão |
||
278 | * @var integer |
||
279 | */ |
||
280 | protected $tpEmis; |
||
281 | /** |
||
282 | * Node infProt |
||
283 | * @var DOMNode |
||
284 | */ |
||
285 | protected $infProt; |
||
286 | /** |
||
287 | * 1-Retrato/ 2-Paisagem |
||
288 | * @var integer |
||
289 | */ |
||
290 | protected $tpImp; |
||
291 | /** |
||
292 | * Node compra |
||
293 | * @var DOMNode |
||
294 | */ |
||
295 | protected $compra; |
||
296 | /** |
||
297 | * ativa ou desativa o modo de debug |
||
298 | * @var integer |
||
299 | */ |
||
300 | protected $debugMode=2; |
||
301 | /** |
||
302 | * Creditos para integrador |
||
303 | * @var string |
||
304 | */ |
||
305 | protected $creditos = ''; |
||
306 | |||
307 | /** |
||
308 | * __construct |
||
309 | * |
||
310 | * @name __construct |
||
311 | * @param string $docXML Conteúdo XML da NF-e (com ou sem a tag nfeProc) |
||
312 | * @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem |
||
313 | * @param string $sPapel Tamanho do papel (Ex. A4) |
||
314 | * @param string $sPathLogo Caminho para o arquivo do logo |
||
315 | * @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S- |
||
316 | * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF |
||
317 | * @param string $fonteDANFE Nome da fonte alternativa do DAnfe |
||
318 | * @param integer $mododebug 0-Não 1-Sim e 2-nada (2 default) |
||
319 | */ |
||
320 | public function __construct( |
||
390 | |||
391 | /** |
||
392 | * Add the credits to the integrator in the footer message |
||
393 | * @param string $message |
||
394 | */ |
||
395 | public function creditsIntegratorFooter($message = '') |
||
399 | |||
400 | /** |
||
401 | * monta |
||
402 | * |
||
403 | * @name monta |
||
404 | * @param string $orientacao |
||
405 | * @param string $papel |
||
406 | * @param string $logoAlign |
||
407 | * @return string |
||
408 | */ |
||
409 | public function monta( |
||
432 | |||
433 | /** |
||
434 | * printDocument |
||
435 | * |
||
436 | * @param string $nome |
||
437 | * @param string $destino |
||
438 | * @param string $printer |
||
439 | * @return object pdf |
||
440 | */ |
||
441 | public function printDocument($nome = '', $destino = 'I', $printer = '') |
||
449 | |||
450 | /** |
||
451 | * montaDANFE |
||
452 | * Monta a DANFE conforme as informações fornecidas para a classe durante sua |
||
453 | * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens. |
||
454 | * A definição de margens e posições iniciais para a impressão são estabelecidas |
||
455 | * pelo conteúdo da funçao e podem ser modificados. |
||
456 | * |
||
457 | * @param string $orientacao (Opcional) Estabelece a orientação da impressão |
||
458 | * (ex. P-retrato), se nada for fornecido será usado o padrão da NFe |
||
459 | * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4) |
||
460 | * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML |
||
461 | */ |
||
462 | public function montaDANFE( |
||
797 | |||
798 | /** |
||
799 | * anfavea |
||
800 | * Função para transformar o campo cdata do padrão ANFAVEA para |
||
801 | * texto imprimível |
||
802 | * |
||
803 | * @param string $cdata campo CDATA |
||
804 | * @return string conteúdo do campo CDATA como string |
||
805 | */ |
||
806 | protected function pAnfavea($cdata = '') |
||
945 | |||
946 | /** |
||
947 | * Dados brutos do PDF |
||
948 | * @return string |
||
949 | */ |
||
950 | public function render() |
||
954 | |||
955 | protected function pNotaCancelada() |
||
967 | |||
968 | protected function pNotaDPEC() |
||
972 | |||
973 | protected function pNotaDenegada() |
||
986 | |||
987 | /** |
||
988 | *cabecalhoDANFE |
||
989 | * Monta o cabelhalho da DANFE (retrato e paisagem) |
||
990 | * |
||
991 | * @param number $x Posição horizontal inicial, canto esquerdo |
||
992 | * @param number $y Posição vertical inicial, canto superior |
||
993 | * @param number $pag Número da Página |
||
994 | * @param number $totPag Total de páginas |
||
995 | * @return number Posição vertical final |
||
996 | */ |
||
997 | protected function pCabecalhoDANFE($x = 0, $y = 0, $pag = '1', $totPag = '1') |
||
998 | { |
||
999 | $oldX = $x; |
||
1000 | $oldY = $y; |
||
1001 | if ($this->orientacao == 'P') { |
||
1002 | $maxW = $this->wPrint; |
||
1003 | } else { |
||
1004 | if ($pag == 1) { // primeira página |
||
1005 | $maxW = $this->wPrint - $this->wCanhoto; |
||
1006 | } else { // páginas seguintes |
||
1007 | $maxW = $this->wPrint; |
||
1008 | } |
||
1009 | } |
||
1010 | //#################################################################################### |
||
1011 | //coluna esquerda identificação do emitente |
||
1012 | $w = round($maxW*0.41, 0); |
||
1013 | if ($this->orientacao == 'P') { |
||
1014 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I'); |
||
1015 | } else { |
||
1016 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'); |
||
1017 | } |
||
1018 | $w1 = $w; |
||
1019 | $h=32; |
||
1020 | $oldY += $h; |
||
1021 | $this->pTextBox($x, $y, $w, $h); |
||
1022 | $texto = 'IDENTIFICAÇÃO DO EMITENTE'; |
||
1023 | $this->pTextBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, ''); |
||
1024 | //estabelecer o alinhamento |
||
1025 | //pode ser left L, center C, right R, full logo L |
||
1026 | //se for left separar 1/3 da largura para o tamanho da imagem |
||
1027 | //os outros 2/3 serão usados para os dados do emitente |
||
1028 | //se for center separar 1/2 da altura para o logo e 1/2 para os dados |
||
1029 | //se for right separa 2/3 para os dados e o terço seguinte para o logo |
||
1030 | //se não houver logo centraliza dos dados do emitente |
||
1031 | // coloca o logo |
||
1032 | if (!empty($this->logomarca)) { |
||
1033 | $logoInfo = getimagesize($this->logomarca); |
||
1034 | $type = strtolower(explode('/', $logoInfo['mime'])[1]); |
||
1035 | if ($type == 'png') { |
||
1036 | $this->logomarca = $this->imagePNGtoJPG($this->logomarca); |
||
1037 | $type == 'jpg'; |
||
1038 | } |
||
1039 | //largura da imagem em mm |
||
1040 | $logoWmm = ($logoInfo[0]/72)*25.4; |
||
1041 | //altura da imagem em mm |
||
1042 | $logoHmm = ($logoInfo[1]/72)*25.4; |
||
1043 | if ($this->logoAlign=='L') { |
||
1044 | $nImgW = round($w/3, 0); |
||
1045 | $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0); |
||
1046 | $xImg = $x+1; |
||
1047 | $yImg = round(($h-$nImgH)/2, 0)+$y; |
||
1048 | //estabelecer posições do texto |
||
1049 | $x1 = round($xImg + $nImgW +1, 0); |
||
1050 | $y1 = round($h/3+$y, 0); |
||
1051 | $tw = round(2*$w/3, 0); |
||
1052 | } elseif ($this->logoAlign=='C') { |
||
1053 | $nImgH = round($h/3, 0); |
||
1054 | $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0); |
||
1055 | $xImg = round(($w-$nImgW)/2+$x, 0); |
||
1056 | $yImg = $y+3; |
||
1057 | $x1 = $x; |
||
1058 | $y1 = round($yImg + $nImgH + 1, 0); |
||
1059 | $tw = $w; |
||
1060 | } elseif ($this->logoAlign=='R') { |
||
1061 | $nImgW = round($w/3, 0); |
||
1062 | $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0); |
||
1063 | $xImg = round($x+($w-(1+$nImgW)), 0); |
||
1064 | $yImg = round(($h-$nImgH)/2, 0)+$y; |
||
1065 | $x1 = $x; |
||
1066 | $y1 = round($h/3+$y, 0); |
||
1067 | $tw = round(2*$w/3, 0); |
||
1068 | } elseif ($this->logoAlign=='F') { |
||
1069 | $nImgH = round($h-5, 0); |
||
1070 | $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0); |
||
1071 | $xImg = round(($w-$nImgW)/2+$x, 0); |
||
1072 | $yImg = $y+3; |
||
1073 | $x1 = $x; |
||
1074 | $y1 = round($yImg + $nImgH + 1, 0); |
||
1075 | $tw = $w; |
||
1076 | } |
||
1077 | $type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null; |
||
1078 | $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, $type); |
||
1079 | } else { |
||
1080 | $x1 = $x; |
||
1081 | $y1 = round($h/3+$y, 0); |
||
1082 | $tw = $w; |
||
1083 | } |
||
1084 | // monta as informações apenas se diferente de full logo |
||
1085 | if ($this->logoAlign !== 'F') { |
||
1086 | //Nome emitente |
||
1087 | $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'B'); |
||
1088 | $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue; |
||
1089 | $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
||
1090 | //endereço |
||
1091 | $y1 = $y1+5; |
||
1092 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
1093 | $fone = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue) |
||
1094 | ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue |
||
1095 | : ''; |
||
1096 | $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr"); |
||
1097 | $nro = $this->pSimpleGetValue($this->enderEmit, "nro"); |
||
1098 | $cpl = $this->pSimpleGetValue($this->enderEmit, "xCpl", " - "); |
||
1099 | $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro"); |
||
1100 | $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP"); |
||
1101 | $CEP = $this->pFormat($CEP, "#####-###"); |
||
1102 | $mun = $this->pSimpleGetValue($this->enderEmit, "xMun"); |
||
1103 | $UF = $this->pSimpleGetValue($this->enderEmit, "UF"); |
||
1104 | $texto = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - " |
||
1105 | . $CEP . "\n" . $mun . " - " . $UF . " " |
||
1106 | . "Fone/Fax: " . $fone; |
||
1107 | $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
||
1108 | } |
||
1109 | |||
1110 | //#################################################################################### |
||
1111 | //coluna central Danfe |
||
1112 | $x += $w; |
||
1113 | $w=round($maxW * 0.17, 0);//35; |
||
1114 | $w2 = $w; |
||
1115 | $h = 32; |
||
1116 | $this->pTextBox($x, $y, $w, $h); |
||
1117 | |||
1118 | if (! $this->pNotaCancelada()) { |
||
1119 | // A PRINCIPIO NÃO PRECISAVA, POIS A NFE ESTÁ AUTORIZADA, |
||
1120 | // SÓ SE RETIRA O DANFE PARA NOTAS NÃO AUTORIZADAS |
||
1121 | $texto = "DANFE"; |
||
1122 | $aFont = array('font'=>$this->fontePadrao, 'size'=>14, 'style'=>'B'); |
||
1123 | $this->pTextBox($x, $y+1, $w, $h, $texto, $aFont, 'T', 'C', 0, ''); |
||
1124 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
1125 | $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica'; |
||
1126 | $h = 20; |
||
1127 | $this->pTextBox($x, $y+6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false); |
||
1128 | } |
||
1129 | |||
1130 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
1131 | $texto = '0 - ENTRADA'; |
||
1132 | $y1 = $y + 14; |
||
1133 | $h = 8; |
||
1134 | $this->pTextBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1135 | $texto = '1 - SAÍDA'; |
||
1136 | $y1 = $y + 17; |
||
1137 | $this->pTextBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1138 | //tipo de nF |
||
1139 | $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'B'); |
||
1140 | $y1 = $y + 13; |
||
1141 | $h = 7; |
||
1142 | $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue; |
||
1143 | $this->pTextBox($x+27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, ''); |
||
1144 | //numero da NF |
||
1145 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1146 | $y1 = $y + 20; |
||
1147 | $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); |
||
1148 | $numNF = $this->pFormat($numNF, "###.###.###"); |
||
1149 | $texto = "Nº. " . $numNF; |
||
1150 | $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1151 | //Série |
||
1152 | $y1 = $y + 23; |
||
1153 | $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); |
||
1154 | $texto = "Série " . $serie; |
||
1155 | $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1156 | //numero paginas |
||
1157 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I'); |
||
1158 | $y1 = $y + 26; |
||
1159 | $texto = "Folha " . $pag . "/" . $totPag; |
||
1160 | $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1161 | |||
1162 | //#################################################################################### |
||
1163 | //coluna codigo de barras |
||
1164 | $x += $w; |
||
1165 | $w = ($maxW-$w1-$w2);//85; |
||
1166 | $w3 = $w; |
||
1167 | $h = 32; |
||
1168 | $this->pTextBox($x, $y, $w, $h); |
||
1169 | $this->pdf->SetFillColor(0, 0, 0); |
||
1170 | $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); |
||
1171 | $bW = 75; |
||
1172 | $bH = 12; |
||
1173 | //codigo de barras |
||
1174 | $this->pdf->Code128($x+(($w-$bW)/2), $y+2, $chave_acesso, $bW, $bH); |
||
1175 | //linhas divisorias |
||
1176 | $this->pdf->Line($x, $y+4+$bH, $x+$w, $y+4+$bH); |
||
1177 | $this->pdf->Line($x, $y+12+$bH, $x+$w, $y+12+$bH); |
||
1178 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1179 | $y1 = $y+4+$bH; |
||
1180 | $h = 7; |
||
1181 | $texto = 'CHAVE DE ACESSO'; |
||
1182 | $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1183 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'); |
||
1184 | $y1 = $y+8+$bH; |
||
1185 | $texto = $this->pFormat($chave_acesso, $this->formatoChave); |
||
1186 | $this->pTextBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
||
1187 | $y1 = $y+12+$bH; |
||
1188 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
1189 | $chaveContingencia=""; |
||
1190 | if ($this->pNotaDPEC()) { |
||
1191 | $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC'; |
||
1192 | } else { |
||
1193 | $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO'; |
||
1194 | } |
||
1195 | if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->pNotaDPEC()) { |
||
1196 | $cabecalhoProtoAutorizacao = "DADOS DA NF-E"; |
||
1197 | $chaveContingencia = $this->pGeraChaveAdicionalDeContingencia(); |
||
1198 | $this->pdf->SetFillColor(0, 0, 0); |
||
1199 | //codigo de barras |
||
1200 | $this->pdf->Code128($x+11, $y1+1, $chaveContingencia, $bW*.9, $bH/2); |
||
1201 | } else { |
||
1202 | $texto = 'Consulta de autenticidade no portal nacional da NF-e'; |
||
1203 | $this->pTextBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
||
1204 | $y1 = $y+16+$bH; |
||
1205 | $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'; |
||
1206 | $this->pTextBox( |
||
1207 | $x+2, |
||
1208 | $y1, |
||
1209 | $w-2, |
||
1210 | $h, |
||
1211 | $texto, |
||
1212 | $aFont, |
||
1213 | 'T', |
||
1214 | 'C', |
||
1215 | 0, |
||
1216 | 'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora' |
||
1217 | ); |
||
1218 | } |
||
1219 | |||
1220 | //#################################################################################### |
||
1221 | //Dados da NF do cabeçalho |
||
1222 | //natureza da operação |
||
1223 | $texto = 'NATUREZA DA OPERAÇÃO'; |
||
1224 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1225 | $w = $w1+$w2; |
||
1226 | $y = $oldY; |
||
1227 | $oldY += $h; |
||
1228 | $x = $oldX; |
||
1229 | $h = 7; |
||
1230 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1231 | $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue; |
||
1232 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1233 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1234 | $x += $w; |
||
1235 | $w = $w3; |
||
1236 | //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E |
||
1237 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1238 | $this->pTextBox($x, $y, $w, $h, $cabecalhoProtoAutorizacao, $aFont, 'T', 'L', 1, ''); |
||
1239 | // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser |
||
1240 | // testada antes de tentar obter a informação. |
||
1241 | // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!! |
||
1242 | // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização. |
||
1243 | // Na minha opinião, deveríamos mostra-lo, mas o manual da NFe v4.01 diz outra coisa... |
||
1244 | if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->pNotaDPEC()) { |
||
1245 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'); |
||
1246 | $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####"); |
||
1247 | $cStat = ''; |
||
1248 | } else { |
||
1249 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1250 | if ($this->pNotaDPEC()) { |
||
1251 | $texto = $this->numero_registro_dpec; |
||
1252 | $cStat = ''; |
||
1253 | } else { |
||
1254 | if (isset($this->nfeProc)) { |
||
1255 | $texto = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ? |
||
1256 | $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : ''; |
||
1257 | $tsHora = $this->pConvertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue); |
||
1258 | if ($texto != '') { |
||
1259 | $texto .= " - " . date('d/m/Y H:i:s', $tsHora); |
||
1260 | } |
||
1261 | $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue; |
||
1262 | } else { |
||
1263 | $texto = ''; |
||
1264 | $cStat = ''; |
||
1265 | } |
||
1266 | } |
||
1267 | } |
||
1268 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1269 | //#################################################################################### |
||
1270 | //INSCRIÇÃO ESTADUAL |
||
1271 | $w = round($maxW * 0.333, 0); |
||
1272 | $y += $h; |
||
1273 | $oldY += $h; |
||
1274 | $x = $oldX; |
||
1275 | $texto = 'INSCRIÇÃO ESTADUAL'; |
||
1276 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1277 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1278 | $texto = $this->pSimpleGetValue($this->emit, "IE"); |
||
1279 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1280 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1281 | //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT. |
||
1282 | $x += $w; |
||
1283 | $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.'; |
||
1284 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1285 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1286 | $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue) |
||
1287 | ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue |
||
1288 | : ''; |
||
1289 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1290 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1291 | //CNPJ |
||
1292 | $x += $w; |
||
1293 | $w = ($maxW-(2*$w)); |
||
1294 | $texto = 'CNPJ / CPF'; |
||
1295 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1296 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1297 | //Pegando valor do CPF/CNPJ |
||
1298 | if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
||
1299 | $texto = $this->pFormat( |
||
1300 | $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
||
1301 | "###.###.###/####-##" |
||
1302 | ); |
||
1303 | } else { |
||
1304 | $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue) ? |
||
1305 | $this->pFormat( |
||
1306 | $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue, |
||
1307 | "###.###.###-##" |
||
1308 | ) : ''; |
||
1309 | } |
||
1310 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1311 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1312 | |||
1313 | //#################################################################################### |
||
1314 | //Indicação de NF Homologação, cancelamento e falta de protocolo |
||
1315 | $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; |
||
1316 | //indicar cancelamento |
||
1317 | if ($this->pNotaCancelada()) { |
||
1318 | //101 Cancelamento |
||
1319 | $x = 10; |
||
1320 | $y = $this->hPrint-130; |
||
1321 | $h = 25; |
||
1322 | $w = $maxW-(2*$x); |
||
1323 | $this->pdf->SetTextColor(90, 90, 90); |
||
1324 | $texto = "NFe CANCELADA"; |
||
1325 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1326 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1327 | $this->pdf->SetTextColor(0, 0, 0); |
||
1328 | } |
||
1329 | |||
1330 | if ($this->pNotaDPEC() || $this->tpEmis == 4) { |
||
1331 | //DPEC |
||
1332 | $x = 10; |
||
1333 | $y = $this->hPrint-130; |
||
1334 | $h = 25; |
||
1335 | $w = $maxW-(2*$x); |
||
1336 | $this->pdf->SetTextColor(200, 200, 200); |
||
1337 | $texto = "DANFE impresso em contingência -\n". |
||
1338 | "DPEC regularmente recebido pela Receita\n". |
||
1339 | "Federal do Brasil"; |
||
1340 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1341 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1342 | $this->pdf->SetTextColor(0, 0, 0); |
||
1343 | } |
||
1344 | if ($this->pNotaDenegada()) { |
||
1345 | //110 301 302 Denegada |
||
1346 | $x = 10; |
||
1347 | $y = $this->hPrint-130; |
||
1348 | $h = 25; |
||
1349 | $w = $maxW-(2*$x); |
||
1350 | $this->pdf->SetTextColor(90, 90, 90); |
||
1351 | $texto = "NFe USO DENEGADO"; |
||
1352 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1353 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1354 | $y += $h; |
||
1355 | $h = 5; |
||
1356 | $w = $maxW-(2*$x); |
||
1357 | if (isset($this->infProt)) { |
||
1358 | $xMotivo = $this->infProt->getElementsByTagName("xMotivo")->item(0)->nodeValue; |
||
1359 | } else { |
||
1360 | $xMotivo = ''; |
||
1361 | } |
||
1362 | $texto = "SEM VALOR FISCAL\n".$xMotivo; |
||
1363 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1364 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1365 | $this->pdf->SetTextColor(0, 0, 0); |
||
1366 | } |
||
1367 | //indicar sem valor |
||
1368 | if ($tpAmb != 1) { |
||
1369 | $x = 10; |
||
1370 | if ($this->orientacao == 'P') { |
||
1371 | $y = round($this->hPrint*2/3, 0); |
||
1372 | } else { |
||
1373 | $y = round($this->hPrint/2, 0); |
||
1374 | } |
||
1375 | $h = 5; |
||
1376 | $w = $maxW-(2*$x); |
||
1377 | $this->pdf->SetTextColor(90, 90, 90); |
||
1378 | $texto = "SEM VALOR FISCAL"; |
||
1379 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1380 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1381 | $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'); |
||
1382 | $texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
||
1383 | $this->pTextBox($x, $y+14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1384 | $this->pdf->SetTextColor(0, 0, 0); |
||
1385 | } else { |
||
1386 | $x = 10; |
||
1387 | if ($this->orientacao == 'P') { |
||
1388 | $y = round($this->hPrint*2/3, 0); |
||
1389 | } else { |
||
1390 | $y = round($this->hPrint/2, 0); |
||
1391 | }//fim orientacao |
||
1392 | $h = 5; |
||
1393 | $w = $maxW-(2*$x); |
||
1394 | $this->pdf->SetTextColor(90, 90, 90); |
||
1395 | //indicar FALTA DO PROTOCOLO se NFe não for em contingência |
||
1396 | if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->pNotaDPEC()) { |
||
1397 | //Contingência |
||
1398 | $texto = "DANFE Emitido em Contingência"; |
||
1399 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1400 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1401 | $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'); |
||
1402 | $texto = "devido à problemas técnicos"; |
||
1403 | $this->pTextBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1404 | } else { |
||
1405 | if (!isset($this->nfeProc)) { |
||
1406 | if (!$this->pNotaDPEC()) { |
||
1407 | $texto = "SEM VALOR FISCAL"; |
||
1408 | $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'); |
||
1409 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1410 | } |
||
1411 | $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'); |
||
1412 | $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ"; |
||
1413 | if (!$this->pNotaDPEC()) { |
||
1414 | $this->pTextBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1415 | } else { |
||
1416 | $this->pTextBox($x, $y+25, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
||
1417 | } |
||
1418 | }//fim nefProc |
||
1419 | }//fim tpEmis |
||
1420 | $this->pdf->SetTextColor(0, 0, 0); |
||
1421 | } |
||
1422 | return $oldY; |
||
1423 | } //fim cabecalhoDANFE |
||
1424 | |||
1425 | /** |
||
1426 | * destinatarioDANFE |
||
1427 | * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem) |
||
1428 | * |
||
1429 | * @name destinatarioDANFE |
||
1430 | * @param number $x Posição horizontal canto esquerdo |
||
1431 | * @param number $y Posição vertical canto superior |
||
1432 | * @return number Posição vertical final |
||
1433 | */ |
||
1434 | protected function pDestinatarioDANFE($x = 0, $y = 0) |
||
1435 | { |
||
1436 | //#################################################################################### |
||
1437 | //DESTINATÁRIO / REMETENTE |
||
1438 | $oldX = $x; |
||
1439 | $oldY = $y; |
||
1440 | if ($this->orientacao == 'P') { |
||
1441 | $maxW = $this->wPrint; |
||
1442 | } else { |
||
1443 | $maxW = $this->wPrint - $this->wCanhoto; |
||
1444 | } |
||
1445 | $w = $maxW; |
||
1446 | $h = 7; |
||
1447 | $texto = 'DESTINATÁRIO / REMETENTE'; |
||
1448 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1449 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1450 | //NOME / RAZÃO SOCIAL |
||
1451 | $w = round($maxW*0.61, 0); |
||
1452 | $w1 = $w; |
||
1453 | $y += 3; |
||
1454 | $texto = 'NOME / RAZÃO SOCIAL'; |
||
1455 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1456 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1457 | $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue; |
||
1458 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1459 | if ($this->orientacao == 'P') { |
||
1460 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
||
1461 | } else { |
||
1462 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, ''); |
||
1463 | } |
||
1464 | //CNPJ / CPF |
||
1465 | $x += $w; |
||
1466 | $w = round($maxW*0.23, 0); |
||
1467 | $w2 = $w; |
||
1468 | $texto = 'CNPJ / CPF'; |
||
1469 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1470 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1471 | //Pegando valor do CPF/CNPJ |
||
1472 | if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
||
1473 | $texto = $this->pFormat( |
||
1474 | $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
||
1475 | "###.###.###/####-##" |
||
1476 | ); |
||
1477 | } else { |
||
1478 | $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ? |
||
1479 | $this->pFormat( |
||
1480 | $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue, |
||
1481 | "###.###.###-##" |
||
1482 | ) : ''; |
||
1483 | } |
||
1484 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1485 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1486 | //DATA DA EMISSÃO |
||
1487 | $x += $w; |
||
1488 | $w = $maxW-($w1+$w2); |
||
1489 | $wx = $w; |
||
1490 | $texto = 'DATA DA EMISSÃO'; |
||
1491 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1492 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1493 | $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ? |
||
1494 | $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : ''; |
||
1495 | if ($dEmi == '') { |
||
1496 | $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ? |
||
1497 | $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : ''; |
||
1498 | $aDemi = explode('T', $dEmi); |
||
1499 | $dEmi = $aDemi[0]; |
||
1500 | } |
||
1501 | $texto = $this->pYmd2dmy($dEmi); |
||
1502 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1503 | if ($this->orientacao == 'P') { |
||
1504 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1505 | } else { |
||
1506 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, ''); |
||
1507 | } |
||
1508 | //ENDEREÇO |
||
1509 | $w = round($maxW*0.47, 0); |
||
1510 | $w1 = $w; |
||
1511 | $y += $h; |
||
1512 | $x = $oldX; |
||
1513 | $texto = 'ENDEREÇO'; |
||
1514 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1515 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1516 | $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue; |
||
1517 | $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; |
||
1518 | $texto .= $this->pSimpleGetValue($this->dest, "xCpl", " - "); |
||
1519 | |||
1520 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1521 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true); |
||
1522 | //BAIRRO / DISTRITO |
||
1523 | $x += $w; |
||
1524 | $w = round($maxW*0.21, 0); |
||
1525 | $w2 = $w; |
||
1526 | $texto = 'BAIRRO / DISTRITO'; |
||
1527 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1528 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1529 | $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue; |
||
1530 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1531 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1532 | //CEP |
||
1533 | $x += $w; |
||
1534 | $w = $maxW-$w1-$w2-$wx; |
||
1535 | $w2 = $w; |
||
1536 | $texto = 'CEP'; |
||
1537 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1538 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1539 | $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ? |
||
1540 | $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue : ''; |
||
1541 | $texto = $this->pFormat($texto, "#####-###"); |
||
1542 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1543 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1544 | //DATA DA SAÍDA |
||
1545 | $x += $w; |
||
1546 | $w = $wx; |
||
1547 | $texto = 'DATA DA SAÍDA/ENTRADA'; |
||
1548 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1549 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1550 | $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) ? |
||
1551 | $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue : ''; |
||
1552 | if ($dSaiEnt == '') { |
||
1553 | $dSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ? |
||
1554 | $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue : ''; |
||
1555 | $aDsaient = explode('T', $dSaiEnt); |
||
1556 | $dSaiEnt = $aDsaient[0]; |
||
1557 | } |
||
1558 | $texto = $this->pYmd2dmy($dSaiEnt); |
||
1559 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1560 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1561 | //MUNICÍPIO |
||
1562 | $w = $w1; |
||
1563 | $y += $h; |
||
1564 | $x = $oldX; |
||
1565 | $texto = 'MUNICÍPIO'; |
||
1566 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1567 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1568 | $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue; |
||
1569 | if (strtoupper(trim($texto)) == "EXTERIOR" && $this->dest->getElementsByTagName("xPais")->length > 0) { |
||
1570 | $texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue; |
||
1571 | } |
||
1572 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1573 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
||
1574 | //UF |
||
1575 | $x += $w; |
||
1576 | $w = 8; |
||
1577 | $texto = 'UF'; |
||
1578 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1579 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1580 | $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue; |
||
1581 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1582 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1583 | //FONE / FAX |
||
1584 | $x += $w; |
||
1585 | $w = round(($maxW -$w1-$wx-8)/2, 0); |
||
1586 | $w3 = $w; |
||
1587 | $texto = 'FONE / FAX'; |
||
1588 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1589 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1590 | $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) ? |
||
1591 | $this->dest->getElementsByTagName("fone")->item(0)->nodeValue : ''; |
||
1592 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1593 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1594 | //INSCRIÇÃO ESTADUAL |
||
1595 | $x += $w; |
||
1596 | $w = $maxW -$w1-$wx-8-$w3; |
||
1597 | $texto = 'INSCRIÇÃO ESTADUAL'; |
||
1598 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1599 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1600 | $IE = $this->dest->getElementsByTagName("IE"); |
||
1601 | $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : ''; |
||
1602 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1603 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1604 | //HORA DA SAÍDA |
||
1605 | $x += $w; |
||
1606 | $w = $wx; |
||
1607 | $texto = 'HORA DA SAÍDA/ENTRADA'; |
||
1608 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1609 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1610 | $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue) ? |
||
1611 | $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue : ''; |
||
1612 | if ($hSaiEnt == '') { |
||
1613 | $dhSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) ? |
||
1614 | $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue : ''; |
||
1615 | $tsDhSaiEnt = $this->pConvertTime($dhSaiEnt); |
||
1616 | if ($tsDhSaiEnt != '') { |
||
1617 | $hSaiEnt = date('H:i:s', $tsDhSaiEnt); |
||
1618 | } |
||
1619 | } |
||
1620 | $texto = $hSaiEnt; |
||
1621 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1622 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1623 | return ($y + $h); |
||
1624 | } //fim da função destinatarioDANFE |
||
1625 | |||
1626 | /** |
||
1627 | * pGetTextoFatura |
||
1628 | * Gera a String do Texto da Fatura |
||
1629 | * |
||
1630 | * @name getTextoFatura |
||
1631 | * @return uma String com o texto ou ""; |
||
1632 | */ |
||
1633 | protected function pGetTextoFatura() |
||
1634 | { |
||
1635 | if (isset($this->cobr)) { |
||
1636 | $fat = $this->cobr->getElementsByTagName("fat")->item(0); |
||
1637 | if (isset($fat)) { |
||
1638 | if (!empty($this->pSimpleGetValue($this->ide, "indPag"))) { |
||
1639 | $textoIndPag = ""; |
||
1640 | $indPag = $this->pSimpleGetValue($this->ide, "indPag"); |
||
1641 | if ($indPag === "0") { |
||
1642 | $textoIndPag = "Pagamento à Vista - "; |
||
1643 | } elseif ($indPag === "1") { |
||
1644 | $textoIndPag = "Pagamento à Prazo - "; |
||
1645 | } |
||
1646 | $nFat = $this->pSimpleGetValue($fat, "nFat", "Fatura: "); |
||
1647 | $vOrig = $this->pSimpleGetValue($fat, "vOrig", " Valor Original: "); |
||
1648 | $vDesc = $this->pSimpleGetValue($fat, "vDesc", " Desconto: "); |
||
1649 | $vLiq = $this->pSimpleGetValue($fat, "vLiq", " Valor Líquido: "); |
||
1650 | $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq; |
||
1651 | return $texto; |
||
1652 | } else { |
||
1653 | $pag = $this->dom->getElementsByTagName("pag"); |
||
1654 | if ($tPag = $this->pSimpleGetValue($pag->item(0), "tPag")) { |
||
1655 | return $this->tipoPag($tPag); |
||
1656 | } |
||
1657 | } |
||
1658 | } |
||
1659 | } |
||
1660 | return ""; |
||
1661 | } //fim getTextoFatura |
||
1662 | |||
1663 | /** |
||
1664 | * pSizeExtraTextoFatura |
||
1665 | * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata. |
||
1666 | * |
||
1667 | * @name pSizeExtraTextoFatura |
||
1668 | * @return integer |
||
1669 | */ |
||
1670 | protected function pSizeExtraTextoFatura() |
||
1671 | { |
||
1672 | $textoFatura = $this->pGetTextoFatura(); |
||
1673 | //verificar se existem duplicatas |
||
1674 | if ($this->dup->length == 0 && $textoFatura !== "") { |
||
1675 | return 10; |
||
1676 | } |
||
1677 | return 0; |
||
1678 | } |
||
1679 | |||
1680 | /** |
||
1681 | * faturaDANFE |
||
1682 | * Monta o campo de duplicatas da DANFE (retrato e paisagem) |
||
1683 | * |
||
1684 | * @name faturaDANFE |
||
1685 | * @param number $x Posição horizontal canto esquerdo |
||
1686 | * @param number $y Posição vertical canto superior |
||
1687 | * @return number Posição vertical final |
||
1688 | */ |
||
1689 | protected function pFaturaDANFE($x, $y) |
||
1690 | { |
||
1691 | $linha = 1; |
||
1692 | $h = 8+3; |
||
1693 | $oldx = $x; |
||
1694 | $textoFatura = $this->pGetTextoFatura(); |
||
1695 | //verificar se existem duplicatas |
||
1696 | if ($this->dup->length > 0 || $textoFatura !== "") { |
||
1697 | //##################################################################### |
||
1698 | //FATURA / DUPLICATA |
||
1699 | $texto = "FATURA / DUPLICATA"; |
||
1700 | if ($this->orientacao == 'P') { |
||
1701 | $w = $this->wPrint; |
||
1702 | } else { |
||
1703 | $w = 271; |
||
1704 | } |
||
1705 | $h = 8; |
||
1706 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1707 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1708 | $y += 3; |
||
1709 | $dups = ""; |
||
1710 | $dupcont = 0; |
||
1711 | $nFat = $this->dup->length; |
||
1712 | if ($textoFatura !== "" && $this->exibirTextoFatura) { |
||
1713 | $myH=6; |
||
1714 | $myW = $this->wPrint; |
||
1715 | if ($this->orientacao == 'L') { |
||
1716 | $myW -= $this->wCanhoto; |
||
1717 | } |
||
1718 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
1719 | $this->pTextBox($x, $y, $myW, $myH, $textoFatura, $aFont, 'C', 'L', 1, ''); |
||
1720 | $y+=$myH+1; |
||
1721 | } |
||
1722 | if ($this->orientacao == 'P') { |
||
1723 | $w = round($this->wPrint/7.018, 0)-1; |
||
1724 | } else { |
||
1725 | $w = 28; |
||
1726 | } |
||
1727 | $increm = 1; |
||
1728 | foreach ($this->dup as $k => $d) { |
||
1729 | $nDup = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue) ? |
||
1730 | $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue : ''; |
||
1731 | $dDup = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) ? |
||
1732 | $this->pYmd2dmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) : ''; |
||
1733 | $vDup = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue) ? |
||
1734 | 'R$ ' . number_format( |
||
1735 | $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue, |
||
1736 | 2, |
||
1737 | ",", |
||
1738 | "." |
||
1739 | ) : ''; |
||
1740 | $h = 8; |
||
1741 | $texto = ''; |
||
1742 | if ($nDup!='0' && $nDup!='') { |
||
1743 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1744 | $this->pTextBox($x, $y, $w, $h, 'Num.', $aFont, 'T', 'L', 1, ''); |
||
1745 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1746 | $this->pTextBox($x, $y, $w, $h, $nDup, $aFont, 'T', 'R', 0, ''); |
||
1747 | } else { |
||
1748 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1749 | $this->pTextBox($x, $y, $w, $h, ($dupcont+1)."", $aFont, 'T', 'L', 1, ''); |
||
1750 | } |
||
1751 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1752 | $this->pTextBox($x, $y, $w, $h, 'Venc.', $aFont, 'C', 'L', 0, ''); |
||
1753 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1754 | $this->pTextBox($x, $y, $w, $h, $dDup, $aFont, 'C', 'R', 0, ''); |
||
1755 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1756 | $this->pTextBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, ''); |
||
1757 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1758 | $this->pTextBox($x, $y, $w, $h, $vDup, $aFont, 'B', 'R', 0, ''); |
||
1759 | $x += $w+$increm; |
||
1760 | $dupcont += 1; |
||
1761 | if ($this->orientacao == 'P') { |
||
1762 | $maxDupCont = 6; |
||
1763 | } else { |
||
1764 | $maxDupCont = 8; |
||
1765 | } |
||
1766 | if ($dupcont > $maxDupCont) { |
||
1767 | $y += 9; |
||
1768 | $x = $oldx; |
||
1769 | $dupcont = 0; |
||
1770 | $linha += 1; |
||
1771 | } |
||
1772 | if ($linha == 5) { |
||
1773 | $linha = 4; |
||
1774 | break; |
||
1775 | } |
||
1776 | } |
||
1777 | if ($dupcont == 0) { |
||
1778 | $y -= 9; |
||
1779 | $linha--; |
||
1780 | } |
||
1781 | return ($y+$h); |
||
1782 | } else { |
||
1783 | $linha = 0; |
||
1784 | return ($y-2); |
||
1785 | } |
||
1786 | } //fim da função faturaDANFE |
||
1787 | |||
1788 | /** |
||
1789 | * impostoDanfeHelper |
||
1790 | * Auxilia a montagem dos campos de impostos e totais da DANFE |
||
1791 | * |
||
1792 | * @name impostoDanfeHelper |
||
1793 | * @param float $x Posição horizontal canto esquerdo |
||
1794 | * @param float $y Posição vertical canto superior |
||
1795 | * @param float $w Largura do campo |
||
1796 | * @param float $h Altura do campo |
||
1797 | * @param float $h Título do campo |
||
1798 | * @param float $h Valor do imposto |
||
1799 | * @return float Sugestão do $x do próximo imposto |
||
1800 | */ |
||
1801 | protected function pImpostoDanfeHelper($x, $y, $w, $h, $titulo, $campoImposto) |
||
1802 | { |
||
1803 | $valorImposto = '0, 00'; |
||
1804 | $the_field = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0); |
||
1805 | if (isset($the_field)) { |
||
1806 | $the_value = $the_field->nodeValue; |
||
1807 | if (!empty($the_value)) { |
||
1808 | $valorImposto = number_format($the_value, 2, ",", "."); |
||
1809 | } |
||
1810 | } |
||
1811 | |||
1812 | $fontTitulo = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1813 | $fontValor = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1814 | $this->pTextBox($x, $y, $w, $h, $titulo, $fontTitulo, 'T', 'L', 1, ''); |
||
1815 | $this->pTextBox($x, $y, $w, $h, $valorImposto, $fontValor, 'B', 'R', 0, ''); |
||
1816 | |||
1817 | $next_x = $x + $w; |
||
1818 | return $next_x; |
||
1819 | } |
||
1820 | |||
1821 | /** |
||
1822 | * impostoDANFE |
||
1823 | * Monta o campo de impostos e totais da DANFE (retrato e paisagem) |
||
1824 | * |
||
1825 | * @param number $x Posição horizontal canto esquerdo |
||
1826 | * @param number $y Posição vertical canto superior |
||
1827 | * @return number Posição vertical final |
||
1828 | */ |
||
1829 | protected function pImpostoDANFE($x, $y) |
||
1830 | { |
||
1831 | $x_inicial = $x; |
||
1832 | //##################################################################### |
||
1833 | |||
1834 | |||
1835 | $campos_por_linha = 9; |
||
1836 | if (!$this->exibirPIS) { |
||
1837 | $campos_por_linha--; |
||
1838 | } |
||
1839 | if (!$this->exibirIcmsInterestadual) { |
||
1840 | $campos_por_linha -= 2; |
||
1841 | } |
||
1842 | |||
1843 | if ($this->orientacao == 'P') { |
||
1844 | $maxW = $this->wPrint; |
||
1845 | $title_size = 31; |
||
1846 | } else { |
||
1847 | $maxW = $this->wPrint - $this->wCanhoto; |
||
1848 | $title_size = 40; |
||
1849 | } |
||
1850 | $w = $maxW / $campos_por_linha; |
||
1851 | |||
1852 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1853 | $texto = "CÁLCULO DO IMPOSTO"; |
||
1854 | $this->pTextBox($x, $y, $title_size, 8, $texto, $aFont, 'T', 'L', 0, ''); |
||
1855 | $y += 3; |
||
1856 | $h = 7; |
||
1857 | |||
1858 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC"); |
||
1859 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS"); |
||
1860 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST"); |
||
1861 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST"); |
||
1862 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII"); |
||
1863 | |||
1864 | if ($this->exibirIcmsInterestadual) { |
||
1865 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet"); |
||
1866 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO FCP", "vFCPUFDest"); |
||
1867 | } |
||
1868 | |||
1869 | if ($this->exibirPIS) { |
||
1870 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS"); |
||
1871 | } |
||
1872 | |||
1873 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. TOTAL PRODUTOS", "vProd"); |
||
1874 | |||
1875 | // |
||
1876 | |||
1877 | $y += $h; |
||
1878 | $x = $x_inicial; |
||
1879 | |||
1880 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete"); |
||
1881 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg"); |
||
1882 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "DESCONTO", "vDesc"); |
||
1883 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro"); |
||
1884 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI"); |
||
1885 | |||
1886 | if ($this->exibirIcmsInterestadual) { |
||
1887 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest"); |
||
1888 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib"); |
||
1889 | } |
||
1890 | |||
1891 | if ($this->exibirPIS) { |
||
1892 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS"); |
||
1893 | } |
||
1894 | $x = $this->pImpostoDanfeHelper($x, $y, $w, $h, "V. TOTAL DA NOTA", "vNF"); |
||
1895 | |||
1896 | return ($y+$h); |
||
1897 | } //fim impostoDANFE |
||
1898 | |||
1899 | /** |
||
1900 | * transporteDANFE |
||
1901 | * Monta o campo de transportes da DANFE (retrato e paisagem) |
||
1902 | * |
||
1903 | * @name transporteDANFE |
||
1904 | * @param float $x Posição horizontal canto esquerdo |
||
1905 | * @param float $y Posição vertical canto superior |
||
1906 | * @return float Posição vertical final |
||
1907 | */ |
||
1908 | protected function pTransporteDANFE($x, $y) |
||
1909 | { |
||
1910 | $oldX = $x; |
||
1911 | if ($this->orientacao == 'P') { |
||
1912 | $maxW = $this->wPrint; |
||
1913 | } else { |
||
1914 | $maxW = $this->wPrint - $this->wCanhoto; |
||
1915 | } |
||
1916 | //##################################################################### |
||
1917 | //TRANSPORTADOR / VOLUMES TRANSPORTADOS |
||
1918 | $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS"; |
||
1919 | $w = $maxW; |
||
1920 | $h = 7; |
||
1921 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
1922 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
||
1923 | //NOME / RAZÃO SOCIAL |
||
1924 | $w1 = $maxW*0.29; |
||
1925 | $y += 3; |
||
1926 | $texto = 'NOME / RAZÃO SOCIAL'; |
||
1927 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1928 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1929 | if (isset($this->transporta)) { |
||
1930 | $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ? |
||
1931 | $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue : ''; |
||
1932 | } else { |
||
1933 | $texto = ''; |
||
1934 | } |
||
1935 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1936 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, ''); |
||
1937 | //FRETE POR CONTA |
||
1938 | $x += $w1; |
||
1939 | $w2 = $maxW*0.15; |
||
1940 | $texto = 'FRETE'; |
||
1941 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1942 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1943 | $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) ? |
||
1944 | $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue : '0'; |
||
1945 | switch ($tipoFrete) { |
||
1946 | case 0: |
||
1947 | $texto = "0-Por conta do Rem"; |
||
1948 | break; |
||
1949 | case 1: |
||
1950 | $texto = "1-Por conta do Dest"; |
||
1951 | break; |
||
1952 | case 2: |
||
1953 | $texto = "2-Por conta de Terceiros"; |
||
1954 | break; |
||
1955 | case 3: |
||
1956 | $texto = "3-Próprio por conta do Rem"; |
||
1957 | break; |
||
1958 | case 4: |
||
1959 | $texto = "4-Próprio por conta do Dest"; |
||
1960 | break; |
||
1961 | case 9: |
||
1962 | $texto = "9-Sem Transporte"; |
||
1963 | break; |
||
1964 | } |
||
1965 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1966 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 1, ''); |
||
1967 | //CÓDIGO ANTT |
||
1968 | $x += $w2; |
||
1969 | $texto = 'CÓDIGO ANTT'; |
||
1970 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1971 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1972 | if (isset($this->veicTransp)) { |
||
1973 | $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue) ? |
||
1974 | $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue : ''; |
||
1975 | } else { |
||
1976 | $texto = ''; |
||
1977 | } |
||
1978 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1979 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1980 | //PLACA DO VEÍC |
||
1981 | $x += $w2; |
||
1982 | $texto = 'PLACA DO VEÍCULO'; |
||
1983 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
1984 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
1985 | if (isset($this->veicTransp)) { |
||
1986 | $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue) ? |
||
1987 | $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue : ''; |
||
1988 | } elseif (isset($this->reboque)) { |
||
1989 | $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue) ? |
||
1990 | $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue : ''; |
||
1991 | } else { |
||
1992 | $texto = ''; |
||
1993 | } |
||
1994 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
1995 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
1996 | //UF |
||
1997 | $x += $w2; |
||
1998 | $w3 = round($maxW*0.04, 0); |
||
1999 | $texto = 'UF'; |
||
2000 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2001 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2002 | if (isset($this->veicTransp)) { |
||
2003 | $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue) ? |
||
2004 | $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue : ''; |
||
2005 | } elseif (isset($this->reboque)) { |
||
2006 | $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue) ? |
||
2007 | $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue : ''; |
||
2008 | } else { |
||
2009 | $texto = ''; |
||
2010 | } |
||
2011 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2012 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2013 | //CNPJ / CPF |
||
2014 | $x += $w3; |
||
2015 | $w = $maxW-($w1+3*$w2+$w3); |
||
2016 | $texto = 'CNPJ / CPF'; |
||
2017 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2018 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2019 | if (isset($this->transporta)) { |
||
2020 | $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? |
||
2021 | $this->pFormat( |
||
2022 | $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
||
2023 | "##.###.###/####-##" |
||
2024 | ) : ''; |
||
2025 | if ($texto == '') { |
||
2026 | $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue) ? |
||
2027 | $this->pFormat( |
||
2028 | $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue, |
||
2029 | "###.###.###-##" |
||
2030 | ) : ''; |
||
2031 | } |
||
2032 | } else { |
||
2033 | $texto = ''; |
||
2034 | } |
||
2035 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2036 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2037 | //##################################################################### |
||
2038 | //ENDEREÇO |
||
2039 | $y += $h; |
||
2040 | $x = $oldX; |
||
2041 | $h = 7; |
||
2042 | $w1 = $maxW*0.44; |
||
2043 | $texto = 'ENDEREÇO'; |
||
2044 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2045 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2046 | if (isset($this->transporta)) { |
||
2047 | $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ? |
||
2048 | $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue : ''; |
||
2049 | } else { |
||
2050 | $texto = ''; |
||
2051 | } |
||
2052 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2053 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, ''); |
||
2054 | //MUNICÍPIO |
||
2055 | $x += $w1; |
||
2056 | $w2 = round($maxW*0.30, 0); |
||
2057 | $texto = 'MUNICÍPIO'; |
||
2058 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2059 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2060 | if (isset($this->transporta)) { |
||
2061 | $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ? |
||
2062 | $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue : ''; |
||
2063 | } else { |
||
2064 | $texto = ''; |
||
2065 | } |
||
2066 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2067 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2068 | //UF |
||
2069 | $x += $w2; |
||
2070 | $w3 = round($maxW*0.04, 0); |
||
2071 | $texto = 'UF'; |
||
2072 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2073 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2074 | if (isset($this->transporta)) { |
||
2075 | $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? |
||
2076 | $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; |
||
2077 | } else { |
||
2078 | $texto = ''; |
||
2079 | } |
||
2080 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2081 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2082 | //INSCRIÇÃO ESTADUAL |
||
2083 | $x += $w3; |
||
2084 | $w = $maxW-($w1+$w2+$w3); |
||
2085 | $texto = 'INSCRIÇÃO ESTADUAL'; |
||
2086 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2087 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2088 | $texto = ''; |
||
2089 | if (isset($this->transporta)) { |
||
2090 | if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) { |
||
2091 | $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue; |
||
2092 | } |
||
2093 | } |
||
2094 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2095 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2096 | //Tratar Multiplos volumes |
||
2097 | $volumes = $this->transp->getElementsByTagName('vol'); |
||
2098 | $quantidade = 0; |
||
2099 | $especie = ''; |
||
2100 | $marca = ''; |
||
2101 | $numero = ''; |
||
2102 | $texto = ''; |
||
2103 | $pesoBruto=0; |
||
2104 | $pesoLiquido=0; |
||
2105 | foreach ($volumes as $volume) { |
||
2106 | $quantidade += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ? |
||
2107 | $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0; |
||
2108 | $pesoBruto += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ? |
||
2109 | $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0; |
||
2110 | $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ? |
||
2111 | $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0; |
||
2112 | $texto = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? |
||
2113 | $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; |
||
2114 | if ($texto != $especie && $especie != '') { |
||
2115 | //tem várias especies |
||
2116 | $especie = 'VARIAS'; |
||
2117 | } else { |
||
2118 | $especie = $texto; |
||
2119 | } |
||
2120 | $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ? |
||
2121 | $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : ''; |
||
2122 | if ($texto != $marca && $marca != '') { |
||
2123 | //tem várias especies |
||
2124 | $marca = 'VARIAS'; |
||
2125 | } else { |
||
2126 | $marca = $texto; |
||
2127 | } |
||
2128 | $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue) ? |
||
2129 | $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue : ''; |
||
2130 | if ($texto != $numero && $numero != '') { |
||
2131 | //tem várias especies |
||
2132 | $numero = 'VARIOS'; |
||
2133 | } else { |
||
2134 | $numero = $texto; |
||
2135 | } |
||
2136 | } |
||
2137 | |||
2138 | //##################################################################### |
||
2139 | //QUANTIDADE |
||
2140 | $y += $h; |
||
2141 | $x = $oldX; |
||
2142 | $h = 7; |
||
2143 | $w1 = round($maxW*0.10, 0); |
||
2144 | $texto = 'QUANTIDADE'; |
||
2145 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2146 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2147 | if (!empty($quantidade)) { |
||
2148 | $texto = $quantidade; |
||
2149 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2150 | $this->pTextBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2151 | } |
||
2152 | //ESPÉCIE |
||
2153 | $x += $w1; |
||
2154 | $w2 = round($maxW*0.17, 0); |
||
2155 | $texto = 'ESPÉCIE'; |
||
2156 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2157 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2158 | $texto = $especie; |
||
2159 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2160 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2161 | //MARCA |
||
2162 | $x += $w2; |
||
2163 | $texto = 'MARCA'; |
||
2164 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2165 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2166 | $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ? |
||
2167 | $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : ''; |
||
2168 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2169 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2170 | //NUMERAÇÃO |
||
2171 | $x += $w2; |
||
2172 | $texto = 'NUMERAÇÃO'; |
||
2173 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2174 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2175 | $texto = $numero; |
||
2176 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2177 | $this->pTextBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
||
2178 | //PESO BRUTO |
||
2179 | $x += $w2; |
||
2180 | $w3 = round($maxW*0.20, 0); |
||
2181 | $texto = 'PESO BRUTO'; |
||
2182 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2183 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2184 | if (is_numeric($pesoBruto) && $pesoBruto > 0) { |
||
2185 | $texto = number_format($pesoBruto, 3, ",", "."); |
||
2186 | } else { |
||
2187 | $texto = ''; |
||
2188 | } |
||
2189 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2190 | $this->pTextBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'R', 0, ''); |
||
2191 | //PESO LÍQUIDO |
||
2192 | $x += $w3; |
||
2193 | $w = $maxW -($w1+3*$w2+$w3); |
||
2194 | $texto = 'PESO LÍQUIDO'; |
||
2195 | $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>''); |
||
2196 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
||
2197 | if (is_numeric($pesoLiquido) && $pesoLiquido > 0) { |
||
2198 | $texto = number_format($pesoLiquido, 3, ",", "."); |
||
2199 | } else { |
||
2200 | $texto = ''; |
||
2201 | } |
||
2202 | $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'); |
||
2203 | $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, ''); |
||
2204 | return ($y+$h); |
||
2205 | } //fim transporteDANFE |
||
2206 | |||
2207 | |||
2208 | |||
2209 | protected function pDescricaoProdutoHelper($origem, $campo, $formato) |
||
2210 | { |
||
2211 | $valor_original = $origem->getElementsByTagName($campo)->item(0); |
||
2212 | if (!isset($valor_original)) { |
||
2213 | return ""; |
||
2214 | } |
||
2215 | $valor_original = $valor_original->nodeValue; |
||
2216 | $valor = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : ''; |
||
2217 | |||
2218 | if ($valor != "") { |
||
2219 | return sprintf($formato, $valor); |
||
2220 | } |
||
2221 | return ""; |
||
2222 | } |
||
2223 | |||
2224 | /** |
||
2225 | * descricaoProduto |
||
2226 | * Monta a string de descrição de cada Produto |
||
2227 | * |
||
2228 | * @name descricaoProduto |
||
2229 | * @param DOMNode itemProd |
||
2230 | * @return string descricao do produto |
||
2231 | */ |
||
2232 | protected function pDescricaoProduto($itemProd) |
||
2233 | { |
||
2234 | $prod = $itemProd->getElementsByTagName('prod')->item(0); |
||
2235 | $ICMS = $itemProd->getElementsByTagName("ICMS")->item(0); |
||
2236 | $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0); |
||
2237 | $impostos = ''; |
||
2238 | |||
2239 | if (!empty($ICMS)) { |
||
2240 | $impostos .= $this->pDescricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%"); |
||
2241 | $impostos .= $this->pDescricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%"); |
||
2242 | $impostos .= $this->pDescricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%"); |
||
2243 | $impostos .= $this->pDescricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s"); |
||
2244 | $impostos .= $this->pDescricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s"); |
||
2245 | } |
||
2246 | if (!empty($ICMSUFDest)) { |
||
2247 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%"); |
||
2248 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%"); |
||
2249 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%"); |
||
2250 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s"); |
||
2251 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s"); |
||
2252 | $impostos .= $this->pDescricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s"); |
||
2253 | } |
||
2254 | $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue) ? |
||
2255 | substr($this->pAnfavea($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue), 0, 500) : ''; |
||
2256 | if (! empty($infAdProd)) { |
||
2257 | $infAdProd = trim($infAdProd); |
||
2258 | $infAdProd .= ' '; |
||
2259 | } |
||
2260 | $loteTxt =''; |
||
2261 | $rastro = $prod->getElementsByTagName("med"); |
||
2262 | if (!isset($rastro)) { |
||
2263 | $rastro = $prod->getElementsByTagName("rastro"); |
||
2264 | } |
||
2265 | if (isset($rastro)) { |
||
2266 | $i = 0; |
||
2267 | while ($i < $rastro->length) { |
||
2268 | $loteTxt .= $this->pSimpleGetValue($rastro->item($i), 'nLote', ' Lote: '); |
||
2269 | $loteTxt .= $this->pSimpleGetValue($rastro->item($i), 'qLote', ' Quant: '); |
||
2270 | $loteTxt .= $this->pSimpleGetDate($rastro->item($i), 'dFab', ' Fab: '); |
||
2271 | $loteTxt .= $this->pSimpleGetDate($rastro->item($i), 'dVal', ' Val: '); |
||
2272 | $loteTxt .= $this->pSimpleGetValue($rastro->item($i), 'vPMC', ' PMC: '); |
||
2273 | $i++; |
||
2274 | } |
||
2275 | if ($loteTxt != '') { |
||
2276 | $loteTxt.= ' '; |
||
2277 | } |
||
2278 | } |
||
2279 | //NT2013.006 FCI |
||
2280 | $nFCI = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ? |
||
2281 | ' FCI:'.$itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : ''; |
||
2282 | $tmp_ad=$infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : ''); |
||
2283 | $texto = $prod->getElementsByTagName("xProd")->item(0)->nodeValue . (strlen($tmp_ad)!=0?"\n ".$tmp_ad:''); |
||
2284 | if ($this->descProdQuebraLinha) { |
||
2285 | $texto = str_replace(";", "\n", $texto); |
||
2286 | } |
||
2287 | return $texto; |
||
2288 | } |
||
2289 | |||
2290 | /** |
||
2291 | * itensDANFE |
||
2292 | * Monta o campo de itens da DANFE (retrato e paisagem) |
||
2293 | * |
||
2294 | * @name itensDANFE |
||
2295 | * @param float $x Posição horizontal canto esquerdo |
||
2296 | * @param float $y Posição vertical canto superior |
||
2297 | * @param float $nInicio Número do item inicial |
||
2298 | * @param float $max Número do item final |
||
2299 | * @param float $hmax Altura máxima do campo de itens em mm |
||
2300 | * @return float Posição vertical final |
||
2301 | */ |
||
2302 | protected function pItensDANFE($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7) |
||
2576 | |||
2577 | /** |
||
2578 | * issqnDANFE |
||
2579 | * Monta o campo de serviços do DANFE |
||
2580 | * |
||
2581 | * @name issqnDANFE (retrato e paisagem) |
||
2582 | * @param float $x Posição horizontal canto esquerdo |
||
2583 | * @param float $y Posição vertical canto superior |
||
2584 | * @return float Posição vertical final |
||
2585 | */ |
||
2586 | protected function pIssqnDANFE($x, $y) |
||
2656 | |||
2657 | /** |
||
2658 | *dadosAdicionaisDANFE |
||
2659 | * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem) |
||
2660 | * |
||
2661 | * @name dadosAdicionaisDANFE |
||
2662 | * @param float $x Posição horizontal canto esquerdo |
||
2663 | * @param float $y Posição vertical canto superior |
||
2664 | * @param float $h altura do campo |
||
2665 | * @return float Posição vertical final (eixo Y) |
||
2666 | */ |
||
2667 | protected function pDadosAdicionaisDANFE($x, $y, $h) |
||
2741 | |||
2742 | /** |
||
2743 | * pRodape |
||
2744 | * Monta o rodapé no final da DANFE com a data/hora de impressão e informações |
||
2745 | * sobre a API NfePHP |
||
2746 | * |
||
2747 | * @name pRodape |
||
2748 | * @param float $xInic Posição horizontal canto esquerdo |
||
2749 | * @param float $yFinal Posição vertical final para impressão |
||
2750 | * @return void |
||
2751 | */ |
||
2752 | protected function pRodape($x, $y) |
||
2766 | |||
2767 | /** |
||
2768 | * pCcanhotoDANFE |
||
2769 | * Monta o canhoto da DANFE (retrato e paisagem) |
||
2770 | * |
||
2771 | * @name canhotoDANFE |
||
2772 | * @param number $x Posição horizontal canto esquerdo |
||
2773 | * @param number $y Posição vertical canto superior |
||
2774 | * @return number Posição vertical final |
||
2775 | * |
||
2776 | * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente |
||
2777 | */ |
||
2778 | protected function pCanhoto($x, $y) |
||
2912 | |||
2913 | /** |
||
2914 | * pGeraInformacoesDaTagCompra |
||
2915 | * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia. |
||
2916 | * Aviso: Esta função não leva em consideração dados na tag xPed do item. |
||
2917 | * |
||
2918 | * @name pGeraInformacoesDaTagCompra |
||
2919 | * @return string com as informacoes dos pedidos. |
||
2920 | */ |
||
2921 | protected function pGeraInformacoesDaTagCompra() |
||
2937 | |||
2938 | /** |
||
2939 | * pGeraChaveAdicionalDeContingencia |
||
2940 | * |
||
2941 | * @name pGeraChaveAdicionalDeContingencia |
||
2942 | * @return string chave |
||
2943 | */ |
||
2944 | protected function pGeraChaveAdicionalDeContingencia() |
||
2976 | |||
2977 | /** |
||
2978 | * pGeraInformacoesDasNotasReferenciadas |
||
2979 | * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não |
||
2980 | * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01 |
||
2981 | * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000] |
||
2982 | * |
||
2983 | * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas. |
||
2984 | */ |
||
2985 | protected function pGeraInformacoesDasNotasReferenciadas() |
||
3062 | |||
3063 | private function imagePNGtoJPG($original) |
||
3064 | { |
||
3065 | $image = imagecreatefrompng($original); |
||
3066 | ob_start(); |
||
3067 | imagejpeg($image, null, 100); |
||
3068 | imagedestroy($image); |
||
3069 | $stringdata = ob_get_contents(); // read from buffer |
||
3070 | ob_end_clean(); |
||
3071 | return 'data://text/plain;base64,'.base64_encode($stringdata); |
||
3072 | } |
||
3073 | } |
||
3074 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.