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.
 
 
 
 
 
 

44 lines
1.3 KiB

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once("bd.php");
$id = $_GET["id"] ?? "0";
$numReg = 0;
$query = "select count(*) from pbx_eventos_agentes where id_motivo_pausa = $id";
$result = pg_query($dbcon, $query);
if ($result) {
// Verifica se existem usuário incluidos neste grupo
$row = @pg_fetch_row($result);
$numReg = $row[0];
if ($numReg == 0) {
$query = "begin";
$result = pg_query($dbcon, $query);
if ($result) {
$query = "delete from pbx_motivos_pausas where id = $id";
$result = pg_query($dbcon, $query);
}
if ($result) {
$query = "commit";
pg_query($dbcon, $query);
echo "OK; Registro excluido com sucesso!";
} else {
$query = "rollback";
pg_query($dbcon, $query);
echo "ERRO; Não é possível excluir este registro! Erro: " . pg_last_error();
}
} else {
echo "ERRO; Não é possível excluir o registro, o mesmo está sendo utilizado para auditorias! O registro será desativado.";
$query = "update pbx_motivos_pausas set flag = '0' where id = $id";
$result = pg_query($dbcon, $query);
}
}
?>