protected function consumidor($dest)
{
//DADOS DO CONSUMIDOR
$consHtml = '';
$consHtml .= "<table width='100%'>\n";
if (!isset($dest)) {
$consHtml .= "<tr><td colspan=\"3\">" . htmlspecialchars('CONSUMIDOR NÃO IDENTIFICADO') . ".</td></tr>\n";
} else {
$enderDest = $dest->getElementsByTagName("enderDest")->item(0);
$consNome = $this->pSimpleGetValue($dest, "xNome");
$consFone = $this->pSimpleGetValue($enderDest, "fone");
$foneLen = strlen($consFone);
if ($foneLen == 10) {
$consFone = $this->pFormat($consFone, "(##) ####-####");
} elseif ($foneLen == 11) {
$consFone = $this->pFormat($consFone, "(##) #####-####");
}
$consLgr = $this->pSimpleGetValue($enderDest, "xLgr");
$consNro = $this->pSimpleGetValue($enderDest, "nro");
$consCpl = $this->pSimpleGetValue($enderDest, "xCpl", " - ");
$consBairro = $this->pSimpleGetValue($enderDest, "xBairro");
$consCEP = $this->pFormat($this->pSimpleGetValue($enderDest, "CEP"));
$consMun = $this->pSimpleGetValue($enderDest, "xMun");
$consUF = $this->pSimpleGetValue($enderDest, "UF");
$consCNPJ = $this->pSimpleGetValue($dest, "CNPJ");
$consCPF = $this->pSimpleGetValue($dest, "CPF");
$considEstrangeiro = $this->pSimpleGetValue($dest, "idEstrangeiro");
//CNPJ, CPF ou ID Estrageiro
if (!empty($consCNPJ)) {
$consCNPJ = $this->pFormat($consCNPJ, "##.###.###/####-##");
$consHtml .= "<tr><td colspan=\"3\">CONSUMIDOR CNPJ: {$consCNPJ} " . htmlspecialchars($consNome) . "</td></tr>\n";
} elseif (!empty($consCPF)) {
$consCPF = $this->pFormat($consCPF, "###.###.###-##");
$consHtml .= "<tr><td colspan=\"3\">CONSUMIDOR CPF: {$consCPF} " . htmlspecialchars($consNome) . "</td></tr>\n";
} elseif (!empty($considEstrangeiro)) {
$consHtml .= "<tr><td colspan=\"3\">CONSUMIDOR Id. Estrangeiro: {$considEstrangeiro} " . htmlspecialchars($consNome) . "</td></tr>\n";
}
if (!empty($consLgr) && !empty($consBairro) && !empty($consMun) && !empty($consUF)) {
$consHtml .= "<tr>\n";
$consHtml .= "<td colspan=\"3\">" . htmlspecialchars("{$consLgr}, {$consNro}, {$consCpl}, {$consBairro}") . "<br>\n" . htmlspecialchars("{$consMun}-{$consUF}") . "<br>\n" . htmlspecialchars("CEP: {$consCEP} - Tel.: {$consFone}") . "</td>\n";
$consHtml .= "</tr>\n";
}
}
$consHtml .= "</table>\n";
return $consHtml;
}