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.
250 lines
14 KiB
250 lines
14 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") { |
|
$id = $_GET["id"] ?? "0"; |
|
|
|
$query = "SELECT * FROM pbx_sip_ramais where id=$id"; |
|
$result = pg_query($dbcon, $query); |
|
$dados = pg_fetch_array($result); |
|
$ramal = $dados['nome']; |
|
|
|
|
|
|
|
//Apaga a relacao entre rotas e ramais |
|
$query = "delete from pbx_rotas_saida_ramais where ramal = '$ramal'"; |
|
pg_query($dbcon, $query); |
|
|
|
//Apaga ch secretaria |
|
$query = "delete from pbx_chefe_secretaria where numero = '$ramal'"; |
|
pg_query($dbcon, $query); |
|
|
|
//Relação de restrição a audios cadastrada na interface de grupo de usuarios |
|
$query = "delete from pbx_grupo_audio_ramal where nome = '$ramal' "; |
|
pg_query($dbcon, $query); |
|
|
|
//Remove ramais da agenda |
|
$query = "delete from rma_depto_ramais where nome = '$ramal' "; |
|
pg_query($dbcon, $query); |
|
|
|
|
|
$query = "delete from pbx_sip_ramais where id='$id'"; |
|
pg_query($dbcon, $query); |
|
GrvAudita($dbcon, $idProg, 'pbx_sip_ramais', 'DEL', array(), array('id' => $id), array('id' => 'ID'), array('id'), true); |
|
|
|
$query = "delete from pbx_voicemail_usuarios where numero_ramal ='$ramal'"; |
|
pg_query($dbcon, $query); |
|
|
|
Ajusta_ramais($ramal, $dbcon, false, false); |
|
Ajusta_tabelas('ramal', $ramal, $dbcon); |
|
|
|
} |
|
?> |
|
|
|
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro"> |
|
<tr> |
|
<td colspan="2">Ramal/Bina</td> |
|
</tr> |
|
<tr> |
|
<td align="left" nowrap="nowrap" > |
|
<input name="numRamal" type="text" id="numRamal" value="<?php echo $_GET["numRamal"]; ?>" onkeyup="ConsultaRamal('index.php?idProg=10009&pbxRequest=1', event);" size="20"> |
|
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10009&pbxRequest=1&pesquisa=1', 0);"> |
|
</td> |
|
<td align="right" nowrap="nowrap" > |
|
<a href="#" onclick="NovaJanela('index.php?idProg=11009&pbxRequest=1&acao=inseri<?php echo $filtroNovo; ?>', 'CadRamalSip', '850', '700', 'resizable=YES,scrollbars=YES');"><img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle" />NOVO RAMAL SIP </a> |
|
<a href="#" onclick="abre_janela('500', '410', 'index.php?idProg=11109&pbxRequest=1');"><img src="images/global.gif" width="20" height="20" border="0" align="absmiddle" />CONFIGURAÇÃO GLOBAL </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"> Ramal</th> |
|
<th align="left"> Bina</th> |
|
<th align="left"> Contexto </th> |
|
<th align="left"> Dispositivo</th> |
|
<th align="right">Saldo Pré-pago</th> |
|
<th align="center">Pré-pago</th> |
|
<th align="center"> <span title="Número de Dependências">Dep</span></th> |
|
<th align="center">Ações</th> |
|
</tr> |
|
<?php |
|
$janW = '500'; |
|
$janH = '400'; |
|
|
|
$tpParcial = 0; |
|
if (strpos($filtro, ',')) { |
|
$tpParcial = 1; |
|
} else if (strpos($filtro, '-')) { |
|
$sql = "select count(*) from pbx_sip_ramais where callerid ilike '%$filtro%'"; |
|
$result = pg_query($dbcon, $sql); |
|
$param = pg_fetch_row($result); |
|
if ($param[0] > 0) { |
|
$tpParcial = 0; |
|
} else { |
|
$tpParcial = 2; |
|
} |
|
} |
|
|
|
if ((!empty($filtro)) && ($tpParcial == 0)) { |
|
$compl = " where (nome ilike '%$filtro%' or callerid ilike '%$filtro%')"; |
|
} else if ((!empty($filtro)) && ($tpParcial == 1)) { |
|
$params = explode(",", $filtro); |
|
$compl = ""; |
|
foreach ($params as $param) { |
|
//$param = trim(str_replace("'", "", $param)); |
|
$dado .= empty($dado) ? "'$param'" : ",'$param'"; |
|
} |
|
|
|
$compl = " where (nome in($dado) or callerid in($dado))"; |
|
} else if ((!empty($filtro)) && ($tpParcial == 2)) { |
|
$params = explode("-", $filtro); |
|
$compl = ""; |
|
$ini = $params[0]; |
|
$fim = $params[1]; |
|
$qtd1 = strlen($ini) - strlen(ltrim($ini, "0")); |
|
$qtd2 = strlen($fim) - strlen(ltrim($fim, "0")); |
|
if ($qtd1 >= 1) { |
|
$ini1 = '-' . $qtd1; |
|
} else { |
|
$ini1 = $ini; |
|
} |
|
if ($qtd2 >= 1) { |
|
$fim1 = '-' . $qtd2; |
|
} else { |
|
$fim1 = $fim; |
|
} |
|
|
|
$compl = " where nome between '$ini' and '$fim' |
|
and ramal between '$ini1' and '$fim1'"; |
|
} else { |
|
$compl = ""; |
|
} |
|
|
|
$query = "drop table if exists ramal_sip; |
|
create temporary table ramal_sip |
|
( |
|
id integer, |
|
nome character varying(100), |
|
context character varying(100), |
|
dispositivo character varying(250), |
|
saldo_prepago numeric(12,4), |
|
habilita_prepago integer, |
|
callerid character varying(100), |
|
ramal bigint |
|
); |
|
|
|
insert into ramal_sip (id,nome, context,dispositivo, saldo_prepago, habilita_prepago,callerid,ramal) |
|
SELECT id,nome, context,dispositivo, saldo_prepago, habilita_prepago,callerid, |
|
cast(case |
|
when (length(nome) - length(ltrim(nome,'0'))) >= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::bigint--||nome |
|
else nome |
|
end as bigint) |
|
FROM pbx_sip_ramais; |
|
|
|
select * from ramal_sip $compl order by ramal asc,nome 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); |
|
$z = 0; |
|
while ($dados = pg_fetch_array($result)) { |
|
$totaldep = GetTotalDependencias('ramal', $dados['nome']); |
|
$opcao = 'ramal'; |
|
$acao = $dados['nome']; |
|
$recursoTipo = 'Ramal'; |
|
$nomeRecurso = $dados['nome']; |
|
$dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep); |
|
?> |
|
<tr> |
|
<td width="50" align="center"><div><?php echo $dados['id']; ?></div></td> |
|
<td align="left"><a href="" style="color:#000" onclick="abre_janela('1024', '700', 'index.php?idProg=11009&pbxRequest=1&acao=edita&id=<?php echo $dados['id']; ?><?php echo $params; ?>');"><?php echo $dados['nome']; ?></a></td> |
|
<td align="left"><?php echo $dados['callerid']; ?></td> |
|
<td align="left"><?php echo $dados['context']; ?></td> |
|
<td align="left"> <?php echo $dados['dispositivo']; ?></td> |
|
<td align="right"><?php echo FormataValor($dados['saldo_prepago']); ?></td> |
|
<td width="20" align="center"><?php |
|
$imgPre = $dados['habilita_prepago'] ? '<img src="images/button_ok16.png" alt="Habilitado!" width="16" height="16" border="0">' : '<img src="images/fecha16.png" alt="Desabilitado!" width="16" height="16" border="0">'; |
|
echo $imgPre; |
|
?></td> |
|
<td width="30" align="center"><?php echo $dep; ?></td> |
|
<td width="40"> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center" style="border-color:#FFFFFF "> |
|
<tr> |
|
<td width="20" style="border:0"><div align="center"><a href="#" title="Editar Ramal: <?php echo $dados['nome']; ?>" onclick="abre_janela('850', '700', 'index.php?idProg=11009&pbxRequest=1&acao=edita&id=<?php echo $dados['id']; ?><?php echo $params; ?>');"><img src="images/edit.gif" alt="EDITAR O RAMAL:<?php echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td> |
|
<?php if (!$totaldep) { ?> |
|
<td width="20" style="border:0"><div align="center"><a href="#" title="Excluir Ramal: <?php echo $dados['nome']; ?>" onclick="excluir('<?php echo $dados['nome']; ?>', '<?php echo $dados['id']; ?>', 'DESEJA REALMENTE EXLUIR O RAMAL:<?php echo trim($dados['nome']); ?>', 'index.php?idProg=10009&pbxRequest=1&acao=deleta&id=<?php echo $dados['id']; ?>&numRamal=<?php echo $params; ?>');"><img src="images/delete.gif" alt="APAGAR O RAMAL:<?php echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td> |
|
<?php } else { ?> |
|
<td style="border:0" width="33%"><div align="center"><img src="images/delete.gif" title="Este registro possui dependências não pode ser apagado!" alt="Este registro não pode ser apagado!" width="16" height="16" border="0" ></div></td> |
|
<?php } ?> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<?php |
|
$z++; |
|
} if ($z == 0) { |
|
?> |
|
<tr align="center" valign="middle" bordercolor="#999999" class="labels"> |
|
<td colspan="9"><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="9"><table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2"><tr><th align="center" style="width: 90%; border:0;"><?php echo $links; ?></th><th align="right" style="width: 10%; border:0;"><?php echo sprintf("%s/%s", $pagMostra, $totalReg); ?></th></tr></table></th> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
|
|
<div id="mensagem" style="display:none;width:300;height:auto"> |
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<td width="5%" align="center" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 16px;color: #990000;background-color: #FFFFFF;"> |
|
</td> |
|
<td width="95%" align="center" bgcolor="#FFFFFF" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 16px;color: #990000;background-color: #FFFFFF;"><div align="center"> |
|
<input name="mens" type="button" value="mens" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 14px;color: #990000;background-color: #FFFFFF;" id="mens"> |
|
</div></td> |
|
</tr> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<td colspan="2" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<span style="color: #FFFFFF"> _ |
|
</span> |
|
</td> |
|
</tr> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<td colspan="2" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<tr> |
|
|
|
<td width="50%" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<div align="center"> |
|
<button id="ramal" class="botoes">Excluir</button> |
|
</div> |
|
</td> |
|
<td width="50%" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<div align="center"> |
|
<button id="cancela" class="botoes">Cancelar</button> |
|
</div> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</body> |
|
</html> |
|
|
|
|