Example #1
0
<?php

include_once '../../includes.sys/ini.php';
include_once '../../includes.sys/metodos.php';
include_once '../DAO/FuncionalidadeDAO.php';
include_once '../Funcionalidade.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once '../../head.php';
$funcionalidade = new Funcionalidade();
$DAO = new FuncionalidadeDAO();
$funcionalidade->setId(limpaTexto($_GET['id']));
// Verifica se a opcao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') {
    // Verifica se o campo nome foi digitado
    if (!empty($_POST['nome'])) {
        $funcionalidade->setNome(limpaTexto($_POST['nome']));
        $funcionalidade->setUsuario(userId());
        $retorno = $DAO->Atualizar($funcionalidade);
        if ($retorno == true) {
            echo '<script language= "JavaScript">alert("Funcionalidade alterada com sucesso");</script>';
            echo '<script language= "JavaScript">location.href="index.php";</script>';
        } else {
            print_r($retorno);
        }
    }
} else {
    $retorno = $DAO->Listar("SELECT * FROM " . MYSQL_BASE_FUNCIONALIDADES . " WHERE ativo='S' AND id=" . $funcionalidade->getId());
    if ($retorno) {
        foreach ($retorno as $item) {
            $funcionalidade->setNome($item['nome']);
        }
 /**
  * method Delete()
  * Delete a record
  */
 function Delete($param)
 {
     try {
         // get the parameter $key
         $key = $param['key'];
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         // instantiates object Funcionalidade
         $object = new Funcionalidade($key);
         // deletes the object from the database
         $object->delete();
         // close the transaction
         TTransaction::close();
         // reload the listing
         $this->onReload($param);
         // shows the success message
         new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted'));
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
Example #3
0
<?php

include_once '../../includes.sys/ini.php';
include_once '../../includes.sys/metodos.php';
include_once '../DAO/FuncionalidadeDAO.php';
include_once '../Funcionalidade.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once '../../head.php';
$funcionalidade = new Funcionalidade();
$DAO = new FuncionalidadeDAO();
// Verifica se a opcao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'inserir') {
    // Verifica se o campo nome foi digitado
    if (!empty($_POST['nome'])) {
        $funcionalidade->setNome(limpaTexto($_POST['nome']));
        $funcionalidade->setUsuario(userId());
        $retorno = $DAO->Gravar($funcionalidade);
        if ($retorno == true) {
            echo '<script language= "JavaScript">alert("Funcionalidade cadastrada com sucesso");</script>';
            echo '<script language= "JavaScript">location.href="new.php";</script>';
        } else {
            print_r($retorno);
        }
    }
}
?>
<!-- topbar ends -->
<div class="container-fluid">
	<div class="row-fluid">

		<!-- left menu starts -->