Ejemplo n.º 1
0
include_once '../../includes.sys/ini.php';
include_once INTERNAL_ROOT_PORTAL . '/includes.sys/metodos.php';
include_once INTERNAL_ROOT_PORTAL . '/ged/DAO/ListagemRelacionamentoDAO.php';
include_once INTERNAL_ROOT_PORTAL . '/ged/ListagemRelacionamento.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once INTERNAL_ROOT_PORTAL . '/head.php';
$ListagemRelacionamento = new ListagemRelacionamento();
$DAO = new ListagemRelacionamentoDao();
//Verifica se a opcao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') {
    $ListagemRelacionamento->setDescricao($_POST['descricao']);
    $ListagemRelacionamento->setArquivos($_POST['arquivos']);
    $ListagemRelacionamento->setId($_POST['id']);
    //Verifica se o descricao foi preenchido
    if ($ListagemRelacionamento->getDescricao() != null || $ListagemRelacionamento->getArquivos() != null) {
        $retorno = $DAO->Atualizar($ListagemRelacionamento);
        if ($retorno == true) {
            $retorno = $DAO->DesativarRelacionamento($ListagemRelacionamento);
            //Verifica se todos os itens foram desativados
            if ($retorno == true) {
                foreach ($ListagemRelacionamento->getArquivos() as $arquivo) {
                    $retorno = $DAO->GravarArquivos($arquivo, userId(), $ListagemRelacionamento->getId());
                    if ($retorno == false) {
                        break;
                    }
                }
                if ($retorno == false) {
                    echo '<script language= "JavaScript">alert("Erro ao cadastrar os documentos");</script>';
                } else {
                    echo '<script language= "JavaScript">alert("Registro alterado com sucesso");</script>';