public function execute() { if (!isset($_POST['deviceToken'])) { $this->setTokenError(); return true; } $action = gfPostVar('action', ''); $class = AppAction::getClass($action); try { $apiAction = new $class($_POST['deviceToken']); $this->content = $apiAction->execute(); } catch (BadOwnershipException $e) { $this->setOwnershipError(); } catch (BannedDeviceException $e) { $this->setBannedError(); } catch (InvalidOfficeCodeException $e) { $this->setOfficeCodeError(); } catch (InvalidParamException $e) { $this->setInvalidParamError(); } catch (InvalidTicketException $e) { $this->setTicketError(); } catch (InvalidTokenException $e) { $this->setTokenError(); } catch (Exception $e) { $this->setInternalError($e); } return true; }
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 __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 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 execute() { global $gvPath, $gvQueueLengthWebLimit, $gvQueueEtaWebLimit; if ($this->redirect) { return $this->redirect; } $td_code = gfPostVar('td_code'); if (!$td_code) { return true; } // Check existence of topical domain $td = TopicalDomain::fromDatabaseByCode($td_code); if (!$td || !$td->getActive()) { $this->message = 'Non è possibile selezionare l\'area tematica indicata.'; return true; } // Check Eta limit if ($td->getEta() < $gvQueueEtaWebLimit) { $message = 'È possibile selezionare solo aree tematiche con almeno %d minuti d\'attesa.'; $this->message = sprintf($message, (int) ($gvQueueEtaWebLimit / 60)); return true; } // Check queue length limit $queueLength = Ticket::getNumberTicketInQueue($td_code); if ($queueLength < $gvQueueLengthWebLimit) { $message = 'È possibile selezionare solo aree tematiche con almeno %d clienti in coda.'; $this->message = sprintf($message, $gvQueueLengthWebLimit); return true; } $_SESSION['step'] = 1; $_SESSION['td_code'] = $td_code; $redirect = new RedirectOutput("{$gvPath}/web/insertPhone"); return $redirect; }
public function execute() { global $gvPath, $gvPhoneCodeLength; if ($this->redirect) { return $this->redirect; } $this->message = ''; $phone = gfPostVar('phone'); if (!$phone) { $this->message = 'Il campo è obbligatorio.'; return true; } // Check only digits have been typed if (!preg_match('/^[0-9]{5,}$/', $phone)) { $this->message = 'Il valore inserito non è valido.'; return true; } // Remove international prefix if present $phone = preg_replace('/^(00|\\+)?39/', '', $phone); $phone = '39' . $phone; // Check no ticket is reserved with this phone number $ticket = Ticket::fromDatabaseBySourceId($phone); if ($ticket) { $this->message = 'Hai già prenotato un ticket con questo numero.'; return true; } // Check phone number is not banned if (Ban::isBanned($phone)) { $this->message = 'Questo numero di telefono è stato bloccato.'; return true; } $hashRandom = (string) mt_rand(0, 100000); $hashRandom .= (string) mt_rand(0, 100000); $hashRandom = strtoupper(sha1($hashRandom)); $positionRandom = mt_rand(0, 40 - $gvPhoneCodeLength); $phone_code = substr($hashRandom, $positionRandom, $gvPhoneCodeLength); $_SESSION['phone_code'] = $phone_code; $_SESSION['phone'] = $phone; // Send SMS $sender = new SmsSender($phone); if (!$sender->sendVerificationCode($phone_code)) { $this->message = 'Errore nell\'invio del messaggio. Verificare che il numero di telefono sia corretto.'; return true; } $_SESSION['step'] = 2; $redirect = new RedirectOutput("{$gvPath}/web/checkPhone"); return $redirect; }
public function execute() { global $gvPath, $gvPhoneCodeLength; if ($this->redirect) { return $this->redirect; } $this->message = ''; $phone_code = gfPostVar('phone_code', ''); $phone_code = strtoupper($phone_code); if (!$phone_code) { $this->message = 'Il campo è obbligatorio.'; return true; } if ($phone_code != $this->phone_code) { $this->message = 'Il codice inserito non è corretto.'; return true; } // check td existence and activation $td_code = gfSessionVar('td_code', ''); $td = TopicalDomain::fromDatabaseByCode($td_code); if (!$td || !$td->getActive()) { // This is very improbable in this // case start again the wizard $_SESSION['step'] = 0; return true; } $ticket = Ticket::nextNewTicket($td_code, 'web', gfSessionVar('phone')); $ticket->save(); $sender = new SmsSender(gfSessionVar('phone')); if (!$sender->sendNewTicket($ticket)) { // False means error while sending $this->message = "Errore nella prenotazione. Assicurarsi di aver inserito il numero corretto."; return true; } $_SESSION['step'] = 3; $_SESSION['ticket'] = $ticket; $redirect = new RedirectOutput("{$gvPath}/web/complete"); return $redirect; }
public function execute() { $this->td_served = gfPostVar('td_served', array()); $_SESSION['td_served'] = $this->td_served; if (!$this->td_served && !isset($_POST['pause'])) { $this->message = "Errore: selezionare almeno un'area tematica."; return true; } // Handle served ticket $served = Ticket::fromDatabaseByDesk($this->getDesk()->getNumber()); if ($served) { $stats = TicketStats::newFromTicket($served); $served->delete(); if (!$stats->save()) { throw new Exception("Unable to save ticket stats."); } } // Handle pause button if (isset($_POST['pause'])) { $this->pauseButtonEnabled = false; $this->ticket_served = null; return true; } // Call next ticket $ticket = Ticket::serveNextTicket($this->td_served, $this->getOperator()->getCode(), $this->getDesk()->getNumber()); if (!$ticket) { $this->message = "Nessun ticket da chiamare"; $this->pauseButtonEnabled = false; $this->ticket_served = null; return true; } $ticket->save(); $this->ticket_served = $ticket; $this->disableNextButton = true; $this->pauseButtonEnabled = true; return true; }
public function execute() { global $gvMinPasswordLength, $gvPath; $op_password = gfPostVar('op_password', ''); $op_password_repete = gfPostVar('op_password_repete', ''); // Trim data $this->op_code = trim($this->op_code); $this->op_name = trim($this->op_name); $this->op_surname = trim($this->op_surname); // Data validation if ($this->op_code === '' || $this->op_name === '' || $this->op_surname === '') { $this->message = "Errore: tutti i campi sono obbligatori."; return true; } if ($this->op_id === 0 && $op_password === '') { $this->message = "Errore: il campo password è obbligatorio."; return true; } if ($op_password && strlen($op_password) < $gvMinPasswordLength) { $this->message = "Errore: la password deve contenere almeno " . "{$gvMinPasswordLength} caratteri."; return true; } if ($op_password !== $op_password_repete) { $this->message = "Errore: le password non coincidono."; return true; } // Allow only letters and digits in op_code if (preg_match('/^[0-9a-z]+$/i', $this->op_code) !== 1) { $this->message = "Errore: il codice operatore non è valido."; return true; } // Check name if (preg_match('/^[a-z \'àèéìòù]+$/i', $this->op_name) !== 1) { $this->message = "Errore: il nome contiene caratteri non validi."; return true; } // Check surname if (preg_match('/^[a-z \'àèéìòù]+$/i', $this->op_surname) !== 1) { $this->message = "Errore: il cognome contiene caratteri non validi."; return true; } // Check if code is taken for new operator $op = Operator::fromDatabaseByCode($this->op_code); if ($op && ($this->op_id === 0 || $this->op_id !== (int) $op->getId())) { $this->message = "Errore: il codice operatore non è disponibile."; return true; } unset($op); // Check operator is offline (only when edit) if ($this->op_id !== 0) { $operator = Operator::fromDatabaseById($this->op_id); if (!$operator) { $this->message = "Errore interno: il record non è presente."; return true; } if ($operator->isOnline()) { $this->message = "L'operatore è online, impossibile modificarlo."; return true; } } if ($this->op_id === 0) { $op = Operator::newRecord(); $op->setCode($this->op_code); $op->setName($this->op_name); $op->setSurname($this->op_surname); $op->setPassword($op_password); } else { $op = Operator::fromDatabaseById($this->op_id); $op->setCode($this->op_code); $op->setName($this->op_name); $op->setSurname($this->op_surname); if ($op_password) { $op->setPassword($op_password); } } if ($op->save()) { gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok'); $redirect = new RedirectOutput("{$gvPath}/application/adminOperatorList"); return $redirect; } else { $this->message = "Impossibile salvare le modifiche. Ritentare in seguito."; return true; } }