D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreEditarAcolhimento.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreEditarAcolhimento * * @copyright (c) year, Carlos Marques - CM */ class GreEditarAcolhimento { private $Resultado; private $Dados; private $DadosId; private $DadosEdit; private $DataRet; private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', ',' => '.', '(' => '', ')' => ''); function getResultado() { return $this->Resultado; } public function verAcolh($DadosId) { $this->DadosId = (int) $DadosId; $verAcolh = new \App\adms\Models\helper\AdmsRead(); $verAcolh->fullRead("SELECT acolh.*, resid.nome resid_nome, acomo.nome acomo_nome, tipoacomo.nome tipoacomo_nome, alas.nome alas_nome, colab.apelido colab_nome, unid.nome unid_nome, filial.nome_fantasia filial_nome, cr.cor cor_cr FROM gre_acolhimento acolh inner join gre_residente resid on resid.id = acolh.gre_residente_id INNER JOIN gre_filial filial ON filial.id= acolh.gre_filial_id INNER JOIN gre_unidade unid ON unid.id= acolh.gre_unidade_id INNER JOIN gre_alas alas on alas.id = acolh.gre_alas_id INNER JOIN adms_usuarios colab ON colab.id= acolh.gre_colaborador_id INNER JOIN gre_tipo_acomodacao tipoacomo ON tipoacomo.id= acolh.gre_tipo_acomodacao_id INNER JOIN gre_acomodacao acomo ON acomo.id= acolh.gre_acomodacao_id INNER JOIN adms_sits sit ON sit.id= acolh.adms_sit_id INNER JOIN adms_cors cr ON cr.id= sit.adms_cor_id INNER JOIN gre_empresa empr on empr.id = filial.gre_empr_princ_id WHERE acolh.id =:acolh_id and empr.cnpj = :cnpj LIMIT :limit", "acolh_id=" . $this->DadosId . "&cnpj=" . CLIENTE . "&limit=1"); $this->Resultado = $verAcolh->getResultado(); return $this->Resultado; } public function altAcolh(array $Dados) { $this->Dados = $Dados; $valCampoVazio = new \App\adms\Models\helper\AdmsCampoVazio; $valCampoVazio->validarDados($this->Dados); if ($valCampoVazio->getResultado()) { $this->updateEditAcolh(); } else { $this->Resultado = false; } } private function updateEditAcolh() { $this->Dados['modified'] = date("Y-m-d H:i:s"); $this->retiraMasc(); if( $this->Dados['pressao_sistolica'] < $this->Dados['pressao_diastolica']) { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Presso Mínima maior ou igual Máxima ! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; }else{ $this->Resultado = true; $this->InvertData($this->Dados['data_inicio_acolhimento']); $this->Dados['data_inicio_acolhimento'] =$this->DataRet; $this->InvertData($this->Dados['data_fim_acolhimento']); $this->Dados['data_fim_acolhimento'] =$this->DataRet; $upAltAcolh = new \App\adms\Models\helper\AdmsUpdate(); $upAltAcolh->exeUpdate("gre_acolhimento", $this->Dados, "WHERE id =:id", "id=" . $this->Dados['id']); if ($upAltAcolh->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Acolhimento 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: Acolhimento 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; } } } function InvertData($campo){ $hora = substr($campo, 11,8); if(substr($campo,2,1)=='/'){ $campo=substr($campo,6,4).'-'.substr($campo,3,2).'-'.substr($campo,0,2);//2012-10-10 } else { $campo=substr($campo,8,2).'/'.substr($campo,5,2).'/'.substr($campo,0,4); //10/10/2012 } $this->DataRet = ($campo.' '.$hora); } public function listarCadastrar($DadosEdit) { $this->DadosEdit = $DadosEdit; // var_dump($this->DadosEdit); $listar = new \App\adms\Models\helper\AdmsRead(); if( $_SESSION['filial']==0){ $listar->fullRead("SELECT colab.id id_colab, colab.apelido nome_colab FROM adms_usuarios colab inner join gre_cargos cargo on cargo.id = colab.gre_cargos_id inner join gre_filial filial on filial.id = colab.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where cargo.permite_avaliacao = 'S' and colab.adms_sit_usuario_id = 1 and empr.cnpj = " . CLIENTE . " ORDER BY colab.nome"); $registro['colab'] = $listar->getResultado(); $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj =". CLIENTE . " ORDER BY filial.id"); $registro['filial'] = $listar->getResultado(); $listar->fullRead("SELECT alas.id id_alas, max(alas.nome) nome_alas, estrut.gre_unidade_id unid_id, estrut.gre_filial_id filial_id FROM gre_estrutura estrut inner join gre_alas alas on estrut.gre_alas_id = alas.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " group by estrut.gre_filial_id,estrut.gre_unidade_id,alas.id ORDER BY filial.id"); $registro['alas'] = $listar->getResultado(); $listar->fullRead("SELECT unid.id id_unid, max(unid.nome) nome_unid, estrut.gre_alas_id alas_id, estrut.gre_filial_id filial_id FROM gre_estrutura estrut inner join gre_unidade unid on estrut.gre_unidade_id = unid.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " group by unid.id,estrut.gre_alas_id,estrut.gre_filial_id ORDER BY filial.id, unid.id"); $registro['unid'] = $listar->getResultado(); $listar->fullRead("SELECT tipoacomo.id id_tipoacomo, nome(tipoacomo.nome) nome_tipoacomo, estrut.gre_unidade_id unid_id FROM gre_estrutura estrut inner join gre_tipo_acomodacao tipoacomo on estrut.gre_tipo_acomodacao_id = tipoacomo.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " group by estrut.gre_unidade_id, tipoacomo.id ORDER BY filial.id, tipoacomo.id"); $registro['tipoacomo'] = $listar->getResultado(); $listar->fullRead("SELECT acomo.id id_acomo, max(acomo.nome) nome_acomo, acomo.gre_tipo_acomodacao_id tipoacomo_id, estrut.gre_unidade_id unid_id FROM gre_estrutura estrut inner join gre_acomodacao acomo on estrut.gre_acomodacao_id = acomo.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " group by estrut.gre_unidade_id, acomo.gre_tipo_acomodacao_id,acomo.id ORDER BY filial.id, acomo.id"); $registro['acomo'] = $listar->getResultado(); }else{ $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj =". CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " ORDER BY filial.id"); $registro['filial'] = $listar->getResultado(); $listar->fullRead("SELECT colab.id id_colab, colab.apelido nome_colab FROM adms_usuarios colab inner join gre_cargos cargo on cargo.id = colab.gre_cargos_id inner join gre_filial filial on filial.id = colab.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where cargo.permite_avaliacao = 'S' AND empr.cnpj =". CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " AND empr.cnpj = " . CLIENTE . " and colab.adms_sit_usuario_id = 1 ORDER BY colab.nome"); $registro['colab'] = $listar->getResultado(); $listar->fullRead("SELECT alas.id id_alas, alas.nome nome_alas, alas.gre_filial_id filial_id FROM gre_estrutura estrut inner join gre_alas alas on estrut.gre_alas_id = alas.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " group by alas.id ORDER BY filial.id"); $registro['alas'] = $listar->getResultado(); $listar->fullRead("SELECT unid.id id_unid, max(unid.nome) nome_unid, estrut.gre_alas_id alas_id, estrut.gre_filial_id filial_id FROM gre_estrutura estrut inner join gre_unidade unid on estrut.gre_unidade_id = unid.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " group by estrut.gre_alas_id,estrut.gre_filial_id,unid.id ORDER BY filial.id, unid.id"); $registro['unid'] = $listar->getResultado(); $listar->fullRead("SELECT tipoacomo.id id_tipoacomo, max(tipoacomo.nome) nome_tipoacomo FROM gre_estrutura estrut inner join gre_tipo_acomodacao tipoacomo on estrut.gre_tipo_acomodacao_id = tipoacomo.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " group by tipoacomo.id ORDER BY tipoacomo.id"); $registro['tipoacomo'] = $listar->getResultado(); $listar->fullRead("SELECT acomo.id id_acomo, max(acomo.nome) nome_acomo, acomo.gre_tipo_acomodacao_id tipoacomo_id FROM gre_estrutura estrut inner join gre_acomodacao acomo on estrut.gre_acomodacao_id = acomo.id inner join gre_filial filial on filial.id = estrut.gre_filial_id join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.cnpj = " . CLIENTE . " AND filial.id = ". $_SESSION['filial'] . " group by acomo.id,acomo.gre_tipo_acomodacao_id ORDER BY acomo.id"); $registro['acomo'] = $listar->getResultado(); } $this->Resultado = ['filial' => $registro['filial'],'colab' => $registro['colab'],'alas' => $registro['alas'],'unid' => $registro['unid'], 'tipoacomo' => $registro['tipoacomo'], 'acomo' => $registro['acomo']]; //var_dump($this->Resultado); return $this->Resultado; } private function retiraMasc() { $this->Dados['peso'] = strtr($this->Dados['peso'] , $this->substituicao); $this->Dados['altura'] = strtr($this->Dados['altura'] , $this->substituicao); $this->Dados['pressao_sistolica'] = strtr($this->Dados['pressao_sistolica'] , $this->substituicao); $this->Dados['pressao_diastolica'] = strtr($this->Dados['pressao_diastolica'] , $this->substituicao); } }