public function execute() { global $gvOfficeCode, $gvQueueLengthAppLimit, $gvQueueEtaAppLimit; if (empty($_POST['queueCode']) || empty($_POST['noticeBefore'])) { throw new InvalidParamException(); } else { $td_code = $_POST['queueCode']; $noticeBefore = $_POST['noticeBefore']; } if ($noticeBefore <= 0) { throw new InvalidParamException(); } else { $noticeBefore = (int) $noticeBefore; } if (Ticket::fromDatabaseBySourceId($this->token)) { return array('ErrorCode' => "AE???", 'ErrorMsg' => "Ticket already exists for this token"); } $td = TopicalDomain::fromDatabaseByCode($td_code); if (!$td || !$td->getActive()) { return array('ErrorCode' => "AE003", 'ErrorMsg' => "Queue specified does not exist"); } if ($td->getEta() < $gvQueueEtaAppLimit || Ticket::getNumberTicketInQueue($td_code) < $gvQueueLengthAppLimit) { return array('ErrorCode' => "AE???", 'ErrorMsg' => "Queue limit not satisfied"); } $ticket = Ticket::nextNewTicket($td_code, 'app', $this->token, $noticeBefore); $ticket->save(); list($people, $eta) = $ticket->getPeopleAndEta(); $content = array(); $content['OfficeCode'] = $gvOfficeCode; $content['Ticket'] = $ticket->getTextString(); $content['Eta'] = (int) ($eta / 60); $content['PeopleBefore'] = $people; $content['AssignedNoticeBefore'] = $noticeBefore; return $content; }
public function execute() { global $gvOfficeCode; $tdList = TopicalDomain::fromDatabaseCompleteList(); $content = array(); if (!$tdList) { $content['ErrorCode'] = "AE003"; $content['ErrorMsg'] = "No queues in this office"; return $content; } $content['OfficeCode'] = $gvOfficeCode; $content['NumQueues'] = count($tdList); $content['Queues'] = array(); foreach ($tdList as $td) { $queueObj = array('Code' => $td->getCode(), 'Name' => $td->getName(), 'Description' => $td->getDescription(), 'Eta' => (int) ($td->getEta() / 60), 'PeopleWaiting' => Ticket::getNumberTicketInQueue($td->getCode())); $content['Queues'][] = $queueObj; } return $content; }
private function getTableBody() { $topicalDomains = TopicalDomain::fromDatabaseCompleteList(true); $tableBody = ''; for ($i = 0; $i < count($topicalDomains); $i++) { $td = $topicalDomains[$i]; $description = $td->getCode() . " - " . htmlspecialchars($td->getName()); $queueLength = Ticket::getNumberTicketInQueue($td->getCode()); $checkbox = $this->getCheckBox($td->getCode(), $description, $queueLength, in_array($td->getCode(), $this->td_served)); if ($i % 4 === 0) { $tableBody .= "<tr>\n"; } $tableBody .= "<td style=\"padding: 5px;\">{$checkbox}</td>\n"; if (($i + 1) % 4 === 0) { $tableBody .= "</tr>\n"; } } // Close row if not closed if (substr($tableBody, -6) !== "</tr>\n") { $tableBody .= "</tr>\n"; } return $tableBody; }
public function canBeDeactivated() { $queueLength = Ticket::getNumberTicketInQueue($this->td_code); return $queueLength === 0; }
public function getTable() { $ret = <<<EOS <table id="listTable"> <tr> <th>Servizio</th> <th>Clienti in coda</th> <th>Attesa stimata</th> </tr> EOS; foreach ($this->tdList as $td) { $code = $td->getCode(); $text = $code . " - " . $td->getName(); $queueLength = Ticket::getNumberTicketInQueue($code); $eta = intval($td->getEta() / 60); $eta .= " min"; $row = <<<EOS <tr class="clickable" data-code="{$code}"> <td>{$text}</td> <td>{$queueLength}</td> <td>{$eta}</td> </tr> EOS; $ret .= $row; } $ret .= "\n</table>\n"; return $ret; }