public function __construct() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $this->td_id = gfPostVar('td_id', 0); // Keep edited information if present $this->td_code = gfPostVar('td_code', ''); $this->td_name = gfPostVar('td_name', ''); $this->td_description = gfPostVar('td_description', ''); $this->td_icon = gfPostVar('td_icon', 0); $this->td_color = gfPostVar('td_color', 0); } else { $this->td_id = gfGetVar('td_id', 0); if ($this->td_id) { $td = TopicalDomain::fromDatabaseById($this->td_id); if ($td !== null) { $this->td_code = $td->getCode(); $this->td_name = $td->getName(); $this->td_description = $td->getDescription(); $this->td_icon = (int) $td->getIcon(); $this->td_color = (int) $td->getColor(); } else { $this->td_id = 0; } } } }
public function getOutput() { $output = new JsonOutput(); $td_code = gfGetVar('td_code', null); if (!$td_code) { $output->setContent(array('result' => 'error')); return $output; } // check td existence and activation $td = TopicalDomain::fromDatabaseByCode($td_code); if (!$td) { $output->setContent(array('result' => 'error')); return $output; } if (!$td->getActive()) { $output->setContent(array('result' => 'error')); return $output; } $ticket = Ticket::nextNewTicket($td_code, 'totem'); $ticket->save(); list($queueLength, $eta) = $ticket->getPeopleAndEta(); $content = array('code' => $ticket->getCode(), 'number' => $ticket->getNumber(), 'eta' => $eta, 'queueLength' => $queueLength); $jsonOutput = new JsonOutput(); $jsonOutput->setContent($content); return $jsonOutput; }
public function afterPermissionCheck() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $this->dev_id = gfPostVar('dev_id', 0); // Keep edited information if present $this->dev_ip_address = gfPostVar('dev_ip_address', ''); $this->dev_desk_number = gfPostVar('dev_desk_number', 0); $this->dev_td_code = gfPostVar('dev_td_code', '0'); } else { $this->dev_id = gfGetVar('dev_id', 0); if ($this->dev_id) { $device = Device::fromDatabaseById($this->dev_id); if ($device !== null) { $this->dev_ip_address = $device->getIpAddress(); $this->dev_desk_number = $device->getDeskNumber(); $this->dev_td_code = $device->getTdCode(); } else { $this->dev_id = 0; } } } if ($this->dev_td_code == '0' || $this->dev_desk_number != 0) { $this->dev_td_code = null; } }
public function afterPermissionCheck() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $this->desk_id = gfPostVar('desk_id', 0); // Keep edited information if present $this->desk_number = gfPostVar('desk_number', 0); $this->desk_ip_address = gfPostVar('desk_ip_address', ''); $this->pairing = gfPostVar('pairing', 0); } else { $this->desk_id = gfGetVar('desk_id', 0); if ($this->desk_id) { $desk = Desk::fromDatabaseById($this->desk_id); if ($desk !== null) { $this->desk_number = $desk->getNumber(); $this->desk_ip_address = $desk->getIpAddress(); } else { $this->desk_id = 0; } } $this->pairing = gfGetVar('pairing', 0); if ($this->pairing) { $this->desk_ip_address = $_SERVER['REMOTE_ADDR']; } } }
public function afterPermissionCheck() { $this->desk_number = (int) gfGetVar('desk_number'); if ($this->desk_number) { $this->ticket = Ticket::fromDatabaseByDesk($this->desk_number); } }
public function afterPermissionCheck() { if (gfGetVar('reset', false)) { Session::setupWebSession(); } $this->redirect = Session::redirectLastStep(0); $this->tdList = TopicalDomain::fromDatabaseCompleteList(); }
public function afterPermissionCheck() { $this->goBack = gfGetVar('goBack', false); if ($this->goBack) { $_SESSION['step'] = 0; } $this->redirect = Session::redirectLastStep(1); $this->td_code = gfSessionVar('td_code', ''); }
public function afterPermissionCheck() { $this->goBack = gfGetVar('goBack', false); if ($this->goBack) { $step = gfSessionVar('step', 0); if ($step == 2) { $_SESSION['step'] = 1; } else { $_SESSION['step'] = 0; } } $this->redirect = Session::redirectLastStep(2); $this->phone_code = gfSessionVar('phone_code', ''); }
function main() { // Check whether this device needs to be redirected somewhere $dev = Device::fromDatabaseByIpAddress($_SERVER['REMOTE_ADDR']); if ($content = getContentForRedirect($dev, 0)) { $output = new JsonOutput(); $output->setContent($content); $output->output(); exit; } $td_code = gfGetVar('td_code', ''); $lastTicket = gfGetVar('lastTicket', 'A000'); $content = null; $startTime = time(); while (time() - $startTime < 120) { sleep(1); // Check every second $currentState = DisplayMain::fromDatabaseCompleteList($td_code); if (count($currentState) == 0) { continue; } if ($lastTicket != $currentState[0]->getTicket()) { // Something changed, compute new tickets $newTickets = array($currentState[0]); $i = 1; while ($i < count($currentState) && $i < 8 && $lastTicket != $currentState[$i]->getTicket()) { $newTickets[] = $currentState[$i]; $i++; } $content = array('status' => 'changed', 'count' => count($newTickets), 'entries' => $newTickets); break; } unset($currentState); } // End while if (!$content) { // Polling wait expired $content = array('status' => 'unchanged'); } $output = new JsonOutput(); $output->setContent($content); $output->output(); }
function getContentForRedirect($dev, $currentDesk) { global $gvPath; $content = array(); if (!$dev) { $rand = rand(1, 100); $content['status'] = 'redirect'; $content['location'] = "{$gvPath}/device?v={$rand}"; } elseif ($dev->getDeskNumber() != $currentDesk) { $content['status'] = 'redirect'; if ($dev->getDeskNumber()) { $content['location'] = "{$gvPath}/device/desk?desk_number={$dev->getDeskNumber()}"; } else { $content['location'] = getUrlForDisplayMain($dev); } } elseif ($dev->getDeskNumber() == 0 && $dev->getTdCode() != gfGetVar('td_code', '')) { $content['status'] = 'redirect'; $content['location'] = getUrlForDisplayMain($dev); } return $content; }
public function afterPermissionCheck() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $this->op_id = gfPostVar('op_id', 0); // Keep edited information if present $this->op_code = gfPostVar('op_code', ''); $this->op_name = gfPostVar('op_name', ''); $this->op_surname = gfPostVar('op_surname', ''); } else { $this->op_id = gfGetVar('op_id', 0); if ($this->op_id) { $op = Operator::fromDatabaseById($this->op_id); if ($op !== null) { $this->op_code = $op->getCode(); $this->op_name = $op->getName(); $this->op_surname = $op->getSurname(); } else { $this->op_id = 0; } } } }
include './displayFunctions.php'; // Do not lock tables Database::lockTables(false); $deskNumber = gfGetVar('deskNumber'); // Check whether this device needs to be redirected somewhere $dev = Device::fromDatabaseByIpAddress($_SERVER['REMOTE_ADDR']); if ($content = getContentForRedirect($dev, (int) $deskNumber)) { $output = new JsonOutput(); $output->setContent($content); $output->output(); exit; } // Response is json $output = new JsonOutput(); $pageTicketCode = gfGetVar('ticketCode', ''); $pageTicketNumber = gfGetVar('ticketNumber', ''); $startTime = time(); while (time() - $startTime < 120) { sleep(1); // Check every second // Update table for session timed out $desk = Desk::fromDatabaseByNumber($deskNumber); $desk->isOpen(); $currentTicket = Ticket::fromDatabaseByDesk($deskNumber); if (!$currentTicket) { if ($pageTicketCode == '' && $pageTicketNumber == '') { // Still no ticket continue; } // Desk is closing send empty stuff $output->setContent(array('status' => 'changed', 'code' => '', 'number' => ''));