Skip to content

Commit

Permalink
Merge pull request #290 from mateusperego/master
Browse files Browse the repository at this point in the history
Mostrar unidade Kg ou Ton
  • Loading branch information
robmachado committed Nov 14, 2019
2 parents 856dcc8 + b78d622 commit 01c3fa7
Showing 1 changed file with 64 additions and 20 deletions.
84 changes: 64 additions & 20 deletions src/MDFe/Damdfe.php
Expand Up @@ -67,7 +67,8 @@ public function __construct(

/**
* Ativa ou desativa o modo debug
* @param bool $activate
*
* @param bool $activate
* @return bool
*/
public function debugMode($activate = null)
Expand Down Expand Up @@ -145,6 +146,7 @@ private function loadDoc($xml)
$this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue;
}
$this->qCarga = $this->dom->getElementsByTagName("qCarga")->item(0)->nodeValue;
$this->cUnid = $this->dom->getElementsByTagName("cUnid")->item(0)->nodeValue;
$this->infModal = $this->dom->getElementsByTagName("infModal")->item(0);
$this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
$this->aereo = $this->dom->getElementsByTagName("aereo")->item(0);
Expand Down Expand Up @@ -177,8 +179,7 @@ private function loadDoc($xml)
}

/**
*buildMDFe
*
* buildMDFe
*/
public function buildMDFe()
{
Expand Down Expand Up @@ -242,9 +243,10 @@ public function buildMDFe()

/**
* headerMDFePaisagem
* @param float $x
* @param float $y
* @param integer $pag
*
* @param float $x
* @param float $y
* @param integer $pag
* @return string
*/
private function headerMDFePaisagem($x, $y, $pag)
Expand Down Expand Up @@ -386,9 +388,9 @@ private function headerMDFePaisagem($x, $y, $pag)
/**
* headerMDFeRetrato
*
* @param float $x
* @param float $y
* @param integer $pag
* @param float $x
* @param float $y
* @param integer $pag
* @return string
*/
private function headerMDFeRetrato($x, $y, $pag)
Expand Down Expand Up @@ -535,8 +537,8 @@ private function headerMDFeRetrato($x, $y, $pag)
/**
* bodyMDFe
*
* @param float $x
* @param float $y
* @param float $x
* @param float $y
* @return void
*/
private function bodyMDFe($x, $y)
Expand Down Expand Up @@ -679,10 +681,15 @@ private function bodyMDFe($x, $y)
$x1 += $x2;
$this->pdf->textBox($x1, $y, $x2, 12);

if ($this->rodo ||
$this->aereo ||
$this->ferrov) {
$texto = 'Peso Total (Kg)';
if ($this->rodo
|| $this->aereo
|| $this->ferrov
) {
if ($this->cUnid == 01) {
$texto = 'Peso Total (Kg)';
} else {
$texto = 'Peso Total (Ton)';
}
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
$this->pdf->textBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
$texto = number_format($this->qCarga, 4, ',', '.');
Expand All @@ -701,7 +708,11 @@ private function bodyMDFe($x, $y)
$ya = $y + 12;
$this->pdf->textBox($x, $ya, $maxW / 2, 12);
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
$texto = 'Peso Total (Kg)';
if ($this->cUnid == 01) {
$texto = 'Peso Total (Kg)';
} else {
$texto = 'Peso Total (Ton)';
}
$this->pdf->textBox($x, $ya, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, '');
$texto = number_format($this->qCarga, 4, ',', '.');
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
Expand Down Expand Up @@ -768,10 +779,18 @@ private function bodyMDFe($x, $y)
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
$altura = $y + 4;
/** @var \DOMNodeList $veicReboque */
/**
*
*
* @var \DOMNodeList $veicReboque
*/
$veicReboque = $this->veicReboque;
foreach ($veicReboque as $item) {
/** @var \DOMElement $item */
/**
*
*
* @var \DOMElement $item
*/
$altura += 4;
$texto = $item->getElementsByTagName('placa')->item(0)->nodeValue;
$this->pdf->textBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
Expand All @@ -790,10 +809,33 @@ private function bodyMDFe($x, $y)
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
$this->pdf->textBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
$altura = $y + 4;
/** @var \DOMNodeList $veicReboque */
/**
* @var \DOMNodeList $veicTracao
*/
$veicTracao = $this->veicTracao->getElementsByTagName('prop');
foreach ($veicTracao as $item) {
/**
* @var \DOMElement $item
*/
$DOMNodeList = $item->getElementsByTagName('RNTRC');
if ($DOMNodeList->length > 0) {
$altura += 4;
$texto = $DOMNodeList->item(0)->nodeValue;
$this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
}
}
/**
*
*
* @var \DOMNodeList $veicReboque
*/
$veicReboque = $this->veicReboque;
foreach ($veicReboque as $item) {
/** @var \DOMElement $item */
/**
*
*
* @var \DOMElement $item
*/
$DOMNodeList = $item->getElementsByTagName('RNTRC');
if ($DOMNodeList->length > 0) {
$altura += 4;
Expand Down Expand Up @@ -1153,6 +1195,7 @@ public function monta(

/**
* Dados brutos do PDF
*
* @return string
*/
public function render()
Expand All @@ -1165,6 +1208,7 @@ public function render()

/**
* Add the credits to the integrator in the footer message
*
* @param string $message
*/
public function creditsIntegratorFooter($message = '')
Expand Down

0 comments on commit 01c3fa7

Please sign in to comment.