You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
1.3 KiB

#!/usr/bin/php -q
<?php
include('bd.php');
include('funcoes/shared.php');
include('util/util.php');
$query = "
select a.id_unk,
a.emp_id,
a.chm_calldate,
'/hdaux/ftp/algar/audios/' || b.emp_diretorio_ftp || '/' || to_char(a.chm_calldate::date, 'yyyy/mm/dd') || '/' || c.prt_proto_parceiro || '.WAV' as origem,
'/hdaux/ftp/algar/audios/' || b.emp_diretorio_ftp || '/' || to_char(a.chm_calldate::date, 'yyyy/mm/dd') || '/' || c.prt_proto_parceiro || '_' || a.uid || '.WAV' as destino
from vds_chamadas a, vds_empresas b, vds_protcolos c, vds_classificacoes d
where b.emp_id = a.emp_id
and c.uid = a.uid
and d.uid = c.uid
and a.chm_data_bilhete >= (now()::date -3)
and a.chm_data_bilhete < (now()::date)
and coalesce(a.chm_controle, 9) = 9
and d.clas_descricao = 'VENDA'
and c.prt_proto_parceiro <> '' ";
$result = pg_query($query);
while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) {
$id = $dados["id_unk"];
$origem = $dados["origem"];
$destino = $dados["destino"];
$controle = 9;
if (file_exists($origem) && rename($origem, $destino)) {
$controle = 1;
}
pg_query("update vds_chamadas set chm_controle = '{$controle}' where id_unk = '{$id}'");
usleep(300);
}
exec("chown -R algar:algar /hdaux");