From fddd6dce8ce0dee9b1ec879c3a029d051f489111 Mon Sep 17 00:00:00 2001 From: Matheo Bonucia Date: Tue, 30 Jul 2024 21:06:40 +0000 Subject: [PATCH] correcoes no AGI e no extensions --- asterisk/etc_asterisk/extensions_padrao.conf | 4 +- .../var_lib_asterisk/agi-bin/agente_fila.php | 10 +- .../var_lib_asterisk/agi-bin/agente_pausa.php | 2 +- .../var_lib_asterisk/agi-bin/info_agente.php | 160 ++---------------- 4 files changed, 18 insertions(+), 158 deletions(-) diff --git a/asterisk/etc_asterisk/extensions_padrao.conf b/asterisk/etc_asterisk/extensions_padrao.conf index 18b02c9f..ce767682 100644 --- a/asterisk/etc_asterisk/extensions_padrao.conf +++ b/asterisk/etc_asterisk/extensions_padrao.conf @@ -123,7 +123,7 @@ exten => _X.,n,Hangup() exten => _X.,n(MANUAL),Wait(1) exten => _X.,n,Set(RINGPADRAO=${TEMPODERING}) exten => _X.,n,Set(RING=${IF($[ "X${DB(RING/${EXTEN})}" = "X" ]? ${RINGPADRAO}: ${DB(RING/${EXTEN})} )}) -exten => _X.,n,Dial(${DB(DIAL/${EXTEN})},${RING},tkrTU(macro-info-agente,s,1,(${EXTEN}))) +exten => _X.,n,Dial(${DB(DIAL/${EXTEN})},${RING},tkrTU(macro-info-agente,${EXTEN})) exten => _X.,n,Noop(status-${DIALSTATUS}) exten => _X.,n,Goto(status-${DIALSTATUS}) @@ -382,7 +382,7 @@ exten => _X.,n,Hangup() ; 3 => Agente/Grupo exten => _X.,1,GotoIf($["${AGD_TIPO}" = "1"]?grupo) exten => _X.,n,AGI(status_agendamento_agentes.php,${AGENTE},${EXTEN},${TIPOLIGACAO},${ID_CLI}) -exten => _X.,n,Dial(Agent/${AGENTE},30,TtU(macro-info-agente,s,1,(AGENDAMENTO,${AGENTE},${CHANNEL},${CMP_ID}))) +exten => _X.,n,Dial(Agent/${AGENTE},30,TtU(macro-info-agente,AGENDAMENTO,${AGENTE},${CHANNEL},${CMP_ID})) exten => _X.,n(grupo),GotoIf($["${AGD_TIPO}" = "2"]?sair) exten => _X.,n,Goto(ext-campanha,${CMP_ID},1) exten => _X.,n(sair),Hangup() diff --git a/asterisk/var_lib_asterisk/agi-bin/agente_fila.php b/asterisk/var_lib_asterisk/agi-bin/agente_fila.php index ae8321a1..42a9f68a 100755 --- a/asterisk/var_lib_asterisk/agi-bin/agente_fila.php +++ b/asterisk/var_lib_asterisk/agi-bin/agente_fila.php @@ -118,7 +118,7 @@ $dataBilhete = sprintf("'%s'", $dataBilhete); * VerificaClassificacao($conexao, $fila, $MATRICULA, $RAMAL, $UNIQUEID, $classifica, FILA); */ $classifica = 1; -VerificaClassificacao($conexao, $fila, $MATRICULA, $RAMAL, $UNIQUEID, $classifica, 'ENTRANTE'); +VerificaClassificacao($conexao, $fila, $MATRICULA, $RAMAL, $UNIQUEID, $classifica, 'ENTRANTE', $org_id); /* * Verifica se o dac possui pausa automatica @@ -153,23 +153,23 @@ if (pg_num_rows($result)) { /* * Modo de atendimento */ -$query = "SELECT upper(a.modo_atendimento) AS modo_atendimento, a.ramal, b.id as fila_id, a.canal_agente +$query = "SELECT upper(a.modo_atendimento) AS modo_atendimento, a.ramal, b.id as fila_id, a.canal_agente, b.nome FROM pbx_supervisor_agentes a, pbx_dacs b - WHERE b.nome = a.dac AND matricula = '$MATRICULA' and a.org_id = $org_id and a.org_id = b.org_id"; + WHERE b.nome = a.dac AND a.matricula = '$MATRICULA' and a.org_id = $org_id and a.org_id = b.org_id"; write("Modo de Atendimento: " . $query, true); $result = pg_query($conexao, $query); $dados = pg_fetch_array($result); $automatico = $dados[0] != 'MANUAL'; $ramalAgente = $dados['ramal']; $filaId = $dados['fila_id']; +$filaNome = $dados['nome']; $displayFone = $FONE . '-' . $TRONCO; $canalAgente = $dados['canal_agente']; $query = "UPDATE pbx_supervisor_agentes SET status = 'OCUPADO', duracao = 'now()', origem_destino = '$displayFone', canal = '$CANAL', uniqueid = '$UNIQUEID', uniqueid2 = '$UNIQUEID', cont_identificador = '$identificador', tipo_ligacao = 'E', protocolo = '$protocolo' -WHERE matricula = '$MATRICULA' and org_id = $org_id -AND dac = '$fila'"; +WHERE matricula = '$MATRICULA' AND org_id = $org_id AND dac = '$filaNome'"; write("Modo de Atendimento Update: " . $query, true); pg_query($conexao, $query); diff --git a/asterisk/var_lib_asterisk/agi-bin/agente_pausa.php b/asterisk/var_lib_asterisk/agi-bin/agente_pausa.php index 50744db3..9596afec 100755 --- a/asterisk/var_lib_asterisk/agi-bin/agente_pausa.php +++ b/asterisk/var_lib_asterisk/agi-bin/agente_pausa.php @@ -74,7 +74,7 @@ if ($dispoAtend && (($exigeClas && $chamdaClassificada) || (!$exigeClas))) { $dados = pg_fetch_row($result); if ($dados[0]) { // write("EXEC UnPauseQueueMember |Agent/$matricula"); - write("EXEC UnPauseQueueMember ,Local/$ramal@app-callcenter/n"); + write("EXEC UnPauseQueueMember ,Local/$org_id$ramal@app-callcenter/n"); read(); } } diff --git a/asterisk/var_lib_asterisk/agi-bin/info_agente.php b/asterisk/var_lib_asterisk/agi-bin/info_agente.php index ff4a2b71..cb075048 100755 --- a/asterisk/var_lib_asterisk/agi-bin/info_agente.php +++ b/asterisk/var_lib_asterisk/agi-bin/info_agente.php @@ -46,7 +46,10 @@ $tipo = $argv[1]; switch ($tipo) { case 'BINA_AGENTE': - $ramal = $argv[2]; + + write("DATABASE GET ORG_RAMAL " . $argv[2]); + $ramal = substr(strrchr(read(), "("), 1, -1); + $query = "select status,matricula,dac,replace(upper(modo_atendimento),'Á','A') as modo_atendimento from pbx_supervisor_agentes where ramal = '$ramal' and org_id = $org_id"; $result = pg_query($dbcon, $query); $row = pg_fetch_array($result); @@ -66,7 +69,8 @@ switch ($tipo) { $consulta = substr(strrchr(read(), "("), 1, -1); if (strtoupper($row["status"]) != "PAUSA") { - $ramal = $argv[2]; + write("DATABASE GET ORG_RAMAL " . $argv[2]); + $ramal = substr(strrchr(read(), "("), 1, -1); $bina = $argv[3]; $idorigem = $argv[4]; $canal_agente = $argv[5]; @@ -90,9 +94,11 @@ switch ($tipo) { //Roda em atendimento manual, apos o agente atender a chamada case 'FILA': $canal_agente = $argv[2]; - $ramal = $argv[3]; + + write("GET VARIABLE CALLERID(num)"); + $ramal = substr(strrchr(read(), "("), 1, -1); - $query = "select matricula from pbx_supervisor_agentes where ramal = '$ramal' and org_id = $org_id"; + $query = "select matricula from pbx_supervisor_agentes where ramal = '$ramal' and org_id = $org_id"; $result = pg_query($dbcon, $query); $row = pg_fetch_array($result); $matricula = $row["matricula"]; @@ -108,152 +114,6 @@ switch ($tipo) { break; } - -// case 'BINA_AGENTE_ATIVO': -// $ramal = $argv[2]; -// $bina = $argv[3]; -// $identificador = $argv[4]; -// $query = "update pbx_supervisor_agentes set status = 'OCUPADO' , origem_destino = '$bina' , duracao = now() ,canal = '' , sala_1 = '' , sala_2 = '' , facilidade = '' , canal_agente = '' , canal_transfer = '' ,cont_identificador = translate('$identificador','-','|'), tipo_ligacao = 'S' where ramal = '$ramal'"; -// pg_query($dbcon, $query); -// break; - -// case 'RECEPTIVO': -// $canal = $argv[2]; -// $ramal = $argv[3]; -// $query = "update pbx_supervisor_agentes set status = 'OCUPADO', canal_agente = '$canal' where ramal = '$ramal'"; -// pg_query($dbcon, $query); -// -// write("GET VARIABLE MATRICULA-ORIGEM"); -// $matriculaorigem = substr(strrchr(read(), "("), 1, -1); -// -// if ($matriculaorigem) { -// -// $query = "update pbx_supervisor_agentes set canal = '$canal' where matricula = '$matriculaorigem'"; -// pg_query($dbcon, $query); -// -// } -// -// $query = "select matricula from pbx_supervisor_agentes where ramal = '$ramal'"; -// $result = pg_query($dbcon, $query); -// $row = pg_fetch_array($result); -// $matricula = $row["matricula"]; -// -// write("SET VARIABLE MATRICULAMESA $matricula"); -// read(); -// -// write("SET VARIABLE MATRICULA $matricula"); -// read(); -// -// -// break; -// case 'APLICACAO': -// write("GET VARIABLE GRAVACAO"); -// $gravacao = substr(strrchr(read(), "("), 1, -1); -// $matricula = $argv[2]; -// $canal = $agi["channel"]; -// -// $query = "select status,motivo_pausa from pbx_supervisor_agentes where matricula = '$matricula'"; -// $result = pg_query($dbcon, $query); -// $row = pg_fetch_array($result); -// -// if (strtoupper($row["status"]) == "PAUSA") { -// $query = "update pbx_supervisor_agentes set canal = '$canal', tipo_discagem = 'MANUAL', status_gravacao = (case when '$gravacao' = '' then 'F' else '$gravacao' end) where matricula = '$matricula'"; -// pg_query($dbcon, $query); -// } else { -// $query = "update pbx_supervisor_agentes set canal = '$canal', status = 'OCUPADO', tipo_discagem = 'MANUAL', status_gravacao = (case when '$gravacao' = '' then 'F' else '$gravacao' end) where matricula = '$matricula'"; -// pg_query($dbcon, $query); -// } -// break; -// -// case 'ATIVO-AUTOMATICO': -// $canal = $argv[2]; -// $origem_destino = $argv[3]; -// $ramal = $argv[4]; -// $query = "update pbx_supervisor_agentes set canal = '$canal', status = 'OCUPADO' , origem_destino = '$origem_destino' where ramal = '$ramal'"; -// pg_query($dbcon, $query); -// break; - -// case 'ORIGINA_AGENTE': -// $agente = $argv[2]; -// $uniqueid = $argv[3]; -// -// /* -// * Função retorna numero de Protocolo de Atendimento para o agente -// */ -// $tentativa = 0; -// while (true) { -// $proto = GetProto($conexao, $uniqueid, $agente); -// if ($proto == '99') { -// $proto = '0000-000000'; -// break; -// } -// -// if (!empty($proto) || $tentativa >= NUM_TENTATIVAS_GERA_PROTO) { -// break; -// } -// $tentativa++; -// } -// -// //$query = "update pbx_supervisor_agentes set uniqueid = '$uniqueid', uniqueid2 = '$uniqueid', protocolo = '$proto' where matricula = '$agente'"; -// $query = "update pbx_supervisor_agentes set protocolo = '$proto' where matricula = '$agente'"; -// pg_query($dbcon, $query); -// -// //RegistraClassificacao(); -// -// break; - -// case 'DIAL_AGENTE': -// $agente = $argv[2]; -// $uniqueid = $argv[3]; -// -// /* -// * Função retorna numero de Protocolo de Atendimento para o agente -// */ -// $tentativa = 0; -// while (true) { -// $proto = GetProto($conexao, $uniqueid, $agente); -// if ($proto == '99') { -// $proto = '0000-000000'; -// break; -// } -// if (!empty($proto) ||$tentativa >= NUM_TENTATIVAS_GERA_PROTO) { -// break; -// } -// $tentativa++; -// } -// -// $query = "update pbx_supervisor_agentes set uniqueid = '$uniqueid', uniqueid2 = '$uniqueid', protocolo = '$proto' where matricula = '$agente'"; -// pg_query($dbcon, $query); -// -// break; - -//function RegistraClassificacao($conexao, $matricula, $uniqueid) { -// /* -// * Não é necessario invocar este script, agente_dial.php já cumpre esta função. -// */ -// return; -// /* -// * Trata classificação -// * Verifica se a classificação esta ativa -// * Verifica se é exigida a classificação -// */ -// -// $query = "select b.prm_agente_classifica, a.exige_classificacao as prm_exige_classificacao -// from pbx_queues_grupos a, pbx_parametros b -// where nome = (select dac from pbx_supervisor_agentes where matricula = '$matricula')"; -// -// -// $result = pg_query($conexao, $query); -// $dados = pg_fetch_row($result); -// if ($dados[0] && $dados[1]) { -// /* -// * Registra a obrigatoriedade da classificação para o agente logado quando configurado. -// */ -// $query = "insert into pbx_registra_classificacao(id_dac, matricula, rgc_entrada, uid, id_login, reg_proc)values((select id from pbx_dacs where nome = (select dac from pbx_supervisor_agentes where matricula = '$matricula')), '$matricula', now(), '$uniqueid', (select max(id) from pbx_eventos_agentes where matricula = '$matricula' ), 'info_agente.php')"; -// pg_query($conexao, $query); -// } -//} - fclose($in); fclose($stdlog); exit;