PABX da Simples IP
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.

117 lines
6.7 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']);
$janW = '500';
$janH = '440';
if ($acao == "deleta") {
$query = "delete from pbx_contextos_canais where id_contexto='$id'";
pg_query($dbcon, $query);
$query = "delete from pbx_contextos_modelos where id_contexto='$id'";
pg_query($dbcon, $query);
$query = "delete from pbx_contextos_opcoes where id_contexto='$id'";
pg_query($dbcon, $query);
$query = "delete from pbx_contextos where id='$id'";
pg_query($dbcon, $query); //gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'CONTEXTOS');
}
$compl = '';
if (isset($_GET['pesquisa']) && $_GET['pesquisa']) {
$compl = PreparaLike($filtro, true);
$compl = sprintf("and (a.nome ilike %s)", $compl);
}
$query = "SELECT id, nome, direcao_chamada FROM pbx_contextos a where 1=1 $compl order by id asc";
$params = "&pbxRequest=1&numRamal=$filtro";
$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=10027&pbxRequest=1', event);" size="20">
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10027&pbxRequest=1&pesquisa=1', 0);">
</td>
<td align="right" nowrap="nowrap">
<a href="#" onClick="abre_janela('540', '540', 'index.php?idProg=11027&pbxRequest=1&acao=inseri<?= $filtroNovo; ?>');"><img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle" />NOVO CONTEXTO </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>Nome </th>
<th align="center">Tipo</th>
<th align="center"> <span title="N<EFBFBD>mero de Depnd<EFBFBD>ncias">Dep</span></th>
<th align="center">A<EFBFBD><EFBFBD>es</th>
</tr>
<?php $z = 0; ?>
<?php while ($dados = pg_fetch_array($result)) {
$totaldep = GetTotalDependencias('contextos', $dados['nome']);
$opcao = 'contextos';
$acao = $dados['nome'];
$recursoTipo = 'Contexto';
$nomeRecurso = $dados['nome'];
$dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep);
?>
<tr>
<td width="50" align="center"><?= $dados['id']; ?></td>
<td><a href="#" style="color: #000;" onClick="abre_janela('540', '540', 'index.php?idProg=11027&pbxRequest=1&acao=edita&id=<?= $dados['id']; ?><?= $params; ?>');"><?= $dados['nome']; ?></td>
<td width="60" align="center"><?= $dados['direcao_chamada'] == 'E' ? 'Entrada' : 'Sa<EFBFBD>da'; ?></td>
<td width="30" align="center"><?= $dep; ?></td>
<td width="40">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td style="border:0">
<div align="center"><a href="#" onClick="abre_janela('540', '540', 'index.php?idProg=11027&pbxRequest=1&acao=edita&id=<?= $dados['id']; ?><?= $params; ?>');"><img src="images/edit.gif" alt="EDITAR A EMPRESA:<?= $dados['descricao']; ?>" width="16" height="16" border="0"></a></div>
</td>
<?php if (!$totaldep) { ?>
<td style="border:0">
<div align="center"><a href="#" onClick="excluir('<?= $dados['id']; ?>', '<?= $dados['nome']; ?>', 'DESEJA REALMENTE EXLUIR O CONTEXTO:<?= $dados['nome']; ?>', 'index.php?idProg=10027&pbxRequest=1&acao=deleta&id=<?= $dados['id']; ?><?= $params; ?>', 'CONTEXTO');"><img src="images/delete.gif" alt="APAGAR A EMPRESA:<?= $dados['descricao']; ?>" width="16" height="16" border="0" onClick="pergunta_apaga('<?= $dados['id']; ?>', '<?= $dados['descricao']; ?>');"></a></div>
</td>
<?php } else { ?>
<td style="border:0" width="33%">
<div align="center"><img src="images/delete.gif" title="Este registro possui depend<EFBFBD>ncias n<EFBFBD>o pode ser apagado!" alt="Este registro n<EFBFBD>o pode ser apagado!" width="16" height="16" border="0"></div>
</td>
<?php } ?>
</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<EFBFBD>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>
</td>
</tr>
</table>
</body>
</html>