/** * Shows the Priceclasses */ function ShowPriceclasses() { require_once PATH_ACCESS . '/GroupManager.php'; try { $groupManager = new GroupManager('groups'); } catch (Exception $e) { $this->pcInterface->dieError($this->msg['err_fetch_groups'] . $e->getMessage()); } try { $priceclasses = $this->pcManager->getTableData(); } catch (Exception $e) { $this->pcInterface->dieError($this->msg['err_fetch_priceclass'] . $e->getMessage()); } foreach ($priceclasses as &$priceclass) { try { $group = $groupManager->getEntryData($priceclass['GID'], 'name'); } catch (MySQLVoidDataException $e) { $priceclass['group_name'] = $this->msg['err']; } catch (Exception $e) { $this->pcInterface->dieError($this->msg['err_fetch_groups'] . $e->getMessage()); } if (!$group) { $priceclass['group_name'] = $this->msg['err']; } else { $priceclass['group_name'] = $group['name']; } } $this->pcInterface->ShowPriceclasses($priceclasses); }
/** *shows the orders in a table */ function ShowOrders() { require_once PATH_ACCESS . '/OrderManager.php'; require_once PATH_ACCESS . '/MealManager.php'; require_once PATH_ACCESS . '/UserManager.php'; require_once PATH_ACCESS . '/GroupManager.php'; require_once PATH_ACCESS . '/GlobalSettingsManager.php'; if (!isset($_POST['ordering_day']) or !isset($_POST['ordering_month']) or !isset($_POST['ordering_year'])) { //Select the date of the orders that should be displayed $today = array('day' => date('d'), 'month' => date('m'), 'year' => date('Y')); $this->mealInterface->ShowOrdersSelectDate($today); } else { //Show the Orders $user_manager = new UserManager(); $groupManager = new GroupManager(); $mysql_orders = array(); $order = array(); if ($_POST['ordering_day'] > 31 or $_POST['ordering_month'] > 12 or $_POST['ordering_year'] < 2000 or $_POST['ordering_year'] > 3000) { $this->mealInterface->dieError($this->msg['err_inp_date']); } $date = $_POST['ordering_year'] . '-' . $_POST['ordering_month'] . '-' . $_POST['ordering_day']; try { $orders = $this->orderManager->getAllOrdersAt($date); } catch (MySQLVoidDataException $e) { $this->mealInterface->dieError($this->msg['err_no_orders']); } catch (MySQLConnectionException $e) { $this->mealInterface->dieError($e->getMessage()); } if (!count($orders)) { $this->mealInterface->dieError($this->msg['err_no_orders']); } foreach ($orders as &$order) { if (!count($meal_data = $this->mealManager->getEntryData($order['MID'], 'name')) or !count($user_data = $user_manager->getEntryData($order['UID'], 'name', 'forename', 'GID'))) { $this->mealInterface->dieError($this->msg['err_order_database']); } else { $order['meal_name'] = $meal_data['name']; $order['user_name'] = $user_data['forename'] . ' ' . $user_data['name']; if (!$order['fetched']) { $order['is_fetched'] = $this->msg['order_not_fetched']; } else { $order['is_fetched'] = $this->msg['order_fetched']; } } } //-------------------- //Count all Orders $num_orders = array(); $mealIdArray = $this->mealManager->GetMealIdsAtDate($date); $counter = 0; foreach ($mealIdArray as $mealIdEntry) { $groups = array(); //to show how many from different groups ordered something $sp_orders = $this->orderManager->getAllOrdersOfMealAtDate($mealIdEntry['MID'], $date); $num_orders[$counter]['MID'] = $mealIdEntry['MID']; $num_orders[$counter]['name'] = $this->mealManager->GetMealName($mealIdEntry['MID']); $num_orders[$counter]['number'] = count($sp_orders); //-------------------- //Get specific Usergroups for Interface foreach ($sp_orders as $sp_order) { $user = $user_manager->getEntryData($sp_order['UID'], 'GID'); $sql_group = $groupManager->getEntryData($user['GID'], 'name'); $group_name = $sql_group['name']; if (count($groups)) { $is_new_group = true; foreach ($groups as &$group) { if (isset($group['name']) && $group['name'] == $group_name) { $group['counter'] += 1; $is_new_group = false; continue; } } if ($is_new_group) { $group_arr = array('name' => $group_name, 'counter' => 1); $groups[] = $group_arr; } } else { //no group defined yet $group_arr = array('name' => $group_name, 'counter' => 1); $groups[] = $group_arr; } } //-------------------- $num_orders[$counter]['user_groups'] = $groups; $counter++; } /** * Sort the Orders */ foreach ($orders as &$order) { $meals[$order['meal_name']][] = $order; } //sorting by usernames foreach ($meals as $meal) { foreach ($meal as $order) { $temp[] = $order['user_name']; } sort($temp); foreach ($temp as $temp_name) { foreach ($meal as &$order) { if ($order['user_name'] == $temp_name) { $sorted_orders[] = $order; $order = NULL; //to avoid bugs with multiple orders from one user break; } } } } /** * Show Orders */ if (isset($num_orders[0]) && $counter) { $this->mealInterface->ShowOrders($num_orders, $sorted_orders, formatDate($date)); } else { $this->mealInterface->dieError(sprintf($this->msg['err_no_orders_at_date'], formatDateTime($date))); } } }