if (!empty($_GET['cmd']) && $_GET['cmd'] == 'del') { $id = ValidateInteger(INPUT_GET, 'id'); $retorno = $DAO->DeletarArquivo($id); if ($retorno == 1) { echo '<script language= "JavaScript">alert("Documento removido com sucesso");</script>'; echo '<script language= "JavaScript">location.href="new.php?id=' . $_GET['id_lista'] . '";</script>'; } else { echo '<script language= "JavaScript">alert("Erro ao remover o registro.");</script>'; } } if (!empty($_GET['id'])) { $remessa->setId($_GET['id']); } //Verifica se a opcao de salvar foi iniciada if (!empty($_POST['cmd']) && $_POST['cmd'] == 'inserir') { $remessa->setTitulo($_POST['titulo']); $remessa->setGrupo($_POST['grupo']); $remessa->setId($_POST['id']); $remessa->setUsuario(userId()); $retorno = $remessa->getId(); if ($_FILES['file']['error'] != 4) { $name = $_FILES['file']['name']; $query = mysql_query("SELECT * FROM " . MYSQL_BASE_REMESSA_ARQUIVOS . " WHERE file = '" . $name . "' AND excluido IS NULL"); $num = mysql_num_rows($query); if ($num == 0) { if ($retorno == "") { $retorno = $DAO->CriarLista($remessa); } if ($retorno > 0) { $result = $DAO->CriarUpload($retorno, $remessa->getTitulo(), $_FILES['file'], $remessa->getGrupo()); if ($result == true) {
include_once '../../includes.sys/ini.php'; include_once '../../includes.sys/metodos.php'; include_once '../DAO/Doc_PendenteDAO.php'; include_once '../Doc_Pendente.class.php'; checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true'); include_once '../../head.php'; if (!in_array(172, listarAcesso())) { echo '<script language= "JavaScript">location.href="' . EXTERNAL_ROOT_PORTAL . '/modulos.php";</script>'; } $remessa = new Doc_Pendente(); $DAO = new Doc_PendenteDAO(); //Verifica se foi executado a acao de salvar if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') { $remessa->setId(limpaTexto($_POST['id'])); $remessa->setTitulo(limpaTexto($_POST['titulo'])); $remessa->setGrupo($_POST['grupo']); $remessa->setFile($_FILES['file']); //Verifica se o nome esta em branco if ($_FILES['file']['error'] != UPLOAD_ERR_NO_FILE) { if ($remessa->getTitulo() != "") { $retorno = $DAO->Atualizar($remessa, $_FILES['file']); if ($retorno == true) { echo '<script language= "JavaScript">alert("Documento alterada com sucesso");</script>'; echo '<script language= "JavaScript">location.href="index.php";</script>'; } else { $msg_erro .= "<br><strong>Erro ao gravar!/<strong>"; } } else { $msg_erro .= "<br><strong>Insisra um titulo!/<strong>"; }