|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
//define o label do botao
|
|
|
|
|
$acaoUser = 'Incluir';
|
|
|
|
|
|
|
|
|
|
// Define mensagem para o usuario
|
|
|
|
|
$msgUser = "";
|
|
|
|
|
|
|
|
|
|
// Define mensagens de erro
|
|
|
|
|
$msgErro = "";
|
|
|
|
|
|
|
|
|
|
$setFocus = "document.getElementById('...').focus();";
|
|
|
|
|
$jsStartup[] = $setFocus;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se o usuario pressionou o bot<EFBFBD>o para inserir
|
|
|
|
|
* o registro
|
|
|
|
|
*/
|
|
|
|
|
if ($formAction == FORM_NEW) {
|
|
|
|
|
LimpaGpVar();
|
|
|
|
|
} else {
|
|
|
|
|
if (trim($_POST["..."] == "")) {
|
|
|
|
|
GetGpValues();
|
|
|
|
|
$msgUser = "alert('O nome do ... <EFBFBD> campo de preenchimento obrigat<EFBFBD>rio!');";
|
|
|
|
|
} else {
|
|
|
|
|
//string para inser<EFBFBD><EFBFBD>o do registro
|
|
|
|
|
$query = "insert into pbx_...(..., ...)
|
|
|
|
|
values(%s, %s)";
|
|
|
|
|
|
|
|
|
|
GetGpValues();
|
|
|
|
|
|
|
|
|
|
// Inicia uma transa<EFBFBD><EFBFBD>o no banco de dados
|
|
|
|
|
$result = pg_query($dbcon, "begin");
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
//Prepara a query para inserir o registro no banco
|
|
|
|
|
$query = sprintf($query, QuotedStr($gp_nome), QuotedStr($gp_status));
|
|
|
|
|
|
|
|
|
|
//Executa a query no banco
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if ($result)
|
|
|
|
|
$result = pg_query($dbcon, "commit");
|
|
|
|
|
}
|
|
|
|
|
if ($result) {
|
|
|
|
|
$acaoUser = 'Incluir';
|
|
|
|
|
$msgUser = "alert('Registro incluido com sucesso');";
|
|
|
|
|
LimpaGpVar();
|
|
|
|
|
} else {
|
|
|
|
|
$erroBd = @pg_last_error($dbcon);
|
|
|
|
|
pg_query($dbcon, "rollback");
|
|
|
|
|
$acaoUser = 'Incluir';
|
|
|
|
|
$msgUser = "alert('A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada!Erro: $erroBd');";
|
|
|
|
|
$msgErro = "A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada!Erro: $erroBd";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($msgUser))
|
|
|
|
|
$jsStartup[] = $msgUser;
|
|
|
|
|
|
|
|
|
|
$smarty->assign("...", $gp_id);
|
|
|
|
|
$smarty->assign("...", $gp_nome);
|
|
|
|
|
$smarty->assign("...", $gp_status);
|
|
|
|
|
$smarty->assign("acaoUser", $acaoUser);
|
|
|
|
|
$smarty->assign("formAction", FORM_INSERT);
|
|
|
|
|
$smarty->assign("erro", $msgErro);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetTemplate($smarty, '...');
|
|
|
|
|
|
|
|
|
|
function LimpaGpVar() {
|
|
|
|
|
$GLOBALS["..."] = "";
|
|
|
|
|
$GLOBALS["..."] = 1;
|
|
|
|
|
$GLOBALS["..."] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetGpValues() {
|
|
|
|
|
$GLOBALS["..."] = $_POST["..."];
|
|
|
|
|
$GLOBALS["..."] = $_POST["..."];
|
|
|
|
|
$GLOBALS["..."] = $_POST["..."];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|