Update: Leitura remoto do ivr json

main
Alan Oliveira 2024-12-12 17:35:22 -03:00
parent 0df56d1f77
commit e4fc10ef5d
3 changed files with 40 additions and 25 deletions

View File

@ -23,6 +23,7 @@ $agientrada = new \Hit\Ami\AGIEntrada(
),
array(
'fgId' => $fgId,
'asteriskip' => '177.107.205.248',
'logEnabled' => $logEnabled,
'appdir' => $appdir,
'isXampp' => $isXampp

View File

@ -32,7 +32,6 @@ function agiLogWrapper($logEnabled)
if (isset($options['new'])) {
file_put_contents($target, $texto);
} else {
$texto = $texto . PHP_EOL;
file_put_contents($target, $texto, FILE_APPEND);
}
}

View File

@ -11,6 +11,7 @@ class AGIEntrada
{
$globais['logEnabled'] = !isset($globais['logEnabled']) ? false : $globais['logEnabled'];
$globais['appdir'] = !isset($globais['appdir']) ? dirname(__FILE__) : $globais['appdir'];
$globais['asteriskip'] = !isset($globais['asteriskip']) ? 'localhost' : $globais['asteriskip'];
$globais['isXampp'] = !isset($globais['isXampp']) ? false : $globais['isXampp'];
$this->globais = $globais;
$this->injection = $injection;
@ -51,6 +52,38 @@ class AGIEntrada
// --------------------------------------------------------------------------------------------------------------------------------
public function ivrGet()
{
$this->globais['fgItens'] = array();
$this->globais['fgItemStart'] = array();
if ($this->globais['fgId'] != '') {
if ($this->globais['asteriskip'] != '') {
// http://177.107.205.248/fluxograma/data-json/8999.json
$target = 'http://' . $this->globais['asteriskip'] . '/fluxograma/data-json/' . $this->globais['fgId'] . '.json';
} else {
if (file_exists('/etc/asterisk')) {
$target = '/var/www/html/fluxograma/data-json/' . $this->globais['fgId'] . '.json';
} else {
$target = 'dial/' . $this->globais['fgId'] . '.json';
}
}
$this->agiLog($target);
$itens = file_get_contents($target);
if ($itens !== false) {
$itens = json_decode($itens, true);
foreach ($itens as $item) {
$this->globais['fgItens'][$item['id']] = $item;
if ($item['cmd'] == 'start') {
$this->globais['fgItemStart'] = $item;
}
}
unset($itens);
}
}
}
// --------------------------------------------------------------------------------------------------------------------------------
public function agiVarGet($varName = '')
{
@ -392,7 +425,7 @@ class AGIEntrada
public function fgItemRunPlayaudio($fgItem = array())
{
$this->agiLog('fgItemRunPlayaudio');
$this->agiLog('===> fgItemRunPlayaudio');
$this->agiLog(print_r($fgItem, true));
$this->globais['digitado'] = '';
@ -538,7 +571,7 @@ class AGIEntrada
function fgItemRunStart($fgItem = array())
{
$this->agiLog('fgItemRunStart');
$this->agiLog('===> fgItemRunStart');
$this->agiLog(print_r($fgItem, true));
// queue_log
@ -552,7 +585,7 @@ class AGIEntrada
function fgItemRunTimeout($fgItem = array())
{
$this->agiLog('fgItemRunTimeout');
$this->agiLog('===> fgItemRunTimeout');
$this->agiLog(print_r($fgItem, true));
$run_next = true;
@ -592,27 +625,9 @@ class AGIEntrada
$this->logStart();
$this->logAdd("<pre>" . print_r($this->globais, true) . "</pre><br>");
$this->globais['fgItens'] = array();
$this->globais['fgItemStart'] = array();
if ($this->globais['fgId'] != '') {
// ...
if (file_exists('/etc/asterisk')) {
$target = '/var/www/html/fluxograma/data-json/' . $this->globais['fgId'] . '.json';
} else {
$target = 'dial/' . $this->globais['fgId'] . '.json';
}
if (file_exists($target)) {
$itens = file_get_contents($target);
$itens = json_decode($itens, true);
foreach ($itens as $item) {
$this->globais['fgItens'][$item['id']] = $item;
if ($item['cmd'] == 'start') {
$this->globais['fgItemStart'] = $item;
}
}
unset($itens);
}
}
$this->ivrGet();
$this->logAdd("<pre>" . print_r($this->globais['fgItens'], true) . "</pre><br>");
$this->logAdd("<pre>" . print_r($this->globais['fgItemStart'], true) . "</pre><br>");