|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\DA\NFe\Traits; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Bloco cabecalho com a identificação e logo do emitente |
|
7
|
|
|
*/ |
|
8
|
|
|
trait TraitBlocoI |
|
9
|
|
|
{ |
|
10
|
|
|
protected function blocoI() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->bloco1H = 18; |
|
|
|
|
|
|
13
|
|
|
$y = $this->margem; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
//$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
16
|
|
|
//$this->pdf->textBox($this->margem, $y, $this->wPrint, $this->bloco1H, '', $aFont, 'T', 'C', true, '', false); |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
$emitRazao = $this->getTagValue($this->emit, "xNome"); |
|
|
|
|
|
|
20
|
|
|
$emitCnpj = $this->getTagValue($this->emit, "CNPJ"); |
|
|
|
|
|
|
21
|
|
|
$emitIE = $this->getTagValue($this->emit, "IE"); |
|
|
|
|
|
|
22
|
|
|
$emitCnpj = $this->formatField($emitCnpj, "###.###.###/####-##"); |
|
|
|
|
|
|
23
|
|
|
$emitLgr = $this->getTagValue($this->enderEmit, "xLgr"); |
|
|
|
|
|
|
24
|
|
|
$emitNro = $this->getTagValue($this->enderEmit, "nro"); |
|
|
|
|
|
|
25
|
|
|
$emitBairro = $this->getTagValue($this->enderEmit, "xBairro"); |
|
|
|
|
|
|
26
|
|
|
$emitMun = $this->getTagValue($this->enderEmit, "xMun"); |
|
|
|
|
|
|
27
|
|
|
$emitUF = $this->getTagValue($this->enderEmit, "UF"); |
|
|
|
|
|
|
28
|
|
|
$h = 0; |
|
|
|
|
|
|
29
|
|
|
$maxHimg = $this->bloco1H - 4; |
|
30
|
|
|
if (!empty($this->logomarca)) { |
|
31
|
|
|
$xImg = $this->margem; |
|
32
|
|
|
$yImg = $this->margem + 1; |
|
33
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
|
|
|
|
|
34
|
|
|
$logoWmm = ($logoInfo[0]/72)*25.4; |
|
35
|
|
|
$logoHmm = ($logoInfo[1]/72)*25.4; |
|
36
|
|
|
$nImgW = $this->wPrint/4; |
|
|
|
|
|
|
37
|
|
|
$nImgH = round($logoHmm * ($nImgW/$logoWmm), 0); |
|
38
|
|
|
if ($nImgH > $maxHimg) { |
|
39
|
|
|
$nImgH = $maxHimg; |
|
40
|
|
|
$nImgW = round($logoWmm * ($nImgH/$logoHmm), 0); |
|
41
|
|
|
} |
|
42
|
|
|
$xRs = ($nImgW) + $this->margem; |
|
43
|
|
|
$wRs = ($this->wPrint - $nImgW); |
|
44
|
|
|
$alignH = 'L'; |
|
45
|
|
|
$this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
46
|
|
|
} else { |
|
47
|
|
|
$xRs = $this->margem; |
|
48
|
|
|
$wRs = $this->wPrint; |
|
49
|
|
|
$alignH = 'C'; |
|
50
|
|
|
} |
|
51
|
|
|
//COLOCA RAZÃO SOCIAL |
|
52
|
|
|
$aFont = ['font'=>$this->fontePadrao, 'size' => 8, 'style' => '']; |
|
|
|
|
|
|
53
|
|
|
$texto = "{$emitRazao}"; |
|
54
|
|
|
$y += $this->pdf->textBox( |
|
55
|
|
|
$xRs+2, |
|
56
|
|
|
$this->margem, |
|
57
|
|
|
$wRs-2, |
|
58
|
|
|
$this->bloco1H-$this->margem-1, |
|
59
|
|
|
$texto, |
|
60
|
|
|
$aFont, |
|
61
|
|
|
'T', |
|
62
|
|
|
$alignH, |
|
63
|
|
|
false, |
|
64
|
|
|
'', |
|
65
|
|
|
true |
|
66
|
|
|
); |
|
67
|
|
|
if ($this->pdf->fontSizePt < 8) { |
|
68
|
|
|
$aFont = ['font'=>$this->fontePadrao, 'size' => $this->pdf->fontSizePt, 'style' => '']; |
|
69
|
|
|
} |
|
70
|
|
|
$texto = "CNPJ: {$emitCnpj} IE: {$emitIE}"; |
|
71
|
|
|
$y += $this->pdf->textBox($xRs+2, $y, $wRs-2, 3, $texto, $aFont, 'T', $alignH, false, '', true); |
|
72
|
|
|
$texto = $emitLgr . ", " . $emitNro; |
|
73
|
|
|
$y += $this->pdf->textBox($xRs+2, $y, $wRs-2, 3, $texto, $aFont, 'T', $alignH, false, '', true); |
|
74
|
|
|
$texto = $emitBairro; |
|
75
|
|
|
$y += $this->pdf->textBox($xRs+2, $y, $wRs-2, 3, $texto, $aFont, 'T', $alignH, false, '', true); |
|
76
|
|
|
$texto = $emitMun . "-" . $emitUF; |
|
77
|
|
|
$y += $this->pdf->textBox($xRs+2, $y, $wRs-2, 3, $texto, $aFont, 'T', $alignH, false, '', true); |
|
78
|
|
|
$this->pdf->dashedHLine($this->margem, $this->bloco1H, $this->wPrint, 0.1, 30); |
|
79
|
|
|
return $this->bloco1H; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: