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.
152 lines
7.9 KiB
152 lines
7.9 KiB
<?php |
|
$acao = isset($_GET['acao']) ? trim($_GET['acao']) : 'select'; |
|
$id = isset($_GET['id']) ? trim($_GET['id']) : 0; |
|
$filtro = isset($_GET["numRamal"]) ? trim($_GET["numRamal"]) : ''; |
|
$filtroNovo = !isset($_GET["pgn"]) ? '' : sprintf("&numRamal%s&pgn=%s&bloco=%s&pg=%s", $_GET["numRamal"], $_GET["pgn"], $_GET["bloco"], $_GET["pg"]); |
|
$recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquisa']); |
|
|
|
if ($acao == "deleta") { |
|
try { |
|
$id = $_GET["id"] ?? "0"; |
|
|
|
$inTran = 0; |
|
$result = pg_query($dbcon, 'begin'); |
|
if (!$result) { |
|
GeraExcept("Não foi posível iniciar a exclusão da \"Rota de Saida\"!"); |
|
} |
|
$inTran = 1; |
|
|
|
//apaga canais ligados as rotas de saida |
|
$query = "delete from pbx_rotas_saida_canais where id_rota ='$id'"; |
|
$result = pg_query($dbcon, $query); //gera arquivos e executa o |
|
if (!$result) { |
|
GeraExcept("Não foi posível excluir as referencias aos canais relacionados a \"Rota de Saida\"!"); |
|
} |
|
|
|
//apaga relacao entre rotas e ramais |
|
$query = "delete from pbx_rotas_saida_ramais where id_rota = '$id'"; |
|
$result = pg_query($dbcon, $query); |
|
if (!$result) { |
|
GeraExcept("Não foi posível excluir as referencias aos ramais relacionados a \"Rota de Saida\"!"); |
|
} |
|
|
|
$query = "delete from pbx_rotas_saida_modelos where id_rota = '$id'"; |
|
$result = pg_query($dbcon, $query); |
|
if (!$result) { |
|
GeraExcept("Não foi posível excluir os modelos relacionados a \"Rota de Saida\"!"); |
|
} |
|
|
|
$query = "delete from pbx_rotas_saida where id='$id'"; |
|
$result = pg_query($dbcon, $query); |
|
if (!$result) { |
|
GeraExcept("Não foi posível excluir a \"Rota de Saida\"!"); |
|
} |
|
|
|
//gera arquivos e executa o reload dos dados no asterisk |
|
gera_arquivos($dbcon, 'ROTAS_SAIDA'); |
|
GrvAudita($dbcon, $idProg, 'pbx_rotas_saida', 'DEL', array(), array('id' => $id), array('id' => 'ID')); |
|
|
|
$result = pg_query($dbcon, 'commit'); |
|
if (!$result) { |
|
GeraExcept("Não foi posível finalizar a exclusão da \"Rota de Saida\"!"); |
|
} |
|
|
|
PbxAlert("Rota excluida com sucesso!"); |
|
} catch (Exception $ex) { |
|
if ($inTran) { |
|
pg_query($dbcon, 'rollback'); |
|
} |
|
GravaLogForms($ex->getMessage(), 'DeletaRotaSaida'); |
|
PbxAlert("Erro ao excluir a Rota de Saida!"); |
|
} |
|
} |
|
|
|
$janW = '500'; |
|
$janH = '400'; |
|
|
|
$compl = ''; |
|
$pesquisa = ''; |
|
if (isset($_GET['pesquisa']) && $_GET['pesquisa']) { |
|
$compl = PreparaLike($filtro, true); |
|
$compl = sprintf("and (nome ilike %s)", $compl); |
|
$pesquisa = "&pesquisa=1"; |
|
} |
|
$query = "SELECT id, nome, portabilidade,tipo FROM pbx_rotas_saida where 1=1 $compl order by id asc"; |
|
$params = "&pbxRequest=1&numRamal=$filtro" . $pesquisa; |
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); |
|
$query .= " limit $regPagina offset $offSet"; |
|
$result = pg_query($dbcon, $query); |
|
|
|
?> |
|
|
|
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro"> |
|
<tr> |
|
<td colspan="2">Palavra Chave</td> |
|
</tr> |
|
<tr> |
|
<td align="left" nowrap="nowrap"> |
|
<input name="numRamal" type="text" id="numRamal" value="<?= $_GET["numRamal"]; ?>" onkeyup="ConsultaRamal('index.php?idProg=10018&pbxRequest=1', event);" size="20"> |
|
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10018&pbxRequest=1&pesquisa=1', 0);"> |
|
</td> |
|
<td align="right" nowrap="nowrap"> |
|
<a href="#" onclick="abre_janela('650', '585', 'index.php?idProg=11018&pbxRequest=1&acao=inseri<?= $filtroNovo; ?>', 'resizable=1, scrollbars=1');"><img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVA ROTA </a> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td colspan="2"> |
|
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2"> |
|
<tr> |
|
<th align="center">Id</th> |
|
<th align="left">Nome</th> |
|
<th align="left">Tipo</th> |
|
<th align="left">PNI*</th> |
|
<th align="center">Ações</th> |
|
</tr> |
|
<?php |
|
$z = 0; |
|
while ($dados = pg_fetch_array($result)) { ?> |
|
<tr> |
|
<td width="40" align="center"><?= $dados['id']; ?></td> |
|
<td align="left"><a href="#" style="color: #000;" title="Editar Rota: <?= $dados['nome']; ?>" onclick="abre_janela('650', '585', 'index.php?idProg=11018&pbxRequest=1&acao=edita&id=<?= $dados['id']; ?><?= $params; ?>', 'resizable=1 , scrollbars=1');"><?= $dados['nome']; ?></a></td> |
|
<td align="left"><?= ($dados['tipo'] == 'I') ? "INTERNO" : "EXTERNO"; ?></td> |
|
<td width="20" align="center"> <img src="<?= $dados['portabilidade'] ? "imgSite/button_ok16.png" : "imgSite/fecha16.png"; ?>" title="<?= $dados['portabilidade'] ? "Plano de Numeração Interna Ativo!" : "Plano de Numeração Interna Inativo!"; ?>" width="16" height="16" border="0"></td> |
|
<td width="40"> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
|
<tr style="border:0"> |
|
<td style="border:0"> |
|
<div align="center"><a href="#" title="Editar Rota: <?= $dados['nome']; ?>" onclick="abre_janela('650', '585', 'index.php?idProg=11018&pbxRequest=1&acao=edita&id=<?= $dados['id']; ?><?= $params; ?>', 'resizable=1 , scrollbars=1');"><img src="images/edit.gif" alt="EDITAR A ROTA:<?= $dados['nome']; ?>" width="16" height="16" border="0"></a></div> |
|
</td> |
|
<td style="border:0"> |
|
<div align="center"><a href="#" title="Excluir Rota: <?= $dados['nome']; ?>" id="<?= $dados['id']; ?>" nome="<?= $dados['nome']; ?>" onclick="excluir('<?= $dados['id']; ?>', '<?= $dados['nome']; ?>', 'DESEJA REALMENTE EXLUIR A ROTA DE SAÍDA:<?= $dados['nome']; ?>', 'index.php?idProg=10018&pbxRequest=1&acao=deleta&id=<?= $dados['id']; ?><?= $params; ?>', 'ROTAS');"><img src="images/delete.gif" alt="APAGAR O TRONCO:<?= $dados['usuario']; ?>" width="16" height="16" border="0"></a></div> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<?php $z++; ?> |
|
<?php } ?> |
|
<?php if ($z == 0) { ?> |
|
<tr align="center" valign="middle" bordercolor="#999999" class="labels"> |
|
<td colspan="8"> |
|
<div align="center" class="info"><img src="images/shutdown.gif" width="24" height="24" border="0" align="absmiddle" /> Não foram encontrados registros </div> |
|
</td> |
|
</tr> |
|
<?php } ?> |
|
<tr> |
|
<th align="center" colspan="8"> |
|
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2"> |
|
<tr> |
|
<th align="center" style="width: 90%; border:0;"><?= $links; ?></th> |
|
<th align="right" style="width: 10%; border:0;"><?= sprintf("%s/%s", $pagMostra, $totalReg); ?></th> |
|
</tr> |
|
</table> |
|
</th> |
|
</tr> |
|
</table> |
|
*PNI - Plano de numeração interna. |
|
</td> |
|
</tr> |
|
</table> |
|
</body> |
|
|
|
</html>
|