Skip to content

Commit

Permalink
Merge pull request nfephp-org#486 from likesistemas/hotfix/nfce-offli…
Browse files Browse the repository at this point in the history
…ne-autotizada

Fix: Mostrar Protocolo e Data Autorização quando transmitida
  • Loading branch information
robmachado authored Oct 4, 2021
2 parents 8e3acea + 26fc91f commit 4fe72ce
Showing 1 changed file with 71 additions and 52 deletions.
123 changes: 71 additions & 52 deletions src/NFe/Traits/TraitBlocoVII.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ protected function blocoVII($y)
if ($this->paperwidth < 70) {
$subSize = 1.5;
}

$protocolo = '';
$dhRecbto = '';
if (!empty($this->nfeProc)) {
$protocolo = $this->formatField($this->getTagValue($this->nfeProc, 'nProt'), '### ########## ##');
$dhRecbto = (new \DateTime($this->getTagValue($this->nfeProc, "dhRecbto")))->format('d/m/Y H:i:s');
}

if ($this->tpEmis == 9) {
$aFont = ['font'=> $this->fontePadrao, 'size' => (7-$subSize), 'style' => ''];
$y += 2*$yPlus;
Expand Down Expand Up @@ -108,22 +116,31 @@ protected function blocoVII($y)
'',
true
);

$texto = "Pendente de autorização";
$aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'I'];
$y5 = $this->pdf->textBox(
$this->margem,
$y+$y1+$y2+$y3+$y4,
$this->wPrint,
3,
$texto,
$aFont,
'B',
'C',
false,
'',
true
);

if( empty($protocolo) ) {
$texto = "Pendente de autorização";
$aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'I'];
$y5 = $this->pdf->textBox(
$this->margem,
$y+$y1+$y2+$y3+$y4,
$this->wPrint,
3,
$texto,
$aFont,
'B',
'C',
false,
'',
true
);
} else {
$this->blocoVII_prot(
$y+$y1+$y2+$y3+$y4,
$subSize,
$protocolo,
$dhRecbto
);
}
} elseif ($this->tpEmis == 4) {
$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => ''];
$y1 = $this->pdf->textBox(
Expand Down Expand Up @@ -243,46 +260,48 @@ protected function blocoVII($y)
true
);

$protocolo = '';
$data = '';
if (!empty($this->nfeProc)) {
$protocolo = $this->formatField($this->getTagValue($this->nfeProc, 'nProt'), '### ########## ##');
$data = (new \DateTime($this->getTagValue($this->nfeProc, "dhRecbto")))->format('d/m/Y H:i:s');
}

$texto = "Protocolo de Autorização: {$protocolo}";
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => ''];
$y3 = $this->pdf->textBox(
$this->margem,
$this->blocoVII_prot(
$y+1+$y1+$y2,
$this->wPrint,
4,
$texto,
$aFont,
'T',
'C',
false,
'',
true
);

$texto = "Data de Autorização: {$data}";
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => ''];
$y4 = $this->pdf->textBox(
$this->margem,
$y+1+$y1+$y2+$y3,
$this->wPrint,
4,
$texto,
$aFont,
'T',
'C',
false,
'',
true
$subSize,
$protocolo,
$dhRecbto
);
}
$this->pdf->dashedHLine($this->margem, $this->bloco7H+$y, $this->wPrint, 0.1, 30);
return $this->bloco7H + $y;
}

protected function blocoVII_prot($y, $subSize, $protocolo, $dhRecbto) {
$texto = "Protocolo de Autorização: {$protocolo}";
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => ''];
$y1 = $this->pdf->textBox(
$this->margem,
$y,
$this->wPrint,
4,
$texto,
$aFont,
'T',
'C',
false,
'',
true
);

$texto = "Data de Autorização: {$dhRecbto}";
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => ''];
return $this->pdf->textBox(
$this->margem,
$y+$y1,
$this->wPrint,
4,
$texto,
$aFont,
'T',
'C',
false,
'',
true
);
}
}

0 comments on commit 4fe72ce

Please sign in to comment.