D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso_ant
/
adm
/
app
/
gre
/
Models
/
Filename :
GreCadastrarFamiliar.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreCadastrarFamiliar * * @copyright (c) year,Carlos Marques CM */ class GreCadastrarFamiliar { private $Resultado; private $Dados; private $UltimoFamilia; Private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', ',' => '', '(' => '', ')' => '' ); function getResultado() { return $this->Resultado; } public function cadFami(array $Dados) { $this->Dados = $Dados; $this->retiraMasc(); date_default_timezone_set ("America/Sao_Paulo"); $this->Dados['created'] = date("Y-m-d H:i:s"); $this->verUltimoFamilia(); $this->Dados['ordem'] = $this->UltimoFamilia[0]['ordem'] + 1; $this->Dados['adms_sit_id'] = 1; $this->Dados['gre_empr_princ_id'] = $_SESSION['id_user']; unset( $this->Dados['gre_residente_id_aux']); // var_dump($this->Dados); // die; $cadFamilia = new \App\adms\Models\helper\AdmsCreate; $cadFamilia->exeCreate("gre_familiar", $this->Dados); if ($cadFamilia->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Familiar cadastrado com sucesso!! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = true; } else { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Erro: Familiar não foi cadastrado! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } private function verUltimoFamilia() { $verFamilia = new \App\adms\Models\helper\AdmsRead(); $verFamilia->fullRead("SELECT ordem FROM gre_familiar ORDER BY ordem DESC LIMIT :limit", "limit=1"); $this->UltimoFamilia = $verFamilia->getResultado(); } /** * <b>Listar registros para chave estrangeira:</b> Buscar informações na tabela "adms_sits" para utilizar como chave estrangeira */ public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("SELECT id id_sit, nome nome_sit FROM adms_sits ORDER BY nome ASC"); $registro['sit'] = $listar->getResultado(); $listar->fullRead("SELECT id id_sexo, nome nome_sexo FROM gre_sexo ORDER BY ordem ASC"); $registro['sexo'] = $listar->getResultado(); $listar->fullRead("SELECT id id_parent, nome nome_parent FROM gre_parentesco ORDER BY ordem ASC"); $registro['parent'] = $listar->getResultado(); $listar->fullRead("SELECT id id_prof, nome nome_prof FROM gre_cbo ORDER BY favoritos desc,nome asc"); $registro['prof'] = $listar->getResultado(); if($_SESSION['filial']==0) { $listar->fullRead("SELECT resid.id id_resid, resid.nome nome_resid, resid.gre_filial_id id_filial FROM gre_residente resid where resid.gre_empr_princ_id = ". $_SESSION['id_user'] . " and resid.adms_sit_id <> 2 ORDER BY resid.nome asc"); }else{ $listar->fullRead("SELECT resid.id id_resid, resid.nome nome_resid, resid.gre_filial_id id_filial FROM gre_residente resid where resid.gre_empr_princ_id = ". $_SESSION['id_user'] . " AND resid.gre_filial_id = " . $_SESSION['filial'] . " and resid.adms_sit_id <> 2 ORDER BY resid.nome asc"); } $registro['resid'] = $listar->getResultado(); if($_SESSION['filial']==0) { $listar->fullRead("SELECT f.id id_filial, f.nome_fantasia nome_filial FROM gre_filial f where f.gre_empr_princ_id = ". $_SESSION['id_user'] . " and f.adms_sit_id <> 2 ORDER BY f.nome asc"); }else{ $listar->fullRead("SELECT SELECT f.id id_filial, f.nome_fantasia nome_filial FROM gre_filial f where f.gre_empr_princ_id = ". $_SESSION['id_user'] . " AND f.id = " . $_SESSION['filial'] . " and f.adms_sit_id <> 2 ORDER BY f.nome asc"); } $registro['filial'] = $listar->getResultado(); $this->Resultado = ['sit' => $registro['sit'], 'sexo' => $registro['sexo'], 'parent' => $registro['parent'], 'prof' => $registro['prof'], 'filial' => $registro['filial'], 'resid' => $registro['resid']]; return $this->Resultado; } private function retiraMasc() { $this->Dados['telefone_residencial'] = strtr($this->Dados['telefone_residencial'] , $this->substituicao); $this->Dados['telefone_comercial'] = strtr($this->Dados['telefone_comercial'] , $this->substituicao); $this->Dados['celular'] = strtr($this->Dados['celular'] , $this->substituicao); } }