You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

<?php
namespace app\Controllers;
use app\Core\Controller;
use app\Models\Atendimento;
/**
* Description of ClientController
*
* @author root
*/
class ClientController extends Controller
{
public function getClientQueueData($number, $fila)
{
$atendimento = new Atendimento();
$atendimentoFila = $atendimento->getAtendimentoByEvento($fila);
$clientInQueue = false;
$queuePosition = 0;
$clientQueue = '';
foreach ($atendimentoFila as $clientes) {
if ($clientes->cliente_id == $number) {
$clientInQueue = true;
$clientQueue = $clientes->fila;
break;
}
}
$queueClientData = array_filter($atendimentoFila, function ($data) use ($clientQueue) {
return $data->fila == $clientQueue;
});
foreach ($queueClientData as $clientes) {
$queuePosition += 1;
if ($clientes->cliente_id == $number) {
break;
}
}
return ["IN_QUEUE" => $clientInQueue, "QUEUE_POSITION" => $queuePosition, "CLIENT_QUEUE" => $clientQueue];
}
}