forked from SimplesIP/pabx-app
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.
73 lines
1.7 KiB
73 lines
1.7 KiB
2 years ago
|
#!/usr/bin/php -q
|
||
|
<?php
|
||
|
include('bd.php');
|
||
|
|
||
|
ob_implicit_flush(true);
|
||
|
set_time_limit(6);
|
||
|
$in = fopen("php://stdin", "r");
|
||
|
$stdlog = fopen("/var/log/asterisk/agente_campanha.log", "w");
|
||
|
|
||
|
// toggle debugging output (more verbose)
|
||
|
$debug = false;
|
||
|
|
||
|
function read() {
|
||
|
global $in, $debug, $stdlog;
|
||
|
$input = str_replace("\n", "", fgets($in, 4096));
|
||
|
if ($debug)
|
||
|
fputs($stdlog, "read: $input\n");
|
||
|
return $input;
|
||
|
}
|
||
|
|
||
|
function errlog($line) {
|
||
|
global $err;
|
||
|
echo "VERBOSE \"$line\"\n";
|
||
|
}
|
||
|
|
||
|
function write($line) {
|
||
|
global $debug, $stdlog;
|
||
|
if ($debug)
|
||
|
fputs($stdlog, "write: $line\n");
|
||
|
echo $line . "\n";
|
||
|
}
|
||
|
|
||
|
// parse agi headers into array
|
||
|
while ($env = read()) {
|
||
|
$s = split(": ", $env);
|
||
|
$agi[str_replace("agi_", "", $s[0])] = trim($s[1]);
|
||
|
if (($env == "") || ($env == "\n")) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//parametro vindo do dialplan
|
||
|
$id_cliente = $argv[1];
|
||
|
$fone = substr($agi["callerid"], -10);
|
||
|
$canal = $agi["channel"];
|
||
|
|
||
|
write("GET VARIABLE TIPOLIGACAO");
|
||
|
$tipoligacao = substr(strrchr(read(), "("), 1, -1);
|
||
|
|
||
|
if ($tipoligacao == 'AGENDAMENTO') {
|
||
|
exit;
|
||
|
}
|
||
|
$query = "update pbx_campanha_contato set cont_discado = '0', cont_peso = '-10' where cont_id = '$id_cliente'";
|
||
|
pg_query($query);
|
||
|
|
||
|
$query = "update pbx_campanha_contato_fone set conf_status = '0',conf_data = 'now()' where cont_id = '$id_cliente' and substr(conf_fone,(length(conf_fone) - 9),10) = '$fone' and conf_status_lista = '1'";
|
||
|
pg_query($query);
|
||
|
|
||
|
|
||
|
$query = "delete from pbx_campanha_canais_discando where id_cliente = '$id_cliente' and status = '0'";
|
||
|
pg_query($query);
|
||
|
pg_close();
|
||
|
|
||
|
write("EXEC SoftHangup $canal");
|
||
|
read();
|
||
|
|
||
|
|
||
|
// clean up file handlers etc.
|
||
|
fclose($in);
|
||
|
fclose($stdlog);
|
||
|
?>
|