D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreApagarContr.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsApagarContr * * @copyright (c) year, Carlos Marques - CM */ class GreApagarContr { private $DadosId; private $Resultado; private $Dados; private $DadosContrInferior; function getResultado() { return $this->Resultado; } public function apagarContr($DadosId = null) { $this->DadosId = filter_input_array(INPUT_GET, FILTER_DEFAULT); $this->verfContr(); if ($this->Resultado) { $this->verfResid(); if ($this->Resultado) { $apagarContr = new \App\adms\Models\helper\AdmsDelete(); $apagarContr->exeDelete("gre_contratante", "WHERE id =:id", "id={$this->DadosId['id']}"); if ($apagarContr->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Contratante apagado com sucesso! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; } else { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Erro: Contratante não foi apagado! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } } } private function verfContr() { $verContr = new \App\adms\Models\helper\AdmsRead(); $verContr->fullRead("SELECT id FROM gre_contratante WHERE id=:id and adms_sit_id <> 3 LIMIT :limit", "id=" . $this->DadosId['id'] . "&limit=2"); if ($verContr->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Erro: O Contratante não pode ser apagado, Situação diferente de ANÁLISE! <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 verfResid() { $verResid = new \App\adms\Models\helper\AdmsRead(); $verResid->fullRead("SELECT id FROM gre_residente WHERE gre_contratante_id = :id LIMIT :limit", "id=" . $this->DadosId['id'] . "&limit=1"); if (empty($verResid->getResultado())) { $this->Resultado = true; } else { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Erro: O Contratante não pode ser apagado, Existe(m) Residente(s) para ele! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } }