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.
 
 
 
 
 
 

84 lines
2.2 KiB

<?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ão para inserir
* o registro
*/
if ($formAction == FORM_NEW) {
LimpaGpVar();
} else {
if (trim($_POST["..."] == "")) {
GetGpValues();
$msgUser = "alert('O nome do ... é campo de preenchimento obrigatório!');";
} else {
//string para inserção do registro
$query = "insert into pbx_...(..., ...)
values(%s, %s)";
GetGpValues();
// Inicia uma transaçã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çã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("...", $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["..."];
}
?>