Browse Source

add modulo de SystemMessage

websocket
lucascardo12 3 years ago
parent
commit
4cf1dff36b
  1. 47
      app/Controllers/SystemMessageController.php
  2. 22
      app/Models/SystemMessage.php
  3. 16
      config/moments.php
  4. 8
      database/att-v3.sql
  5. 11
      includes/config.php

47
app/Controllers/SystemMessageController.php

@ -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;
}
}
}

22
app/Models/SystemMessage.php

@ -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();
}
}

16
config/moments.php

@ -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');

8
database/att-v3.sql

@ -67,6 +67,14 @@ CREATE TABLE md_atendimento (
nome varchar NULL
);
CREATE TABLE md_system_message (
id SERIAL NOT NULL PRIMARY KEY,
data_reg timestamp NULL DEFAULT now(),
texto varchar NOT NULL,
ordem int NOT NULL,
momento varchar NULL
);
CREATE TABLE md_supervisor (
id SERIAL NOT NULL PRIMARY KEY,
ramal varchar NULL,

11
includes/config.php

@ -114,4 +114,15 @@ if (file_exists(__DIR__ . '/../config/display_errors.php')) {
*/
if (file_exists(__DIR__ . '/../config/telegram.php')) {
require __DIR__ . '/../config/telegram.php';
}
/*
|--------------------------------------------------------------------------
| Configuracao de momentis
|--------------------------------------------------------------------------
|
| Variaveis do moments das mensagens padrão.
|
*/
if (file_exists(__DIR__ . '/../config/moments.php')) {
require __DIR__ . '/../config/moments.php';
}
Loading…
Cancel
Save