@ -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,12 +670,13 @@ 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) {
@ -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);
}
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);
$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);
GravaLog("INSERE CLIENTE AUDIO: QUERY: $query | DADOS: [uniqueid: $uniqueid] [contid: $contid] \n", CONF_PATH_LOG_DISCADORCLIENT);
if ($result) {
return true;
}
if ($result) {
return true;
}
return false;
}
?>
return false;
}