D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreCadastrarResidLancServ.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit();} /** * Description of GreCadastrarEstoqueResidente * * @copyright (c) year,Carlos Marques CM */ class GreCadastrarResidLancServ{ private $Resultado; private $Dados; private $ResidId; private $idResidLanc; private $idUser; private $UltimoResidLanc; private $substituicao = array( ' ' => '', '_' => '', '/' => '', '.' => '', ',' => '.', '(' => '', ')' => ''); function getResultado() { return $this->Resultado; } public function cadLancServ(array $Dados) { $this->Dados = $Dados; $this->retiraMasc(); $this->Dados['created'] = date("Y-m-d H:i:s"); $this->Dados['gre_usuario_id'] = $_SESSION['usuario_id']; $this->Dados['valor_total'] = $this->Dados['preco'] * $this->Dados['qtde']; if($this->Dados['valor_repasse'] == '') { unset($this->Dados['valor_repasse']); } if (!empty($this->Dados['complemento'])){ $this->Dados['descricao'] .= ' - '. $this->Dados['complemento']; } unset( $this->Dados['complemento']); unset( $this->Dados['created']); unset( $this->Dados['valor_venda']); unset( $this->Dados['exige_compl']); $this->Dados['data'] = $this->Dados['data'].' '.date('h:i:s'); $this->Dados['intervalo_id'] = 1; unset( $this->Dados['data_min']); $this->Dados['gre_status_id'] = 1; var_dump($this->Dados); $cadLancServ = new \App\adms\Models\helper\AdmsCreate; $cadLancServ->exeCreate("gre_serv_mov_residente", $this->Dados); if ($cadLancServ->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'] = strtr($this->Dados['qtde'] , $this->substituicao); //$this->Dados['qtde_apres'] = strtr($this->Dados['qtde_apres'] , $this->substituicao); $this->Dados['preco'] = strtr($this->Dados['preco'] , $this->substituicao); $this->Dados['valor_repasse'] = strtr($this->Dados['valor_repasse'] , $this->substituicao); } public function listarCadastrar() { $this->ResidId = filter_input(INPUT_GET, 'id'); $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(); if($_SESSION['filial']==0){ $listar->fullRead("SELECT resid.id id_resid, resid.nome resid_nome, resid.gre_filial_id resid_gre_filial_id, resid.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(); $listar->fullRead("SELECT tabpreco.gre_filial_id, serv.gre_grupo_servico_id grupo_serv_id, serv.id serv_id, format(COALESCE(tabpreco.preco_venda, 0), 2, 'de_DE') preco_venda, format(COALESCE(tabpreco.valor_repasse, 0), 2, 'de_DE') valor_repasse FROM gre_servico serv left join gre_preco_servico tabpreco on tabpreco.gre_grupo_servico_id = serv.gre_grupo_servico_id and tabpreco.gre_servico_id = serv.id WHERE tabpreco.gre_empr_princ_id = ". $_SESSION['id_user'] . " and tabpreco.gre_filial_id is not null"); $registro['tabpreco'] = $listar->getResultado(); }else{ $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 AND resid.gre_filial_id = ". $_SESSION['filial']); $registro['resid'] = $listar->getResultado(); $listar->fullRead("SELECT tabpreco.gre_filial_id, serv.gre_grupo_servico_id grupo_serv_id, serv.id serv_id, format(COALESCE(tabpreco.preco_venda, 0), 2, 'de_DE') preco_venda, format(COALESCE(tabpreco.valor_repasse, 0), 2, 'de_DE') valor_repasse FROM gre_servico serv left join gre_preco_servico tabpreco on tabpreco.gre_grupo_servico_id = serv.gre_grupo_servico_id and tabpreco.gre_servico_id = serv.id WHERE tabpreco.gre_empr_princ_id = ". $_SESSION['id_user'] . " and tabpreco.gre_filial_id = ". $_SESSION['filial'] . " and tabpreco.gre_filial_id is not null"); $registro['tabpreco'] = $listar->getResultado(); } $listar->fullRead("SELECT grupserv.id grupserv_id, grupserv.nome grupserv_nome FROM gre_grupo_servico grupserv order by grupserv.id"); $registro['grupserv'] = $listar->getResultado(); $listar->fullRead("SELECT serv.id serv_id, serv.gre_grupo_servico_id grupo_id, serv.gre_grupo_fatura_id grupo_fatura_id, serv.nome serv_nome, serv.exige_complemento exige_complemento FROM gre_servico serv"); $registro['serv'] = $listar->getResultado(); $this->Resultado = ['empr' => $registro['empr'], 'tabpreco' => $registro['tabpreco'], 'resid' => $registro['resid'],'grupserv' => $registro['grupserv'], 'serv' => $registro['serv']]; return $this->Resultado; } }