Viewing file: ResultadoConsulta.php (5.91 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//Conexão
header('Content-Type: text/html; charset=iso-8859-1');
//Includes
include("config/config.php");
include("includes/conexaoBD.php");
$matricula = $_REQUEST['matricula'];
function CalculoDigito($Dados) {
if (strlen($Dados) == 30) {
echo "<br />";
//Primeiro dígito
$Acumulado = 0;
$Multiplicador = 1;
$Posicao = 29;
while ($Posicao >= 0) {
$Ch = $Dados[$Posicao];
$Multiplicador++;
$Acumulado += ($Multiplicador * intval($Ch));
$Posicao--;
}
$Acumulado = $Acumulado * 10;
$Aux = intval($Acumulado / 11);
$DV1 = $Acumulado - $Aux * 11;
if ($DV1 == 10)
$DV1 = 1;
$Dados .= $DV1;
//Segundo dígito
$Acumulado = 0;
$Multiplicador = 1;
$Posicao = 30;
while ($Posicao >= 0) {
$Ch = $Dados[$Posicao];
$Multiplicador++;
$Acumulado += ($Multiplicador * intval($Ch));
$Posicao--;
}
$Acumulado = $Acumulado * 10;
$Aux = intval($Acumulado / 11);
$DV2 = $Acumulado - $Aux * 11;
if ($DV2 == 10)
$DV2 = 1;
$Result = $DV1 * 10 + $DV2;
}
else
$Result = -1;
return $Result;
}
/*
1 nascimento - A
2 casamento civil - B
3 casamento religioso - BA
4 óbito - C
5 natimorto - CA
7 livro e - E
*/
function Livro($identificador,$livro) {
//echo '<p>Identificador: '.$identificador.' - Livro: '.$livro.'</p>';
// Acrescenta a letra ao número do livro de acordo com o tipo de ato
switch($identificador) {
case "01":
$letra_livro = "A";
break;
case "02":
$letra_livro = "B";
break;
case "03":
$letra_livro = "BA";
break;
case "04":
$letra_livro = "C";
break;
case "05":
$letra_livro = "CA";
break;
case "07":
$letra_livro = "E";
break;
}
$livro = $letra_livro . "-" . $livro;
return $livro;
}
function Tipo($identificador) {
switch($identificador) {
case "01":
$tipo = 'Nascimento';
break;
case "02":
$tipo = 'Casamento Civil';
break;
case "03":
$tipo = 'Casamento Religioso';
break;
case "04":
$tipo = 'Óbito';
break;
case "05":
$tipo = 'Natimorto';
break;
case "07":
$tipo = 'Livro E';
break;
}
return $tipo;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="margin:0px;">
<div style="padding:5px;">
<?php
//echo $matricula.'<br />';
$serventia = intval(substr($matricula,0,6));
$acervo = substr($matricula,6,2);
$servico = substr($matricula,8,2);
$ano = substr($matricula,10,4);
$livroTipo = Livro(substr($matricula,14,1),intval(substr($matricula,15,5)));
$folha = substr($matricula,20,3);
$termo = intval(substr($matricula,23,7));
$dgVerificador = substr($matricula,30,2);
if (CalculoDigito(substr($matricula,0,30)) != $dgVerificador) {
$msg = '<h2 style="font-size:15px; color:#F00;">*** O NÚMERO DE MATRÍCULA DIGITADO É INVÁLIDO ***</h2>';
} else {
$msg = '<h2 style="font-size:15px; color:#F00;">*** O NÚMERO DE MATRÍCULA DIGITADO É VÁLIDO ***</h2>';
}
$sqlBuscaDados = "
SELECT
ODC_Oficio_DR, ODC_CodigoCNJ,
OFI_Descricao, OFI_Cidades_DR as 'Codigo',
CID_Descricao as 'Cidade'
FROM oficios_dados_cnj
INNER JOIN oficios ON OFI_RowID = ODC_Oficio_DR
INNER JOIN cidades ON CID_RowID = OFI_Cidades_DR
WHERE ODC_CodigoCNJ = $serventia
";
$exeBuscaDados = mysqli_query($conexao,$sqlBuscaDados);
$rsBusca = mysqli_fetch_assoc($exeBuscaDados);
//echo "<p>$sqlBuscaDados</p>";
?>
<table width="100%" border="0">
<tr>
<td colspan="2" align="center"><?= $msg ?></td>
</tr>
<?php if (CalculoDigito(substr($matricula,0,30)) == $dgVerificador) { ?>
<tr>
<td colspan="2">Este documento foi emitido pelo cartório e sob o número de Registro apresentados abaixo:</td>
</tr>
<tr>
<td colspan="2" align="center"><hr /></td>
</tr>
<tr>
<td align="right"><strong>Numero de Matrícula:</strong></td>
<td align="left"><span style="font-weight:bold; font-size:14px"><?= substr($matricula,0,6) . $acervo . $servico . ' ' . $ano . ' ' . substr($matricula,14,1) . ' ' . substr($matricula,15,5) . ' ' . $folha . ' ' . substr($matricula,23,7) . ' ' . $dgVerificador ?></span></td>
</tr>
<tr>
<td width="30%" align="right"><strong>Cartório: </strong></td><td align="left"><?= $rsBusca['OFI_Descricao']?></td>
</tr>
<tr>
<td align="right"><strong>Cidade: </strong></td><td align="left"><?= $rsBusca['Cidade']?></td>
</tr>
<tr>
<td align="right"><strong>Acervo: </strong></td>
<td align="left">
<?php
switch($acervo) {
case '01':
echo "Acervo Próprio";
break;
case '02':
echo "Acervo Incorporado";
break;
}
?>
</td>
</tr>
<tr>
<td align="right"><strong>Tipo: </strong></td><td align="left"><?= Tipo(substr($matricula,14,1))?></td>
</tr>
<tr>
<td align="right"><strong>Ano: </strong></td><td align="left"><?= $ano?></td>
</tr>
<tr>
<td align="right"><strong>Livro: </strong></td><td align="left"><?= $livroTipo?></td>
</tr>
<tr>
<td align="right"><strong>Folha:</strong></td><td align="left"><?= $folha?></td>
</tr>
<tr>
<td align="right"><strong>Termo: </strong></td><td align="left"><?= $termo?></td>
</tr>
<tr>
<td colspan="2" align="center"><hr /></td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
|