Browse Source

correcoes para multiempresa

dev
Lucas Awade 10 months ago
parent
commit
108a68dc77
  1. 331
      admin/iax.php
  2. 57
      agente/agenteAgenda.php
  3. 69
      agente/agenteAnota.php
  4. 2
      agente/agentert.php
  5. 366
      agente/funcoesAgente.php
  6. 4
      asterisk/etc_asterisk/editado_manual/extensions_padrao.conf
  7. 12
      cadastros/organizacao/atribuirOrganizacao.php
  8. 45
      contacteFunc.php
  9. 41
      include/util/funcoesApl.php
  10. 46
      seguranca/usuarioCad.php
  11. 6
      templates/seguranca/usuario.tpl

331
admin/iax.php

@ -1,193 +1,202 @@
<?php
$acao = isset($_GET['acao']) ? $_GET['acao'] : '';
$id = isset($_GET['id']) ? $_GET['id'] : '';
$id2 = isset($_GET['id2']) ? $_GET['id2'] : '';
$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_iax_pbx where id=$id";
$result = pg_query($dbcon, $query);
if ($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);
$query = "delete from pbx_iax_pbx where id='$id'";
pg_query($dbcon, $query);
$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, true, false);
gera_arquivos($dbcon, 'IAX_PBX', 1, 0);
$acao = isset($_GET['acao']) ? $_GET['acao'] : '';
$id = isset($_GET['id']) ? $_GET['id'] : '';
$id2 = isset($_GET['id2']) ? $_GET['id2'] : '';
$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_iax_pbx where id=$id";
$result = pg_query($dbcon, $query);
if ($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);
$query = "delete from pbx_iax_pbx where id='$id'";
pg_query($dbcon, $query);
$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, true, false);
gera_arquivos($dbcon, 'IAX_PBX', 1, 0);
}
?>
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro">
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro">
<tr>
<td colspan="2">Ramal/Bina</td>
</tr>
<tr >
<td nowrap="nowrap" >
<tr>
<td nowrap="nowrap">
<input name="numRamal" type="text" id="numRamal" value="<?php echo $_GET["numRamal"]; ?>" onkeyup="ConsultaRamal('index.php?idProg=10010&pbxRequest=1', event);" size="20">
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10010&pbxRequest=1&pesquisa=1');">
</td>
<td align="right" nowrap="nowrap" >
<td align="right" nowrap="nowrap">
<a href="#" onclick="abre_janela('710', '700', 'index.php?idProg=11010&pbxRequest=1&acao=inseri<?php echo $filtroNovo; ?>');"><img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle" />NOVO RAMAL IAX </a>
<a href="#" onclick="abre_janela('600', '240', 'index.php?idProg=11110&pbxRequest=1');"><img src="images/global.gif" width="20" height="20" border="0" align="absmiddle" />CONFIGURA&Ccedil;&Atilde;O GLOBAL </a>
</td>
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2">
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2">
<tr>
<th align="center" ><div align="center">Id</div></th>
<th align="left" > Ramal</th>
<th align="left" > Bina</th>
<th align="left" > Contexto</th>
<th align="left" > Dispositivo </th>
<th align="center">
<div align="center">Id</div>
</th>
<th align="left"> Ramal</th>
<th align="left"> Bina</th>
<th align="left"> Contexto</th>
<th align="left"> Dispositivo </th>
<th align="center"> <span title="Número de Depndências">Dep</span></th>
<th align="center" >Ações</th>
<th align="center">Ações</th>
</tr>
<?php
$janW = '500';
$janH = '400';
$compl = "";
$janW = '500';
$janH = '400';
$compl = "";
$tpParcial = 0;
if (strpos($filtro, ',')) {
$tpParcial = 1;
} else if (strpos($filtro, '-')) {
$sql = "SELECT count(*) FROM pbx_iax_pbx WHERE identificador ILIKE '%$filtro%'";
$result = pg_query($dbcon, $sql);
$param = pg_fetch_row($result);
if ($param[0] > 0) {
$tpParcial = 0;
} else {
$tpParcial = 2;
}
}
$tpParcial = 0;
if (strpos($filtro, ',')) {
$tpParcial = 1;
} else if (strpos($filtro, '-')) {
$sql = "select count(*) from pbx_iax_pbx where identificador 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 = " AND (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'";
}
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'";
$compl = " AND (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 {
$compl = "";
$fim1 = $fim;
}
$query = "drop table if exists ramal_iax;
create temporary table ramal_iax(
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 integer
);
insert into ramal_iax (id,nome, context,dispositivo, saldo_prepago, habilita_prepago,callerid,ramal)
SELECT id,nome, context,dispositivo, saldo_prepago, habilita_prepago,identificador,
cast(case when (length(nome) - length(ltrim(nome,'0'))) >= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::int--||nome
$compl = " AND nome BETWEEN '$ini' AND '$fim' AND ramal BETWEEN '$ini1' AND '$fim1'";
} else {
$compl = "";
}
$query = "SELECT id, nome, context, dispositivo, saldo_prepago, habilita_prepago, identificador,
cast(case when (length(nome) - length(ltrim(nome,'0'))) >= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::int
else nome
end as int)
FROM pbx_iax_pbx;
select * from ramal_iax $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('710', '700', 'index.php?idProg=11010&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 width="30" align="center"><?php echo $dep; ?></td>
<td width="40">
<table width="100%" border="0" cellpadding="1" cellspacing="0" bordercolor="#EAEAEA">
<tr>
<td width="20" style="border:0"><div align="center"><a href="#" title="Editar Ramal: <?php echo $dados['nome']; ?>" onclick="abre_janela('710', '700', 'index.php?idProg=11010&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 $dados['nome']; ?>', 'index.php?idProg=10010&pbxRequest=1&acao=deleta&id=<?php echo $dados['id']; ?><?php echo $params; ?>', 'RAMAL IAX');" id="<?php echo $dados['id']; ?>" nome="<?php echo $dados['nome']; ?>" ><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="6"><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;"><?php echo $links; ?></th><th align="right" style="width: 10%; border:0;"><?php echo sprintf("%s/%s", $pagMostra, $totalReg); ?></th></tr></table></th>
end as int) AS ramal
FROM pbx_iax_pbx
WHERE 1=1
$compl ORDER BY 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('710', '700', 'index.php?idProg=11010&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 width="30" align="center"><?php echo $dep; ?></td>
<td width="40">
<table width="100%" border="0" cellpadding="1" cellspacing="0" bordercolor="#EAEAEA">
<tr>
<td width="20" style="border:0">
<div align="center"><a href="#" title="Editar Ramal: <?php echo $dados['nome']; ?>" onclick="abre_janela('710', '700', 'index.php?idProg=11010&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 $dados['nome']; ?>', 'index.php?idProg=10010&pbxRequest=1&acao=deleta&id=<?php echo $dados['id']; ?><?php echo $params; ?>', 'RAMAL IAX');" id="<?php echo $dados['id']; ?>" nome="<?php echo $dados['nome']; ?>"><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="6">
<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;"><?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>
</table>
</td>
</tr>
</table>
</body>
</html>
</html>

57
agente/agenteAgenda.php

@ -18,6 +18,7 @@ $email = "";
$endereco = "";
$result = "";
$msg = "";
$org_id = GetOrganizacao();
if (isset($_GET["formAction"])) {
$idDel = $_GET["id"];
@ -25,15 +26,15 @@ if (isset($_GET["formAction"])) {
pg_query($dbcon, $query);
}
if (strtoupper($btAgenda) == "PESQUISAR") {
$query = "select id, nome, telefone, celular, email, endereco
from pbx_agendas
where (nome like '%$pesqAgenda%'
or telefone like '%$pesqAgenda%'
or celular like '%$pesqAgenda%'
or email like '%$pesqAgenda%'
or endereco like '%$pesqAgenda%')";
$query = "SELECT id, nome, telefone, celular, email, endereco
FROM pbx_agendas
WHERE (nome LIKE '%$pesqAgenda%'
OR telefone LIKE '%$pesqAgenda%'
OR celular LIKE '%$pesqAgenda%'
OR email LIKE '%$pesqAgenda%'
OR endereco LIKE '%$pesqAgenda%')
AND org_id = $org_id ";
$result = pg_query($dbcon, $query);
$linha = "";
while ($row = pg_fetch_array($result)) {
@ -72,12 +73,12 @@ if (strtoupper($_POST["btEditaAgenda"]) == "INSERIR") {
} else if (strlen($endereco) > 80) {
$msg = "alert('Informe no máximo 80 caracteres no campo endereço!');";
} else {
$query = "insert into pbx_agendas(nome, telefone, celular, email, endereco)
values('$nome', '$telefone', '$celular', '$email', '$endereco' )";
$query = "INSERT INTO pbx_agendas(nome, telefone, celular, email, endereco, org_id)
VALUES('$nome', '$telefone', '$celular', '$email', '$endereco', $org_id)";
$result = pg_query($dbcon, $query);
if ($result)
if ($result) {
$result = pg_affected_rows($result);
}
$msg = $result ? "alert('Operação realizada com sucesso!'); window.close();" : "alert('A operação não pode ser realizada!');";
}
@ -91,13 +92,13 @@ if (strtoupper($_POST["btEditaAgenda"]) == "INSERIR") {
} else if (strlen($endereco) > 80) {
$msg = "Informe no máximo 80 caracteres no campo endereço!";
} else {
$query = "update pbx_agendas
set nome = '$nome',
telefone = '$telefone',
celular = '$celular',
email = '$email',
endereco = '$endereco'
where id = $idEdita";
$query = "UPDATE pbx_agendas
SET nome = '$nome',
telefone = '$telefone',
celular = '$celular',
email = '$email',
endereco = '$endereco'
WHERE id = $idEdita";
$result = pg_query($dbcon, $query);
if ($result)
$result = pg_affected_rows($result);
@ -110,9 +111,10 @@ if (strtoupper($_POST["btEditaAgenda"]) == "INSERIR") {
}
if ($acao == 2) {
$query = "select id, nome, telefone, celular, email, endereco
from pbx_agendas
where id = $idEdita";
$query = "SELECT id, nome, telefone, celular, email, endereco
FROM pbx_agendas
WHERE id = $idEdita
AND org_id = $org_id ";
$result = pg_query($dbcon, $query);
$row = pg_fetch_array($result);
@ -125,7 +127,6 @@ if ($acao == 2) {
$endereco = $row["endereco"];
}
if (empty($linha))
$linha = "<tr align=\"center\"><td colspan=5>Nenhum registro encontrado!</td></tr>";
@ -149,11 +150,11 @@ if ($acao == 0) {
DispLogin($smarty, $acao);
function DispLogin($smarty, $acao) {
if ($acao == 0)
function DispLogin($smarty, $acao)
{
if ($acao == 0) {
$smarty->display('callcenter/agente/agenteAgenda.tpl');
else
} else {
$smarty->display('callcenter/agente/agenteAgendaEdita.tpl');
}
}
?>

69
agente/agenteAnota.php

@ -14,13 +14,13 @@ $btAnota = isset($_POST["btAnota"]) ? $_POST["btAnota"] : "";
$listaAgente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : GetMatricula();
$dataIni = !isset($_POST["dataIni"]) ? date('d/m/Y') : $_POST["dataIni"];
$dataFim = !isset($_POST["dataFim"]) ? date('d/m/Y') : $_POST["dataFim"];
$org_id = GetOrganizacao();
$msg = "";
$pesquisa = "";
if (isset($_GET["formAction"])) {
$idDel = $_GET["id"];
$query = "delete from pbx_anotacoes where id_text = '$idDel'";
$query = "DELETE FROM pbx_anotacoes WHERE id_text = '$idDel'";
pg_query($dbcon, $query);
}
@ -37,8 +37,7 @@ if (!is_date($dataIni)) {
} else if ($valida && empty($agtAnota)) {
$msg = "Insira uma anotação!";
} else if (!$consultar && $valida) {
$query = "insert into pbx_anotacoes(conteudo, matricula_agente, fone_cliente)
values('$agtAnota', '$matricula', '$agtFone')";
$query = "INSERT INTO pbx_anotacoes(conteudo, matricula_agente, fone_cliente, org_id) VALUES('$agtAnota', '$matricula', '$agtFone', $org_id)";
$result = pg_query($dbcon, $query);
if ($result) {
$agtAnota = "";
@ -46,11 +45,10 @@ if (!is_date($dataIni)) {
}
}
$pesquisa = PesquisaFone($dbcon, $agtFone);
if (empty($pesquisa))
if (empty($pesquisa)) {
$pesquisa = "<tr><td colspan=4>Nenhum registro encontrado!</td></tr>";
}
$cor = !$msg || stripos($msg, 'sucesso') ? '#0000FF' : '#FF0000';
$smarty->assign("AnotaFone", $agtFone);
@ -66,52 +64,67 @@ $smarty->assign("prm_label_protoco_pesquisa", $_SESSION['prm_label_protoco_pesqu
$smarty->assign("prm_label_protoco_texto", $_SESSION['prm_label_protoco_texto']);
$smarty->assign("prm_label_protoco_grid", $_SESSION['prm_label_protoco_grid']);
if (IsSuper()) {
$agentes = GetAgentesAnotacoes($listaAgente);
$agentes = GetAgentesAnotacoes($dbcon, $listaAgente);
$smarty->assign("listaAgente", $agentes);
}
DispLogin($smarty);
function PesquisaFone($db, $num) {
function PesquisaFone($db, $num)
{
global $listaAgente, $dataIni, $dataFim;
$org_id = GetOrganizacao();
$mat = IsSuper() ? $listaAgente : GetMatricula();
$query = "select a.id_text, a.conteudo, a.matricula_agente, a.fone_cliente, a.data, b.apelido from pbx_anotacoes a, pbx_usuarios b where b.matricula = a.matricula_agente::text ";
$query .= $mat ? " and a.matricula_agente::text = '$mat' " : "";
$query .= sprintf(" and data::date >= %s and data::date <= %s ", FormatDtMssql($dataIni, true), FormatDtMssql($dataFim, true));
$query .= " and fone_cliente like '%" . $num . "%'";
$query .= " order by b.apelido, a.data desc";
$query = "SELECT a.id_text, a.conteudo, a.matricula_agente, a.fone_cliente, a.data, b.apelido
FROM pbx_anotacoes a, pbx_usuarios b
WHERE b.matricula = a.matricula_agente::text ";
$query .= $mat ? " AND a.matricula_agente::text = '$mat' " : "";
$query .= sprintf(" AND data::date >= %s AND data::date <= %s ", FormatDtMssql($dataIni, true), FormatDtMssql($dataFim, true));
if ($num) {
$query .= " AND fone_cliente LIKE '%" . $num . "%'";
}
$query .= " AND org_id = $org_id ";
$query .= " ORDER BY b.apelido, a.data desc";
$result = pg_query($db, $query);
//if(IsAdmin()) echo $query;
$linha = "";
while (($result) && ($row = pg_fetch_array($result))) {
$fone = GetAnotacoesKey() ? FormataFone($row["fone_cliente"]) : $row["fone_cliente"];
$content = $row["conteudo"];
$matAgt = $row["matricula_agente"] . '-' . $row["apelido"];
$data = date('d/m/Y', strtotime($row["data"]));
$imgDel = GetLinkFormDelete($row["id_text"], 'DeletaAnotacao');
$linha .= "<tr>
<td align=left>$data</td>";
$linha .= "<tr><td align=left>$data</td>";
if (IsSuper()) {
$linha .= " <td align=left>$matAgt</td>";
$linha .= "<td align=left>$matAgt</td>";
}
$linha .= " <td align=left>$fone</td>
<td align=left>$content</td>
<td align=center>$imgDel</td>
</tr>";
$linha .= "<td align=left>$fone</td>
<td align=left>$content</td>
<td align=center>$imgDel</td>
</tr>";
}
$colspan = IsSuper() ? 4 : 3;
if (empty($linha))
if (empty($linha)) {
$linha = "<tr><td colspan=\"$colspan\">Nenhum registro encontrado!</td></tr>";
}
return $linha;
}
function DispLogin($smarty) {
function DispLogin($smarty)
{
$smarty->display('callcenter/agente/agenteAnota.tpl');
}
function GetAgentesAnotacoes($matricula) {
$query = "select id, apelido, nome, matricula from pbx_usuarios where delete_ = 0 and apelido not in('sinccontasenha' )"; //'admin',
$result = pg_query($query);
function GetAgentesAnotacoes($dbcon, $matricula)
{
$query = "SELECT id, apelido, nome, matricula
FROM pbx_usuarios
WHERE delete_ = 0
AND apelido
NOT IN('sinccontasenha')"; //'admin',
$result = pg_query($dbcon, $query);
$sel = $matricula == "0" ? ' Selected="selected" ' : '';
$item = "<option value=\"0\"$sel>Todos</option>\n";
while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) {
@ -122,5 +135,3 @@ function GetAgentesAnotacoes($matricula) {
}
return $item;
}
?>

2
agente/agentert.php

@ -1198,7 +1198,7 @@ function EntraPausa($db, $codMotivo)
GetExcept("Falha ao colocar o agente em pausa na central!");
}
$query = "select canal, canal_transfer, canal_agente, ramal, nome, dac, uniqueid, status from pbx_supervisor_agentes where matricula = '$matricula'";
$query = "SELECT canal, canal_transfer, canal_agente, ramal, nome, dac, uniqueid, status FROM pbx_supervisor_agentes WHERE matricula = '$matricula'";
$result = pg_query($db, $query);
if ($result) {
$row = @pg_fetch_array($result);

366
agente/funcoesAgente.php

@ -1,13 +1,14 @@
<?php
define('CONF_PATH_LOG_DISCADORCLIENT', '/var/log/asterisk/discadorclient.log');
define('CONF_PATH_LOG_DISCADORCLIENT', '/var/log/asterisk/discadorclient.log');
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
function GetQryStatusChamadas($useAgt = true) {
function GetQryStatusChamadas($useAgt = true)
{
$matricula = $_SESSION["SSmatriculaUser"];
$dac = $_SESSION[AGT_DAC_CONECT];
$query = "SELECT fila
@ -45,13 +46,15 @@ function GetQryStatusChamadas($useAgt = true) {
return $query;
}
function GetQryInfoGeral() {
function GetQryInfoGeral()
{
$dac = $_SESSION[AGT_DAC_CONECT_DESC];
return "select abandonadas, espera from pbx_supervisor_dacs where upper(trim(dac)) = upper(trim('$dac')) ";
//atendidas, abandonadas, espera, (tempo_espera * (interval '1 second')) as tempo_espera, cast(percentual_nivel_servico as varchar) || '%' as tempo_nivel_servico
}
function GetQryInfoChamadasCorrente() {
function GetQryInfoChamadasCorrente()
{
$matricula = $_SESSION["SSmatriculaUser"];
//$dac = $_SESSION[AGT_DAC_CONECT_DESC];
return "select ramal, matricula, nome, (LOCALTIMESTAMP(0) - tempo_login) as tempo_login, modo_atendimento, origem_destino, status, (LOCALTIMESTAMP(0) - duracao) as duracao,
@ -59,11 +62,13 @@ function GetQryInfoChamadasCorrente() {
where matricula = '$matricula' ";
}
function DispRel($smarty, $tpl) {
function DispRel($smarty, $tpl)
{
$smarty->display($tpl);
}
function GetStChamada($db, &$tme, &$tma, &$atd, &$fila) {
function GetStChamada($db, &$tme, &$tma, &$atd, &$fila)
{
$result = pg_query($db, GetQryStatusChamadas());
$st = @pg_num_rows($result) > 0;
$dados = @pg_fetch_array($result);
@ -73,7 +78,8 @@ function GetStChamada($db, &$tme, &$tma, &$atd, &$fila) {
$fila = $dados["fila"];
}
function GetInfoChamada($db, &$stAgtAtende, &$lgd, &$dura, &$qtFila, &$fone, &$abd, &$unqId) {
function GetInfoChamada($db, &$stAgtAtende, &$lgd, &$dura, &$qtFila, &$fone, &$abd, &$unqId)
{
$result = pg_query($db, GetQryInfoGeral());
$st = @pg_num_rows($result) > 0;
@ -96,7 +102,8 @@ function GetInfoChamada($db, &$stAgtAtende, &$lgd, &$dura, &$qtFila, &$fone, &$a
$_SESSION[RAMAL_DESTINO] = $fone;
}
function UpdateLogoff($db) {
function UpdateLogoff($db)
{
$idLogoff = $_SESSION[AGT_ID_LOGIN];
$matricula = GetMatricula();
@ -122,7 +129,8 @@ function UpdateLogoff($db) {
}
}
function UpdatePausa($db) {
function UpdatePausa($db)
{
if (AgentePausa()) {
$idPausa = $_SESSION[AGT_ID_PAUSA];
@ -134,7 +142,8 @@ function UpdatePausa($db) {
}
}
function AgentePausa() {
function AgentePausa()
{
$matricula = GetMatricula();
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(status) = 'PAUSA' ";
$result = pg_query($query);
@ -142,7 +151,8 @@ function AgentePausa() {
return $row[0];
}
function AgenteLivre() {
function AgenteLivre()
{
$matricula = GetMatricula();
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(status) = 'LIVRE' ";
$result = pg_query($query);
@ -150,7 +160,8 @@ function AgenteLivre() {
return $row[0];
}
function AgtAtivaControles($status) {
function AgtAtivaControles($status)
{
$arControlesAgt = array();
$arControlesAgt["btConDac"] = false;
$arControlesAgt["listaDacs"] = false;
@ -198,7 +209,8 @@ function AgtAtivaControles($status) {
return $arControlesAgt;
}
function ConvertStatusStr($status) {
function ConvertStatusStr($status)
{
$status = strtoupper($status);
if ($status == "LIVRE")
@ -214,11 +226,13 @@ function ConvertStatusStr($status) {
return AGT_STATUS_OFF;
}
function SetLoginMotivo($motivoLogin) {
function SetLoginMotivo($motivoLogin)
{
$_SESSION['PAUSA_LOGIN'] = $motivoLogin;
}
function GetMotivoPausa() {
function GetMotivoPausa()
{
global $dbcon;
$matricula = GetMatricula();
$query = "SELECT motivo_pausa FROM pbx_supervisor_agentes WHERE matricula = '$matricula'";
@ -227,11 +241,13 @@ function GetMotivoPausa() {
return strtoupper($row['motivo_pausa']);
}
function GetPausaLogin() {
function GetPausaLogin()
{
return $_SESSION['PAUSA_LOGIN'];
}
function CarregaMunicipios($db) {
function CarregaMunicipios($db)
{
$query = "select uf from pbx_uf order by 1";
$result = pg_query($db, $query);
@ -293,7 +309,8 @@ if(ufValue == 0)munId = 0;
$GLOBALS["jsStartup"][] = $ufs;
}
function CarregaClassificacao($db, $dacSel) {
function CarregaClassificacao($db, $dacSel)
{
$query = " SELECT distinct c.id_dac, a.clas_id, a.clas_descricao
FROM pbx_classifica_atendimento a, pbx_classifica_item b, pbx_classifica_dacs c
where b.clas_id = a.clas_id
@ -369,7 +386,8 @@ function CarregaClassificacao($db, $dacSel) {
return $clas;
}
function ___GetItem($db, $idClas, $idItem) {
function ___GetItem($db, $idClas, $idItem)
{
$query = " SELECT clit_id, clit_descricao FROM pbx_classifica_item where clas_id = $idClas and clit_status = 1 order by 2";
$result = pg_query($db, $query);
$clas = "<select name=\"listaItem\" style=\"width:169px;\">";
@ -389,7 +407,8 @@ function ___GetItem($db, $idClas, $idItem) {
return $clas;
}
function ConectarDac() {
function ConectarDac()
{
/*
* Verifica se o usuário clicou no botao desconectar.
*/
@ -408,7 +427,8 @@ function ConectarDac() {
return !$row[0];
}
function GetAgenteDisponivelFila() {
function GetAgenteDisponivelFila()
{
/*
* Retorna true se o usuario não estiver conectado.
*/
@ -422,7 +442,8 @@ function GetAgenteDisponivelFila() {
return $row[0] ? true : false;
}
function DesconectarDac() {
function DesconectarDac()
{
/*
* Verifica se o usuário clicou no botao desconectar.
*/
@ -439,17 +460,18 @@ function DesconectarDac() {
return $row[0];
}
function SairDePausa() {
function SairDePausa()
{
return isset($_POST["btPausa"]) && AgentePausa();
//return isset($_POST["btPausa"]) && $_SESSION[SS_PAUSA_AGENTE];
}
function RegistraLogAgente($metodo, $msg, $ex = null) {
function RegistraLogAgente($metodo, $msg, $ex = null)
{
$matricula = GetMatricula();
$log[] = "/****************************** INICIO ****************************";
$log[] = sprintf("Matricula: %s", $matricula);
$log[] = sprintf("Metodo: %s", $metodo);
;
$log[] = sprintf("Metodo: %s", $metodo);;
$log[] = sprintf("Data: %s", Date("d-m-Y H:i:s"));
$log[] = sprintf("Msg: %s", $msg);
if ($ex) {
@ -461,32 +483,35 @@ function RegistraLogAgente($metodo, $msg, $ex = null) {
RegistraLog($log, $file);
}
function ArrayToStr($ar) {
function ArrayToStr($ar)
{
$strLog = '';
$strLog = '';
foreach ($ar as $key => $value) {
foreach ($ar as $key => $value) {
if (is_array($value)) {
$strLog .= !$strLog ? ("{$key}{" . ArrayToStr($value) . "}" ) : ("|{$key}{" . ArrayToStr($value) . "}");
} else {
$strLog .= !$strLog ? "{$key}: $value" : "|{$key}: $value";
}
if (is_array($value)) {
$strLog .= !$strLog ? ("{$key}{" . ArrayToStr($value) . "}") : ("|{$key}{" . ArrayToStr($value) . "}");
} else {
$strLog .= !$strLog ? "{$key}: $value" : "|{$key}: $value";
}
return $strLog;
}
return $strLog;
}
function LogAgente($modulo, $msg, $data = true) {
global $detalhaLog;
if ($detalhaLog) {
if ($data) {
$msg .= " Data:[" . ArrayToStr($_REQUEST) . "]\n";
}
RegistraLogAgente($modulo, $msg);
function LogAgente($modulo, $msg, $data = true)
{
global $detalhaLog;
if ($detalhaLog) {
if ($data) {
$msg .= " Data:[" . ArrayToStr($_REQUEST) . "]\n";
}
RegistraLogAgente($modulo, $msg);
}
}
function EntrarPausa() {
function EntrarPausa()
{
return isset($_POST["btPausa"]) && (!AgentePausa());
}
@ -494,11 +519,13 @@ function EntrarPausa() {
* Funçoes para o alerta sonoro na classificação obrigatoria.
*/
function SetAlertAgente($stAlerta) {
function SetAlertAgente($stAlerta)
{
$_SESSION['SSstartAlert'] = $stAlerta;
}
function GetAlertAgente() {
function GetAlertAgente()
{
if (!isset($_SESSION['SSstartAlert'])) {
return false;
}
@ -506,11 +533,13 @@ function GetAlertAgente() {
return $_SESSION['SSstartAlert'];
}
function SetAlertOcupado($status) {
function SetAlertOcupado($status)
{
$_SESSION["SSagenteOcupdo"] = $status;
}
function GetAlertOcupado() {
function GetAlertOcupado()
{
if (!isset($_SESSION['SSagenteOcupdo'])) {
return false;
}
@ -518,11 +547,13 @@ function GetAlertOcupado() {
return $_SESSION["SSagenteOcupdo"];
}
function SetAlertTempo($tempo) {
function SetAlertTempo($tempo)
{
$_SESSION['SStempoAlert'] = $tempo;
}
function GetAlertTempo() {
function GetAlertTempo()
{
if (!isset($_SESSION['SStempoAlert'])) {
return false;
}
@ -534,7 +565,8 @@ function GetAlertTempo() {
* Funcoes para o Discador-X.
*/
function HabilitaDiscador() {
function HabilitaDiscador()
{
return $_SESSION["prm_use_discador"];
}
@ -542,11 +574,13 @@ function HabilitaDiscador() {
* Usa o cliente em uma nova janela quando true.
*/
function AgenteNovaJanela() {
function AgenteNovaJanela()
{
return $_SESSION["prm_agente_nova_janela"];
}
function GetCampanhaDiscador($idDac) {
function GetCampanhaDiscador($idDac)
{
if (!HabilitaDiscador()) {
return false;
@ -574,7 +608,8 @@ function GetCampanhaDiscador($idDac) {
return $dados[0];
}
function AtualizaNumDiscador($db, $contfId, $numeroDiscar) {
function AtualizaNumDiscador($db, $contfId, $numeroDiscar)
{
global $dac;
if (!$contfId)
return true;
@ -603,15 +638,17 @@ function AtualizaNumDiscador($db, $contfId, $numeroDiscar) {
return true;
}
function LmpaUidAgente($db, $matricula) {
function LmpaUidAgente($db, $matricula)
{
$query = "update pbx_supervisor_agentes set uniqueid2 = '' where matricula = %s";
$query = sprintf($query, QuotedStr($matricula));
return pg_query($db, $query) ? true : false;
}
function GetNumDiscadoStatus($conf_id) {
function GetNumDiscadoStatus($conf_id)
{
$matricula = GetMatricula();
$query = "select a.conf_id, a.cont_id, a.conf_fone, a.conf_status
$query = "select a.conf_id, a.cont_id, a.conf_fone, a.conf_status
from pbx_campanha_contato_fone a, pbx_campanha_operacao b
where b.cont_id = a.cont_id
and b.matricula = '%s'
@ -633,13 +670,14 @@ function GetNumDiscadoStatus($conf_id) {
return false;
}
function AtivaNumeroDiscagem($db, $matricula) {
function AtivaNumeroDiscagem($db, $matricula)
{
global $dac;
if (!GetPendenciaDiscador($db, true)) {
FechaRegistroDiscaor($db);
}
if (!GetPendenciaDiscador($db, true)) {
FechaRegistroDiscaor($db);
}
$dadosDiscador = GetDadosDiscador($dac, 0);
if ($dadosDiscador !== false) {
$query = "update pbx_campanha_operacao set carrega_fone = 0 where cmpo_id = %s and matricula = %s";
@ -653,7 +691,8 @@ function GetNumDiscadoStatus($conf_id) {
}
}
function SetDispoDiscador($status) {
function SetDispoDiscador($status)
{
/*
* Quando o agente inicia a operação de discagem o agente é colocado antes como indisponivel
* para fila, o status atual é guardado e restaurado qdo finalizada a operacao de discagem.
@ -661,11 +700,13 @@ function SetDispoDiscador($status) {
$_SESSION['SSDispoDiscador'] = $status;
}
function GetDispoDiscador() {
function GetDispoDiscador()
{
return $_SESSION['SSDispoDiscador'];
}
function GetDadosDiscador($dac, $idCampanha = 0) {
function GetDadosDiscador($dac, $idCampanha = 0)
{
$inTran = 0;
$dadosCampanha = array();
/*
@ -696,12 +737,12 @@ function GetDadosDiscador($dac, $idCampanha = 0) {
return false;
}
$sql = "SELECT cmp_seletiva FROM pbx_campanha WHERE cmp_id = {$idCampanha}";
$res = pg_query($sql);
$cmpExclusiva = pg_fetch_assoc($res);
if ($cmpExclusiva['cmp_seletiva'] == 1) {
$cmplCamp .= " AND conf_matricula_exclusiva = '{$matricula}' ";
}
$sql = "SELECT cmp_seletiva FROM pbx_campanha WHERE cmp_id = {$idCampanha}";
$res = pg_query($sql);
$cmpExclusiva = pg_fetch_assoc($res);
if ($cmpExclusiva['cmp_seletiva'] == 1) {
$cmplCamp .= " AND conf_matricula_exclusiva = '{$matricula}' ";
}
/*
* Procura por um registro disponivel para discagem.
@ -785,15 +826,16 @@ function GetDadosDiscador($dac, $idCampanha = 0) {
}
function ocultarDadosAgente($dadosCampanha){
function ocultarDadosAgente($dadosCampanha)
{
$campoOcultar = array();
foreach($dadosCampanha as $key => $info){
foreach ($dadosCampanha as $key => $info) {
ocultarCampo($info, $key, $campoOcultar);
}
foreach($campoOcultar as $key => $dt){
if(strpos('disp', $key) !== false){
foreach ($campoOcultar as $key => $dt) {
if (strpos('disp', $key) !== false) {
$key = str_replace('disp', 'cont', $key);
}
$dadosCampanha[$key] = ocultarLGPD($key, $dt);
@ -801,12 +843,34 @@ function ocultarDadosAgente($dadosCampanha){
return $dadosCampanha;
}
function RegistraContatoAgente($matricula, $dadosCampanha) {
function RegistraContatoAgente($matricula, $dadosCampanha)
{
$query = "insert "
. " into pbx_campanha_operacao(matricula,cmp_id,list_id,cont_id,conf_id,cmp_descricao,list_nome,cont_identificador,cont_param1,cont_param2,"
. "cont_param3,cont_param4,cont_param5,disp_param1,disp_param2,disp_param3,disp_param4,disp_param5,conf_fone,lista_fones_discador, cmpo_status)"
. " values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,'0')";
$query = sprintf($query, QuotedStr($matricula), QuotedStr($dadosCampanha["cmp_id"]), QuotedStr($dadosCampanha["list_id"]), QuotedStr($dadosCampanha["cont_id"]), QuotedStr($dadosCampanha["conf_id"]), QuotedStr($dadosCampanha["cmp_descricao"]), QuotedStr($dadosCampanha["list_nome"]), QuotedStr($dadosCampanha["cont_identificador"]), QuotedStr($dadosCampanha["cont_param1"]), QuotedStr($dadosCampanha["cont_param2"]), QuotedStr($dadosCampanha["cont_param3"]), QuotedStr($dadosCampanha["cont_param4"]), QuotedStr($dadosCampanha["cont_param5"]), QuotedStr($dadosCampanha["disp_param1"]), QuotedStr($dadosCampanha["disp_param2"]), QuotedStr($dadosCampanha["disp_param3"]), QuotedStr($dadosCampanha["disp_param4"]), QuotedStr($dadosCampanha["disp_param5"]), QuotedStr($dadosCampanha["conf_fone"]), QuotedStr($dadosCampanha["lista_fones_discador"])
. " into pbx_campanha_operacao(matricula,cmp_id,list_id,cont_id,conf_id,cmp_descricao,list_nome,cont_identificador,cont_param1,cont_param2,"
. "cont_param3,cont_param4,cont_param5,disp_param1,disp_param2,disp_param3,disp_param4,disp_param5,conf_fone,lista_fones_discador, cmpo_status)"
. " values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,'0')";
$query = sprintf(
$query,
QuotedStr($matricula),
QuotedStr($dadosCampanha["cmp_id"]),
QuotedStr($dadosCampanha["list_id"]),
QuotedStr($dadosCampanha["cont_id"]),
QuotedStr($dadosCampanha["conf_id"]),
QuotedStr($dadosCampanha["cmp_descricao"]),
QuotedStr($dadosCampanha["list_nome"]),
QuotedStr($dadosCampanha["cont_identificador"]),
QuotedStr($dadosCampanha["cont_param1"]),
QuotedStr($dadosCampanha["cont_param2"]),
QuotedStr($dadosCampanha["cont_param3"]),
QuotedStr($dadosCampanha["cont_param4"]),
QuotedStr($dadosCampanha["cont_param5"]),
QuotedStr($dadosCampanha["disp_param1"]),
QuotedStr($dadosCampanha["disp_param2"]),
QuotedStr($dadosCampanha["disp_param3"]),
QuotedStr($dadosCampanha["disp_param4"]),
QuotedStr($dadosCampanha["disp_param5"]),
QuotedStr($dadosCampanha["conf_fone"]),
QuotedStr($dadosCampanha["lista_fones_discador"])
);
$result = pg_query($query);
@ -817,7 +881,8 @@ function RegistraContatoAgente($matricula, $dadosCampanha) {
return GetCurrVal('pbx_campanha_operacao');
}
function GetFonesContato($contId, $value) {
function GetFonesContato($contId, $value)
{
global $sZListaFones;
$lista = sprintf('<select name="ListaFones" type="text" id="ListaFones" style="%s" onchange="SetFoneDiscador();">', $sZListaFones);
/*
@ -837,18 +902,30 @@ function GetFonesContato($contId, $value) {
return $lista;
}
function GetStatusDiscador($value, $cmpId = 0) {
function GetStatusDiscador($value, $cmpId = 0)
{
$lista = '';
$org_id = GetOrganizacao();
/*
* Pega a lista de status da operação.
*/
$query = "select ctst_id, ctst_nome from pbx_campanha_contato_status where ctst_status = 1 and not exists(select '' from pbx_status_contato_campanha where cmp_id = '{$cmpId}')
union
select a.ctst_id, a.ctst_nome from pbx_campanha_contato_status a, pbx_status_contato_campanha b where b.ctst_id = a.ctst_id and b.cmp_id = '{$cmpId}' and a.ctst_status = 1 order by ctst_nome;";
$query = "SELECT ctst_id, ctst_nome
FROM pbx_campanha_contato_status
WHERE ctst_status = 1
AND NOT EXISTS(SELECT '' FROM pbx_status_contato_campanha WHERE cmp_id = '{$cmpId}')
AND org_id = $org_id
UNION
SELECT a.ctst_id, a.ctst_nome
FROM pbx_campanha_contato_status a, pbx_status_contato_campanha b
WHERE b.ctst_id = a.ctst_id
AND b.cmp_id = '{$cmpId}'
AND a.ctst_status = 1
AND a.org_id = $org_id
ORDER BY ctst_nome;";
$result = pg_query($query);
$sel = $value ? " selected" : "";
$lista = "<option value='' $sel>---------------</option>";
$lista = "<option value='' $sel>---------------</option>";
while ($dados = @pg_fetch_row($result)) {
@ -862,7 +939,8 @@ select a.ctst_id, a.ctst_nome from pbx_campanha_contato_status a, pbx_status_con
return $lista;
}
function GetDadosIntegracao($dadosIntegracao) {
function GetDadosIntegracao($dadosIntegracao)
{
$arLabels = array('disp_param0', 'disp_param1', 'disp_param2', 'disp_param3', 'disp_param4', 'disp_param5');
$arValuesId = array('cont_identificador', 'cont_param1', 'cont_param2', 'cont_param3', 'cont_param4', 'cont_param5');
@ -891,7 +969,8 @@ function GetDadosIntegracao($dadosIntegracao) {
return $arDados;
}
function RealizaConsultaIntegracao() {
function RealizaConsultaIntegracao()
{
include '/var/lib/asterisk/scripts/integracao/localDataBase.php';
$patScript = "/var/lib/asterisk/scripts/integracao/custom/";
@ -919,7 +998,7 @@ function RealizaConsultaIntegracao() {
$celular = explode(',', $cliente['celular']);
$numeroCliente = array(
soNumero($celular[0]),
soNumero($celular[0]),
soNumero($telefone[0])
);
@ -940,65 +1019,66 @@ function RealizaConsultaIntegracao() {
}
}
function ClassificacaoAudioEscuta($audioFone) {
$cmd = array();
$resp = "";
if (strpos($audioFone, 'AUTO') !== false) {
$audioFone = explode('|', $audioFone)[1];
$cmd["Channel"] = sprintf('Local/%s@app-callcenter', GetRamalMonitorar(RAMAL_MONITOR_AUDIO));
} else {
$cmd["Channel"] = GetRamalMonitorar(CANAL_MONITOR_AUDIO);
}
function ClassificacaoAudioEscuta($audioFone)
{
$cmd = array();
$resp = "";
if (strpos($audioFone, 'AUTO') !== false) {
$audioFone = explode('|', $audioFone)[1];
$cmd["Channel"] = sprintf('Local/%s@app-callcenter', GetRamalMonitorar(RAMAL_MONITOR_AUDIO));
} else {
$cmd["Channel"] = GetRamalMonitorar(CANAL_MONITOR_AUDIO);
}
$cmd["Action"] = "Originate";
$cmd["Context"] = 'audio-escuta-apl';
$cmd["Exten"] = 's';
$cmd["Priority"] = '1';
$cmd["CallerID"] = GetRamalMonitorar(RAMAL_MONITOR_AUDIO);
$cmd["Variable"] = sprintf("AVISO=OK,AUDIO=%s", $audioFone);
$cmd["Action"] = "Originate";
$cmd["Context"] = 'audio-escuta-apl';
$cmd["Exten"] = 's';
$cmd["Priority"] = '1';
$cmd["CallerID"] = GetRamalMonitorar(RAMAL_MONITOR_AUDIO);
$cmd["Variable"] = sprintf("AVISO=OK,AUDIO=%s", $audioFone);
$retCmd = CommandoAmi($cmd);
if ($retCmd === false) {
$resp = "ERRO";
} else {
$retCmd = strtoupper(trim($retCmd));
$resp = $retCmd == 'OK' ? "OK" : "ERRO";
}
$retCmd = CommandoAmi($cmd);
if ($retCmd === false) {
$resp = "ERRO";
} else {
$retCmd = strtoupper(trim($retCmd));
$resp = $retCmd == 'OK' ? "OK" : "ERRO";
}
return $resp;
}
return $resp;
}
function GetClientOperacao($matricula)
{
$query = "SELECT cont_identificador FROM pbx_campanha_operacao WHERE cmpo_id = (SELECT max(cmpo_id)::INT FROM pbx_campanha_operacao WHERE matricula = '{$matricula}')";
$result = pg_query($query);
return pg_fetch_assoc($result);
}
function GetClientOperacao($matricula) {
$query = "SELECT cont_identificador FROM pbx_campanha_operacao WHERE cmpo_id = (SELECT max(cmpo_id)::INT FROM pbx_campanha_operacao WHERE matricula = '{$matricula}')";
function GetContidClient($contid, $uniqueid)
{
if ($uniqueid || $uniqueid != 'null') {
$query = "SELECT client_id
FROM pbx_campanha_operacao a
INNER JOIN pbx_cliente b ON a.cont_id = b.cont_id
WHERE a.cont_id = {$contid}
AND client_id NOT IN (SELECT client_id FROM pbx_cliente_audio x WHERE x.client_id = b.client_id) ";
$result = pg_query($query);
return pg_fetch_assoc($result);
}
$res = pg_fetch_assoc($result);
function GetContidClient($contid, $uniqueid) {
if ($uniqueid || $uniqueid != 'null') {
$query = "SELECT client_id
FROM pbx_campanha_operacao a
INNER JOIN pbx_cliente b ON a.cont_id = b.cont_id
WHERE a.cont_id = {$contid}
AND client_id NOT IN (SELECT client_id FROM pbx_cliente_audio x WHERE x.client_id = b.client_id) ";
$result = pg_query($query);
$res = pg_fetch_assoc($result);
if (!$res) {
return;
}
if (!$res) {
return;
}
$query = sprintf("INSERT INTO pbx_cliente_audio (client_id, uid) VALUES(%s, %s);", QuotedStr($res['client_id']), $uniqueid);
$result = pg_query($query);
$query = sprintf("INSERT INTO pbx_cliente_audio (client_id, uid) VALUES(%s, %s);", QuotedStr($res['client_id']), $uniqueid);
$result = pg_query($query);
GravaLog("INSERE CLIENTE AUDIO: QUERY: $query | DADOS: [uniqueid: $uniqueid] [contid: $contid] \n", CONF_PATH_LOG_DISCADORCLIENT);
if ($result) {
return true;
}
GravaLog("INSERE CLIENTE AUDIO: QUERY: $query | DADOS: [uniqueid: $uniqueid] [contid: $contid] \n", CONF_PATH_LOG_DISCADORCLIENT);
if ($result) {
return true;
}
return false;
}
?>
return false;
}

4
asterisk/etc_asterisk/editado_manual/extensions_padrao.conf

@ -1307,7 +1307,7 @@ exten => s,n,AGI(agente_pausa.php,${MATRICULA})
exten => s,n,AGI(${INTEGRACAO_ABD},${UNIQUEID},${IF($[${ISNULL(${DAC})}]?${FILA-ORIGEM}:${DAC})},${IF($[${ISNULL(${DESTINO-ORIGEM})}]?${BINA_RETORNO}:${DESTINO-ORIGEM})},${MATRICULA_RETORNO})
exten => s,n,MacroExit()
exten => s,n(consulta-agente),Set(EVENTO=$[COMPLETEAGENTRAMAL"])
exten => s,n(consulta-agente),Set(EVENTO=$["COMPLETEAGENTRAMAL"])
exten => s,n,Set(FIM_DIAL=$[${EPOCH}])
exten => s,n,Set(DURACAO=$[${FIM_DIAL} - ${INICIO_DIAL} - ${TEMPO_CHAMANDO}])
@ -1320,7 +1320,7 @@ exten => s,n(dialstatus),Goto(sw-3-${DIALSTATUS},10)
exten => s,n,Hangup()
exten => _sw-3-.,10,NoOp(don't know how to handle ${DIALSTATUS})
exten => _sw-3-.,10,NoOp(dont know how to handle ${DIALSTATUS})
exten => _sw-3-.,11,Goto(s,atualiza)
exten => sw-3-ANSWER,10,Noop(FIM_DIAL=${FIM_DIAL} - INICIO_DIAL=${INICIO_DIAL} - ANSWEREDTIME=${ANSWEREDTIME} - TEMPO_CHAMANDO = ${TEMPO_CHAMANDO})
exten => sw-3-ANSWER,n,Set(INICIO_ATENDIMENTO=${IF($[${ISNULL(${INICIO_ATENDIMENTO})}]?${DB(INICIO_ATENDIMENTO/${UNIQUEID})}:${INICIO_ATENDIMENTO})})

12
cadastros/organizacao/atribuirOrganizacao.php

@ -40,10 +40,10 @@ function GetUser($dbcon, $codSel, $infos, $idOrg)
$sel = "";
$infos['name'] = $infos['name'] . "inc";
$query = "SELECT DISTINCT id, apelido
$query = "SELECT DISTINCT id, apelido, matricula
FROM pbx_usuarios WHERE id
NOT IN (SELECT id_usuario FROM pbx_organizacao_usuarios WHERE id_organizacao = $idOrg)
AND id NOT IN (341,356,357,462,466,467);";
AND id NOT IN (342,341,356,357,462,466,467);";
$result = pg_query($dbcon, $query);
@ -51,7 +51,7 @@ function GetUser($dbcon, $codSel, $infos, $idOrg)
$lista = sprintf($lista, $infos['name'], ($infos['multiple'] ? "[]" : ""), $infos['name'], $infos['size'], $infos['width'], ($infos['multiple'] ? 'multiple="multiple"' : ''), "\n");
while ($row = pg_fetch_array($result)) {
$sel = ($codSel == $row["apelido"]) ? "selected" : "";
$lista .= "<option value=\"{$row["id"]}\" $sel>{$row["apelido"]}</option>\n";
$lista .= "<option value=\"{$row["id"]}\" $sel>{$row["apelido"]} [{$row["matricula"]}]</option>\n";
}
$lista .= "</select>\n";
return $lista;
@ -62,11 +62,11 @@ function GetEmpresaUser($dbcon, $codSel, $infos, $idOrg)
$sel = "";
$infos['name'] = $infos['name'] . "rm";
$query = "SELECT DISTINCT pu.id, pu.apelido
$query = "SELECT DISTINCT pu.id, pu.apelido, matricula
FROM pbx_usuarios pu
INNER JOIN pbx_organizacao_usuarios pou on pou.id_usuario = pu.id
INNER JOIN pbx_organizacao po on po.id = pou.id_organizacao
WHERE pu.id NOT IN (341,356,357,462,466,467)
WHERE pu.id NOT IN (342,341,356,357,462,466,467)
AND pu.id IN (SELECT id_usuario FROM pbx_organizacao_usuarios WHERE id_organizacao = {$idOrg});";
$result = pg_query($dbcon, $query);
@ -76,7 +76,7 @@ function GetEmpresaUser($dbcon, $codSel, $infos, $idOrg)
while (($row = @pg_fetch_array($result))) {
$sel = ($codSel == $row["id"]) ? "selected" : "";
$lista .= "<option value=\"{$row["id"]}\" $sel>{$row["apelido"]}</option>\n";
$lista .= "<option value=\"{$row["id"]}\" $sel>{$row["apelido"]} [{$row["matricula"]}]</option>\n";
}
$lista .= "</select>";
return $lista;

45
contacteFunc.php

@ -276,21 +276,23 @@ function GetPausa($dbcon, $mat, $verPausa = false)
* da pelo supervisor precisamos alimentar os parametro da sessao cor-
* rente entao $verPausa é definido como false.
*/
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$mat' and upper(status) = 'PAUSA'";
$query = "SELECT count(*) FROM pbx_supervisor_agentes WHERE matricula = '$mat' AND upper(status) = 'PAUSA'";
$result = pg_query($dbcon, $query);
$row = @pg_fetch_row($result);
$ret = $row[0];
if ($verPausa && ($ret == 0))
if ($verPausa && ($ret == 0)) {
return false;
else if ($verPausa)
} else if ($verPausa) {
return true;
}
if ($ret > 0) {
$query = "select id, id_motivo_pausa from pbx_eventos_agentes a
where matricula = '$mat'
and entrada_pausa is not null
and id = (select max(id) from pbx_eventos_agentes where matricula = a.matricula)";
$query = "SELECT id, id_motivo_pausa
FROM pbx_eventos_agentes a
WHERE matricula = '$mat'
AND entrada_pausa IS NOT NULL
AND id = (SELECT max(id) FROM pbx_eventos_agentes WHERE matricula = a.matricula)";
$result = pg_query($dbcon, $query);
$row = pg_fetch_row($result);
$_SESSION[AGT_ID_PAUSA] = $row[0];
@ -303,7 +305,7 @@ function GetPausa($dbcon, $mat, $verPausa = false)
function GetPausaDescricao($dbcon, $codigo)
{
$query = "select motivo from pbx_motivos_pausas where id = '$codigo'";
$query = "SELECT motivo FROM pbx_motivos_pausas WHERE id = '$codigo'";
$result = pg_query($dbcon, $query);
$row = pg_fetch_row($result);
return $row[0];
@ -311,7 +313,7 @@ function GetPausaDescricao($dbcon, $codigo)
function GetDacCod($dbcon, $dac)
{
$query = "select d.id from pbx_dacs d where upper(d.nome) = upper('$dac')";
$query = "SELECT d.id FROM pbx_dacs d WHERE upper(d.nome) = upper('$dac')";
$result = pg_query($dbcon, $query);
$row = pg_fetch_row($result);
$ret = $row[0];
@ -322,9 +324,9 @@ function GetDacPadraoAgente($dbcon, $getId = true)
{
$idUser = GetIdUser();
if (IsAdmin())
$query = "select * from pbx_dacs a where a.status = 'A' and exists(select '' from pbx_fila_grupos where id = a.id) order by 1 limit 1";
$query = "SELECT * FROM pbx_dacs a WHERE a.status = 'A' AND EXISTS(SELECT '' FROM pbx_fila_grupos WHERE id = a.id) ORDER BY 1 LIMIT 1";
else
$query = "select dac_padrao as id_dac, b.nome from pbx_usuarios a, pbx_dacs b where b.id = a.dac_padrao and a.id = $idUser ";
$query = "SELECT dac_padrao AS id_dac, b.nome FROM pbx_usuarios a, pbx_dacs b WHERE b.id = a.dac_padrao AND a.id = $idUser ";
//echo $query;
$result = pg_query($dbcon, $query);
$row = @pg_fetch_row($result);
@ -334,7 +336,7 @@ function GetDacPadraoAgente($dbcon, $getId = true)
function GetSiteDesc($dbcon, $id)
{
$query = "select d.descricao from pbx_sites d where id = $id";
$query = "SELECT d.descricao FROM pbx_sites d WHERE id = $id";
$result = pg_query($dbcon, $query);
$row = pg_fetch_row($result);
$ret = $row[0];
@ -344,6 +346,8 @@ function GetSiteDesc($dbcon, $id)
function GetMotivo($dbcon, $codMotivo, $disableb = "", $incTodos = 0, $incTpPausa = 0)
{
global $sZlistaMotivo;
$org_id = GetOrganizacao();
/*
* Carrega lista de pausas disponiveis por dac.
*/
@ -369,14 +373,15 @@ function GetMotivo($dbcon, $codMotivo, $disableb = "", $incTodos = 0, $incTpPaus
/*
* a pausa de login é adicionada na verificação pois não pode ser atribuida manualmente para um grupo.
*/
$query = "select a.id, upper(a.motivo) as motivo, a.produtiva from pbx_motivos_pausas a $mot $motAusente and a.flag = 1 " .
(UsePausaGrupo() ? "and id in(
select $idMotivoLogin union
select c.id from pbx_grupo a, pbx_grupo_usuario b, pbx_pausa_grupo_usuario c
where b.gp_id = a.gp_id
and c.gp_id = b.gp_id
and b.user_id = $idUsuario
)" : "") . " order by a.motivo";
$query = "SELECT a.id, upper(a.motivo) AS motivo, a.produtiva FROM pbx_motivos_pausas a $mot $motAusente AND a.flag = 1 AND org_id = $org_id " .
(UsePausaGrupo() ? "AND id IN(
SELECT $idMotivoLogin
UNION
SELECT c.id FROM pbx_grupo a, pbx_grupo_usuario b, pbx_pausa_grupo_usuario c
WHERE b.gp_id = a.gp_id
AND c.gp_id = b.gp_id
AND b.user_id = $idUsuario
)" : "") . " ORDER BY a.motivo";
$result = pg_query($dbcon, $query);
$sel = "";

41
include/util/funcoesApl.php

@ -2327,16 +2327,19 @@ function GetCaminhoProducao()
function GetPesquisaDisponivel($db, $dac)
{
$org_id = GetOrganizacao();
$sel = '';
$sel = "selected";
$item = "<option value=\"0\" $sel>------------</option>";
$query = "select distinct b.pl_id, b.pl_descricao
from pbx_pesquisa_liberacao_dacs a, pbx_pesquisa_liberacao b
where b.pl_id = a.pl_id
and a.id_dac = '$dac'
and ( (now()::date >= b.pl_data_inicio) or (b.pl_data_inicio is null))
and ( (now()::date <= b.pl_data_fim) or (b.pl_data_fim is null))
and b.pl_ativa = 1 order by 2";
$query = "SELECT DISTINCT b.pl_id, b.pl_descricao
FROM pbx_pesquisa_liberacao_dacs a, pbx_pesquisa_liberacao b
WHERE b.pl_id = a.pl_id
AND a.id_dac = '$dac'
AND ((NOW()::date >= b.pl_data_inicio) OR (b.pl_data_inicio IS NULL))
AND ((NOW()::date <= b.pl_data_fim) OR (b.pl_data_fim IS NULL))
AND b.pl_ativa = 1
AND b.org_id = $org_id
ORDER BY 2";
$result = pg_query($db, $query);
@ -2354,17 +2357,17 @@ function GetLinksFromLink($db, $link)
$idUser = GetIdUser();
if (!$link)
$link = 0;
$query = IsAdmin() ? " select distinct d.fun_id, d.fun_nome, d.fun_menu, d.fun_menu_text, d.fun_menu_url, d.fun_menu_img, d.fun_id_pai, (select count(*) from pbx_funcoes where fun_id_pai = d.fun_id) as filhos
from pbx_funcoes d
where fun_id_pai = $link order by 4" : "select *
from (
select distinct d.fun_id, d.fun_nome, d.fun_menu, d.fun_menu_text, d.fun_menu_url, d.fun_menu_img, d.fun_id_pai, (select count(*) from pbx_funcoes where fun_id_pai = d.fun_id) as filhos
from pbx_usuarios a, pbx_grupo_usuario b, pbx_grupo_funcoes c, pbx_funcoes d
where b.user_id = a.id
and c.gp_id = b.gp_id
and d.fun_id = c.fun_id
and a.id = coalesce($idUser, a.id) order by d.fun_id
) a where fun_id_pai = $link order by 4";
$query = IsAdmin() ? "SELECT DISTINCT d.fun_id, d.fun_nome, d.fun_menu, d.fun_menu_text, d.fun_menu_url, d.fun_menu_img, d.fun_id_pai, (SELECT count(*) FROM pbx_funcoes WHERE fun_id_pai = d.fun_id) AS filhos
FROM pbx_funcoes d
WHERE fun_id_pai = $link ORDER BY 4" : "SELECT *
FROM (
SELECT DISTINCT d.fun_id, d.fun_nome, d.fun_menu, d.fun_menu_text, d.fun_menu_url, d.fun_menu_img, d.fun_id_pai, (SELECT count(*) FROM pbx_funcoes WHERE fun_id_pai = d.fun_id) AS filhos
FROM pbx_usuarios a, pbx_grupo_usuario b, pbx_grupo_funcoes c, pbx_funcoes d
WHERE b.user_id = a.id
AND c.gp_id = b.gp_id
AND d.fun_id = c.fun_id
AND a.id = coalesce($idUser, a.id) ORDER BY d.fun_id
) a WHERE fun_id_pai = $link ORDER BY 4";
$result = pg_query($db, $query);
@ -2377,9 +2380,7 @@ function GetLinksFromLink($db, $link)
if ($row["filhos"] > 0)
$ret .= GetLinksFromLink($db, $row["fun_id"]);
}
$ret .= "</ul>\n";
return $ret;
}

46
seguranca/usuarioCad.php

@ -22,7 +22,7 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
} else if (isset($_GET["idUser"]) && $_GET["idUser"] > 0) {
$msgLogin = "disabled";
$acaoUser = 'Alterar';
$query = "SELECT id, nome, apelido, matricula, flag, coalesce(\"admin\", false)::int as adm , senha, coalesce(supervisor, false)::int as supervisor, coalesce(agente,false)::int as agente, email, coalesce(status,true)::int as status, penalidade, senha_dias_expira FROM pbx_usuarios \n";
$query = "SELECT id, nome, apelido, matricula, flag, coalesce(\"admin\", false)::int as adm , senha, coalesce(supervisor, false)::int as supervisor, coalesce(agente,false)::int as agente, email, coalesce(status,true)::int as status, penalidade, senha_dias_expira, org_padrao FROM pbx_usuarios \n";
$query .= "WHERE id = $idUser";
$result = pg_query($dbcon, $query);
@ -37,6 +37,7 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$userExpiraSenha = $dados["senha_dias_expira"];
$userStatus = $dados["status"] ? "checked" : "";
$penalidade = $dados["penalidade"];
$empPadrao = $dados['org_padrao'];
$dacAgente = GetIdDacPadrao($dbcon, $idUser);
$dacPadrao = GetDacs($dbcon, $dacAgente, "", 0, 1);
} else if ((isset($_POST["btGravar"]))) {
@ -53,7 +54,7 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$msg = "alert('Matrícula já cadastrada!');";
} else if ($_POST["userEmail"] && !is_email($_POST["userEmail"])) {
$msg = "alert('Email Inválido!');";
} else if (ExisteRegistro($dbcon, "pbx_usuarios", "email", (strtolower($_POST["userEmail"])), ($idUser ? "id <> {$idUser}" : ''))) {
} else if (ExisteRegistro($dbcon, "pbx_usuarios", "email", (strtolower($_POST["userEmail"])), ($idUser ? "a.id <> {$idUser}" : ''))) {
$msg = "alert('O e-mail informado já foi registrado!');";
} else if ($_POST["userExpiraSenha"] < 0) {
$msg = "alert('O tempo de expiração deve ser maior ou igual 0 'zero');";
@ -67,6 +68,7 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$acaoUser = $_POST["btGravar"];
$penalidade = $_POST["penalidade"] ? soNumero($_POST["penalidade"]) : "0";
$dacPadraoSel = $_POST["listaDacs"] ? $_POST["listaDacs"] : "0";
$empPadrao = $_POST["empPadrao"] ? $_POST["empPadrao"] : null;
$dacPadrao = GetDacs($dbcon, $dacPadraoSel, "", 0, 1);
$userExpiraSenha = $_POST["userExpiraSenha"] ? $_POST["userExpiraSenha"] : 0;
@ -74,9 +76,9 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$result = pg_query($dbcon, "begin");
if ($result) {
$userMatricula = GetMatriculaAgente($dbcon);
$query = "INSERT INTO pbx_usuarios(nome, apelido, matricula, flag, \"admin\", senha, supervisor, agente, email, status, penalidade, dac_padrao, check_vl, senha_dias_expira)
$query = "INSERT INTO pbx_usuarios(nome, apelido, matricula, flag, \"admin\", senha, supervisor, agente, email, status, penalidade, dac_padrao, check_vl, senha_dias_expira, org_padrao)
VALUES(%s, lower(%s), %s, %s, %s, md5(%s), %s, %s, %s, %s, %s, %s, md5(lower(%s)), %s) RETURNING id;";
$query = sprintf($query, QuotedStr($userNome), QuotedStr($userLogin), QuotedStr($userMatricula), 1, $userAdm == "checked" ? 'true' : 'false', QuotedStr($userPassword), $userSuper == "checked" ? 'true' : 'false', $userAgente == "checked" ? 'true' : 'false', QuotedStr($userEmail), $userStatus == "checked" ? 'true' : 'false', $penalidade, QuotedStr($dacPadraoSel), QuotedStr($userLogin), $userExpiraSenha);
$query = sprintf($query, QuotedStr($userNome), QuotedStr($userLogin), QuotedStr($userMatricula), 1, $userAdm == "checked" ? 'true' : 'false', QuotedStr($userPassword), $userSuper == "checked" ? 'true' : 'false', $userAgente == "checked" ? 'true' : 'false', QuotedStr($userEmail), $userStatus == "checked" ? 'true' : 'false', $penalidade, QuotedStr($dacPadraoSel), QuotedStr($userLogin), $userExpiraSenha, $empPadrao);
$result = pg_query($dbcon, $query);
if ($result) {
@ -133,7 +135,6 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$userPassword = "1234";
$penalidade = 0;
$jsStartup[] = "window.opener.ResetForm();";
// $jsStartup[] = 'window.close()';
} else {
$erroBd = @pg_last_error($dbcon);
pg_query($dbcon, "rollback");
@ -157,7 +158,8 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
status = %s,
penalidade = %s,
dac_padrao = %s,
senha_dias_expira = %s
senha_dias_expira = %s,
org_padrao = %s
WHERE id = %s ";
if ($updSenha) {
@ -168,7 +170,7 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$updSenha = '';
}
$query = sprintf($query, QuotedStr($userNome), $updSenha, QuotedStr($userEmail), $userStatus == "checked" ? 'true' : 'false', $penalidade, $dacPadraoSel, $userExpiraSenha, $idUser);
$query = sprintf($query, QuotedStr($userNome), $updSenha, QuotedStr($userEmail), $userStatus == "checked" ? 'true' : 'false', $penalidade, $dacPadraoSel, $userExpiraSenha, $empPadrao, $idUser);
$result = pg_query($dbcon, $query);
/*
@ -217,6 +219,7 @@ $smarty->assign("userStatus", $limpaVar ? "checked" : $userStatus);
$smarty->assign("acaoUser", $acaoUser);
$smarty->assign("idUser", $idUser);
$smarty->assign("dacPadrao", $dacPadrao);
$smarty->assign("empPadrao", getOrgPadrao($dbcon, $idUser));
$smarty->assign("penalidade", $penalidade ? $penalidade : "0");
$jsJQuery[] = "\$('#userLogin').change(function(){limpaEspaco(this);}) ";
@ -249,7 +252,7 @@ function ValidaPassword($password)
function VerificaEmailExists($dbcon, $email)
{
$query = "select email from pbx_usuarios where email = '$email';";
$query = "SELECT email FROM pbx_usuarios WHERE email = '$email';";
$result = pg_query($dbcon, $query);
$res = pg_fetch_assoc($result);
return $res;
@ -270,3 +273,30 @@ function getEmailUser($dbcon, $email, $id = null)
}
return true;
}
function getOrgPadrao($dbcon, $idUser)
{
$query = "SELECT a.id, a.nome, a.master, org_padrao
FROM pbx_organizacao a
INNER JOIN pbx_organizacao_usuarios b ON b.id_organizacao = a.id
INNER JOIN pbx_usuarios c ON c.id = b.id_usuario
WHERE b.id_usuario = {$idUser}
AND a.status = 1
ORDER BY a.id";
$result = pg_query($dbcon, $query);
$data = pg_fetch_all($result);
if (!$data) {
return null;
}
$select = "<select name='empPadrao' id='empPadrao'>";
foreach ($data as $v) {
$sel = $v['id'] == $v['org_padrao'] ? 'selected' : '';
$select .= "<option value='{$v['id']}' $sel>{$v['nome']}</option>";
}
$select .= "</select>";
return $select;
}

6
templates/seguranca/usuario.tpl

@ -36,6 +36,12 @@
<th align="left">Dac Padr&atilde;o</th>
<td>{$dacPadrao} </td>
</tr>
{if $empPadrao}
<tr>
<th align="left">Empresa Padrão</th>
<td>{$empPadrao}</td>
</tr>
{/if}
<tr>
<th align="left">Status</th>
<td>

Loading…
Cancel
Save