if ($_SESSION["SS_CK_DISPO"] && LiberaPausa($db, $matricula)) {
if ($_SESSION["SS_CK_DISPO"] && LiberaPausa($db, $matricula)) {
@ -2606,7 +2606,7 @@ function GetChamadaClassificada() {
*/
*/
$matricula = GetMatricula();
$matricula = GetMatricula();
$query = "select '' from pbx_supervisor_agentes where matricula = '$matricula' and ( (chamada_classificado <> 0) or (coalesce(uniqueid2, '') = '') or (upper(motivo_pausa) in('AUSENTE', 'RECUSADA')))";
$query = "select '' from pbx_supervisor_agentes where matricula = '$matricula' and ( (chamada_classificado <> 0) or (coalesce(uniqueid2, '') = '') or (upper(motivo_pausa) in('AUSENTE', 'RECUSADA')))";
$result = @pg_query($query);
$result = pg_query($query);
if (!$result || !pg_num_rows($result)) {
if (!$result || !pg_num_rows($result)) {
return false;
return false;
@ -2624,7 +2624,7 @@ function GetCanalAudioClassificacao() {
function LiberaPausa($db, $matricula) {
function LiberaPausa($db, $matricula) {
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(motivo_pausa) = 'ACW'";
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(motivo_pausa) = 'ACW'";
if ($_SESSION["SS_CK_DISPO"] && LiberaPausa($db, $matricula)) {
if ($_SESSION["SS_CK_DISPO"] && LiberaPausa($db, $matricula)) {
@ -2588,7 +2588,7 @@ function GetChamadaClassificada() {
*/
*/
$matricula = GetMatricula();
$matricula = GetMatricula();
$query = "select '' from pbx_supervisor_agentes where matricula = '$matricula' and ( (chamada_classificado <> 0) or (coalesce(uniqueid2, '') = '') or (upper(motivo_pausa) in('AUSENTE', 'RECUSADA')))";
$query = "select '' from pbx_supervisor_agentes where matricula = '$matricula' and ( (chamada_classificado <> 0) or (coalesce(uniqueid2, '') = '') or (upper(motivo_pausa) in('AUSENTE', 'RECUSADA')))";
$result = @pg_query($query);
$result = pg_query($query);
if (!$result || !pg_num_rows($result)) {
if (!$result || !pg_num_rows($result)) {
return false;
return false;
@ -2606,7 +2606,7 @@ function GetCanalAudioClassificacao() {
function LiberaPausa($db, $matricula) {
function LiberaPausa($db, $matricula) {
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(motivo_pausa) = 'ACW'";
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(motivo_pausa) = 'ACW'";
$query = "select id_cliente,canal,substring(canal FROM (POSITION ('/' IN canal) + 1) FOR (POSITION ('@' IN canal) - 7)) as cont_fone from pbx_campanha_canais_discando where status = '0' order by id_canais desc limit 1";
$query = "select id_cliente,canal,substring(canal FROM (POSITION ('/' IN canal) + 1) FOR (POSITION ('@' IN canal) - 7)) as cont_fone from pbx_campanha_canais_discando where status = '0' order by id_canais desc limit 1";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$idcliente = $row['id_cliente'];
$idcliente = $row['id_cliente'];
$canal = $row['canal'];
$canal = $row['canal'];
@ -129,7 +129,7 @@ if ($TIPOLIGACAO == 'RECEPTIVA') {
if ($troncos_pa > '1') {
if ($troncos_pa > '1') {
$query = "select id_cliente,canal,substring(canal FROM (POSITION ('/' IN canal) + 1) FOR (POSITION ('@' IN canal) - 7)) as cont_fone from pbx_campanha_canais_discando where status = '0' and id_cliente <> '$ID' order by id_canais desc limit ($troncos_pa - 1)";
$query = "select id_cliente,canal,substring(canal FROM (POSITION ('/' IN canal) + 1) FOR (POSITION ('@' IN canal) - 7)) as cont_fone from pbx_campanha_canais_discando where status = '0' and id_cliente <> '$ID' order by id_canais desc limit ($troncos_pa - 1)";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
while ($row = @pg_fetch_array($result)) {
while ($row = @pg_fetch_array($result)) {
$idcliente = $row['id_cliente'];
$idcliente = $row['id_cliente'];
$canal = $row['canal'];
$canal = $row['canal'];
@ -153,7 +153,7 @@ if ($troncos_pa > '1') {
$query = "select cmp_aguarda_agente,cmp_id from pbx_campanha where cmp_status <> 0 and cmp_descricao = '$campanha'";
$query = "select cmp_aguarda_agente,cmp_id from pbx_campanha where cmp_status <> 0 and cmp_descricao = '$campanha'";
$query = "select retorno_cliente from pbx_integracao_reg where (reg_uniqueid = '$UNIQUEID' or reg_uniqueid_old = '$UNIQUEID_CALLBACK')";
$query = "select retorno_cliente from pbx_integracao_reg where (reg_uniqueid = '$UNIQUEID' or reg_uniqueid_old = '$UNIQUEID_CALLBACK')";
$result = @pg_query($query);
$result = pg_query($query);
if (pg_num_rows($result)) {
if (pg_num_rows($result)) {
$dados = pg_fetch_array($result);
$dados = pg_fetch_array($result);
$identificador = $dados['retorno_cliente'];
$identificador = $dados['retorno_cliente'];
@ -149,7 +149,7 @@ if (pg_num_rows($result)) {
* Modo de atendimento
* Modo de atendimento
*/
*/
$query = "select upper(a.modo_atendimento) as modo_atendimento, a.ramal, b.id as fila_id, a.canal_agente from pbx_supervisor_agentes a, pbx_dacs b where b.nome = a.dac and matricula = '$MATRICULA'";
$query = "select upper(a.modo_atendimento) as modo_atendimento, a.ramal, b.id as fila_id, a.canal_agente from pbx_supervisor_agentes a, pbx_dacs b where b.nome = a.dac and matricula = '$MATRICULA'";
$result = @pg_query($query);
$result = pg_query($query);
$dados = pg_fetch_array($result);
$dados = pg_fetch_array($result);
$automatico = $dados[0] != 'MANUAL';
$automatico = $dados[0] != 'MANUAL';
$ramalAgente = $dados['ramal'];
$ramalAgente = $dados['ramal'];
@ -180,7 +180,7 @@ if ($MATRICULAORIGEM) {
}
}
$query = "select itgm_id from pbx_integracao_reg a, pbx_integracao_metodo b where b.itgm_id_pai = a.reg_id_metodo and b.evento = 3 and a.reg_uniqueid = '$UNIQUEID'";
$query = "select itgm_id from pbx_integracao_reg a, pbx_integracao_metodo b where b.itgm_id_pai = a.reg_id_metodo and b.evento = 3 and a.reg_uniqueid = '$UNIQUEID'";
$result = @pg_query($query);
$result = pg_query($query);
write($query);
write($query);
if (pg_num_rows($result)) {
if (pg_num_rows($result)) {
@ -200,13 +200,13 @@ if (pg_num_rows($result)) {
write($str);
write($str);
@exec($str);
@exec($str);
$query = "update pbx_integracao_reg set reg_ramal = '$ramalAgente' where reg_uniqueid = '$UNIQUEID'";
$query = "update pbx_integracao_reg set reg_ramal = '$ramalAgente' where reg_uniqueid = '$UNIQUEID'";
$result = @pg_query($query);
$result = pg_query($query);
}
}
//Identifica o ramal que atendeu a fila
//Identifica o ramal que atendeu a fila
//JA FOI IDENTIFICADO NO INICIO DO SCRIPT ATRAVES DA VARIAVEL MEMBERINTERFACE POIS UTILIZA NA VerificaClassificacao
//JA FOI IDENTIFICADO NO INICIO DO SCRIPT ATRAVES DA VARIAVEL MEMBERINTERFACE POIS UTILIZA NA VerificaClassificacao
//$query = "select ramal from pbx_supervisor_agentes where matricula = '$MATRICULA' and dac = '$fila'";
//$query = "select ramal from pbx_supervisor_agentes where matricula = '$MATRICULA' and dac = '$fila'";
//$result = @pg_query($query);
//$result = pg_query($query);
//$dados = pg_fetch_row($result);
//$dados = pg_fetch_row($result);
//$RAMAL = $dados[0];
//$RAMAL = $dados[0];
@ -218,7 +218,7 @@ if (!$RAMAL) {
}
}
$query = "insert into ast_bilhetes_complemento (uniqueid2,direcao,destino) values ('$UNIQUEID','fila-ramal','$RAMAL')";
$query = "insert into ast_bilhetes_complemento (uniqueid2,direcao,destino) values ('$UNIQUEID','fila-ramal','$RAMAL')";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
write("SET VARIABLE __RAMALAGENTE $RAMAL"); //PARA O QUE EH UTILIZADO???
write("SET VARIABLE __RAMALAGENTE $RAMAL"); //PARA O QUE EH UTILIZADO???
$query = "select count(*) as resultado from pbx_callback a inner join pbx_callback_numeros b on a.id = b.id_callback where a.id = '$callback' and '$numeroConsulta' similar to b.numero";
$query = "select count(*) as resultado from pbx_callback a inner join pbx_callback_numeros b on a.id = b.id_callback where a.id = '$callback' and '$numeroConsulta' similar to b.numero";
$query = "select count(*) as resultado from pbx_disa a inner join pbx_disa_numeros b on a.id = b.id_disa where a.numero = '$disa' and '$numeroConsulta' similar to b.numeros";
$query = "select count(*) as resultado from pbx_disa a inner join pbx_disa_numeros b on a.id = b.id_disa where a.numero = '$disa' and '$numeroConsulta' similar to b.numeros";
//Pega o nome da fila passado via parametro pelo plano de discagem
//Pega o nome da fila passado via parametro pelo plano de discagem
$FILA = $argv[1];
$FILA = $argv[1];
$query = "SELECT ind_file,ind_feriado,CASE WHEN CURRENT_TIME(0)::time BETWEEN ind_inicio AND ind_fim THEN 1 ELSE 0 END AS indisponivel FROM pbx_indisponivel where status = '1' and ind_data = CURRENT_DATE and id_dac in (select id from pbx_dacs where upper(nome) = upper('$FILA'))";
$query = "SELECT ind_file,ind_feriado,CASE WHEN CURRENT_TIME(0)::time BETWEEN ind_inicio AND ind_fim THEN 1 ELSE 0 END AS indisponivel FROM pbx_indisponivel where status = '1' and ind_data = CURRENT_DATE and id_dac in (select id from pbx_dacs where upper(nome) = upper('$FILA'))";
@ -225,7 +225,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
$conta = $argv[2];
$conta = $argv[2];
$destino = $argv[3];
$destino = $argv[3];
$query = "select id from pbx_cs_usuarios where matricula = '$conta' and upper(status) = upper('a')";
$query = "select id from pbx_cs_usuarios where matricula = '$conta' and upper(status) = upper('a')";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$id_usuario = $row['id'];
$id_usuario = $row['id'];
@ -243,7 +243,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
$ramal = strtolower($agi["callerid"]);
$ramal = strtolower($agi["callerid"]);
$query = "select matricula,dac from pbx_supervisor_agentes where ramal = '$ramal'";
$query = "select matricula,dac from pbx_supervisor_agentes where ramal = '$ramal'";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$matricula = $row['matricula'];
$matricula = $row['matricula'];
$dac = $row['dac'];
$dac = $row['dac'];
@ -252,7 +252,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
if ($matricula) {
if ($matricula) {
//$query = "select count(*) from ast_bilhetes_complemento where uniqueid2 = '$idorigem' and conta = '$matricula' and direcao = 'app-conta-senha'";
//$query = "select count(*) from ast_bilhetes_complemento where uniqueid2 = '$idorigem' and conta = '$matricula' and direcao = 'app-conta-senha'";
$query = "select conta from ast_bilhetes_complemento where uniqueid2 = '$idorigem' and direcao = 'app-conta-senha'";
$query = "select conta from ast_bilhetes_complemento where uniqueid2 = '$idorigem' and direcao = 'app-conta-senha'";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$conta = $row['conta'];
$conta = $row['conta'];
@ -272,7 +272,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
if ($matricula) {
if ($matricula) {
$query = "select conta from ast_bilhetes_complemento where uniqueid2 = '$uniqueid' and direcao = 'app-conta-senha'";
$query = "select conta from ast_bilhetes_complemento where uniqueid2 = '$uniqueid' and direcao = 'app-conta-senha'";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$conta = $row['conta'];
$conta = $row['conta'];
@ -336,7 +336,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
//Monitoramento Ligações Recebidas CallCenter
//Monitoramento Ligações Recebidas CallCenter
//$query = "select matricula,dac,status from pbx_supervisor_agentes where ramal = '$destino' and upper(status) in ('LIVRE','PAUSA')";
//$query = "select matricula,dac,status from pbx_supervisor_agentes where ramal = '$destino' and upper(status) in ('LIVRE','PAUSA')";
$query = "select matricula,dac,status,chamada_classificado,upper(modo_atendimento) as modo_atendimento from pbx_supervisor_agentes where ramal = '$destino'";
$query = "select matricula,dac,status,chamada_classificado,upper(modo_atendimento) as modo_atendimento from pbx_supervisor_agentes where ramal = '$destino'";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$row = @pg_fetch_array($result);
$row = @pg_fetch_array($result);
$resultado = pg_num_rows($result);
$resultado = pg_num_rows($result);
$matricula = $row['matricula'];
$matricula = $row['matricula'];
@ -589,7 +589,7 @@ if (strtolower($contexto) == 'ext-transferencia') {
$query = "select a.matricula, (select id from pbx_dacs where nome = a.dac) as id_dac, dac from pbx_supervisor_agentes a where uniqueid2 = '$uniqueid' ";
$query = "select a.matricula, (select id from pbx_dacs where nome = a.dac) as id_dac, dac from pbx_supervisor_agentes a where uniqueid2 = '$uniqueid' ";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$dados = pg_fetch_array($result);
$dados = pg_fetch_array($result);
$idDac = $dados["id_dac"];
$idDac = $dados["id_dac"];
$mat = $dados["matricula"];
$mat = $dados["matricula"];
@ -20,15 +20,15 @@ if ($argv[1] == 'ini') {
( uniqueid, id_dac, matricula, data_reg )
( uniqueid, id_dac, matricula, data_reg )
values ('$uniqueid', '$idDac', '$mat', now() )";
values ('$uniqueid', '$idDac', '$mat', now() )";
$result = @pg_query($conexao, $query);
$result = pg_query($conexao, $query);
$sqlVpsq = "SELECT uniqueid FROM pbx_pesquisa_log WHERE uniqueid = '$uniqueid'";
$sqlVpsq = "SELECT uniqueid FROM pbx_pesquisa_log WHERE uniqueid = '$uniqueid'";
$query = sprintf("update clientes set %s = '%s' where cli_id = '%s'", "fone2", $fone, $globais['cli_id']);
$query = sprintf("update clientes set %s = '%s' where cli_id = '%s'", "fone2", $fone, $globais['cli_id']);
@pg_query($query);
pg_query($query);
$audio = "fone_incluido_$uid";
$audio = "fone_incluido_$uid";
$textoConctAudio = "Senhor %s este telefone foi associado ao seu cadastro este procedimento irá agilizar o seu atendimento na próxima vez em que nos ligar. A seguir você será redirecionado para o menu de atendimento.";
$textoConctAudio = "Senhor %s este telefone foi associado ao seu cadastro este procedimento irá agilizar o seu atendimento na próxima vez em que nos ligar. A seguir você será redirecionado para o menu de atendimento.";
$query = "select cfg_id as id, cfg_descricao as desc from pbx_backup_configuracao a where exists(select '' from pbx_backup where cfg_id = a.cfg_id) order by 2";
$query = "select cfg_id as id, cfg_descricao as desc from pbx_backup_configuracao a where exists(select '' from pbx_backup where cfg_id = a.cfg_id) order by 2";
$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);
$result = pg_query($dbcon, $query);
$row = @pg_fetch_row($result);
$row = @pg_fetch_row($result);
$ret = $row[0];
$ret = $row[0];
@ -306,7 +306,7 @@ function GetDacPadraoAgente($dbcon, $getId = true) {
else
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;
//echo $query;
$result = @pg_query($dbcon, $query);
$result = pg_query($dbcon, $query);
$row = @pg_fetch_row($result);
$row = @pg_fetch_row($result);
$ret = $getId ? $row[0] : $row[1];
$ret = $getId ? $row[0] : $row[1];
return $ret;
return $ret;
@ -392,7 +392,7 @@ function SetPbx($db, $idUser) {
and a.user_id = $idUser";
and a.user_id = $idUser";
$result = @pg_query($db, $query);
$result = pg_query($db, $query);
if (!$result)
if (!$result)
$_SESSION["SSacessoPbx"] = 0;
$_SESSION["SSacessoPbx"] = 0;
@ -636,7 +636,7 @@ function GetRamalSip($dbcon, $ramalAgente) {
function GetIdUserFromMatricula($dbcon, $matricula) {
function GetIdUserFromMatricula($dbcon, $matricula) {
$query = "select id from pbx_usuarios where matricula = '$matricula'";
$query = "select id from pbx_usuarios where matricula = '$matricula'";
$result = @pg_query($dbcon, $query);
$result = pg_query($dbcon, $query);
$row = @pg_fetch_row($result);
$row = @pg_fetch_row($result);
$ret = $row[0];
$ret = $row[0];
return $ret;
return $ret;
@ -827,7 +827,7 @@ function IsSupervisor($db) {
function GetClassificacao($db, $idClas, $dac, $useSelect = 1) {
function GetClassificacao($db, $idClas, $dac, $useSelect = 1) {
$query = " SELECT clas_id, clas_descricao FROM pbx_classifica_atendimento where clas_status = 1 and clas_id in(select clas_id from pbx_classifica_dacs where id_dac = '$dac' ) order by 2";
$query = " SELECT clas_id, clas_descricao FROM pbx_classifica_atendimento where clas_status = 1 and clas_id in(select clas_id from pbx_classifica_dacs where id_dac = '$dac' ) order by 2";