/** * Fetches the data of Soli-Users to be processed * * @throws Exception if something has gone wrong while fetching the data * @return array(...) */ protected static function soliDataFetch() { try { self::$_soliData = TableMng::query(sprintf('SELECT u.ID AS userId, o.ID AS orderId, o.fetched AS fetched, m.name AS mealname, m.price_class AS pc_ID, pc.price AS price, m.date AS mealdate, o.ID AS orderId, CONCAT(u.forename, " ", u.name) AS userWholename, o.ordertime AS ordertime, /*Does the Meal and the priceclass still exist?*/ (SELECT m.ID FROM BabeskMeals m JOIN BabeskPriceClasses pc ON m.price_class = pc.pc_ID WHERE m.ID = o.MID GROUP BY pc.pc_ID ) AS existMealAndPriceclass FROM SystemUsers u JOIN BabeskOrders o ON o.UID = u.ID /*We want to check if meal exists manually (for error-output), so using LEFT JOIN instead of JOIN*/ LEFT JOIN BabeskMeals m ON o.MID = m.ID /*Fetch the price of the meal for the user*/ LEFT JOIN (SELECT ID, pc_ID, GID, price FROM BabeskPriceClasses) pc ON pc.pc_ID = m.price_class AND pc.GID = u.GID WHERE /*does the order already exist in soli_orders?*/ (SELECT COUNT(*) FROM BabeskSoliOrders so WHERE o.ID = so.ID) = 0'), true); } catch (MySQLVoidDataException $e) { self::$_interface->dieError('Alle passenden Bestellungen wurden schon korrekt abgelegt oder es gibt keine Bestellungen mit soli-Status'); } }
public function execute($dataContainer) { defined('_AEXEC') or die('Access denied'); require_once 'AdminSoliInterface.php'; require_once 'AdminSoliProcessing.php'; parent::entryPoint($dataContainer); parent::initSmartyVariables($dataContainer); $this->_interface = $dataContainer->getInterface(); $soliInterface = new AdminSoliInterface($this->relPath); $soliProcessing = new AdminSoliProcessing($soliInterface); if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_GET['action'])) { $action = $_GET['action']; switch ($action) { case 1: //add coupon if (isset($_POST['UID']) && isset($_POST['StartDateYear'])) { $soliProcessing->AddCoupon($_POST['StartDateYear'] . '-' . $_POST['StartDateMonth'] . '-' . $_POST['StartDateDay'], $_POST['EndDateYear'] . '-' . $_POST['EndDateMonth'] . '-' . $_POST['EndDateDay'], $_POST['UID']); } else { $soliProcessing->AddCoupon(NULL, NULL, NULL); } break; case 2: //show coupons $soliProcessing->ShowCoupons(); break; case 3: //show Soliusers $soliProcessing->ShowUsers(); break; case 4: //show SoliOrders for specific User and Week if (isset($_POST['ordering_kw']) && isset($_POST['user_id'])) { $soliProcessing->ShowSoliOrdersByDate($_POST['ordering_kw'], $_POST['user_id']); } else { $soliProcessing->ShowSoliOrdersByDate(false, false); } break; case 5: //delete coupon if (isset($_POST['delete'])) { $soliProcessing->DeleteCoupon($_GET['ID'], true); } else { if (isset($_POST['not_delete'])) { $soliProcessing->ShowCoupons(); } else { $soliProcessing->DeleteCoupon($_GET['ID'], false); } } break; case 6: //Change Soli-Settings if (isset($_POST['user_id'])) { $soliProcessing->ChangeSettings($_POST['soli_price']); } else { $soliProcessing->ChangeSettings(NULL); } break; case 7: //copy old orders to soli if (isset($_POST['copy'])) { // $soliProcessing->CopyOldOrdersToSoli(); CopyOldOrdersToSoli::init($soliInterface, $this->_em); CopyOldOrdersToSoli::execute(); } else { if (isset($_POST['dont_copy'])) { $soliInterface->ShowInitialMenu(); } else { $soliInterface->AskCopyOldOrdersToSoli(); } } break; case 8: //Download SoliOrders of all Users for a specific week/month if (isset($_POST['ordering_kw'])) { $soliProcessing->AllSoliOrdersToPDFByWeekOrMonth($dataContainer, $_POST['ordering_kw'], true); } elseif (isset($_POST['ordering_month'])) { $soliProcessing->AllSoliOrdersToPDFByWeekOrMonth($dataContainer, $_POST['ordering_month'], false); } else { $soliInterface->AskWeekForPdf(); } break; } } else { if (parent::execPathHasSubmoduleLevel(1, $this->_submoduleExecutionpath)) { $this->submoduleExecuteAsMethod($this->_submoduleExecutionpath); } else { $soliInterface->ShowInitialMenu(); } } }
/** * Fetches the Price that soli-users should pay when ordering meals * * Saves it into the protected variable $_soliprice */ protected static function solipriceFetch() { try { $res = TableMng::query('SELECT value FROM SystemGlobalSettings WHERE name = "soli_price"'); } catch (Exception $e) { throw new Exception('Could not fetch the soliprice'); } self::$_soliprice = $res[0]['value']; }