$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 = "update pbx_campanha_contato set cont_discado = '0', cont_peso = '-10' where cont_id = '$idcliente'";
pg_query($query);
$query = "update pbx_campanha_contato_fone set conf_status = '0',conf_data = 'now()' where cont_id = '$idcliente' and substr(conf_fone,(length(conf_fone) - 9),10) = '$cont_fone' and conf_status_lista = '1'";
pg_query($query);
}
write("EXEC PauseQueueMember |$MEMBERINTERFACE");
read();
$query = "update pbx_campanha_canais_discando set status = '1' where id_cliente = '$idcliente'";
pg_query($query);
pg_close();
fclose($in);
fclose($stdlog);
exit;
}
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 = "update pbx_campanha_contato set cont_peso = '0',cont_discado = '1' where cont_id = '$ID'";
pg_query($query);
//Identifica agente na tabela pbx_campanha_contatos_fone
$query = "update pbx_campanha_contato_fone set agente = '$MATRICULA',conf_status = 'HUMAN-ATENDIDA', conf_data = 'now()' where substr(conf_fone,(length(conf_fone) - 9),10) = '$FONE' and cont_id = '$ID' and cmp_id = '$cmp_id_campanha' and conf_status_lista = '1' ";
pg_query($query);
$query = "delete from pbx_campanha_canais_discando where id_cliente='$ID' and status = '0'";
pg_query($query);
//Relatorio de desempenho do discador
$query = "insert into pbx_campanha_complemento(uniqueid, matricula, login_id, cmp_id, list_id, cont_id,conf_id) (select '$UNIQUEID','$MATRICULA',(select max(id) from pbx_eventos_agentes where login::date = cast(now() as date) and matricula = '$MATRICULA' and id_dac = '$cmp_id_campanha'),cmp_id,list_id,cont_id,conf_id from pbx_campanha_contato_fone where substr(conf_fone,(length(conf_fone) - 9),10) = '$FONE' and cont_id = '$ID' and cmp_id = '$cmp_id_campanha' and conf_status_lista = '1') ";