Ejemplo n.º 1
0
include_once INTERNAL_ROOT_PORTAL . '/cadastros/Usuario.class.php';
include_once INTERNAL_ROOT_PORTAL . '/medicao/ListagemRelacionamento.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once INTERNAL_ROOT_PORTAL . '/head.php';
$usuario = new Usuario();
$item = new ListagemRelacionamento();
$DAO = new ListagemRelacionamentoDao();
//Verifica se a opcao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'inserir') {
    $item->setIdPessoa($_POST['pessoa']);
    $item->setIdItem($_POST['item']);
    $item->setEmpresa($_POST['empresa']);
    $item->setUsuario(userId());
    //Verifica se o item foi preenchido
    if ($item->getIdPessoa() != null || $item->getIdItem() != null) {
        echo $item->getEmpresa();
        $retorno = $DAO->Gravar($item);
        if ($retorno == true) {
            echo '<script language= "JavaScript">alert("Registro cadastrado com sucesso");</script>';
            echo '<script language= "JavaScript">location.href="new.php";</script>';
        } else {
            echo '<script language= "JavaScript">alert("Erro ao cadastrar Registro");</script>';
        }
    } else {
        echo '<script language= "JavaScript">alert("Preenchas todos os campos.");</script>';
    }
}
?>

<style type="text/css">