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.
72 lines
1.7 KiB
72 lines
1.7 KiB
#!/usr/bin/php -q |
|
<? |
|
include('bd.php'); |
|
|
|
ob_implicit_flush(true); |
|
set_time_limit(6); |
|
error_reporting(0); |
|
$in = fopen("php://stdin", "r"); |
|
$stdlog = fopen("/var/log/asterisk/facilidades_callcenter.log", "w"); |
|
|
|
// Habilita modo debugging (mais verbose) |
|
$debug = true; |
|
|
|
// Do function definitions before we start the main loop |
|
function read() { |
|
global $in, $debug, $stdlog; |
|
$input = str_replace("\n", "", fgets($in, 4096)); |
|
if ($debug) |
|
fputs($stdlog, "read: $input\n"); |
|
return $input; |
|
} |
|
|
|
function write($line) { |
|
global $debug, $stdlog; |
|
if ($debug) |
|
fputs($stdlog, "write: $line\n"); |
|
echo $line . "\n"; |
|
} |
|
|
|
// Colocando headers AGI dentro de um array |
|
while ($env = read()) { |
|
$s = split(": ", $env); |
|
$agi[str_replace("agi_", "", $s[0])] = trim($s[1]); |
|
if (($env == "") || ($env == "\n")) { |
|
break; |
|
} |
|
} |
|
|
|
$tipo = $argv[1]; |
|
|
|
if (strtoupper($tipo) == 'TRANSFERENCIA') { |
|
//AGI(facilidades_callcenter.php|TRANSFERENCIA|${MATRICULA}|${CHANNEL}) |
|
$matricula = $argv[2]; |
|
$canal = $argv[3]; |
|
|
|
write("SET VARIABLE TIPO $tipo"); |
|
read(); |
|
|
|
$query = "update pbx_supervisor_agentes set canal_transfer = '$canal' where matricula = '$matricula'"; |
|
pg_query($query); |
|
} else if (strtoupper($tipo) == 'RETORNA_TRANSFER') { |
|
$matricula = $argv[2]; |
|
|
|
write("SET VARIABLE TIPO $tipo"); |
|
read(); |
|
|
|
$query = "update pbx_supervisor_agentes set canal_transfer = '' where matricula = '$matricula'"; |
|
pg_query($query); |
|
} |
|
|
|
/* |
|
else { |
|
|
|
$query = "update pbx_supervisor_agentes set sala_1 = '$sala', sala_2 = ('$sala' + 1) , canal_agente = '$canal' , facilidade = '$facilidade' where matricula = '$agente'"; |
|
pg_query($query); |
|
|
|
} |
|
*/ |
|
fclose($in); |
|
fclose($stdlog); |
|
exit; |
|
?>
|
|
|