D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreEditarItemFatura.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreEditarItemFatura * * @copyright (c) year, Carlos Marques - CM */ class GreEditarItemFatura { private $Resultado; private $Dados; private $DadosId; private $IdFat; private $ProdId; private $IdCat; private $Docto; private $Id; private $substituicao = array( ' ' => '', '_' => '', '/' => '', '.' => '.', ',' => '.', '(' => '', ')' => ''); function getResultado() { return $this->Resultado; } public function verItemFat() { $this->DadosId = filter_input_array(INPUT_GET, FILTER_DEFAULT); $this->IdFat = $this->DadosId['id_fat']; $pieces = explode("-", $this->IdFat); $this->Docto = $pieces[0]; $this->Id = $pieces[1]; $verItemFat = new \App\adms\Models\helper\AdmsRead(); $verItemFat->fullRead("SELECT fat.*, round(fat.valor_total / fat.qtde,4) preco_unit, concat(fat.anomes, fat.gre_empr_princ_id, fat.gre_filial_id, fat.gre_residente_id) id_fat FROM gre_fatura fat WHERE fat.id =:id and fat.docto = :id_fat LIMIT :limit", "id=" . $this->Id . "&id_fat=". $this->Docto . "&limit=1"); $this->Resultado = $verItemFat->getResultado(); return $this->Resultado; } public function altFat(array $Dados) { $this->Dados = $Dados; $valCampoVazio = new \App\adms\Models\helper\AdmsCampoVazio; $valCampoVazio->validarDados($this->Dados); if ($valCampoVazio->getResultado()) { $this->updateEditFat(); } else { $this->Resultado = false; } } private function updateEditFat() { $this->IdFat = $this->Dados['id']; $this->IdCab = $this->Dados['docto']; $this->ProdId = $this->Dados['produto_id']; // var_dump($this->Dados); // var_dump($this->IdFat); // var_dump($this->IdCab); // var_dump($this->ProdId); unset( $this->Dados['produto_id']); unset( $this->Dados['preco_unit'] ); unset( $this->Dados['id_fat'] ); unset( $this->Dados['id'] ); unset( $this->Dados['docto'] ); $this->retiraMasc(); //var_dump($this->Dados); $upAltFat = new \App\adms\Models\helper\AdmsUpdate(); $upAltFat->exeUpdate("gre_fatura", $this->Dados, "WHERE id =:id and docto= :docto and gre_produto= :prod_id", "id=" . $this->IdFat."&docto=" . $this->IdCab."&prod_id=" . $this->ProdId); $upAltCab = new \App\adms\Models\helper\AdmsProcedure1(); $upAltCab->exeProcedure("atualiza_fat_edit", $this->IdCab); if ($upAltFat->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Item atualizado 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: Item não foi atualizado! <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['valor_total'] = strtr($this->Dados['valor_total'] , $this->substituicao); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("SELECT id id_sit, nome nome_sit FROM adms_sits ORDER BY nome ASC"); $registro['sit'] = $listar->getResultado(); $this->Resultado = ['sit' => $registro['sit']]; return $this->Resultado; } }