D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreListarAcolhimento.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsListarAcolhimento * * @copyright (c) year, Carlos Marques - CM */ class GreListarAcolhimento { private $Dados; private $Resultado; private $PageId; private $LimiteResultado = 10; private $ResultadoPg; function getResultadoPg() { return $this->ResultadoPg; } public function listarAcolh($PageId = null, $Dados = null) { $this->PageId = (int) $PageId; $this->Dados = $Dados; // if( $_SESSION['filial']<>0){ $this->Dados['gre_filial_id'] = $_SESSION['filial']; } // var_dump($this->Dados['gre_filial_id']); if(isset($this->Dados['gre_filial_id'])) { $this->Dados['gre_filial_id'] = trim($this->Dados['gre_filial_id']); if(!empty($this->Dados['gre_filial_id'])){ $this->pesquisarFiliCod(); return $this->Resultado; }else{ $this->listarCadastrar(); } } } private function pesquisarFiliCod() { $paginacao = new \App\adms\Models\helper\AdmsPaginacao(URLADM . 'acomodacao/listar', '?gre_filial_id='.$this->Dados['gre_filial_id']); $paginacao->condicao($this->PageId, $this->LimiteResultado); $paginacao->paginacao("SELECT COUNT(id) AS num_result FROM gre_filial"); $this->ResultadoPg = $paginacao->getResultado(); $listarSelect = new \App\gre\Models\GreListarAcolhimento(); $this->Dados['select'] = $listarSelect->listarCadastrar(); $listarAcolh = new \App\adms\Models\helper\AdmsRead(); $listarAcolh->fullRead("SELECT resid.id, resid.cpf resid_cpf, resid.nome resid_nome, resid.gre_filial_id filial_id, filial.nome_fantasia filial_nome, sit.nome nome_sit, cr.cor cor_cr FROM gre_residente resid join gre_filial filial on filial.id = resid.gre_filial_id inner join gre_empresa empr on empr.id = filial.gre_empr_princ_id INNER JOIN adms_sits sit ON sit.id= resid.adms_sit_id INNER JOIN adms_cors cr ON cr.id=sit.adms_cor_id WHERE filial.id = :filial_id AND empr.id = :empr_id and resid.adms_sit_id in(1,3) and resid.id not in (select a.gre_residente_id from gre_acolhimento a where a.gre_filial_id = :filial_id) ORDER BY filial.id LIMIT :limit OFFSET :offset", "filial_id={$this->Dados['gre_filial_id']}&empr_id={$_SESSION['id_user']}&limit={$this->LimiteResultado}&offset={$paginacao->getOffset()}"); $this->Resultado = $listarAcolh->getResultado(); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); if( $_SESSION['filial']==0){ $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.id =". $_SESSION['id_user'] . " ORDER BY filial.id"); $registro['filial'] = $listar->getResultado(); $listar->fullRead("SELECT alas.id id_alas, max(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.id =". $_SESSION['id_user'] . " group by alas.gre_filial_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.id =". $_SESSION['id_user'] . " 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.id =". $_SESSION['id_user'] . " 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.id =". $_SESSION['id_user'] . " group by acomo.id, como.gre_tipo_acomodacao_id ORDER BY 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.id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " ORDER BY filial.id"); $registro['filial'] = $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.id =". $_SESSION['id_user'] . " 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, unid.gre_alas_id alas_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.id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " group by unid.id, unid.gre_alas_id ORDER BY 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.id =". $_SESSION['id_user'] . " 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.id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " group by acomo.id,como.gre_tipo_acomodacao_id ORDER BY acomo.id"); $registro['acomo'] = $listar->getResultado(); } $this->Resultado = ['filial' => $registro['filial'],'alas' => $registro['alas'],'unid' => $registro['unid'], 'tipoacomo' => $registro['tipoacomo'], 'acomo' => $registro['acomo']]; //var_dump($this->Resultado); return $this->Resultado; } }