public function updateStatusProgress() { $idDish = $_GET["id_dish"]; $idOrder = $_GET["id_order"]; $idResto = $_GET["id_restaurant"]; //TODO cek id_resto di order header apakah sama degan $Resto $resto = new MasterRestaurantModel(); $resto->getByID($resto); $od = new OrderDetailModel(); $arrOrDetails = $od->getWhere("id_order='{$idOrder}' AND id_dish='{$idDish}'"); foreach ($arrOrDetails as $oDetails) { if ($oDetails->status_progress < 2) { $oDetails->status_progress++; $sp = $oDetails->status_progress; } else { //TODO ERROR order already out } } $order = $this->updateOrderHeaderStatusProgress($idOrder); $ids = $order->user_guest_id + "," + $order->id_user; $msg = "Your "; if ($order->type_order == "0") { $msg .= "Dine In "; } elseif ($order->type_order == "3") { $msg .= "Take Away "; } else { $json["status_code"] = 1; $json["results"]["id_dish"] = $idDish; $json["results"]["id_order"] = $idDish; $json["results"]["id_restaurant"] = $idDish; $json["results"]["status_progress"] = $sp; $json["results"]["order_status_progress"] = $order->status_progress; die; } $msg .= "order's status at {$resto->name} has been updated"; $j["id_order"] = $idOrder; $json = json_encode($j); $_POST["ids"] = $ids; $_POST["msg"] = $msg; $_POST["json"] = $json; $_POST["type"] = 41; $p = new PushTo(); $p->users(); die; }
public static function getAllOrderDetailsByIDOrder($id_order) { $objOrderDetails = new OrderDetailModel(); $arrOrderDetails = $objOrderDetails->getWhere("id_order='{$id_order}' ORDER BY status_progress ASC, id_dish ASC"); // MasterDish::checkCount($arrOrderDetails); $orderdetails = array(); if (count($arrOrderDetails) > 0) { $exp = explode(",", str_replace(" ", "", $objOrderDetails->crud_webservice_allowed)); foreach ($arrOrderDetails as $order) { $sem = array(); foreach ($exp as $attr) { $sem[$attr] = stripslashes($order->{$attr}); } $sem['name'] = MasterDish::getDishNameByID($order->id_dish); $orderdetails[] = $sem; } } return $orderdetails; }
public static function getOrderDetailsByIDOrderAndUserID($id_order, $id_user) { $objOrderDetails = new OrderDetailModel(); $objUser = new UserModel(); $objUser->getByID($id_user); $arrOrderDetails = $objOrderDetails->getWhere("id_order='{$id_order}' AND id_user='******'"); // MasterDish::checkCount($arrOrderDetails); if (count($arrOrderDetails) > 0) { $exp = explode(",", str_replace(" ", "", $objOrderDetails->crud_webservice_allowed)); $orderdetails = array(); foreach ($arrOrderDetails as $order) { $sem = array(); foreach ($exp as $attr) { $sem[$attr] = stripslashes($order->{$attr}); } $sem['name'] = MasterDish::getDishNameByID($order->id_dish); $sem['image_user'] = _BPATH . _PHOTOURL . $objUser->pic; $orderdetails[] = $sem; } } return $orderdetails; }
private function forceDoneOrder($orderId) { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $order = new MasterOrderModel(); $order->getByID($orderId); $order->status_progress = 9; $order->save(); $o = new OrderDetailModel(); $orderDetails = $o->getWhere("id_order='{$orderId}'"); foreach ($orderDetails as $orderDetail) { $orderDetail->load = 1; $orderDetail->status_progress = 9; $orderDetail->save(); } $resto = new MasterRestaurantModel(); $resto->getByID($order->id_restaurant); if ($order->id_table != 0) { Mastertable::clearTable($order->id_table); } if ($order->id_user != 0) { $guestId = $order->id_user; if ($order->user_guest_id != "" || $order->user_guest_id != ",") { $guestId .= $order->user_guest_id; } $j["id_order"] = $orderId; $j['datetime'] = date('Y-m-d H:i:s'); $msg = "Your order at restaurant {$resto->name} with order ID {$orderId} has been voided"; $this->pushToUser($guestId, $msg, $j, Push::$typeUpdateWaiting); die; } }
public function getHistoryDishByRestaurantId() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idUser = Generic::mustCheck($_GET['id_user'], "User ID not Found"); $idResto = Generic::mustCheck($_GET['id_restaurant'], "Restaurant ID not Found"); $page = $_GET['page']; $limit = $_GET['limit']; $page--; $p = $page * $limit; $q = "id_user = '******' AND status_progress = '4' GROUP BY id_dish ORDER BY datetime_order DESC"; $q .= Generic::IsNullOrEmptyString($page) || Generic::IsNullOrEmptyString($limit) ? "" : " LIMIT {$p},{$limit}"; $o = new OrderDetailModel(); $arrOrderDetail = $o->getWhere($q); $user = new UserModel(); $user->getByID($idUser); $arrFavDishIds = explode(',', $user->fav_dishes_ids); $hasFav = count($arrFavDishIds) <= 0; $result['history_dish'] = array(); foreach ($arrOrderDetail as $oDetail) { unset($dish); $dish = new MasterDishModel(); $dish->getByID($oDetail->id_dish); if ($dish->id_restaurant != $idResto) { continue; } $b['id_dish'] = $dish->id_dish; $b['id_restaurant'] = $dish->id_restaurant; $b['name'] = $dish->name; $b['image_foto'] = Generic::insertImageUrl($dish->image_foto); $b["is_favorite"] = !$hasFav ? false : in_array($oDetail->id_dish, $arrFavDishIds); $resto = new MasterRestaurantModel(); $resto->getByID($dish->id_restaurant); $b['restaurant_name'] = $resto->name; $b['$restaurant_image'] = $resto->image_logo; $result['history_dish'][] = $b; } $this->finish($result); }
public function getMenu() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_restaurant = isset($_GET['id_restaurant']) ? addslashes($_GET['id_restaurant']) : ""; if (!$id_restaurant) { $json['status_code'] = 0; $json['status_message'] = "No ID Found"; echo json_encode($json); die; } $objRestaurant = new MasterRestaurantModel(); $arrResto = $objRestaurant->getWhere("id_restaurant={$id_restaurant}"); if (count($arrResto) == 0) { $json['status_code'] = 0; $json['status_message'] = "Can't find Restaurant in the Database!"; echo json_encode($json); die; } $resto = User::getRestaurant($id_restaurant); $json['results']['restaurant'][] = $resto; global $db; $objDish = new MasterDishModel(); $q = "SELECT id_category FROM {$objDish->table_name} WHERE availability=1 AND id_restaurant={$id_restaurant}"; $arrCat = $objDish->getWhere("availability=1 AND id_restaurant='{$id_restaurant}'"); if (count($arrCat) == 0) { $json['status_code'] = 1; $json['status_message'] = "Can't find dish in the Restaurant!"; $json['results']['categories'] = array(); echo json_encode($json); die; } $catIds = explode(",", $resto["id_categories"]); // pr($catIds); // foreach ($arrCat as $idCat) { // $arrIDCategory[] = $idCat->id_category; // $arrIDCategory = array_unique($arrIDCategory); // } $objCategory = new MasterCategoryModel(); $objDish = new MasterDishModel(); // $expCategory = explode(",", str_replace(" ", "", $objCategory->crud_webservice_allowed)); // $expDish = explode(",", str_replace(" ", "", $objDish->crud_webservice_allowed)); // $arrPicsDishToAddPhotoUrl = $objDish->crud_add_photourl; // pr($arrIDCategory); foreach ($catIds as $val) { $cat = MasterCategory::getCategoryByID($val); //echo "abc: " . $val ; $arrDish = $objDish->getWhere("availability=1 AND id_category='{$val}' AND id_restaurant='{$id_restaurant}'"); if (count($arrDish) == 0) { continue; } $dishHelp = array(); foreach ($arrDish as $val) { // echo $val->id_dish; $dishHelp[] = MasterDish::getDish($val->id_dish); } $cat['dishes'] = $dishHelp; $json['results']['categories'][] = $cat; } //TODO add order utk ini perlu user_id dan id_order $idUser = Generic::getOrDefault($_GET['id_user'], Keys::$EMPTY); $idOrder = Generic::getOrDefault($_GET['id_order'], Keys::$EMPTY); if ($idOrder != Keys::$EMPTY) { //ambil semua order yang active //dan isi2nya $orderModel = new MasterOrderModel(); $orderModel->getByID($idOrder); // $orderDetails = Util::getOrderDetailsByIDOrder($idOrder); // $order["Order_Details"] = Array(); $orderDetail = new OrderDetailModel(); $orderDetails = $orderDetail->getWhere("id_order = '{$idOrder}' AND id_user = '******'"); $new = array(); foreach ($orderDetails as $or) { if ($or->quantity < 1) { continue; } $new[] = Util::extractModel($or); } $json['order_details'] = $new; // pr($orderDetails); // $sudah = array(); // foreach ($new as $orderDetail) { // if($orderDetail['status_progress']=="")$orderDetail['status_progress'] = 0; // $dish = new MasterDishModel(); // $dish->getByID($orderDetail['id_dish']); // $userInstance = Util::createUserInstance($orderDetail["id_user"], $orderDetail["note"], $orderDetail["id_order_detail"]); // $string_name = rtrim(trim(preg_replace('/\s\s+/', ' ', $orderDetail['name']))); // $order['Order_Details_new'][$orderDetail['id_dish']]['quantity'] += $orderDetail['quantity']; // $order['Order_Details_new'][$orderDetail['id_dish']]['price'] += ($orderDetail['quantity']*$dish->price); // if($order['Order_Details'][$orderDetail['id_dish']]['status_progress']!==null) // $order['Order_Details_new'][$orderDetail['id_dish']]['status_progress'] = min($orderDetail['status_progress'],$order['Order_Details'][$orderDetail['id_dish']]['status_progress']); // else // $order['Order_Details_new'][$orderDetail['id_dish']]['status_progress'] = 0; // $order['Order_Details_new'][$orderDetail['id_dish']]['id_dish'] = $orderDetail['id_dish']; // $order['Order_Details_new'][$orderDetail['id_dish']]['name'] = $string_name; // $order['Order_Details_new'][$orderDetail['id_dish']]['single_price'] = (double)$dish->price; // $order['Order_Details_new'][$orderDetail['id_dish']]['users'][] = $userInstance; // } //// pr($order['Order_Details_new']); // // // foreach($order['Order_Details_new'] as $obj){ // if($obj['quantity']<1)continue; // $json['order_details'][] = $obj; // } // $orderDetail = new OrderDetailModel(); // $arrOrderDetail = $orderDetail->getWhere("id_order = '$idOrder'"); // // $json['order'] = Util::extractModel($orderModel); // // $new = array(); // foreach($arrOrderDetail as $or){ // // $new[] = Util::extractModel($or); // } // $json['order_details'] = $order['Order_Details']; } echo json_encode($json); die; }
public function updateSubTotal() { $od = new OrderDetailModel(); $q = $this->calcPending ? "id_order='{$this->idOrder}'\n AND voided='0'\n AND status ='1'\n AND order_now='0'" : "id_order='{$this->idOrder}'\n AND voided='0'\n AND status ='1'\n AND order_now='1'"; if ($this->calcPending == 2) { $q = "id_order='{$this->idOrder}' AND status_progress != '9'"; } $this->orderDetails = $od->getWhere($q); $this->countOrderDetail = count($this->orderDetails); foreach ($this->orderDetails as $orderDetail) { if (!$orderDetail instanceof OrderDetailModel) { continue; } if ($orderDetail->status_progress == 9) { continue; } //void $this->countDish += $orderDetail->quantity; $this->subTotal += $orderDetail->price; } }
public function updateStatusProgress() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idDish = $_GET["id_dish"]; $idOrder = $_GET["id_order"]; $idResto = $_GET["id_restaurant"]; //TODO cek id_resto di order header apakah sama degan $Resto $objOrder = new MasterOrderModel(); $arrOrder = $objOrder->getWhere("id_order='{$idOrder}' AND order_now='1' AND status_payment='0'"); // $objOrder->getByID($idOrder); if ($arrOrder[0]->id_restaurant != $idResto) { Generic::errorMsg("ID Resto in Order is not same as id resto!"); } $resto = new MasterRestaurantModel(); $resto->getByID($idResto); $od = new OrderDetailModel(); $arrOrDetails = $od->getWhere("id_order='{$idOrder}' AND id_dish='{$idDish}' AND status_progress > 3"); Generic::checkCountWithMsg($arrOrDetails, "Dish already out!"); //pr($arrOrDetails); foreach ($arrOrDetails as $oDetails) { if ($oDetails->status_progress < 2) { pr($oDetails->status_progress); $oDetails->status_progress = $oDetails->status_progress + 1; $oDetails->load = 1; $oDetails->save(); $sp = $oDetails->status_progress; } else { //TODO ERROR order already out } } $order = $this->updateOrderHeaderStatusProgress($idOrder); $ids = $order->user_guest_id + "," + $order->id_user; $msg = "Your "; if ($order->type_order == "0") { $msg .= "Dine In "; } elseif ($order->type_order == "3") { $msg .= "Take Away "; } else { $json["status_code"] = 1; $json["results"]["id_dish"] = $idDish; $json["results"]["id_order"] = $idDish; $json["results"]["id_restaurant"] = $idDish; $json["results"]["status_progress"] = $sp; $json["results"]["order_status_progress"] = $order->status_progress; echo json_encode($json); die; } $msg .= "order's status at {$resto->name} has been updated"; $j["id_order"] = $idOrder; $json = json_encode($j); $_POST["ids"] = $ids; $_POST["msg"] = $msg; $_POST["json"] = $json; $_POST["type"] = 41; $p = new PushTo(); $p->users(); echo json_encode($json); die; }