예제 #1
0
$courseDao = new CourseDao($em);
$drinkDao = new DrinkDao($em);
$dessertDao = new DessertDao($em);
$timeFrameDao = new TimeFrameDao($em);
$locationDao = new LocationDao($em);
$orderDao = new OrderDao($em);
$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);