D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
idoso
/
adm
/
app
/
gre
/
Models
/
Filename :
GreApagarUnidade.php
back
Copy
<?php namespace App\gre\Models; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsApagarUnidade * * @copyright (c) year, Carlos Marques - CM */ class GreApagarUnidade { private $DadosId; private $Resultado; private $Dados; function getResultado() { return $this->Resultado; } public function apagarUnid($DadosId = null) { $this->DadosId = (int) $DadosId; $this->verEstrutura(); if ($this->Resultado) { $apagarUnid = new \App\adms\Models\helper\AdmsDelete(); $apagarUnid->exeDelete("gre_unidade", "WHERE id =:id", "id={$this->DadosId}"); if ($apagarUnid->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-success' role='alert'> Unidade excluida 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: Unidade não foi excluida! <button type='button' class='close' data-dismiss='alert' aria-label='Close'> <span aria-hidden='true'>×</span></button> </div>"; $this->Resultado = false; } } } private function verEstrutura() { $verUnid = new \App\adms\Models\helper\AdmsRead(); $verUnid->fullRead("SELECT id FROM gre_estrutura WHERE gre_unidade_id= :unid_id LIMIT :limit", "unid_id=" . $this->DadosId . "&limit=1"); if ($verUnid->getResultado()) { $_SESSION['msg'] = "<div class='alert alert-danger' role='alert'> Erro: Unidade não pode ser apagada, existe Estrutura nessa Unidade! <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; } } }