D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso_ant
/
adm
/
app
/
gre
/
Models
/
Filename :
GreCadastrarInventarioResidente.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit();} /** * Description of GreCadastrarInventarioResidente * * @copyright (c) year,Carlos Marques CM */ class GreCadastrarInventarioResidente{ private $Resultado; private $Dados; private $ResidId; private $idResidLanc; private $idUser; private $UltimoResidLanc; private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', ',' => '.', '(' => '', ')' => ''); function getResultado() { return $this->Resultado; } public function cadInvResid(array $Dados) { $this->Dados = $Dados; $this->retiraMasc(); $this->Dados['gre_usuario_id'] = $_SESSION['usuario_id']; $this->Dados['adms_sit_id'] = 1; date_default_timezone_set ("America/Sao_Paulo"); $this->Dados['data'] = date("Y-m-d H:i:s"); unset( $this->Dados['gre_produto_id_aux']); unset( $this->Dados['apres_sigla']); if($this->Dados['qtde_fracionada'] == ''){ $this->Dados['qtde_fracionada'] = 0; } //var_dump($this->Dados); //die; $cadInvResid = new \App\adms\Models\helper\AdmsCreate; $cadInvResid->exeCreate("gre_inventario_residente", $this->Dados); if ($cadInvResid->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Lançamento incluído 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: Lançamento não foi incluído! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } private function retiraMasc() { $this->Dados['qtde_caixa'] = strtr($this->Dados['qtde_caixa'] , $this->substituicao); $this->Dados['qtde_fracionada'] = strtr($this->Dados['qtde_fracionada'] , $this->substituicao); } public function listarCadastrar($Dados = null) { $this->ResidId = (int) $Dados; $listar = new \App\adms\Models\helper\AdmsRead(); $this->idUser = $_SESSION['id_user']; $listar->fullRead("SELECT empr.id id_empr FROM gre_empresa empr where empr.id= ". $this->idUser); $registro['empr'] = $listar->getResultado(); $listar->fullRead("Select pro.* from gre_estoque_residente est inner join gre_produto pro on pro.id = est.gre_produto_id where adms_sit_id = 1 and est.gre_residente_id = {$this->ResidId} and est.gre_empr_princ_id = " . $_SESSION['id_user'] . " group by est.gre_produto_id order by pro.nome"); $registro['produtos'] = $listar->getResultado(); $listar->fullRead("SELECT resid.id id_resid, resid.nome resid_nome, resid.gre_filial_id resid_gre_filial_id, fili.data_ult_fechamento FROM gre_residente resid inner join gre_filial fili on resid.gre_empr_princ_id = fili.gre_empr_princ_id and resid.gre_filial_id = fili.id where resid.id=". $this->ResidId ." AND resid.adms_sit_id = 1"); $registro['resid'] = $listar->getResultado(); if($_SESSION['filial']==0){ $listar->fullRead("SELECT est.gre_residente_id est_resid, est.gre_produto_id est_prod, coalesce(est.qtde,0) est_qtde, format(est.custo_medio_fracionado, 4, 'de_DE') est_preco, format(pre.preco_venda, 2, 'de_DE') est_preco_emb FROM gre_estoque_residente est inner join gre_tabela_precos pre on pre.gre_empr_princ_id = est.gre_empr_princ_id and pre.gre_filial_id = est.gre_filial_id and pre.gre_produto_id = est.gre_produto_id WHERE and est.gre_residente_id = {$this->ResidId} and est.gre_empr_princ_id=". $_SESSION['id_user']); }else{ $listar->fullRead("SELECT est.gre_residente_id est_resid, est.gre_produto_id est_prod, coalesce(est.qtde,0) est_qtde, format(est.custo_medio_fracionado, 4, 'de_DE') est_preco, format(pre.preco_venda, 2, 'de_DE') est_preco_emb FROM gre_estoque_residente est inner join gre_tabela_precos pre on pre.gre_empr_princ_id = est.gre_empr_princ_id and pre.gre_filial_id = est.gre_filial_id and pre.gre_produto_id = est.gre_produto_id WHERE est.gre_empr_princ_id=". $_SESSION['id_user'] . " and est.gre_residente_id = {$this->ResidId} and est.gre_filial_id=". $_SESSION['filial']); } $registro['est_resid'] = $listar->getResultado(); $listar->fullRead("SELECT gruplanc.gre_origem_id, gruplanc.id gruplanc_id, gruplanc.nome gruplanc_nome, gruplanc.sigla gruplanc_sigla FROM gre_est_grupo_lancamento gruplanc where gruplanc.gre_origem_id = 2"); $registro['gruplanc'] = $listar->getResultado(); $listar->fullRead("SELECT tipolanc.id tipolanc_id, tipolanc.gre_est_grupo_lancamento_id grupo_id, tipolanc.nome tipolanc_nome, tipolanc.sigla tipolanc_sigla, tipolanc.mov_fin, tipolanc.fornecimento, tipolanc.lanca_duplo, tipolanc.contra_partida, tipolanc.exige_emb_fechada FROM gre_est_tipo_lancamento tipolanc where tipolanc.gre_origem_id = 2"); $registro['tipolanc'] = $listar->getResultado(); $this->Resultado = ['empr' => $registro['empr'], 'produtos' => $registro['produtos'],'resid' => $registro['resid'],'est_resid' => $registro['est_resid'],'gruplanc' => $registro['gruplanc'], 'tipolanc' => $registro['tipolanc']]; return $this->Resultado; } }