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.
82 lines
2.0 KiB
82 lines
2.0 KiB
#!/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_fila.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 |
|
$matricula = $argv[1]; |
|
/* |
|
* Dados da sessao do agente |
|
*/ |
|
$query = "select disponivel_atendimento, chamada_classificado, dac, status, ramal from pbx_supervisor_agentes where matricula = '$matricula'"; |
|
$result = pg_query($conexao, $query); |
|
$dados = pg_fetch_row($result); |
|
$dispoAtend = $dados[0]; |
|
$chamdaClassificada = $dados[1]; |
|
$dac = $dados[2]; |
|
$status = $dados[3]; |
|
$ramal = $dados[4]; |
|
|
|
if ($status == 'OCUPADO') { |
|
exit; |
|
} |
|
|
|
/* |
|
* Verifica se o dac exige classificação! |
|
*/ |
|
$query = "select exige_classificacao from pbx_queues_grupos where nome = '$dac'"; |
|
$result = pg_query($conexao, $query); |
|
$dados = pg_fetch_row($result); |
|
$exigeClas = $dados[0]; |
|
|
|
if ($dispoAtend && (($exigeClas && $chamdaClassificada) || (!$exigeClas))) { |
|
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and upper(status) <> 'PAUSA'"; |
|
$result = pg_query($conexao, $query); |
|
$dados = pg_fetch_row($result); |
|
if ($dados[0]) { |
|
// write("EXEC UnPauseQueueMember |Agent/$matricula"); |
|
write("EXEC UnPauseQueueMember ,Local/$ramal@app-callcenter/n"); |
|
read(); |
|
} |
|
} |
|
|
|
// clean up file handlers etc. |
|
fclose($in); |
|
fclose($stdlog); |
|
?>
|
|
|