D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreListarEntradaMerc.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreListarEntradaMerc * * @copyright (c) year, Carlos Marques - CM */ class GreListarEntradaMerc { private $Dados; private $Resultado; private $PageId; private $LimiteResultado = 10; private $ResultadoPg; function getResultadoPg() { return $this->ResultadoPg; } public function listarEntMerc($PageId = null, $Dados = null) { $this->PageId = (int) $PageId; $this->Dados = $Dados; if( $_SESSION['filial']<>0){ $this->Dados['gre_filial_id'] = $_SESSION['filial']; } 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_pedido where gre_empr_princ_id = ". $_SESSION['id_user']); $this->ResultadoPg = $paginacao->getResultado(); $listarSelect = new \App\gre\Models\GreListarContr(); $this->Dados['select'] = $listarSelect->listarCadastrar(); $listEntMerc = new \App\adms\Models\helper\AdmsRead(); $listEntMerc->fullRead("SELECT ped.*, prod.dv prod_dv, prod.nome prod_nome, prod.gre_departamento_id, apres.unid_adm, prod.qtde_apres, asso.gre_empresa_id, coalesce(est.qtde, 0) est_qtde from gre_pedido ped join gre_filial filial on filial.id =ped.gre_filial_id join gre_produto prod on prod.id = ped.gre_produto_id join gre_prod_apres apres on prod.gre_apres_id = apres.id join gre_assoprod asso on asso.gre_departamento_id = prod.gre_departamento_id left join gre_estoque_clinica est on est.gre_empr_princ_id = ped.gre_empr_princ_id and est.gre_filial_id = ped.gre_empr_princ_id and est.gre_empresa_id = asso.gre_empresa_id and est.gre_produto_id = ped.gre_produto_id WHERE filial.id = :filial_id AND ped.gre_empr_princ_id = :id_user and ped.data = :data and ped.gre_status_fat_id = 2 ORDER BY filial.id LIMIT :limit OFFSET :offset", "filial_id={$this->Dados['gre_filial_id']}&id_user={$_SESSION['id_user']}&data={$this->Dados['data']}&limit={$this->LimiteResultado}&offset={$paginacao->getOffset()}"); $this->Resultado = $listEntMerc->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_pedido ped on ped.gre_filial_id = filial.id where ped.gre_status_fat_id = 2 and filial.gre_empr_princ_id =". $_SESSION['id_user'] . " group by filial.id,filial.nome_fantasia ORDER BY filial.id"); }else{ $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial join gre_pedido ped on ped.gre_filial_id = filial.id where ped.gre_status_fat_id = 2 and filial.gre_empr_princ_id =". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " GROUP BY filial.id, filial.nome_fantasia "); } $registro['filial'] = $listar->getResultado(); if( $_SESSION['filial']==0){ $listar->fullRead("SELECT forn.id forn_id, forn.nome_fantasia forn_nome FROM gre_fornecedores forn inner join gre_pedido ped on ped.gre_fornecedor_id = forn.id where ped.gre_status_fat_id = 2 and ped.gre_empr_princ_id =". $_SESSION['id_user'] . " group by forn.id, forn.nome_fantasia "); }else{ $listar->fullRead("SELECT forn.id forn_id, forn.nome_fantasia forn_nome FROM gre_fornecedores forn inner join gre_pedido ped on ped.gre_fornecedor_id = forn.id where ped.gre_status_fat_id = 2 and ped.gre_empr_princ_id =" . $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " group by forn.id, forn.nome_fantasia " ); } $registro['forn'] = $listar->getResultado(); if( $_SESSION['filial']==0){ $listar->fullRead("SELECT data, date_format(data, '%d/%m%Y') data_imp FROM gre_pedido WHERE gre_status_fat_id = 2 and gre_empr_princ_id = ". $_SESSION['id_user'] . " group by data"); }else{ $listar->fullRead("SELECT data, date_format(data, '%d/%m%Y') data_imp FROM gre_pedido WHERE gre_status_fat_id = 2 and gre_empr_princ_id = ". $_SESSION['id_user'] . " AND filial.id = ". $_SESSION['filial'] . " group by data " ); } $registro['data'] = $listar->getResultado(); $this->Resultado = ['filial' => $registro['filial'], 'data' => $registro['data'], 'forn' => $registro['forn']]; // var_dump($this->Resultado); return $this->Resultado; } }