$imgNovo = "<ahref=\"javaScript:NovaJanela('index.php?idProg=186&pl_id=0','pesquisaCadLiberacao','$janW','$janH','resizable=NO,scrollbars=YES');\">$imgNovo Nova Libera<EFBFBD><EFBFBD>o</a>";
if ($isDelete) {
try {
/*
* Verifica se j<EFBFBD> existe movimenta<EFBFBD><EFBFBD>es para a pesquisa.
*/
$nomePesquisa = $_GET["pl_descricao"];
$query = "select (case when(exists(select '' from pbx_pesquisa_movimento where pl_id = '$isDelete'))then 1 else 0 end) as pp_bloqueado ";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel verificar a pesquisa: $nomePesquisa!");
}
$dados = pg_fetch_array($result);
$deleta = $dados["pp_bloqueado"];
if ($deleta) {
GeraExcept("N<EFBFBD>o <EFBFBD> poss<EFBFBD>vel excluir a libera<EFBFBD><EFBFBD>o para a pesquisa: $nomePesquisa! J<EFBFBD> existe movimenta<EFBFBD><EFBFBD>o para a mesma.");
}
$query = "begin";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel iniciar a exclus<EFBFBD>o da libera<EFBFBD><EFBFBD>o: $nomePesquisa!");
}
$query = "delete from pbx_pesquisa_liberacao_dacs where pl_id = '$isDelete'";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel deletar a liberacao: $nomePesquisa! Erro ao remover DACS.");
}
$query = "delete from pbx_pesquisa_liberacao where pl_id = '$isDelete'";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel deletar a libera<EFBFBD><EFBFBD>o: $nomePesquisa! Erro ao remover libera<EFBFBD><EFBFBD>o.");
}
$query = "commit";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel deletar a libera<EFBFBD><EFBFBD>o: $nomePesquisa! Erro ao gravar opera<EFBFBD><EFBFBD>o no banco de dados.");
}
Alert("Remo<EFBFBD><EFBFBD>o concluida com sucesso!");