Esempio n. 1
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;
 }