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.
50 lines
1.3 KiB
50 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; |
|
|
|
/* |
|
* Verifica se exite registro para delecao |
|
*/ |
|
$query = "select * from pbx_..._ where ... = $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_... where ... = $id"; |
|
$result = pg_query($dbcon, $query); |
|
|
|
if ($result) { |
|
$query = "delete from pbx_... where gp_... = $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 este registro, o mesmo já foi utilizada na movimentação!"; |
|
} |
|
} |
|
?>
|
|
|