/* */ /* Date: 15/10/2015 23:55 */ /* All right reserved */ /*-----------------------------------------------------*/ use MealBooker\manager\SecurityManager; use MealBooker\model\Location; use MealBooker\model\TimeFrame; use MealBooker\models\dao\LocationDao; if (!SecurityManager::get()->getCurrentUser($_SESSION)->isAdmin()) { header('Location:' . WEB_PATH); } $locationDao = new LocationDao($em); //save mode if (isset($_POST['name']) && isset($_POST['id']) && isset($_POST['state'])) { // @var Location $location = $locationDao->getByPrimaryKey($_POST['id']); if ($location == null) { $location = new Location(); } $location->setName($_POST['name']); $location->setStatus($_POST['state']); $locationDao->save($location); header('Location:' . WEB_PATH . '?page=admin&tab=location'); } //view Mode if (isset($_GET['id'])) { $location = $locationDao->getByPrimaryKey($_GET['id']); if ($location == null) { header('Location:' . WEB_PATH); } } else {
$mealDao = new MealDao($em); //if no cart or not logged in if (!isset($_SESSION['mealCart']) || !isset($_POST['location'])) { header('Location : ' . WEB_PATH); exit; } $mealCart = json_decode($_SESSION['mealCart']); if (sizeof($mealCart->cart) > 0) { $order = new MealOrder(); $order->setUser(SecurityManager::get()->getCurrentUser($_SESSION)); //set time fram if provide //$timeframe = $timeFrameDao->getByPrimaryKey($_POST['timeframe']); //if ($timeframe != null) // $order->setTimeFrame($timeframe); //set location $location = $locationDao->getByPrimaryKey($_POST['location']); if ($location != null) { $order->setLocation($location); } //fill order with meal $mealArray = array(); foreach ($mealCart->cart as $mealStub) { $drink = $drinkDao->getByPrimaryKey($mealStub->drink); $dessert = $dessertDao->getByPrimaryKey($mealStub->dessert); $course = $courseDao->getByPrimaryKey($mealStub->course); if ($drink != null && $course != null) { $meal = new Meal(); $meal->setBookingId($mealStub->id); if ($drink != null) { $meal->setDrink($drink); }