I think it’s cool to do it like this:
The user who wants to be served makes a minimum registration on a form
example: name and e-mail.
Through the post method it is inserted into a table and redirected to the queue.
adding.php
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
// repare que criei um status que será usado mais tarde, se for 0 significa que está na fila
mysql_query("INSERT INTO fila(id_fila, nome_usuario, email_usuario, status) VALUES (0, '$nome', '$email', 0");
// abre uma sessao
$_SESSION['email'] = $email;
header("Location: esperando.php");
?>
expecting php.
<?php
$emailUsuario = $_SESSION['email'];
$selecionaUsuariosEspera = mysql_query("SELECT * FROM fila WHERE email = '$emailUsuario'");
$usuariosEmEspera = mysql_fetch_assoc($selecionaUsuariosEspera);
//verifica se o usuário ainda está na fila
if($usuariosEmEspera['status'] == 1){
//se o status dele for 1 significa que o atendente solicitou a presença em um outro ambiente, e ai ele vai.....
header("Location: areaDeAtendimento.php");
} else {
//se não ele continua a esperar.....
?>
<html>
<head>
// repare abaixo que a página vai ficar fazendo refresh a cada 1 minuto(acho)...
// Para que? Para fazer a analise do banco de dados denovo...
<meta http-equiv="refresh" content="60">
</head>
<body>
aguarde...
</body>
</html>
<?php } ?>
areaDoAtendente.php
You will have to create a service table like this..
-id
-sender
-destinatario
-msg
-on-call
When the attendant clicks on the "Next to the Queue!" button it goes to another page that will happen this...
requestUsuario.php
<?php
//seleciona o último da fila que o status = 0
$selecionaUltimoDaFIla = mysql_query("SELECT * FROM fila WHERE status = 0 LIMIT 1");
$ultimoUsuario = mysql_fetch_assoc($selecionaUltimoDaFIla);
$email = $ultimoUsuario['email'];
//altera o status do usuario selecionado
mysql_query("UPDATE fila SET status = 1 WHERE email = $email");
//seleciona o ultimo numero de atendimento realizado
$ultimoNumero = mysql_query("SELECT num_atendimento FROM atendimento ORDER BY num_atendimento DESC LIMIT 1");
$numero = mysql_fetch_assoc($selecionaUltimoDaFIla);
$numero = numero + 1;
mysql_query("INSERT INTO atendimento(id, remetente, destinatario, msg, num_atendimento)VALUES(0, '$atendente', '$email', 'Seja Bem Vindo! Em que possoa ajudar', $numero)");
$_SESSION['id_atendimento'] = $numero;
header("Location: areaDeAtendimento.php");
?>
in the area of php support. you select all posts where the call number was = the call SESSION.
I think I’ve gone too far. kkk ... I don’t know if that’s what you need in the end but ok
Hug!
The best way to do this is with javascript, because only with php, mysql sessoes or cookies can create a problem. imagine that the attendant closes the browser without closing the session or leaving the page wrongly... the other attendants will not be able to access the page because the last attendant did not confirm his exit correctly from that location.
– Andrei Coelho
I put the javascript tag to see if someone appears, because I don’t know
– Andrei Coelho
@Andreicoelho The solution may even involve Javascript, but it is linked to a global state of the application, and that state can only be on the server. Javascript may even help in terms of usability, but the crux of the problem is server-side.
– bfavaretto
True... you have rasão @bfavaretto, but only with php mysql will generate problem.
– Andrei Coelho
@Andreicoelho The suggestion you had given and deleted (why?! was good!) can be implemented only with PHP and a BD.
– bfavaretto
That way yes @bfavaretto but I thought that’s not what Alan asked why I deleted.. =)
– Andrei Coelho
@Could Andreicoelho show the suggestion you had erased? It might be useful.
– Alan Garmatter
So Alan, my suggestion was this: there will be a queue of users... The attendant who is free, requests a user to be served
– Andrei Coelho
He clicks on a button... "I’m Free"... then you link that user with that attendant.. I know that’s not what you’re developing, but it might help
– Andrei Coelho
@Andreicoelho, it’s a very interesting idea. And he believes that I could do it using PHP and Mysql, or even Javascript?
– Alan Garmatter
This way you only need php and mysql. Because the queue is only linked to users who are waiting to be served.. if you want I can make an example
– Andrei Coelho
Please, friend, give me an example just so I can get a sense of what it would be like, then I’ll turn around.
– Alan Garmatter