D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreListarPrescricaoResidente.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsPrescricaoResidentecServ * * @copyright (c) year, Carlos Marques - CM */ class GreListarPrescricaoResidente { private $Resultado; public function listPrescrResid() { $this->DadosForm = filter_input_array(INPUT_GET, FILTER_DEFAULT); $listarPrescrResid = new \App\adms\Models\helper\AdmsRead(); if ($_SESSION['filial'] == 0) { $listarPrescrResid->fullRead("SELECT prescr.id, date_format(prescr.data_inicio_tratamento, '%d/%m/%Y') data_inicio_tratamento, case when prescr.data_fim_tratamento = '9999-12-31' then 'Sem validade Final' else date_format(prescr.data_fim_tratamento, '%d/%m/%Y') end data_fim_tratamento, prescr.gre_produto_id, prod.nome prod_nome, resid.id resid_id, resid.nome resid_nome, sit.nome nome_sit, cr.cor cor_cr FROM gre_prescricao prescr inner join gre_residente resid on resid.id = prescr.gre_residente_id and resid.gre_empr_princ_id = prescr.gre_empr_princ_id inner join gre_produto prod on prod.id = prescr.gre_produto_id and prod.gre_empr_princ_id = prescr.gre_empr_princ_id left join gre_prod_departamento depto on depto.id = prod.gre_departamento_id INNER JOIN adms_sits sit ON sit.id=prescr.adms_sit_id INNER JOIN adms_cors cr ON cr.id= sit.adms_cor_id Where prescr.gre_empr_princ_id = :id_user and prescr.gre_residente_id = :id_resid ORDER BY prescr.id desc", "id_user={$_SESSION['id_user']}&id_resid={$this->DadosForm['id']}"); }else{ $listarPrescrResid->fullRead("SELECT prescr.id prescr_id, depto.nome depto_nome, prescr.gre_produto_id, prod.nome prod_nome, resid.nome resid_nome, sit.nome nome_sit, cr.cor cor_cr FROM gre_prescricao prescr inner join gre_residente resid on resid.id = prescr.gre_residente_id and resid.gre_empr_princ_id = prescr.gre_empr_princ_id inner join gre_produto prod on prod.id = prescr.gre_produto_id and prod.gre_empr_princ_id = prescr.gre_empr_princ_id inner join gre_prod_departamento depto on depto.id = prod.gre_departamento_id INNER JOIN adms_sits sit ON sit.id=prescr.adms_sit_id INNER JOIN adms_cors cr ON cr.id=sit.adms_cor_id Where prescr.gre_empr_princ_id = :id_user and gre_filial_id = :filial and gre_residente_id = :id_resid ORDER BY depto.id, prod.nome ASC", "id_resid={$this->DadosForm['id']}&id_user={$_SESSION['id_user']}&filial={$_SESSION['filial']}"); } $this->Resultado = $listarPrescrResid->getResultado(); return $this->Resultado; } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); if($_SESSION['filial']==0){ $listar->fullRead("SELECT filial.nome_fantasia filial_nome, filial.id filial_id FROM gre_filial filial where filial.gre_empr_princ_id =". $_SESSION['id_user']. " ORDER BY filial.id asc"); $registro['filial'] = $listar->getResultado(); }ELSE{ $listar->fullRead("SELECT filial.nome_fantasia filial_nome, filial.id filial_id FROM gre_filial filial inner join gre_empresa empr on empr.id = filial.gre_empr_princ_id where empr.id= ". $_SESSION['id_user']. " and filial.id = " . $_SESSION['FILIAL'] . "and filial.gre_empr_princ_id =". $_SESSION['id_user']. " ORDER BY filial.nome_fantasia asc"); $registro['filial'] = $listar->getResultado(); } $this->Resultado = ['filial' => $registro['filial']]; return $this->Resultado; } }