コード例 #1
0
ファイル: FlightController.php プロジェクト: jimobama/app
 public function Create($planeId, $from, $to, $depatureDate, $landingDate, $boardingtime, $landingTime, $noOfStops, $ticketPrice, $option = null)
 {
     $id = null;
     $this->filter($id, $from, $to, $depatureDate, $landingDate, $boardingtime, $landingTime, $noOfStops, $ticketPrice, $option);
     $flight = new Flight();
     $flight->set($planeId, $from, $to, $depatureDate, $landingDate, $boardingtime, $landingTime, $ticketPrice, $noOfStops);
     $flightModel = new FlightModel($flight, $this->db);
     $this->flightModelView->flight = $flight;
     Session::set("modifier_plane", $planeId);
     $this->ViewBag("Title", "New Flight");
     $this->ViewBag("Controller", "Flight");
     $this->ViewBag("Page", "Create");
     if (isset($option) && $option != 'null') {
         if ($flight->validate()) {
             $this->flightModelView->flightDbModel = $flightModel;
             if ($flightModel->isExists($from, $to, $boardingtime)) {
                 ContextManager::ValidationFor("warning", "There is already a flight leaving at the same time to the same destination");
             } else {
                 //else if did not exists
                 $referenceNumber = $flightModel->AddFlight();
                 if ($referenceNumber != null) {
                     $content = $flight->toString();
                     $path = ContextManager::CreateQRBarcode($content, $referenceNumber);
                 } else {
                     ContextManager::ValidationFor("warning", "Transaction fails : " . $flightModel->GetError());
                     $flightModel->Rollback($flight->Id);
                 }
             }
         } else {
             ContextManager::ValidationFor("warning", $flight->error);
         }
     }
     $listOfFlights = $flightModel->GetAllFlights();
     $this->flightModelView->flightList = $listOfFlights;
     return $this->View($this->flightModelView, "Account", "Index");
 }
コード例 #2
0
ファイル: AgentController.php プロジェクト: jimobama/app
 function Create($email, $firstname, $lastname, $phone, $password, $repassword, $sendButton = null)
 {
     $repassword = $repassword == "null" ? null : $repassword;
     $agent = new Agent();
     $agent->set($firstname, $lastname, $email, $phone, $password);
     $agentModel = new AgentModel($agent);
     $list = $agentModel->GetUsers();
     $this->agentModelView->agent = $agent;
     $this->agentModelView->agentList = $list;
     if ($agent->validated()) {
         if ($password != $repassword) {
             Session::set("warning", " Password mis-matched, re-enter passwords again!");
             return $this->View($this->agentModelView, "Agent", "Create");
         } else {
             $this->agentModelView->agentDbModel = $agentModel;
             if ($agentModel->Exists()) {
                 Session::set("warning", "The user with the given email address [{$email}] already exists!");
             } else {
                 try {
                     //else create the user
                     if ($agentModel->Create()) {
                         $sessionID = Validator::UniqueKey(20);
                         $agentModel->SaveVerificationCode($email, $sessionID);
                         //create a barcode
                         $param = new ArrayIterator();
                         $param->offsetSet("username", $agent->email);
                         $param->offsetSet("verificationCode", $sessionID);
                         $url = ContextManager::CreateURL("Agent", "Login", $param);
                         $imgPath = ContextManager::CreateQRBarcode($url, $agent->agentId);
                         if ($this->_sendVerificationEmail($agent, $sessionID, $imgPath)) {
                             //navigate to comfirmation page
                             return $this->View($agent, "Agent", "Confirmation");
                         } else {
                             Session::set("warning", "could not send mail ");
                             $agentModel->DeleteAgent($email);
                         }
                     }
                 } catch (Exception $err) {
                     Session::set("warning", $err->getMessage());
                 }
             }
         }
         // create a database record here
     } else {
         Session::set("warning", $agent->getError());
     }
     return $this->View($this->agentModelView, "Agent", "Create");
 }