Пример #1
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;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
 public function execute()
 {
     global $gvPath;
     // Trim data
     $this->dev_ip_address = trim($this->dev_ip_address);
     $this->dev_desk_number = trim($this->dev_desk_number);
     // Data validation
     if ($this->dev_ip_address === '' || $this->dev_desk_number === '') {
         $this->message = "Errore: tutti i campi sono obbligatori.";
         return true;
     }
     // dev_desk_number should contain... numbers
     if (preg_match('/^(0|[1-9][0-9]*)$/', $this->dev_desk_number) !== 1) {
         $this->message = "Errore: il numero dello sportello non è valido.";
         return true;
     }
     // Check ip_address
     if (!filter_var($this->dev_ip_address, FILTER_VALIDATE_IP)) {
         $this->message = "Errore: l'indirizzo IP non è valido.";
         return true;
     }
     // Check if desk number really exists
     if ((int) $this->dev_desk_number !== 0) {
         $desk = Desk::fromDatabaseByNumber($this->dev_desk_number);
         if (!$desk) {
             $this->message = "Errore: lo sportello specificato non esiste.";
             return true;
         }
         unset($desk);
     }
     // Check tdCode exists and active
     if ($this->dev_td_code) {
         $td = TopicalDomain::fromDatabaseByCode($this->dev_td_code);
         if (!$td || !$td->getActive()) {
             $this->message = "Errore: l'area tematica selezionata non è disponibile.";
             return true;
         }
     }
     // Check ip is not taken
     $device = Device::fromDatabaseByIpAddress($this->dev_ip_address);
     $desk = Desk::fromDatabaseByIpAddress($this->dev_ip_address);
     if ($desk || $device && ($this->dev_id === 0 || $this->dev_id !== (int) $device->getId())) {
         $this->message = "Errore: l'indirizzo IP è gia stato assegnato.";
         return true;
     }
     unset($device);
     if ($this->dev_id === 0) {
         $device = Device::newRecord();
     } else {
         $device = Device::fromDatabaseById($this->dev_id);
     }
     $device->setIpAddress($this->dev_ip_address);
     $device->setDeskNumber($this->dev_desk_number);
     $device->setTdCode($this->dev_td_code);
     if ($device->save()) {
         gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok');
         $redirect = new RedirectOutput("{$gvPath}/application/adminDeviceList");
         return $redirect;
     } else {
         $this->message = "Impossibile salvare le modifiche. Ritentare in seguito.";
         return true;
     }
 }
Пример #6
0
 public static function nextNewTicket($td_code, $source = 'totem', $source_id = '', &$noticeBefore = -1)
 {
     if (!in_array($source, array('totem', 'web', 'app'))) {
         throw new Exception(__METHOD__ . " Invalid source value");
     }
     if ($source == 'totem') {
         $noticeBefore = -1;
         $source_id = '';
     } else {
         if (!$source_id) {
             throw new Exception(__METHOD__ . " web and app tickets need a source_id");
         }
     }
     $ticket = self::newRecord('ticket_in');
     $ticket->setCode($td_code);
     $ticket->setTimeIn(time());
     $ticket->setSource($source);
     $ticket->setSourceId($source_id);
     // Check existence of topical domain
     $td = TopicalDomain::fromDatabaseByCode($td_code);
     if (!$td || !$td->getActive()) {
         throw new Exception(__METHOD__ . " td_code not valid");
     }
     $number = $td->incrementNextGeneratedTicket();
     $td->save();
     $ticket->setNumber($number);
     if ($source != 'totem') {
         $ticketBefore = self::countTicketBefore($td_code, $number);
         if ($source == 'web') {
             $ticket->setNoticeCounter((int) ($ticketBefore / 2));
         } else {
             $ticket->setNoticeBeforeForApp($noticeBefore, $ticketBefore);
         }
     }
     return $ticket;
 }