|
|
|
|
<?php
|
|
|
|
|
include($_SESSION["SSabsPath"] . "funcoesFormulario.php");
|
|
|
|
|
$fieldsForm = array();
|
|
|
|
|
$fieldsForm = $_REQUEST;
|
|
|
|
|
$pbxRequest = $fieldsForm['pbxRequest'];
|
|
|
|
|
$idprog = $fieldsForm['idProg'];
|
|
|
|
|
|
|
|
|
|
//Id da campanha
|
|
|
|
|
$idFila = $fieldsForm['id'];
|
|
|
|
|
$fieldsForm['erro'] = "";
|
|
|
|
|
|
|
|
|
|
if (isset($fieldsForm['btIncGrupo'])) {
|
|
|
|
|
if (empty($fieldsForm['listaGrupos'])) {
|
|
|
|
|
$fieldsForm['erro'] = fmtMsg('Selecione um grupo!');
|
|
|
|
|
} else {
|
|
|
|
|
$result = @pg_query($dbcon, 'begin');
|
|
|
|
|
foreach ($fieldsForm['listaGrupos'] as $idGrupo) {
|
|
|
|
|
$query = "insert into pbx_fila_grupos(gp_id, id)values('%s', '%s')";
|
|
|
|
|
$query = sprintf($query, $idGrupo, $idFila);
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
if (!$result)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
@pg_query($dbcon, 'commit');
|
|
|
|
|
$fieldsForm['erro'] = fmtMsg('Grupo incluido com sucesso!');
|
|
|
|
|
} else {
|
|
|
|
|
@pg_query($dbcon, 'rollback');
|
|
|
|
|
$fieldsForm['erro'] = fmtErro('O grupo n<EFBFBD>o pode ser incluido!', pg_last_error($dbcon));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (isset($fieldsForm['btRmGrupo'])) {
|
|
|
|
|
if (empty($fieldsForm['listaGrupoInc'])) {
|
|
|
|
|
$fieldsForm['erro'] = fmtMsg('Selecione um Grupo!');
|
|
|
|
|
} else {
|
|
|
|
|
$result = @pg_query($dbcon, 'begin');
|
|
|
|
|
foreach ($fieldsForm['listaGrupoInc'] as $idGrupo) {
|
|
|
|
|
$query = "delete from pbx_fila_grupos where gp_id = %s and id = %s";
|
|
|
|
|
$query = sprintf($query, $idGrupo, $idFila);
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
if (!$result)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
/*
|
|
|
|
|
* Remove os usu<EFBFBD>rios da rela<EFBFBD><EFBFBD>o Campnha/Usu<EFBFBD>rios caso
|
|
|
|
|
* estes usu<EFBFBD>rios n<EFBFBD>o tenham mais acesso ao DAC relacionado a camapanha.
|
|
|
|
|
*/
|
|
|
|
|
$query = "delete from pbx_campanha_usuarios where matricula not in(
|
|
|
|
|
select c.matricula
|
|
|
|
|
from pbx_fila_grupos a, pbx_grupo_usuario b, pbx_usuarios c, pbx_campanha_usuarios d
|
|
|
|
|
where b.gp_id = a.gp_id
|
|
|
|
|
and c.id = b.user_id
|
|
|
|
|
and d.matricula = c.matricula
|
|
|
|
|
and a.id = '%s')
|
|
|
|
|
and cmp_id in(select cmp_id from pbx_campanha where id_dac = '%s')";
|
|
|
|
|
$query = sprintf($query, $idFila, $idFila);
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
pg_query($dbcon, 'commit');
|
|
|
|
|
$fieldsForm['erro'] = fmtMsg('Grupo removido com sucesso!');
|
|
|
|
|
} else {
|
|
|
|
|
@pg_query($dbcon, 'rollback');
|
|
|
|
|
$fieldsForm['erro'] = fmtErro('O grupo n<EFBFBD>o pode ser removido!', pg_last_error($dbcon));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isset($fieldsForm['listaGrupos'])) {
|
|
|
|
|
$fieldsForm['listaGrupos'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($fieldsForm['listaGrupoInc'])) {
|
|
|
|
|
$fieldsForm['listaGrupoInc'] = '';
|
|
|
|
|
}
|
|
|
|
|
$fieldsForm['listaGrupos'] = GetAgentesCampanha($dbcon, 'listaGrupos', $idFila, $fieldsForm['listaGrupos'], 0, 1);
|
|
|
|
|
$fieldsForm['listaGrupoInc'] = GetAgentesCampanha($dbcon, 'listaGrupoInc', $idFila, $fieldsForm['listaGrupoInc'], 1, 1);
|
|
|
|
|
|
|
|
|
|
$erro = $fieldsForm['erro'];
|
|
|
|
|
|
|
|
|
|
function GetAgentesCampanha($dbcon, $nomeCombo, $idFila = 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>";
|
|
|
|
|
|
|
|
|
|
$query = "select a.gp_id, a.gp_nome || case when(a.user_id = 0)then '' else '**' end as gp_nome
|
|
|
|
|
from pbx_grupo a
|
|
|
|
|
where gp_status = 1 and gp_nome <> 'SincContaSenha'
|
|
|
|
|
and " . ($gpInc ? "" : " not ") . " exists(select '' from pbx_fila_grupos where gp_id = a.gp_id and id = $idFila)
|
|
|
|
|
order by a.user_id, a.gp_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]\" $sel>$dados[1]</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="id" value="<?php echo $idFila; ?>" />
|
|
|
|
|
<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">Grupo Usuário/Fila</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">Grupos Disponíveis</th>
|
|
|
|
|
<td rowspan="2" align="center" valign="middle"><input type="submit" name="btIncGrupo" value=">" />
|
|
|
|
|
<br/>
|
|
|
|
|
<br/>
|
|
|
|
|
<input type="submit" name="btRmGrupo" value="<" /></td>
|
|
|
|
|
<th class="labels">Grupos Incluídos</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="45%"><?php echo $fieldsForm['listaGrupos']; ?></td>
|
|
|
|
|
<td><?php echo $fieldsForm['listaGrupoInc']; ?></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>
|