function action_order() { session_start(); $model = $_SESSION['basket']; $login = $_SESSION["login"]; if (!is_null($_SESSION["login"])) { $account = AccountService::GetByName($login, true); $order = OrderHelper::PopulateOrderFromBasketViewModel($model, $account->account_id); $order = OrderService::Create($order); $products = $model->products; for ($i = 0; $i < count($products); $i++) { for ($j = 0; $j < $model->counts[$i]; $j++) { $orderlist = new OrderList(); $orderlist->order_id = $order->order_id; $orderlist->product_id = $products[$i]->Id; OrderListService::Create($orderlist); } } $_SESSION['basket'] = null; EmailService::SendNewOrderMessage($account, $order->order_id, $model->SumPrice()); $data = $order->order_id; $this->view->generate('Order_view.php', 'template_view.php', $data); } else { header('Location: /Account/login'); } }