D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso_ant
/
adm
/
app
/
gre
/
Models
/
Filename :
GreCadastrarPrecoServico.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreCadastrarPrecoServico * * @copyright (c) year,Carlos Marques CM */ class GreCadastrarPrecoServico { private $Resultado; private $Dados; private $UltimoPrecoServ; private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', ',' => '.', '(' => '', ')' => '' ); function getResultado() { return $this->Resultado; } public function cadPrecoServ(array $Dados) { $this->Dados = $Dados; $this->retiraMasc(); $this->verPrecoServDuplo(); if ($this->Resultado) { $this->verPreco(); if ($this->Resultado) { $this->inserirPrecoServ(); } } } private function verPreco(){ if($this->Dados['preco_venda'] < $this->Dados['valor_repasse']) { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Erro: Valor do Repasse MAIOR que Preço de Venda! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; }else{ $this->Resultado = true; } } private function inserirPrecoServ() { $this->Dados['created'] = date("Y-m-d H:i:s"); $this->Dados['gre_empr_princ_id'] = $_SESSION['id_user']; // var_dump($this->Dados); $cadPrecoServ = new \App\adms\Models\helper\AdmsCreate; $cadPrecoServ->exeCreate("gre_preco_servico", $this->Dados); if ($cadPrecoServ->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Preço do Serviço cadastrado 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: Preço do Serviço não foi cadastrado! <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['preco_venda'] = strtr($this->Dados['preco_venda'] , $this->substituicao); $this->Dados['valor_repasse'] = strtr($this->Dados['valor_repasse'] , $this->substituicao); } public function listarCadastrar() { $listar = new \App\adms\Models\helper\AdmsRead(); $listar->fullRead("SELECT gruposerv.id id_gruposerv, gruposerv.nome nome_gruposerv FROM gre_grupo_servico gruposerv ORDER BY gruposerv.ordem ASC"); $registro['gruposerv'] = $listar->getResultado(); $listar->fullRead("SELECT serv.id id_serv, serv.nome nome_serv, serv.gre_grupo_servico_id gruposerv_id FROM gre_servico serv WHERE serv.nome <> 'Outros' ORDER BY serv.ordem ASC"); $registro['serv'] = $listar->getResultado(); $listar->fullRead("SELECT baspre.id id_baspre, baspre.nome nome_baspre FROM gre_base_preco baspre order by baspre.id" ); $registro['baspre'] = $listar->getResultado(); $listar->fullRead("SELECT filial.id id_filial, filial.nome_fantasia nome_filial FROM gre_filial filial where filial.gre_empr_princ_id = ". $_SESSION['id_user'] . " order by filial.id" ); $registro['filial'] = $listar->getResultado(); $this->Resultado = ['gruposerv' => $registro['gruposerv'],'serv' => $registro['serv'],'filial' => $registro['filial'], 'baspre' => $registro['baspre']]; return $this->Resultado; } public function verPrecoServDuplo(){ $verPrecoServDuplo = new \App\adms\Models\helper\AdmsRead(); $verPrecoServDuplo->fullRead("SELECT id FROM gre_preco_servico WHERE gre_grupo_servico_id= :gre_grupo_servico_id and gre_servico_id = :gre_servico_id and gre_filial_id = :filial_id LIMIT :limit", "gre_grupo_servico_id=" . $this->Dados['gre_grupo_servico_id'] . "&filial_id=" . $this->Dados['gre_filial_id']. "&gre_servico_id=" . $this->Dados['gre_servico_id']. "&limit=1"); if ($verPrecoServDuplo->getResultado()) { if ($verEstrutServDupla->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Erro: Preço do serviço já cadastrado! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } else { $this->Resultado = true; } } } }