D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
gre
/
Models
/
Cotacao
/
Filename :
ModCtRespondeNegociacaoEditar.php
back
Copy
<?php namespace App\gre\Models\Cotacao; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GreEditarEmpr * * @copyright (c) year, Carlos Marques - CM */ class ModCtRespondeNegociacaoEditar { private $Resultado; private $Dados; private $DadosId; private $DadosUsuario; private $DadosRegr; private $IdCotacao; private $PrecoCotado; private $substituicao = array( ' ' => '', '_' => '', '-' => '', '/' => '', '.' => '', ',' => '.', '(' => '', ')' => '' ); function getResultado() { return $this->Resultado; } public function altNegociacao(array $Dados) { $this->Dados = $Dados; $this->DadosUsuario[0]['apelido'] = $this->Dados['comp_apelido']; $this->DadosUsuario[0]['usu_email'] = $this->Dados['repres_email']; $this->DadosUsuario[0]['usu_apelido'] = $this->Dados['repres_apelido'].' - '.$this->Dados['repres_nome']; $this->DadosUsuario[0]['email'] = $this->Dados['comp_email']; $this->DadosUsuario[0]['data'] = $this->Dados['data_cotacao']; $this->DadosUsuario[0]['usu_celular'] = $this->Dados['repres_celular']; // var_dump($this->Dados); // var_dump($this->DadosUsuario); foreach ($this->Dados['qtde']as $keye => $valuee) { foreach($valuee as $keyEmb => $valueEmb){ if($valueEmb == ''){ $valueEmb = 0; } $valueEmb = strtr($valueEmb , $this->substituicao); $this->DadosId['id'] = $keyEmb; $this->DadosRegr['qtde_resposta_negociacao'] = $valueEmb; $upAltEmb = new \App\adms\Models\helper\AdmsUpdate(); $upAltEmb->exeUpdate("ct_cotacao", $this->DadosRegr, "WHERE id =:id", "id=" . $this->DadosId['id']); } } unset($this->DadosId); unset($this->DadosRegr); foreach ($this->Dados['preco']as $keyPreco => $valuePreco) { foreach($valuePreco as $keyPreco => $valuePreco){ if($valuePreco == ''){ $valuePreco = '0,00'; // var_dump('aqui'); } $valuePreco = strtr($valuePreco , $this->substituicao); $this->DadosId['id'] = $keyPreco; $this->DadosRegr['preco_resposta_negociacao'] = $valuePreco; date_default_timezone_set ("America/Sao_Paulo"); $this->DadosRegr['data_resposta_negociacao'] = date("Y-m-d H:i:s"); $this->DadosRegr['status_id'] = 7; //var_dump($this->DadosId); $upAltPreco = new \App\adms\Models\helper\AdmsUpdate(); $upAltPreco->exeUpdate("ct_cotacao", $this->DadosRegr, "WHERE id =:id", "id=" . $this->DadosId['id']); } } foreach ($this->Dados['observacao']as $keyObs => $valueObs) { foreach($valueObs as $keyObs => $valueObs){ if($valueObs == ''){ $valueObs = null; } $this->DadosId['id'] = $keyObs; if($valueObs == '9') { $this->DadosRegr['observacao'] = 'Não Cubro'; }else{ if($valueObs == '1') { $this->DadosRegr['observacao'] = 'Cubro Preço'; }else{ if($valueObs == '2') { $this->DadosRegr['observacao'] = 'Cubro com Verba'; $this->pegaCotado(); if($this->PrecoCotado[0]['preco_cotado'] > 0) { $this->DadosRegr['preco_resposta_negociacao'] = $this->PrecoCotado[0]['preco_cotado']; } } } } $upAltEmb = new \App\adms\Models\helper\AdmsUpdate(); $upAltEmb->exeUpdate("ct_cotacao", $this->DadosRegr, "WHERE id =:id", "id=" . $this->DadosId['id']); unset($this->DadosRegr['preco_resposta_negociacao']); } } if ($upAltPreco->getResultado()) { $this->enviaEmail(); $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Resposta Atualizada 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: Resposta NÂO ATUALIZADA ! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } private function pegaCotado(){ $listPrecoCotado = new \App\adms\Models\helper\AdmsRead(); $listPrecoCotado->fullRead("select preco_cotado from ct_cotacao where id = ". $this->DadosId['id'] ); $this->PrecoCotado = $listPrecoCotado->getResultado(); } private function enviaEmail() { //date_format(data, '%d/%m/%Y') data, repres_id, repr.email, repr.dusuario, repr.apelido, usu.apelido usu_apelido, usu.email usu_email, MASK(usu.celular, '(##) #####-####') usu_celular // var_dump($this->DadosUsuario); // foreach ($this->DadosUsuario as $email) { // extract($email); // if ($gre_forma_pagto_id == 2) { // $gerBol = new \App\gre\Models\GreGerarBoletoUnico(); // $gerBol->gerBol($docto); // } $prim_nome = utf8_decode('Olá, '.$this->DadosUsuario[0]['apelido'].'.'); //$prim_nome = utf8_decode('Olá, '.$apelido.'.'); $orig_nome = utf8_decode($this->DadosUsuario[0]['usu_apelido']); //var_dump($this->DadosUsuario); // die; $this->DadosEmail['orig_email'] = $this->DadosUsuario[0]['usu_email']; $this->DadosEmail['orig_nome'] = $orig_nome; $this->DadosEmail['dest_nome'] = $prim_nome; $this->DadosEmail['dest_email'] = $this->DadosUsuario[0]['email']; $this->DadosEmail['titulo_email'] = utf8_decode("RESPOSTA DE NEGOCIAÇÃO"); $this->DadosEmail['cont_email'] = $prim_nome."<br><br>"; $this->DadosEmail['cont_email'] .= utf8_decode($this->DadosUsuario[0]['usu_apelido'] ." enviou Resposta da Negociação solicitada, referente à cotação de ". $this->DadosUsuario[0]['data']."<br>"); $this->DadosEmail['cont_email'] .= utf8_decode("Dúvidas, "); $this->DadosEmail['cont_email'] .= utf8_decode(" entre em contato com <b>". $this->DadosUsuario[0]['usu_apelido'] . "</b> pelo telefone: <b>" . $this->DadosUsuario[0]['usu_celular'] . "</b><br><br> " ); $this->DadosEmail['cont_email'] .= utf8_decode("Atenciosamente.<br><br> "); $this->DadosEmail['cont_email'] .= utf8_decode("<b>".$this->DadosUsuario[0]['usu_apelido']."</b>"); $this->DadosEmail['cont_email'] .= utf8_decode("<br>e-mail enviado em: ").date("d-m-Y h:i:s"); $this->DadosEmail['cont_text_email'] = $this->DadosEmail['cont_email']; $emailPHPMailer = new \App\adms\Models\helper\AdmsPhpMailer(); $emailPHPMailer->emailPhpMailer($this->DadosEmail); // nao esta chamando essa function if ($emailPHPMailer->getResultado()) { // $atuEmail = new \App\gre\Models\GreAtualizaEnvioEmailFatura(); // $atuEmail->atuEmail($docto); $_SESSION['msg'] = "<div class='alert alert-success'>E-mails enviados com sucesso !</div>"; // $this->Resultado = true; } else { $_SESSION['msg'] = "<div class='alert alert-danger'>Erro: Erro ao enviar E-mails!</div>"; $this->Resultado = false; } return $this->Resultado; } //} }