Viewing file: ServicoCtrl.php (3.84 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require_once(APP_PATH."/system/ServiceDB.php");
require_once(APP_PATH."/controller/CertidaoCtrl.php");
class ServicoCtrl {
var $db;
/**
* Construtor principal
* Inicia a classe principal de controle informando o Modelo Atual
*/
public function __construct() {
$this->db = new ServiceDB();
$this->db->connect();
}
/**
* Retorna a ista de aniversariantes do dia
* @return Array
*/
public function getAniversariantesDia() {
$dia = date("d/m");
$array = array();
$sql = $this->db -> query("SELECT CON_Nascimento as nascimento, CON_Descricao as nome, CON_Email as email "
. "FROM contatos WHERE MONTH(CON_Nascimento) = '".date("m")."' AND DAY(CON_Nascimento) = '".date("d")."' "
. "AND CON_Perfil_DR <> 1 ORDER BY CON_Descricao");
while($row = $this->db -> fetch($sql)){
$array[] = $row;
}
return $array;
}
/**
* Retorna a ista de aniversariantes do mês
* @return Array
*/
public function getAniversariantesMes() {
$mes = date("m");
$array = array();
$sql = $this->db -> query("SELECT DAY(CON_Nascimento) as dia, CON_Descricao as nome, CON_Email as email FROM contatos WHERE MONTH(CON_Nascimento) = '".$mes."' AND CON_Perfil_DR <> 1 ORDER BY DAY(CON_Nascimento), CON_Descricao");
while($row = $this->db -> fetch($sql)){
$array[] = $row;
}
return $array;
}
/**
* Valida o número da matrícula
* @param type $matricula
*/
public function validaMatricula($matricula){
$certidaoCtrl = new CertidaoCtrl();
$serventia = intval(substr($matricula,0,6));
$acv = substr($matricula,6,2);
$servico = substr($matricula,8,2);
$dgVerificador = substr($matricula,30,2);
$ano = substr($matricula,10,4);
$folha = substr($matricula, 20, 3);
switch($acv) {
case '01':
$acervo = "Acervo Próprio"; break;
case '02':
$acervo = "Acervo Incorporado"; break;
}
$calcDigito = $certidaoCtrl->calculoDigito(substr($matricula,0,30));
//echo $calcDigito;
//echo $serventia;
if($calcDigito != $dgVerificador || $calcDigito == -1) {
$status = false;
} else {
$status = true;
}
$array = array();
$sql = $this->db -> query("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);
$row = $this->db -> fetch($sql);
$array['oficio'] = utf8_encode($row['OFI_Descricao']);
$array['cidade'] = utf8_encode($row['Cidade']);
$array['ano'] = $ano;
$array['livroTipo'] = utf8_encode($certidaoCtrl->getLivro(substr($matricula,14,1), intval(substr($matricula,15,5))));
$array['acervo'] = utf8_encode($acervo);
$array['matricula'] = substr($matricula, 0, 6) . $acv . $servico . ' ' . $ano . ' ' . substr($matricula, 14, 1) . ' ' . substr($matricula, 15, 5) . ' ' . $folha . ' ' . substr($matricula, 23, 7) . ' ' . $dgVerificador;
$array['tipo'] = utf8_encode($certidaoCtrl->getTipo(substr($matricula, 14, 1)));
$array['folha'] = substr($matricula, 20, 3);
$array['termo'] = intval(substr($matricula,23,7));
$array['status'] = $status;
return $array;
}
}
?>
|