|
|
|
@ -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']) { |
|
|
|
|