$rootPath = $router->rootPath; if (!$isCorporate) { $logger->serverData(); $logger->addWarning("User attempted to access unauthorized location."); $error = rawurlencode('Not an authenticated corporate user.'); die(header("Location:{$rootPath}goodsite/corporate/corporatelogin.php?errors={$error}")); } $models = new stdClass(); $models->redis = $redis; $models->errorRunner = $errorRunner; $models->pdo = $pdo; $models->logger = $logger; $models->blackList = $blackList; $order = new stdClass(); $order->session = $_SESSION; $ordersController = new EmployeeGroupsOrdersController($models, $order); $ordersController->setOrders(); $orders = $ordersController->getOrders(); $corporateOrders = ""; // $pdo query returns false on fail $canEdit = $isAdmin; $addNewOrderButton = $orderButton = $customerList = null; if ($canEdit) { $ordersController->setCustomerList(); $customers = $ordersController->getCustomerList(); $customerList = ''; foreach ($customers as $customer) { $customerList .= "<option value='{$customer['id']}'>{$customer['username']}</option>"; } $orderButton = "<button type='button' class='btn btn-info'\n id='createNewOrder'>\n <span class='glyphicon glyphicon-plus' aria-hidden='true'></span>\n <span id='textForOrder'>Make new order</span>\n </button>"; $addNewOrderButton = "<button type='submit'\n class='btn btn-default' name='submitNewOrder' id='submitNewOrder'>\n Add Order\n </button>";
$models = new stdClass(); $models->logger = $logger; $models->errorRunner = $errorRunner; $models->auth = $auth; $models->pdo = $pdo; $models->checkAuth = $checkAuth; $isAuth = $checkAuth->isAuth(); $isCorporate = $checkAuth->isCorporate(); $isGroup = $checkAuth->isGroup(); $isAuth || ($errors[] = "Not authenticated"); $isGroup || ($errors[] = "Not valid group member"); $isCorporate || ($errors[] = "Incorrect user type."); isset($_SESSION) || ($errors[] = "No customer is available."); $order = new stdClass(); $order->session = $_SESSION; $order->groupID = $_SESSION['groupid']; $session = $_SESSION; if (empty($errors)) { $controller = new EmployeeGroupsOrdersController($models, $order); $controller->getCustomerValues(); if ($isAjax) { echo json_encode($controller); } if (!$isAjax) { // Do something else } } if (!empty($errors)) { $errorRunner->runErrors($errors); } }