<?php require 'tables.php'; $products = json_decode($_POST['products']); $order = new Orders(); $order->uid = $_POST['uid']; $order->amount = $_POST['amount']; $order->status = $_POST['state']; $order->comment = $_POST['comment']; $order->rid = $_POST['rid']; $oid = $order->insert(); foreach ($products as $p) { $orderProducts = new orderProducts(); $orderProducts->oid = $oid; $orderProducts->pid = $p->pid; $orderProducts->numofItems = $p->numofItems; $orderProducts->insert(); }
}; */ //if(){ $limit = isset($_GET['limit']) ? $_GET['limit'] : 0; // echo $limit ; // echo $_GET['code'] ; $res = $order->selectLimit($limit, 2); $ordersArray = array(); for ($i = 0; $i < count($res); $i++) { $ordersArray[$i]['date'] = $res[$i][0]; $ordersArray[$i]['name'] = $res[$i][1]; $ordersArray[$i]['room'] = $res[$i][2]; $ordersArray[$i]['ext'] = $res[$i][3]; $ordersArray[$i]['amount'] = $res[$i][4]; $ordersArray[$i]['oid'] = $res[$i][5]; $product = new orderProducts(); $product->oid = $ordersArray[$i]['oid']; $Oproducts = $product->selectByOrderId(); $arr = array(); for ($j = 0; $j < count($Oproducts); $j++) { $arr[$j]['pid'] = $Oproducts[$j]['pid']; $arr[$j]['numofItems'] = $Oproducts[$j]['numofItems']; $p = new Products(); $p->pid = $Oproducts[$j]['pid']; $pInfo = $p->selectbykey(); $arr[$j]['pname'] = $pInfo[1]; $arr[$j]['picture'] = $pInfo[2]; $arr[$j]['price'] = $pInfo[3]; } $ordersArray[$i]['products'] = $arr; }
if ($_GET['code'] == "1") { $product->pid = $_GET['PID']; ////////////////////// $Product = new Products(); $Product->pname = $name_product; $Product->productPicture = $upimage; $Product->price = $price_prodect; $Product->available = '1'; $Product->cid = $category; ////////////// // $product->updatecolumn('pname',$Product->pname); } else { if ($_GET['code'] == "2") { $product = new Products(); $product->pid = $_GET['pid']; $Op = new orderProducts(); $Op->pid = $_GET['pid']; $Op->deleteByPID(); $product->delete(); } } $limit = isset($_GET['limit']) ? $_GET['limit'] : 0; $res = $product->selectLimit($limit, 4); $productsArray = array(); for ($i = 0; $i < count($res); $i++) { $productsArray[$i]['pid'] = $res[$i][0]; $productsArray[$i]['name'] = $res[$i][1]; $productsArray[$i]['price'] = $res[$i][3]; $productsArray[$i]['image'] = $res[$i][2]; } $replayArr["limit"] = $limit;