lucascardo12
3 years ago
5 changed files with 104 additions and 0 deletions
@ -0,0 +1,47 @@
|
||||
<?php |
||||
|
||||
namespace app\Controllers; |
||||
|
||||
use app\Core\Controller; |
||||
use app\Interfaces\IApiMedia; |
||||
use app\Models\Queue; |
||||
use app\Models\EventQueue; |
||||
use app\Models\SupervisorQueue; |
||||
use app\Models\SystemMessage; |
||||
use Exception; |
||||
|
||||
/** |
||||
* Description of SupervisorController |
||||
* |
||||
* @author root |
||||
*/ |
||||
class SystemMessageController extends Controller |
||||
{ |
||||
|
||||
private $sysMessage; |
||||
private $supervisorqueue; |
||||
public function __construct() |
||||
{ |
||||
$this->sysMessage = new SystemMessage(); |
||||
} |
||||
public function sendMessageSystem($momento, $variavels, IApiMedia $api) |
||||
{ //$variavels = [["nome" => '@cliente', "valor" => 'afonso']] |
||||
try { |
||||
$msgs = $this->sysMessage->findMessage($momento); |
||||
foreach ($msgs as $key => $msg) { |
||||
foreach ($variavels as $key => $variavel) { |
||||
logger('debuge')->info(print_r($variavel, true)); |
||||
$vari = $variavel['nome']; |
||||
$pattern = "/$vari/i"; |
||||
$msg->texto = preg_replace($pattern, $variavel['valor'], $msg->texto); |
||||
} |
||||
$api->enviarMsg($api->getPhone(), utf8_encode($msg->texto)); |
||||
} |
||||
return $msgs; |
||||
} catch (Exception $ex) { |
||||
$this->supervisorqueue->rollback(); |
||||
logger()->error($ex->getMessage()); |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace app\Models; |
||||
|
||||
use app\Core\Model; |
||||
|
||||
/** |
||||
* Description of Ramal |
||||
* |
||||
* @author Lucas Awade |
||||
*/ |
||||
class SystemMessage extends Model |
||||
{ |
||||
|
||||
private $table = 'md_system_message'; |
||||
|
||||
public function findMessage($momento) |
||||
{ |
||||
$this->query = "SELECT * FROM {$this->table} m WHERE m.momento = :momento ORDER BY ordem;"; |
||||
return $this->read($this->query, ['momento' => $momento])->fetchAll(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
/* |
||||
|-------------------------------------------------------------------------- |
||||
| Momonts |
||||
|-------------------------------------------------------------------------- |
||||
| |
||||
| Eventos utilizados pelo gerenciamento dos atendimentos. |
||||
| |
||||
*/ |
||||
|
||||
define("CONF_MOMENT_SAUDACAO", 'SAUDACAO'); |
||||
define("CONF_MOMENT_INICIAR_ATENDIMENTO", 'INICIAR_ATENDIMENTO'); |
||||
define("CONF_MOMENT_FINALIZAR_ATENDIMENTO", 'FINALIZAR_ATENDIMENTO'); |
||||
define("CONF_MOMENT_CANCELAR_FILA", 'CANCELAR_FILA'); |
||||
define("CONF_MOMENT_ENTRAR_FILA", 'ENTRAR_FILA'); |
Loading…
Reference in new issue