|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
//define o label do botao
|
|
|
|
|
$acaoUser = 'Gravar';
|
|
|
|
|
|
|
|
|
|
// 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_UPDATE) {
|
|
|
|
|
GetGpValues($dbcon);
|
|
|
|
|
} else {
|
|
|
|
|
if (trim($_POST["..."] == "")) {
|
|
|
|
|
GetGpValues(null);
|
|
|
|
|
$msgUser = "alert('O ... <EFBFBD> campo de preenchimento obrigat<EFBFBD>rio!');";
|
|
|
|
|
} else {
|
|
|
|
|
//string para inser<EFBFBD><EFBFBD>o do registro
|
|
|
|
|
$query = "update pbx_... set ... = %s, ... = %s where ... = %d";
|
|
|
|
|
|
|
|
|
|
GetGpValues();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Prepara a query para inserir o registro no banco
|
|
|
|
|
$query = sprintf($query, QuotedStr($_1), QuotedStr($_2), $gp_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Executa a query no banco
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
GetGpValues();
|
|
|
|
|
$msgUser = "alert('Registro alterado com sucesso');";
|
|
|
|
|
$jsStartup[] = "window.opener.ResetForm();";
|
|
|
|
|
} else {
|
|
|
|
|
$erroBd = @pg_last_error($dbcon);
|
|
|
|
|
$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("...", ...);
|
|
|
|
|
// $smarty->assign("...", ...);
|
|
|
|
|
// $smarty->assign("...", ...);
|
|
|
|
|
// $smarty->assign("acaoUser", $acaoUser);
|
|
|
|
|
$smarty->assign("formAction", FORM_SAVE);
|
|
|
|
|
$smarty->assign("erro", $msgErro);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetTemplate($smarty, '...');
|
|
|
|
|
|
|
|
|
|
function GetGpValues($db) {
|
|
|
|
|
if (!empty($db)) {
|
|
|
|
|
$id = $_GET["..."];
|
|
|
|
|
$query = "select ... from pbx_... where ... = $id";
|
|
|
|
|
$result = pg_query($db, $query);
|
|
|
|
|
if ($result)
|
|
|
|
|
$row = pg_fetch_array($result, $row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$GLOBALS["..."] = empty($db) ? $_POST["..."] : $row["..."];
|
|
|
|
|
$GLOBALS["..."] = empty($db) ? ($_POST["..."] ? 1 : 0) : $row["..."];
|
|
|
|
|
$GLOBALS["..."] = empty($db) ? $_POST["..."] : $row["..."];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|