public function actionOrder() { $name = $this->request->name; $email = $this->request->email; $phone = $this->request->phone; $address = $this->request->region . ", " . $this->request->index . ", " . $this->request->street . ", " . $this->request->home . ", квартира " . $this->request->float; $pay = new PayDB(); $pay->load($this->request->pay); $pay_id = $pay->id; $delivery = new DeliveryDB(); $delivery->load($this->request->delivery); $delivery_id = $delivery->id; $notice = $this->request->notice; $products = BasketData::getItems(); $summ = BasketData::getSumm(); $order_db = new OrderDB(); $order_db->name = $name; $order_db->phone = $phone; $order_db->email = $email; $order_db->address = $address; $order_db->pay_id = $pay->id; $order_db->delivery_id = $delivery->id; $order_db->summ = $summ; $order_db->notice = $notice; if (!($order_id = $order_db->save())) { exit("error"); } foreach ($products as $product) { $purchase_db = new PurchaseDB(); $purchase_db->order_id = $order_id; $purchase_db->product_id = $product->id; $purchase_db->count = $product->count; $purchase_db->save(); } $this->mail->send(Config::ADM_EMAIL, array("site" => Config::SITENAME, "name" => $name, "email" => $email, "phone" => $phone, "address" => $address, "pay" => $pay->title, "delivery" => $delivery->title, "products" => $products, "summ" => $summ, "notice" => $notice), "admin_order"); $this->mail->send(Config::ADM_EMAIL2, array("site" => Config::SITENAME, "name" => $name, "email" => $email, "phone" => $phone, "address" => $address, "pay" => $pay->title, "delivery" => $delivery->title, "products" => $products, "summ" => $summ, "notice" => $notice), "admin_order"); $this->mail->send(Config::ADM_EMAIL3, array("site" => Config::SITENAME, "name" => $name, "email" => $email, "phone" => $phone, "address" => $address, "pay" => $pay->title, "delivery" => $delivery->title, "products" => $products, "summ" => $summ, "notice" => $notice), "admin_order"); $this->mail->send($this->request->email, array("site" => Config::SITENAME, "name" => $name, "products" => $products, "summ" => $summ), "client_order"); echo "success"; }
require_once "../Model/ShoppingcartDB.php"; require_once "../Model/FoodDB.php"; require_once "../Model/Food.php"; session_start(); // Start a session, there is no need to add this line if session is active. $page = ""; if (isset($_GET["action"])) { $page = $_GET["action"]; } else { if (isset($_POST["action"])) { $page = $_POST["action"]; } else { $page = "original"; } } $orderdb = new OrderDB(); if ($page == "all") { $orders = $orderdb->getAllOrders(AuthModel::getUser('id')); $items = array(); foreach ($orders as $order) { $item = $orderdb->getItemByOrder($order->Order_id); $items[] = $item; } include "show.php"; } else { if ($page == "payment") { $orders = $orderdb->getUnpaidOrder(AuthModel::getUser('id')); $items = array(); foreach ($orders as $order) { $item = $orderdb->getItemByOrder($order->Order_id); $items[] = $item;