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.
 
 
 
 
 
 

168 lines
6.8 KiB

<?php
include($_SESSION["SSabsPath"] . "funcoesFormulario.php");
$pbxRequest = $_REQUEST['pbxRequest'];
$idprog = $_REQUEST['idProg'];
//Id da campanha
$idLista = $_REQUEST['idLista'];
$_REQUEST['erro'] = "";
if (isset($_REQUEST['btIncRota'])) {
if (empty($_REQUEST['listaRotas'])) {
$_REQUEST['erro'] = fmtMsg('Selecione uma rota!');
} else {
$result = pg_query($dbcon, 'begin');
foreach ($_REQUEST['listaRotas'] as $idRotas) {
$id = explode('|', $idRotas);
$idRota = $id[1];
$tiporota = $id[0];
$query = "insert into pbx_listanegra_rota(id_rota, id_lista, tipo_rota)values('%s', '%s', '%s')";
$query = sprintf($query, $idRota, $idLista, $tiporota);
$result = pg_query($dbcon, $query);
if (!$result) {
break;
}
}
if ($result) {
pg_query($dbcon, 'commit');
$_REQUEST['erro'] = fmtMsg('Rota incluida com sucesso!');
} else {
pg_query($dbcon, 'rollback');
$_REQUEST['erro'] = fmtErro('A Rota não pode ser incluido!', pg_last_error($dbcon));
}
}
} else if (isset($_REQUEST['btRmRota'])) {
if (empty($_REQUEST['listaRotaInc'])) {
$_REQUEST['erro'] = fmtMsg('Selecione uma Rotagr!');
} else {
$result = pg_query($dbcon, 'begin');
foreach ($_REQUEST['listaRotaInc'] as $idRotas) {
$id = explode('|', $idRotas);
$idRota = $id[1];
$tiporota = $id[0];
$query = "delete from pbx_listanegra_rota where id_rota = '%s' and id_lista = '%s' and tipo_rota = '%s'";
$query = sprintf($query, $idRota, $idLista, $tiporota);
$result = pg_query($dbcon, $query);
if (!$result)
break;
}
if ($result) {
pg_query($dbcon, 'commit');
$_REQUEST['erro'] = fmtMsg('Rota removida com sucesso!');
} else {
pg_query($dbcon, 'rollback');
$_REQUEST['erro'] = fmtErro('A Rota não pode ser removido!', pg_last_error($dbcon));
}
}
}
if (!isset($_REQUEST['listaRotas'])) {
$_REQUEST['listaRotas'] = '';
}
if (!isset($_REQUEST['listaRotaInc'])) {
$_REQUEST['listaRotaInc'] = '';
}
$_REQUEST['listaRotas'] = GetListaRotas($dbcon, 'listaRotas', $idLista, $_REQUEST['listaRotas'], 0, 1);
$_REQUEST['listaRotaInc'] = GetListaRotas($dbcon, 'listaRotaInc', $idLista, $_REQUEST['listaRotaInc'], 1, 1);
$erro = $_REQUEST['erro'];
function GetListaRotas($dbcon, $nomeCombo, $idLista = 0, $codSel = 0, $gpInc = 0, $multiple = 0)
{
$org_id = GetOrganizacao();
//$gpInc -> Pesquisa grupos incluidos qunado seu valor é = 1
$nomeComboDisp = $multiple ? ($nomeCombo . "[]") : $nomeCombo;
$multiple = $multiple ? 'multiple="multiple"' : "";
$agentes = "<select name=\"$nomeComboDisp\" style=\"width:280px\" id=\"$nomeCombo\" size=\"8\" $multiple>";
//select tipo, id, nome from pbx_rotas;
$query = "SELECT tipo, id, nome FROM pbx_rotas a
WHERE " . ($gpInc ? "" : " NOT ") . " EXISTS (SELECT '' FROM pbx_listanegra_rota where id_rota = a.id and tipo_rota = a.tipo and id_lista = '$idLista' and org_id = {$org_id})
ORDER BY nome ";
$result = pg_query($dbcon, $query);
while ($dados = pg_fetch_row($result)) {
if ($codSel == $dados[0]) {
$sel = "selected";
} else {
$sel = "";
}
$agentes .= "<option value=\"$dados[0]|$dados[1]\" $sel>$dados[2]($dados[0])</option>";
}
$agentes .= "</select>";
return $agentes;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Configuração de acesso a fila</title>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form1" method="get">
<table class="tabela" border="0" cellpadding="2" cellspacing="0" width="100%">
<tbody>
<tr>
<td><input type="hidden" name="idLista" value="<?= $idLista; ?>" />
<input name="pbxRequest" type="hidden" value="<?= ($pbxRequest ? '1' : '0'); ?>">
<input name="idProg" type="hidden" value="<?= $idprog; ?>">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<th align="center" class="cabecalho" background="img/button03.gif">Lista Negra/Rotas</th>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr style="border:0;" align="center">
<th width="45%" class="labels">Rotas Dispon&iacute;veis</th>
<td rowspan="2" align="center" valign="middle">
<input type="submit" name="btIncRota" value="&gt;" id="btIncRota" />
<br />
<input type="submit" name="btRmRota" value="&lt;" id="btRmRota" />
</td>
<th class="labels">Rotas Inclu&iacute;dos</th>
</tr>
<tr>
<td width="45%">
<?= $_REQUEST['listaRotas']; ?>
</td>
<td>
<?= $_REQUEST['listaRotaInc']; ?>
</td>
</tr>
<tr>
<td>
<input name="btClose" type="submit" id="btClose" value="Fechar" onclick="window.close();" />
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td><?= (isset($erro) && $erro ? $erro : ""); ?></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>