forked from SimplesIP/pabx-app
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.
79 lines
2.1 KiB
79 lines
2.1 KiB
<?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ão para inserir |
|
* o registro |
|
*/ |
|
if ($formAction == FORM_UPDATE) { |
|
GetGpValues($dbcon); |
|
} else { |
|
if (trim($_POST["..."] == "")) { |
|
GetGpValues(null); |
|
$msgUser = "alert('O ... é campo de preenchimento obrigatório!');"; |
|
} else { |
|
//string para inserçã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ção não pode ser realizada!Erro: $erroBd');"; |
|
$msgErro = "A operação nã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["..."]; |
|
} |
|
|
|
?>
|
|
|