public function addCategoria(BannerCategoria $bC) { if ($bC->getId() != '' && $this->getId() != '') { $con = BDConexao::__Abrir(); $con->executar("INSERT INTO " . Sistema::$BDPrefixo . "relacionamento_banners_categorias(banner, categoria) VALUES('" . $this->getId() . "','" . $bC->getId() . "')"); } }
public function deletar(BannerCategoria $t) { if ($t->getBanners()->getTotal() > 0) { throw new Exception("Está categoria possui banners cadastrados, não foi possível removê-la!"); } else { parent::deletar($t); $where = "WHERE " . self::ID . " = '" . $t->getId() . "'"; $this->con->deletar(Sistema::$BDPrefixo . $this->tabela, $where); } }
<?php header('Content-type: application/json; charset=iso-8859-1', true); require_once '../../lib/php/conn.php'; require_once '../../models/BannerCategoria.php'; $data = new BannerCategoria(); foreach ($_REQUEST as $key => $value) { if (!is_array($value)) { $_REQUEST[$key] = utf8_decode($value); } elseif (is_array($value)) { foreach ($value as $key2 => $value2) { $_REQUEST[$key][$key2] = utf8_decode($value2); } } } if ($_REQUEST['acao'] == 1 && $_REQUEST['operacao'] == 2) { if ($data->add()) { echo json_encode(array('success' => 1)); } else { echo json_encode(array('success' => 0)); } } elseif ($_REQUEST['acao'] == 2 && $_REQUEST['operacao'] == 2) { if ($data->edit()) { echo json_encode(array('success' => 1)); } else { echo json_encode(array('success' => 0)); } } elseif ($_REQUEST['acao'] == 3 && $_REQUEST['operacao'] == 2) { if ($data->delete()) { echo json_encode(array('success' => 1)); } else {
$tituloPagina = 'Utilidades > Publicidades > Banners > Categorias > Cadastrar'; $iTPC = new IFAdmin(new Arquivos(Sistema::$adminLayoutCaminhoDiretorio . "/SistemaUtilidades/bannerCategoria.html")); $lI = new ListaIdiomas(); if (!empty($_POST)) { $erro = ''; if (empty($_POST['titulo'])) { $erro = "<b>Titulo</b> não preenchido!<br><br>"; } if (empty($_POST['largura'])) { $erro = "<b>Largura</b> não preenchido!<br><br>"; } if (empty($_POST['altura'])) { $erro = "<b>Altura</b> não preenchido!<br><br>"; } if (empty($erro)) { $bC = new BannerCategoria(); $bC->titulo = $_POST['titulo']; $bC->setLargura($_POST['largura']); $bC->setAltura($_POST['altura']); $lB = new ListaBannerCategorias(); $lB->inserir($bC); while ($i = $lI->listar()) { $t = new Traducao(); $t->setIdConteudo($bC->getId()); $t->setCampoConteudo(ListaBannerCategorias::TITULO); $t->setTabelaConteudo($lB->getTabela()); $t->conteudo = $bC->titulo; $t->traducao = $_POST['ititulo'][$i->getId()]; $i->addTraducao($t); } $lI->resetCondicoes();