diff --git a/admin/iax.php b/admin/iax.php index 1a2a8a8..569ff92 100644 --- a/admin/iax.php +++ b/admin/iax.php @@ -1,193 +1,202 @@ - +
- - + - +
Ramal/Bina
+
" onkeyup="ConsultaRamal('index.php?idProg=10010&pbxRequest=1', event);" size="20"> + NOVO RAMAL IAX CONFIGURAÇÃO GLOBAL -
- +
- - - - - + + + + + - + 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); - ?> - - - - - - - - - - - - - - - - + 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); + ?> + + + + + + + + + + + + + + + + -
Id
Ramal Bina Contexto Dispositivo +
Id
+
Ramal Bina Contexto Dispositivo DepAçõesAções
- - - - - - - - - -
EDITAR O RAMAL:<?php echo $dados['nome']; ?>
APAGAR O RAMAL:<?php echo $dados['nome']; ?>
Este registro não pode ser apagado!
-
Não foram encontrados registros
+
+
+ + + + + + + + + +
+
EDITAR O RAMAL:<?php echo $dados['nome']; ?>
+
+
APAGAR O RAMAL:<?php echo $dados['nome']; ?>
+
+
Este registro não pode ser apagado!
+
+
+
Não foram encontrados registros
+
+ + + + + +
+
+
- + + \ No newline at end of file diff --git a/agente/agenteAgenda.php b/agente/agenteAgenda.php index 699d235..7b05040 100644 --- a/agente/agenteAgenda.php +++ b/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 = "Nenhum registro encontrado!"; @@ -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'); + } } - -?> diff --git a/agente/agenteAnota.php b/agente/agenteAnota.php index 8430c93..6acd653 100644 --- a/agente/agenteAnota.php +++ b/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 = "Nenhum registro encontrado!"; - +} $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 .= " - $data"; + $linha .= "$data"; if (IsSuper()) { - $linha .= " $matAgt"; + $linha .= "$matAgt"; } - $linha .= " $fone - $content - $imgDel - "; + $linha .= "$fone + $content + $imgDel + "; } $colspan = IsSuper() ? 4 : 3; - if (empty($linha)) + if (empty($linha)) { $linha = "Nenhum registro encontrado!"; - + } 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 = "\n"; while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) { @@ -122,5 +135,3 @@ function GetAgentesAnotacoes($matricula) { } return $item; } - -?> diff --git a/agente/agentert.php b/agente/agentert.php index 8c5f578..8329fba 100644 --- a/agente/agentert.php +++ b/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); diff --git a/agente/funcoesAgente.php b/agente/funcoesAgente.php index 07b5a63..cc0e3e0 100644 --- a/agente/funcoesAgente.php +++ b/agente/funcoesAgente.php @@ -1,13 +1,14 @@ 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 = "', $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 = ""; + $lista = ""; 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; +} diff --git a/asterisk/etc_asterisk/editado_manual/extensions_padrao.conf b/asterisk/etc_asterisk/editado_manual/extensions_padrao.conf index 0755267..cb5a748 100644 --- a/asterisk/etc_asterisk/editado_manual/extensions_padrao.conf +++ b/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})}) diff --git a/cadastros/organizacao/atribuirOrganizacao.php b/cadastros/organizacao/atribuirOrganizacao.php index b3acc28..3828cce 100644 --- a/cadastros/organizacao/atribuirOrganizacao.php +++ b/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 .= "\n"; + $lista .= "\n"; } $lista .= "\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 .= "\n"; + $lista .= "\n"; } $lista .= ""; return $lista; diff --git a/contacteFunc.php b/contacteFunc.php index a0f389c..f7eba22 100644 --- a/contacteFunc.php +++ b/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 = ""; diff --git a/include/util/funcoesApl.php b/include/util/funcoesApl.php index 5c7a25c..804d3dc 100755 --- a/include/util/funcoesApl.php +++ b/include/util/funcoesApl.php @@ -2327,16 +2327,19 @@ function GetCaminhoProducao() function GetPesquisaDisponivel($db, $dac) { + $org_id = GetOrganizacao(); $sel = ''; $sel = "selected"; $item = ""; - $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 .= "\n"; - return $ret; } diff --git a/seguranca/usuarioCad.php b/seguranca/usuarioCad.php index b043523..1fda228 100644 --- a/seguranca/usuarioCad.php +++ b/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 = ""; + + return $select; +} diff --git a/templates/seguranca/usuario.tpl b/templates/seguranca/usuario.tpl index 233fbff..b6342ca 100644 --- a/templates/seguranca/usuario.tpl +++ b/templates/seguranca/usuario.tpl @@ -36,6 +36,12 @@ Dac Padrão {$dacPadrao} + {if $empPadrao} + + Empresa Padrão + {$empPadrao} + + {/if} Status