You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$tpLayout = -1;
|
|
|
|
|
/*
|
|
|
|
|
* RECEBE VALORES!
|
|
|
|
|
*/
|
|
|
|
|
$nome = strtoupper(trim($_REQUEST['nome']));
|
|
|
|
|
$id = $_REQUEST['id'];
|
|
|
|
|
$acao = $id ? 'update' : 'insert';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsPostBack()) {
|
|
|
|
|
try {
|
|
|
|
|
if (!$nome) {
|
|
|
|
|
GeraExcept('Informe um nome para a "Regional"');
|
|
|
|
|
}
|
|
|
|
|
if (ExisteRegistro($dbcon, 'vds_grupos', 'grp_nome', $nome)) {
|
|
|
|
|
GeraExcept('Esta "Regional" j<EFBFBD> esta cadastrada!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query = $acao == 'update' ? sprintf("update vds_grupos set grp_nome = %s where grp_id = %s", QuotedStr($nome), QuotedStr($id)) : sprintf("insert into vds_grupos (grp_nome) VALUES (%s)", QuotedStr($nome));
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
GeraExcept('Erro ao inserir registro!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$jsStartup[] = sprintf("alert('Registro %s com sucesso!'); window.opener.ResetForm(); window.close();", $acao == 'update' ? 'alterado' : 'inserido');
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
$jsStartup[] = sprintf("alert('%s');", $ex->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->assign('id', $id);
|
|
|
|
|
$smarty->assign('nome', $nome);
|
|
|
|
|
$smarty->display("vendas/grupoVendasCad.tpl");
|
|
|
|
|
?>
|