Simple queue management system in PHP

Submitted by Nicola Rainiero on 2021-05-08 (last updated on 2021-05-17)

Two weeks ago, I was looking for a method to control a waiting list showing the booking time. I wanted to show that time on a series of screens and be able to update it with one or more remote controllers. I was able to achieve this by creating two web pages: one in PHP and the other in HTML. Below I share with you the final result: a slideshow with booking time and educational banners.

Regarding the method, the first and realistic solution imagined, was a direct connection by HDMI to a server with a Powerpoint presentation or similar. However, I found it boring and I tried another way: PHP and AJAX.

Simple queue management system in PHP

Thanks to Google and Stackoverflow, in particular, this page: Execute PHP function with onclick, I was able to made this:

Message on the screens:
Remote controller:

The refresh button is useful when I have two or more controllers and I want to synchronize the time with the others and the screens. Then I put the page with the message in an awesome script by Troy Wolf, you can find it here: SiteShow -- Create a slideshow of web pages. It is very easy to use an HTML/Javascript page, simply edit an array of pages or "slides". You define a title, duration, and URL for each slide. The pages fade out and fade in between slides. You can change the fade-out colour as desired. And the final result was nice:

Slideshow:(Fullscreen)

Obviously, you can custom the message and the info page with banners, photos or whatever you want to entertain visitors while they wait. 

How it works

It is composed by three files:

  1. controller.php is the remote controller that checks the hour in the index.html if exists otherwise, it starts from 8:00;
  2. index.html is the output that shows the hour to the visitors, it is overwritten every time you click the minus and plus buttons;
  3. login.php is a simple login that allows access to the controller.php, inserting a password defined in itself.

Below there is the whole code, here I put three pieces of code to show you the mechanism of the minus button:

HTML

<button onclick="removeMin(event)" class="btn"><i class="fa fa-minus-circle"></i></button>

Javascript

  async function removeMin(e) {
    e.preventDefault(); 
    time = document.getElementById("ora").innerHTML; 
    document.getElementById("ora").innerHTML = await(await fetch('?remove='+time)).text();
  }

PHP

  function removeMin() { 
  $timeIn = $_GET['remove'];
  $minutes_to_remove = 5;
  $time = new DateTime($timeIn);
  $time->sub(new DateInterval('PT' . $minutes_to_remove . 'M'));

  $stamp = $time->format('H:i');
  writeFile($stamp); // call the function
  echo $stamp;}

  if (isset($_GET['remove'])) { return removeMin(); }

Download

Get the zip or clone my repository from GitHub: rainnic/simple-queue-system-PHP



Related Content:

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.