|
|
|
|
<?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<EFBFBD>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<EFBFBD>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) {
|
|
|
|
|
//$gpInc -> Pesquisa grupos incluidos qunado seu valor <EFBFBD> = 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')
|
|
|
|
|
order by nome ";
|
|
|
|
|
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
while ($dados = pg_fetch_row($result)) {
|
|
|
|
|
if ($codSel == $dados[0]) {
|
|
|
|
|
$sel = "selected";
|
|
|
|
|
$i = 1;
|
|
|
|
|
} 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<EFBFBD><EFBFBD>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="<?php echo $idLista; ?>" />
|
|
|
|
|
<input name="pbxRequest" type="hidden" value="<?php echo ($pbxRequest ? '1' : '0'); ?>">
|
|
|
|
|
<input name="idProg" type="hidden" value="<?php echo $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íveis</th>
|
|
|
|
|
<td rowspan="2" align="center" valign="middle"><input type="submit" name="btIncRota" value=">" id="btIncRota" />
|
|
|
|
|
<br/>
|
|
|
|
|
<input type="submit" name="btRmRota" value="<" id="btRmRota" /></td>
|
|
|
|
|
<th class="labels">Rotas Incluídos</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="45%"><?php echo $_REQUEST['listaRotas']; ?></td>
|
|
|
|
|
<td><?php echo $_REQUEST['listaRotaInc']; ?></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><input name="btClose" type="submit" id="btClose" value="Fechar" onclick="window.close();" /></td>
|
|
|
|
|
<td> </td>
|
|
|
|
|
<td> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<table>
|
|
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><?php echo (isset($erro) && $erro ? $erro : ""); ?></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|