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.
260 lines
15 KiB
260 lines
15 KiB
<?php |
|
//include dos arquivos padrões do sistema |
|
$acao = isset($_REQUEST['acao']) ? trim($_REQUEST['acao']) : 'select'; |
|
$id = isset($_REQUEST['id']) ? trim(intval($_REQUEST['id'])) : 0; |
|
$filtro = isset($_REQUEST["numRamal"]) ? trim($_REQUEST["numRamal"]) : ''; |
|
$filtroNovo = !isset($_REQUEST["pgn"]) ? '' : sprintf("&numRamal%s&pgn=%s&bloco=%s&pg=%s&status=%s", $_REQUEST["numRamal"], $_REQUEST["pgn"], $_REQUEST["bloco"], $_REQUEST["pg"], $_REQUEST["status"]); |
|
$recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_REQUEST['pesquisa']); |
|
$org_id = GetOrganizacao(); |
|
$status = isset($_REQUEST["status"]) ? trim($_REQUEST["status"]) : 'A'; |
|
$matricula = GetMatricula(); |
|
|
|
if ($acao == "deleta") { |
|
$query = "SELECT numero, nome FROM pbx_queues_grupos WHERE id=$id and org_id = $org_id"; |
|
$result = pg_query($dbcon, $query); |
|
|
|
if ($dados = pg_fetch_array($result)) { |
|
$numero = $dados['numero']; |
|
$nomeFila = $dados['nome']; |
|
} |
|
|
|
//Remove o dac da interface de supervisao |
|
$query = "UPDATE pbx_queues_grupos set status='I', opcao = null, acao = null, context = null where id='$id' and org_id = $org_id"; |
|
pg_query($dbcon, $query); |
|
|
|
$query = "DELETE FROM pbx_supervisor_dacs WHERE trim(dac) = trim((select nome from pbx_dacs where id = '$id' and org_id = $org_id"; |
|
pg_query($dbcon, $query); |
|
|
|
$query = "DELETE FROM pbx_fila_audios WHERE id = '$id' and org_id = $org_id"; |
|
pg_query($dbcon, $query); |
|
|
|
$query = "DELETE FROM pbx_queues_membros WHERE id_fila = '$id' and org_id = $org_id"; |
|
pg_query($dbcon, $query); |
|
|
|
$query = "DELETE FROM pbx_prioridades_atendimento WHERE dac = '$nomeFila' and org_id = $org_id"; |
|
pg_query($dbcon, $query); |
|
|
|
// //gera arquivos e executa o reload dos dados no asterisk |
|
// gera_arquivos($dbcon, 'QUEUES_GRUPOS'); |
|
Ajusta_tabelas('filas', $numero, $dbcon); |
|
} |
|
?> |
|
|
|
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro"> |
|
|
|
<tr> |
|
<td> |
|
<table align="left" border="0" cellpadding="2" cellspacing="0"> |
|
<tr> |
|
<td>Palavra Chave</td> |
|
<td>Filtro Status</td> |
|
</tr> |
|
<tr> |
|
<td align="left" nowrap="nowrap"> |
|
<input name="numRamal" type="text" id="numRamal" value="<?php echo $_REQUEST["numRamal"]; ?>" size="20"> <?php //onkeyup="ConsultaRamal('index.php?idProg=10002&pbxRequest=1', event);" |
|
?> |
|
</td> |
|
<td align="left" nowrap="nowrap"> |
|
<div class="geral" nowrap="nowrap"> |
|
<input name="status" class="clean" type="radio" value="A" <?= $status == "A" ? 'checked' : ''; ?>>Ativa |
|
<input name="status" class="clean" type="radio" value="I" <?= $status == "I" ? 'checked' : ''; ?>>Desativada |
|
<input name="status" class="clean" type="radio" value="T" <?= $status == "T" ? 'checked' : ''; ?>>Todos |
|
</div> |
|
</td> |
|
<td> |
|
<input name="locaRamal" type="submit" id="locaRamal" value="Localizar"> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
<td align="right" nowrap="nowrap"> |
|
<a href="#" onclick="NovaJanela('index.php?idProg=11002&pbxRequest=1&acao=inseri<?= $filtroNovo; ?>&status=<?= $status ?>', 'CadFila', '780', '560.', 'resizable=YES,scrollbars=YES');"><img src="admin/images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVA FILA </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"> Número </th> |
|
<th align="left"> Estratégia </th> |
|
<th align="left"> Timeout Fila </th> |
|
<th align="center"> <span title="Número de Depndências">Dep</span></th> |
|
<th align="center"> Status </th> |
|
<th align="center">Ações</th> |
|
</tr> |
|
<?php |
|
$strategia['ringall'] = 'Simultaneo - Chama todos os agentes disponíveis'; |
|
$strategia['leastrecent'] = 'Tempo Livre - Chama o agente que está a mais tempo sem receber ligações'; |
|
$strategia['fewestcalls'] = 'Numero de Ligações - Chama o agente com o menor numero de ligações atendidas'; |
|
$strategia['random'] = 'Randomico - Chama os agentes de forma aleatoria'; |
|
$strategia['rrordered'] = 'Sequencial - Chama o agente respeitando a ordem cadastrada (Membros Estáticos)'; |
|
$acessoAudio = VerificaPerfilAcesso($dbcon, GetIdProgFromNomeArq('audio.php')); |
|
$compl = ''; |
|
if (IsPostBack() || (!empty($filtro))) { |
|
$compl = PreparaLike($filtro, true); |
|
$compl = sprintf("and (a.nome ilike %s or a.numero ilike %s) ", $compl, $compl); |
|
} |
|
|
|
$statuSql = ""; |
|
if ($status == 'A') { |
|
$statuSql = " and a.status = 'A'"; |
|
} |
|
elseif ($status == 'I') { |
|
$statuSql = " and a.status = 'I'"; |
|
} |
|
|
|
$compl .= " and a.org_id = {$org_id} "; |
|
|
|
/* WITH cria verdedaireo se tem matricula true para admin no pbx_usuarios |
|
* a tabela do with é testada se for true sempre da verdadeiro a todos os INNER JOIN |
|
* |
|
* 1 = 1 = Serve para não testar se é a primeira sobre AND |
|
*/ |
|
$query = "WITH admin_check AS ( |
|
SELECT |
|
CASE |
|
WHEN EXISTS ( |
|
SELECT 1 |
|
FROM pbx_usuarios |
|
WHERE matricula = '$matricula' AND admin = TRUE |
|
) THEN TRUE |
|
ELSE FALSE |
|
END AS is_admin |
|
) |
|
SELECT |
|
distinct ON(a.id) a.id, |
|
a.nome, |
|
a.numero, |
|
a.strategy, |
|
a.timeout2, |
|
a.status |
|
FROM |
|
pbx_queues_grupos a |
|
WHERE |
|
(SELECT is_admin FROM admin_check) = TRUE $statuSql $compl |
|
|
|
UNION |
|
|
|
SELECT |
|
distinct ON(a.id) a.id, |
|
a.nome, |
|
a.numero, |
|
a.strategy, |
|
a.timeout2, |
|
a.status |
|
FROM |
|
pbx_queues_grupos a |
|
INNER JOIN pbx_fila_grupos pfg ON |
|
((SELECT is_admin FROM admin_check) = TRUE OR pfg.id = a.id) |
|
AND pfg.org_id = a.org_id |
|
INNER JOIN pbx_grupo_usuario pgu ON |
|
((SELECT is_admin FROM admin_check) = TRUE OR pgu.gp_id = pfg.gp_id) |
|
AND pgu.org_id = pfg.org_id |
|
INNER JOIN pbx_usuarios pu ON |
|
((pu.id = pgu.user_id AND pu.matricula = '$matricula') OR (SELECT is_admin FROM admin_check)) |
|
WHERE |
|
1 = 1 |
|
$statuSql |
|
$compl |
|
ORDER BY |
|
id ASC"; |
|
|
|
$params = "&pbxRequest=1&numRamal=$filtro&status=$status"; |
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); |
|
$query .= " limit $regPagina offset $offSet"; |
|
|
|
//if(IsAdmin()){ echo $query;} |
|
$result = pg_query($dbcon, $query); |
|
$z = 0; |
|
while ($dados = pg_fetch_array($result)) { |
|
$tamOper = $acessoAudio ? 80 : 60; |
|
$totaldep = GetTotalDependencias('filas', $dados['numero']); |
|
$opcao = 'filas'; |
|
$acao = $dados['numero']; |
|
$recursoTipo = 'Fila'; |
|
$nomeRecurso = $dados['nome']; |
|
$dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep); |
|
?> |
|
<tr> |
|
<td width="50" align="center"><?php echo $dados['id']; ?></td> |
|
<td> |
|
<a href="#" style="color: #000" onclick="abre_janela('780', '560', 'index.php?idProg=11002&pbxRequest=1&acao=edita&id=<?php echo $dados['id']; ?><?= $params; ?>');"> |
|
<?= $dados['nome']; ?> |
|
</a> |
|
</td> |
|
<td width="120"><?php echo $dados['numero']; ?></td> |
|
<td width="250"><?php echo $strategia[$dados['strategy']]; ?></td> |
|
<td width="80"><?php echo $dados['timeout2']; ?></td> |
|
<td width="30" align="center"><?php echo $dep; ?></td> |
|
<td align="center" width="30"> |
|
<div align="center"> |
|
<?php echo GetStatusModulo($dados['status']); ?> |
|
</div> |
|
</td> |
|
<td width="<?= $tamOper; ?>"> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="2" style="border:0;"> |
|
<tr style="border:0;"> |
|
<td style="border:0;"> |
|
<div align="center"><a href="#" title="Editar Fila: <?php echo RemoveExibicaoOrg($dados['nome']); ?>" onclick="abre_janela('780', '560.', 'index.php?idProg=11002&pbxRequest=1&acao=edita&id=<?php echo $dados['id']; ?><?= $params; ?>');"><img src="admin/images/edit.gif" alt="EDITAR A FILA:<?php echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div> |
|
</td> |
|
|
|
<?php if (!$totaldep) { ?> |
|
<?php if ($dados['status'] == 'A') { ?> |
|
<td style="border:0;"> |
|
<div align="center"><a href="#" title="DESATIVAR Fila: <?php echo RemoveExibicaoOrg($dados['nome']); ?>" onclick="excluir('<?php echo $dados['id']; ?>', '<?php echo RemoveExibicaoOrg($dados['nome']); ?>', 'DESEJA REALMENTE DESATIVAR A FILA:<?php echo RemoveExibicaoOrg($dados['nome']); ?>', 'index.php?idProg=10002&pbxRequest=1&acao=deleta&id=<?php echo $dados['id']; ?><?= $params; ?>', 'FILAS:');"><img src="admin/images/delete.gif" title="DESATIVAR A FILA:<?php echo RemoveExibicaoOrg($dados['nome']); ?>" width="16" height="16" border="0"></a></div> |
|
</td> |
|
<?php } else { ?> |
|
<td style="border:0;"><img src="imgSite/fecha16.png" title="FILA INATIVA: <?php echo RemoveExibicaoOrg($dados['nome']); ?>" width="16" height="16" border="0"></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 desativado!" alt="Este registro não pode ser desativado!" width="16" height="16" border="0"></div> |
|
</td> |
|
<?php } ?> |
|
<td style="border:0;" align="center"> |
|
<div align="center"><a href="#" title="Grupos da Fila: <?php echo RemoveExibicaoOrg($dados['nome']); ?>" onclick="NovaJanela('index.php?idProg=10006&pbxRequest=1&id=<?php echo $dados['id']; ?>&nome=<?php echo RemoveExibicaoOrg($dados['nome']); ?>', 'QeuesGrupos', '680', '250', 'resizable=NO,scrollbars=NO');"><img src="admin/images/usuarios.gif" alt="Configura acesso a Fila:<?php echo RemoveExibicaoOrg($dados['nome']); ?>" width="16" height="16" border="0"></a></div> |
|
</td> |
|
<?php if ($acessoAudio) { ?> |
|
<td style="border:0;" align="center"> |
|
<div align="center"><a href="#" title="Áudios da Fila: <?php echo RemoveExibicaoOrg($dados['nome']); ?>" onclick="NovaJanela('index.php?idProg=10051&pbxRequest=1&id=<?php echo $dados['id']; ?>&nome=<?php echo RemoveExibicaoOrg($dados['nome']); ?>', 'QeuesAudios', '680', '250', 'resizable=NO,scrollbars=NO');"><img src="admin/images/sound22.png" alt="Configura acesso a Fila:<?php echo RemoveExibicaoOrg($dados['nome']); ?>" width="16" height="16" border="0"></a></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ã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> |
|
<div id="campos" style="display:none" align="center"> |
|
<iframe src="" frameborder="0" scrolling="no" name="geral" id="geral" align="middle"></iframe> |
|
</div> |
|
|
|
</body> |
|
|
|
</html>
|