Ejemplo n.º 1
0
include_once '../../includes.sys/metodos.php';
include_once '../DAO/TipoDocumentoDAO.php';
include_once '../TipoDocumento.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once '../../head.php';
$acesso = listarAcesso();
if (!in_array(133, $acesso)) {
    echo '<script language= "JavaScript">location.href="' . EXTERNAL_ROOT_PORTAL . '/projeto/documentos/fase_projeto.php";</script>';
}
$DAO = new TipoDocumentoDAO();
$tipoDocumento = new TipoDocumento();
//Verifica se foi executado a acao de salvar
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') {
    $tipoDocumento->setNome(limpaTexto($_POST['nome']));
    $tipoDocumento->setCodigo(limpaTexto($_POST['codigo']));
    $tipoDocumento->setId(limpaTexto($_POST['id']));
    if (!preg_match("/[0-9]/", $tipoDocumento->getCodigo())) {
        //Verifica se o nome esta em branco
        if ($tipoDocumento->getNome() != "" && $tipoDocumento->getCodigo() != "") {
            $retorno = $DAO->Atualizar($tipoDocumento);
            if ($retorno == true) {
                echo '<script language= "JavaScript">alert("Registro alterado com sucesso");</script>';
                echo '<script language= "JavaScript">location.href="index.php";</script>';
            } else {
                echo $retorno;
            }
        }
    } else {
        $msg = utf8_encode("O Código deve ser alfabético");
        echo '<script language= "JavaScript">alert("' . $msg . '");</script>';
    }