D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreEditarFamiliar.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreEditarFamiliar * * @copyright (c) year, Carlos Marques - CM */ class GreEditarFamiliar { private $Resultado; private $Dados; private $DadosId; private $DadosFav; private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', '(' => '', ')' => '' ); function getResultado() { return $this->Resultado; } public function verFami($DadosId) { $this->DadosId = $DadosId; $verFami = new \App\adms\Models\helper\AdmsRead(); $verFami->fullRead("SELECT fami.*, parent.nome parente_nome, prof.nome prof_nome, sexo.nome sexo_nome, resid.nome resid_nome, gre_residente_id, filial.nome_fantasia filial_nome, :filial_sel filial_sel, :resid_sel resid_sel, :fam_sel fam_sel FROM gre_familiar fami INNER JOIN gre_residente resid ON resid.id= fami.gre_residente_id INNER JOIN gre_filial filial ON filial.id= resid.gre_filial_id INNER JOIN gre_cbo prof ON prof.id= fami.gre_cbo_id INNER JOIN gre_parentesco parent ON parent.id= fami.gre_parentesco_id INNER JOIN gre_sexo sexo ON sexo.id= fami.gre_sexo_id INNER JOIN adms_sits sit ON sit.id=fami.adms_sit_id INNER JOIN adms_cors cr ON cr.id=sit.adms_cor_id WHERE fami.id = :id LIMIT :limit", "id=" . $this->DadosId['id'] . "&resid_sel=" . $this->DadosId['resid_sel']. "&fam_sel=" . $this->DadosId['fam_sel']. "&filial_sel=" . $this->DadosId['filial_sel']. "&limit=1"); $this->Resultado = $verFami->getResultado(); return $this->Resultado; } public function altFami(array $Dados) { $this->Dados = $Dados; unset($this->Dados['EditFami'],$this->Dados['resid_nome'],$this->Dados['sexo_nome'], $this->Dados['parent__nome'], $this->Dados['prof_nome']); $this->Dados['modified'] = date("Y-m-d H:i:s"); $this->retiraMasc(); //var_dump($this->Dados); $upAltFami = new \App\adms\Models\helper\AdmsUpdate(); $upAltFami->exeUpdate("gre_familiar", $this->Dados, "WHERE id =:id", "id=" . $this->Dados['id']); if ($upAltFami->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Familiar atualizado 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 atualizado! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } 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_resid, nome nome_resid FROM gre_residente where adms_sit_id = 3 ORDER BY nome asc"); $registro['resid'] = $listar->getResultado(); $listar->fullRead("SELECT id id_sexo, nome nome_sexo FROM gre_sexo ORDER BY id"); $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"); $registro['prof'] = $listar->getResultado(); $this->Resultado = ['sit' => $registro['sit'], 'resid' => $registro['resid'], 'sexo' => $registro['sexo'],'parent' => $registro['parent'],'prof' => $registro['prof']]; 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); } }