Browse Source

add parametro de quantidade e listar todos no listaatendimentos agente

websocket
lucascardo12 3 years ago
parent
commit
788aae293a
  1. 15
      app/Middleware/ApiAgente.php
  2. 21
      app/Models/Atendimento.php

15
app/Middleware/ApiAgente.php

@ -446,14 +446,15 @@ class ApiAgente implements IApi
function listaAtendimentoAgent($request)
{
$agente = $this->supervisor->findAgentByMatricula($request['matricula']);
//verifica se existe agente
if (empty($agente)) {
$this->retorno("Agente não encontrado");
return;
if ($request['matricula']) {
$agente = $this->supervisor->findAgentByMatricula($request['matricula']);
//verifica se existe agente
if (empty($agente)) {
$this->retorno("Agente não encontrado");
return;
}
}
$ret = $this->atendimento->findAtendAgent($request['matricula']);
$ret = $this->atendimento->findAtendAgent($request['matricula'], $request['quantidade']);
$this->retorno(
$ret ? "Sucesso" : "Erro",
$ret ? $ret : null,

21
app/Models/Atendimento.php

@ -45,8 +45,9 @@ class Atendimento extends Model
return $this->read($this->query, ['evento' => $evento, 'fila' => $fila])->fetchAll();
}
public function findAtendAgent($matricula)
public function findAtendAgent($matricula, $quantidade = 10)
{
$data = [];
$this->query = "SELECT ma.*,
ma.nome AS profile_name,
ppr.protocolo as protocolo,
@ -56,11 +57,17 @@ class Atendimento extends Model
ELSE 0
END AS status
FROM {$this->atendimento} ma
INNER JOIN pbx_protocolo_reg ppr ON ma.uniqueid = ppr.uniqueid
WHERE ma.matricula = :matricula
ORDER BY status DESC, data_reg DESC
LIMIT 10";
return $this->read($this->query, ['matricula' => $matricula])->fetchAll();
INNER JOIN pbx_protocolo_reg ppr ON ma.uniqueid = ppr.uniqueid ";
if ($matricula) {
$this->query .= " WHERE ma.matricula = :matricula ";
$data['matricula'] = $matricula;
}
$data['quantidade'] = $quantidade;
$this->query .= " ORDER BY status DESC, data_reg DESC
LIMIT :quantidade ";
return $this->read($this->query, $data)->fetchAll();
}
public function findAtenEmAberto($cliente_id = null)
@ -116,7 +123,7 @@ class Atendimento extends Model
WHERE (SELECT m2.evento FROM md_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';
$this->query .= ' AND me.fila = :fila';
$data['fila'] = $fila;
}
return $this->read($this->query, $data)->fetchAll();

Loading…
Cancel
Save