public function execute($dataContainer) { //No direct access defined('_WEXEC') or die("Access denied"); require_once PATH_ACCESS . '/GlobalSettingsManager.php'; require_once PATH_ACCESS . '/OrderManager.php'; require_once PATH_ACCESS . '/MealManager.php'; $smarty = $dataContainer->getSmarty(); $orderManager = new OrderManager('BabeskOrders'); $mealManager = new MealManager('BabeskMeals'); $meal = array(); $orders_existing = true; $meal_problems = false; $mealHistory = array(); try { $orders = $orderManager->getAllOrdersOfUser($_SESSION['uid'], strtotime(date('Y-m-d'))); } catch (MySQLVoidDataException $e) { $smarty->assign('error', 'Keine Bestellungen vorhanden.'); $orders_existing = false; } catch (Exception $e) { die('Error: ' . $e); } if ($orders_existing) { $today = date('Y-m-d'); $hour = date('H', time()); $this->_lastCancel = $this->lastOrdercancelDatemodGet(); foreach ($orders as $order) { try { $mealname = $mealManager->getEntryData($order['MID'], 'name'); } catch (MySQLVoidDataException $e) { $meal_problems = true; $smarty->assign('error', '<p class="error">Zu bestimmten Bestellung(-en) fehlen Daten einer Mahlzeit! Bitte benachrichtigen sie den Administrator!</p>'); continue; } if (!$order['fetched'] and $order['date'] >= $today) { //fetch last_order_time from database and compare with actual time $hour = date('H:i', time()); $cancelAllowed = $this->isAllowedToCancel($order['date']); $meal[] = array('date' => formatDate($order["date"]), 'name' => $mealname["name"], 'orderID' => $order['ID'], 'cancel' => $cancelAllowed); } else { $mealHistory[] = array('date' => formatDate($order["date"]), 'name' => $mealname["name"], 'orderID' => $order['ID'], 'cancel' => false, 'fetched' => $order['fetched']); } } } if (!count($meal) && !count($mealHistory) && !$meal_problems) { //no new meals there $smarty->assign('error', 'Keine Bestellungen vorhanden.'); } $smarty->assign('meal', $meal); $smarty->assign('mealHistory', $mealHistory); $smarty->display($this->smartyPath . 'menu.tpl'); }
/** *Returns the requested pricefield on the based on the User-ID and the Meal-ID * *@return: string *returns false if nothing found, else the priceData */ function getPrice($uid, $mid) { require_once PATH_ACCESS . '/UserManager.php'; require_once PATH_ACCESS . '/MealManager.php'; $userManager = new UserManager(); $mealManager = new MealManager('BabeskMeals'); $gid = $userManager->getEntryData($uid, 'GID'); $gid = $gid['GID']; //this is pc_ID in the table, not ID! $priceclass_ID = $mealManager->getEntryData($mid, 'price_class'); $priceclass_ID = $priceclass_ID['price_class']; if (!$priceclass_ID) { throw new Exception(''); } $priceData = $this->searchEntry('GID = ' . $gid . ' AND pc_ID = ' . $priceclass_ID); if (!isset($priceData['price'])) { throw new Exception('invalid Data gained from MySQL-Server:' . var_dump($priceData)); } return $priceData['price']; }