Browse Source

remove md_ das tabelas

main
lucas cardoso 2 years ago
parent
commit
9c872a34a1
  1. 30
      app/Models/Atendimento.php
  2. 4
      app/Models/Evento.php
  3. 6
      app/Models/Message.php
  4. 36
      app/Models/SupervisorModel.php
  5. 4
      app/Models/SystemMessage.php

30
app/Models/Atendimento.php

@ -7,8 +7,8 @@ use app\Core\Model;
class Atendimento extends Model
{
private $evento = 'md_evento';
private $atendimento = 'md_atendimento';
private $evento = 'evento';
private $atendimento = 'atendimento';
public function getAtendimentoByCliente($cliente_id, $evento = 'EMESPERA')
{
@ -16,13 +16,13 @@ class Atendimento extends Model
INNER JOIN {$this->evento} me
ON ma.uniqueid = me.uniqueid
WHERE ma.cliente_id = :cliente_id
AND (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento";
AND (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento";
return $this->read($this->query, ['cliente_id' => $cliente_id, 'evento' => $evento])->fetch();
}
public function getStatusAtendimento($uniqueid)
{
$this->query = "SELECT evento FROM md_evento WHERE uniqueid = :uniqueid ORDER BY id DESC LIMIT 1";
$this->query = "SELECT evento FROM evento WHERE uniqueid = :uniqueid ORDER BY id DESC LIMIT 1";
return $this->read($this->query, ['uniqueid' => $uniqueid])->fetch();
}
@ -40,7 +40,7 @@ class Atendimento extends Model
$this->query = "SELECT ma.* FROM {$this->atendimento} ma
INNER JOIN {$this->evento} me
ON ma.uniqueid = me.uniqueid
WHERE (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento
WHERE (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento
AND me.fila = :fila";
return $this->read($this->query, ['evento' => $evento, 'fila' => $fila])->fetchAll();
}
@ -51,9 +51,9 @@ class Atendimento extends Model
$this->query = "SELECT ma.*,
ma.nome AS profile_name,
ppr.protocolo as protocolo,
(SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) AS evento,
(SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) AS evento,
CASE
WHEN (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START' THEN 1
WHEN (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START' THEN 1
ELSE 0
END AS status
FROM {$this->atendimento} ma
@ -77,7 +77,7 @@ class Atendimento extends Model
public function findAtenEmAberto($cliente_id = null)
{
$this->query = "SELECT ma.* FROM {$this->atendimento} ma
WHERE (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START'
WHERE (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START'
AND ma.matricula notnull ";
$data = [];
if ($cliente_id) {
@ -91,7 +91,7 @@ class Atendimento extends Model
public function getAtendimentoAbertoByAgente($matricula)
{
$this->query = "SELECT ma.* FROM {$this->atendimento} ma
WHERE (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START'
WHERE (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START'
AND ma.matricula = :matricula ";
return $this->read($this->query, ['matricula' => $matricula])->fetchAll();
}
@ -103,7 +103,7 @@ class Atendimento extends Model
// ON ma.uniqueid = me.uniqueid
// WHERE me.evento = :evento
// AND me.fila = :fila
// AND (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'LOST_CONNECTION' ";
// AND (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'LOST_CONNECTION' ";
// return $this->read($this->query, ['evento' => $evento, 'fila' => $fila])->fetchAll();
// }
public function getAtendFila($fila)
@ -113,7 +113,7 @@ class Atendimento extends Model
ON ma.uniqueid = me.uniqueid
AND me.evento IN('EMESPERA', 'LOST_CONNECTION')
WHERE me.fila = :fila
AND (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) IN('EMESPERA', 'LOST_CONNECTION') ";
AND (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) IN('EMESPERA', 'LOST_CONNECTION') ";
return $this->read($this->query, ['fila' => $fila])->fetchAll();
}
@ -124,7 +124,7 @@ class Atendimento extends Model
INNER JOIN {$this->evento} me
ON ma.uniqueid = me.uniqueid
AND me.evento = 'ABANDON'
WHERE (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'ABANDON'
WHERE (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'ABANDON'
AND ma.data_reg >= CURRENT_DATE ";
if ($fila) {
$this->query .= ' AND me.fila = :fila';
@ -186,9 +186,9 @@ class Atendimento extends Model
$this->query = "SELECT ma.*,
ma.nome AS profile_name,
ppr.protocolo as protocolo,
(SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) AS evento,
(SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) AS evento,
CASE
WHEN (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START' THEN 1
WHEN (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = 'START' THEN 1
ELSE 0
END AS status
FROM {$this->atendimento} ma
@ -202,7 +202,7 @@ class Atendimento extends Model
$this->query .= " AND ppr.protocolo::varchar LIKE '%{$parametros['protocolo']}%' ";
}
if ($parametros['evento']) {
$this->query .= " AND (SELECT m2.evento FROM md_evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento ";
$this->query .= " AND (SELECT m2.evento FROM evento m2 WHERE ma.uniqueid = m2.uniqueid ORDER BY id DESC LIMIT 1) = :evento ";
$dados['evento'] = $parametros['evento'];
}
if ($parametros['nome']) {

4
app/Models/Evento.php

@ -6,7 +6,7 @@ use app\Core\Model;
class Evento extends Model
{
private $evento = 'md_evento';
private $evento = 'evento';
public function createEvento($uniqueid, $evento, $data_evento, $data_reg, $fila = null, $matricula = null)
{
@ -47,4 +47,4 @@ class Evento extends Model
$this->query = "SELECT evento FROM {$this->evento} WHERE uniqueid = :uniqueid ORDER BY id DESC LIMIT 1";
return $this->read($this->query, ['uniqueid' => $uniqueid])->fetch();
}
}
}

6
app/Models/Message.php

@ -12,7 +12,7 @@ use app\Core\Model;
class Message extends Model
{
const MESSAGE = "md_message";
const MESSAGE = "message";
public function addMessage($uniqueid, $src, $dst, $tipo, $content, $profile_name, $media, $status, $mimetype = null, $file_name = null, $id_provedor = null)
{
@ -78,8 +78,8 @@ class Message extends Model
public function getNameCliente($uniqueid, $cliente_id)
{
$this->query = "SELECT profile_name FROM md_message mm WHERE uniqueid = :uniqueid AND src = :cliente_id LIMIT 1";
$this->query = "SELECT profile_name FROM message mm WHERE uniqueid = :uniqueid AND src = :cliente_id LIMIT 1";
return $this->read($this->query, ['uniqueid' => $uniqueid, 'cliente_id' => $cliente_id])->fetch();
}
}
}

36
app/Models/SupervisorModel.php

@ -8,13 +8,13 @@ class SupervisorModel extends Model
{
const USUARIOS = "pbx_usuarios";
const SUPERVISOR_AGENTE = "md_supervisor";
const SUPERVISOR_AGENTE = "supervisor";
const EVENTO_AGENTE = 'pbx_eventos_agentes';
const BILHETE = 'pbx_bilhetes';
const EVENTOS_DACS = 'pbx_eventos_dacs';
private $supervisor = 'md_supervisor';
private $atendimento = 'md_atendimento';
private $supervisor = 'supervisor';
private $atendimento = 'atendimento';
public function listaAgentesDisponivel($status = null, $somenteLivre = true)
{
@ -24,8 +24,8 @@ class SupervisorModel extends Model
SELECT
count(*)
FROM
md_atendimento ma
WHERE 'START' = (SELECT m2.evento FROM md_evento m2
atendimento ma
WHERE 'START' = (SELECT m2.evento FROM evento m2
WHERE ma.uniqueid = m2.uniqueid
ORDER BY m2.id DESC LIMIT 1)
AND ma.matricula = ms.matricula
@ -35,12 +35,12 @@ class SupervisorModel extends Model
SELECT
count(*)
FROM
md_atendimento ma
atendimento ma
WHERE ma.data_reg >= current_date
AND ma.matricula = ms.matricula
) AS numero_atendimento_dia
FROM md_supervisor ms
FROM supervisor ms
WHERE 1=1
";
if ($somenteLivre) {
@ -48,8 +48,8 @@ class SupervisorModel extends Model
SELECT
count(*)
FROM
md_atendimento ma
WHERE 'START' = (SELECT m2.evento FROM md_evento m2
atendimento ma
WHERE 'START' = (SELECT m2.evento FROM evento m2
WHERE ma.uniqueid = m2.uniqueid
ORDER BY m2.id DESC LIMIT 1)
AND ma.matricula = ms.matricula
@ -72,14 +72,14 @@ class SupervisorModel extends Model
SELECT
count(*)
FROM
md_atendimento ma
WHERE 'START' = (SELECT m2.evento FROM md_evento m2
atendimento ma
WHERE 'START' = (SELECT m2.evento FROM evento m2
WHERE ma.uniqueid = m2.uniqueid
ORDER BY m2.id DESC LIMIT 1)
AND ma.matricula = ms.matricula
) AS numero_atendimento
FROM
md_supervisor ms
supervisor ms
WHERE ms.matricula = :matricula ";
return $this->read($this->query, ['matricula' => $matricula])->fetch();
@ -116,7 +116,7 @@ class SupervisorModel extends Model
$data['queue'] = $queue;
}
if($media){
if ($media) {
$this->query .= " AND media <> :media";
$data['media'] = $media;
}
@ -151,15 +151,15 @@ class SupervisorModel extends Model
{
$data = [];
$this->query = "SELECT *
FROM md_supervisor ms
FROM supervisor ms
WHERE ms.fila = :queue
AND ms.status = :status
ORDER BY (
SELECT
count(*)
FROM
md_atendimento ma
WHERE 'START' = (SELECT m2.evento FROM md_evento m2
atendimento ma
WHERE 'START' = (SELECT m2.evento FROM evento m2
WHERE ma.uniqueid = m2.uniqueid
ORDER BY m2.id DESC LIMIT 1)
AND ma.matricula = ms.matricula
@ -346,7 +346,7 @@ class SupervisorModel extends Model
{
$data = [];
$this->query = "DELETE FROM pbx_supervisor_agentes WHERE matricula = :matricula ";
if($media){
if ($media) {
$this->query .= "AND media {$oper} :media ";
$data['media'] = $media;
}
@ -405,4 +405,4 @@ class SupervisorModel extends Model
$data['ramal'] = $ramal;
return $this->update($this->query, $data);
}
}
}

4
app/Models/SystemMessage.php

@ -12,7 +12,7 @@ use app\Core\Model;
class SystemMessage extends Model
{
private $table = 'md_system_message';
private $table = 'system_message';
public function findMessage($momento, $fila = null)
{
@ -31,4 +31,4 @@ class SystemMessage extends Model
$this->query .= " AND m.momento = :momento ORDER BY ordem";
return $this->read($this->query, $data)->fetchAll();
}
}
}

Loading…
Cancel
Save