public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ /*var_dump($formFields['bookingDate']); var_dump($date); var_dump($date > $formFields['bookingDate']); die();*/ $date = new DateTime(); $userSession = new UserSession(); $bookingModel = new BookingModel(); $customerId = intval($userSession->getId()); if ($userSession->isAuthenticated()) { $customerId = intval($userSession->getId()); $checkBookingById = $bookingModel->checkBookingById($customerId, intval($formFields['bookingId']), $formFields['bookingDate']); if (ctype_digit($formFields['bookingId']) && $date < new DateTime($formFields['bookingDate']) && $checkBookingById) { $bookingModel->DeletBooking($formFields['bookingId']); $flashBag = new FlashBag(); $flashBag->add('Réservation ' . $formFields["bookingId"] . ' bien supprimée'); $http->redirectTo('/'); } $flashBag = new FlashBag(); $flashBag->add('Problème lors de la suppression de la réservation (Vous ne pouvez supprimer des réservations posterieur à aujourd\'hui)'); $http->redirectTo('/Booking'); } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ /*$date = new DateModel(); var_dump($date->testDate($formFields['dateResa'])); //0 FAUX - 1 VRAI REJEX */ $userSession = new UserSession(); if ($userSession->isAuthenticated()) { $dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']); $now = new DateTime("now"); $resaDate = date_format($dateTime, 'Y-m-d'); $resaTime = date_format($dateTime, 'H:i:s'); //var_dump($formFields); if (!empty($formFields['dateResa']) && !empty($formFields['timeResa']) && !empty($formFields['NumberOfSeats']) && $dateTime > $now && ctype_digit($formFields['NumberOfSeats'])) { $userId = $userSession->getId(); $Booking = new BookingModel(); $resultat = $Booking->register($userId, $resaDate, $resaTime, $formFields['NumberOfSeats']); return ['resultat' => $resultat]; } elseif ($dateTime < $now) { return ['Error' => 'Nous ne pouvons vous réserver une table pour une date antérieur à aujourd\'hui']; } else { return ['Error' => 'Un champ n\'a pas était remplie correctement']; } } else { echo 'lu'; die; $http->redirectTo('/'); } }
function CreateBookingTables($types) { $bookingModel = new BookingModel(); $bookingArray = $bookingModel->GetBookingByType($types); $result = ""; foreach ($bookingArray as $key => $booking) { $result = $result . "<table class = 'bookingTable'>\n <tr>\n \n \n \n <th width = '75px' >BookingId : </th>\n <td>{$booking->BookingId}</td>\n </tr>\n \n <tr>\n <th width = '75px' >Customer Name : </th>\n <td>{$booking->CustomerName}</td>\n </tr>\n \n <tr>\n <th>Contact Number : </th>\n <td>{$booking->ContactNo}</td>\n </tr>\n \n <tr>\n <th>Email : </th>\n <td>{$booking->Email}</td>\n </tr>\n \n \n <tr>\n <th>No.of Persons : </th>\n <td>{$booking->PersonNumber}</td>\n </tr>\n \n <tr>\n <th>BookingDate : </th>\n <td>{$booking->BookingDate}</td>\n </tr>\n \n <tr>\n <th>TimeBand : </th>\n <td>{$booking->TimeBand}</td>\n </tr>\n \n \n \n \n </table>"; } return $result; }
public function __construct() { parent::__construct(); $this->_form = new BookingForm(); $this->_bookingModel = BookingModel::getInstance(); $this->_view = View::getInstance(); }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ /*$date = new DateModel(); var_dump($date->testDate($formFields['dateResa'])); //0 FAUX - 1 VRAI REJEX */ try { $userSession = new UserSession(); if ($userSession->isAuthenticated()) { $dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']); if ($dateTime == false) { throw new InvalidArgumentException(BookingModel::$dateException); } $now = new DateTime("now"); $resaDate = date_format($dateTime, 'Y-m-d'); $resaTime = date_format($dateTime, 'H:i:s'); //var_dump($formFields); if (!empty($formFields['dateResa']) && !empty($formFields['timeResa']) && !empty($formFields['NumberOfSeats']) && $dateTime > $now && ctype_digit($formFields['NumberOfSeats'])) { $userId = $userSession->getId(); $booking = new BookingModel(); $resultat = $booking->register($userId, $resaDate, $resaTime, $formFields['NumberOfSeats']); $flashBag = new FlashBag(); $flashBag->add("Votre réservation numero {$resultat} du {$resaDate} à {$resaTime} pour " . $formFields['NumberOfSeats'] . " est bien pris en compte"); $http->redirectTo('/'); } elseif ($dateTime < $now) { throw new InvalidArgumentException(BookingModel::$PasseDateException); } else { throw new InvalidArgumentException(BookingModel::$FieldsException); } } else { $http->redirectTo('/'); } } catch (InvalidArgumentException $event) { //var_dump($event); $form = new BookingForm(); $form->bind($formFields); $form->setErrorMessage($event->getMessage()); return ['_form' => $form]; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return BookingModel the loaded model * @throws CHttpException */ public function loadModel($id) { $model = BookingModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
This controller directs the control to a particular model depending on the action. */ session_start(); include "../classes/User.php"; include "../classes/BookingDetails.php"; include "../classes/FlightSearchParameters.php"; include "../classes/FlightDetails.php"; include "../classes/Review.php"; include "../classes/Passenger.php"; include "../model/UserAccountModel.php"; include "../model/BookingModel.php"; include "../model/FlightModel.php"; include "../model/ReviewModel.php"; $userModel = new UserAccountModel(); $bookingModel = new BookingModel(); $flightModel = new FlightModel(); $reviewModel = new ReviewModel(); if ($_SESSION['action'] == "login") { $user = unserialize($_SESSION['user']); $arrayOfBookings = array(); if ($userModel->isUserPresent($user->getLoginId(), $user->getPassword()) == true) { $user = $userModel->getUserInstance($user->getLoginId(), $user->getPassword()); $_SESSION['userId'] = $user->getUserId(); $_SESSION['userMiles'] = $user->getMiles(); $_SESSION['loginName'] = $user->getLoginId(); $arrayOfBookings = $bookingModel->getBookings($user->getUserId()); $_SESSION['bookingsArray'] = serialize($arrayOfBookings); header("Location: ../view/Startup.php"); } else { $_SESSION['loginToken'] = "invalid";