public function changeStatusProgress() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_order_detail = isset($_GET['id_order_detail']) ? addslashes($_GET['id_order_detail']) : ""; if (!$id_order_detail) { Generic::errorMsg("id order detail not found!"); } $objOrderDetail = new OrderDetailModel(); $objOrderDetail->getByID($id_order_detail); if ($objOrderDetail->id_order == "") { Generic::errorMsg("id order detail not found!"); } $statusProgress = intval($objOrderDetail->status_progress); if ($statusProgress == 2) { Generic::errorMsg("Status is " . $statusProgress); } $statusProgress = $statusProgress + 1; $objOrderDetail->status_progress = strval($statusProgress); $objOrderDetail->load = 1; $objOrderDetail->save(); $json['results'] = $statusProgress; echo json_encode($json); die; }
public function updateNote() { $userId = $_POST["id_user"]; $newNote = $_POST["note"]; $idOrderDetail = $_POST["id_order_detail"]; $od = new OrderDetailModel(); $od->getByID($idOrderDetail); //TODO CHECK USER ID apakah sama dengan OrderDetailMpdel dengan id $idOrderDetail //TODO ERROR OUT KALAU TIDAK SAMA $od->note = $newNote; $od->save(); }
public static function pushRestoOrderStatusChanged($idDetailOrder) { $detailOrder = new OrderDetailModel(); $detailOrder->getByID($idDetailOrder); $order = new MasterOrderModel(); $order->getByID($detailOrder->id_order); $restaurant = new MasterRestaurantModel(); $restaurant->getByID($detailOrder->id_restaurant); $dish = new MasterDishModel(); $dish->getByID($detailOrder->id_dish); $textStatusProgress = Util::getStatusProgress($detailOrder->status_progress); $title = "Order {$textStatusProgress} for {$dish->name}"; $message = "Your Order Status for {$dish->name} At Restaurant {$restaurant->name} has been Changed to {$textStatusProgress}"; //buat tracker untuk inbox $tracker = new TrackerNotificationModel(); $tracker->id_from = $detailOrder->id_restaurant; $tracker->id_to = $detailOrder->id_restaurant; $tracker->id_reference = $detailOrder->id_order; $tracker->reference_desc = Keys::$TRACKER_REF_DESC_ID_ORDER; $tracker->type = Keys::$typeNotifDetailOrderStatusChange; $tracker->title = $title; $tracker->image = Keys::$EMPTY; $tracker->message = $message; $tracker->readed = Keys::$NO; $tracker->answered = Keys::$NO; $tracker->canceled = Keys::$NO; $tracker->status = Keys::$YES; $idTracker = $tracker->save(); if (!$idTracker) { Generic::errorMsg(Keys::$ERR_FAILED_CREATE_TRACKER); } $tracker->getByID($idTracker); //push to friend //preparation $_POST["ids"] = $detailOrder->id_restaurant; $_POST["msg"] = $message; $_POST["json"] = $idTracker; $_POST["type"] = Keys::$typeNotifDetailOrderStatusChange; // pr($_POST); // die(); $push = new PushTo(); $results["message"] = "Success"; $results["status_progress"] = (string) $order->status_progress; $results["new_detail_status_progress"] = (string) $detailOrder->status_progress; $results['push_status'] = $push->cashierMR(); $results['id_tracker'] = strval($idTracker); $results['tracker'] = Util::extractModel($tracker); return $results; }
public function voidDetailOrder() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $revert = true; $detailOrderId = $this->mustCheck($_POST["id_order_detail"], "No Order Detail ID"); $voided = $this->mustCheckBool($_POST["voided"], "Void?"); $orderDetail = new OrderDetailModel(); $orderDetail->getByID($detailOrderId); $curStatus = $orderDetail->status_progress; if ($curStatus == 9) { Generic::errorMsg("This Detail Order already Voided"); } $orderDetail->status_progress = 9; $orderDetail->save(); $orderDetail->load = 1; $newStatus = $this->checkSiblingsStatus($orderDetail); //TODO RECALCULATE INVOICE, masukkan ke json results $order = new MasterOrderModel(); $order->getByID($orderDetail->id_order); $json = array(); $json['status_code'] = 1; $json['results']["message"] = "Success"; $json['results']["status_progress"] = (string) $newStatus; $json['results']["new_detail_status_progress"] = (string) $orderDetail->status_progress; $json['results']["invoice"] = $this->calcRechnungAndSave($order->id_restaurant, $orderDetail->id_order); echo json_encode($json); die; }
public function cancelPendingOrder() { $idOrder = Generic::mustCheck($_POST['id_order'], "ID Order Not Found"); $idUser = Generic::mustCheck($_POST['id_user'], "ID User Not Found"); $order = new MasterOrderModel(); $order->getByID($idOrder); //reject if order already set if ($order->order_now == "1") { Generic::errorMsg("Order already been set"); } $isLeader = $order->id_user == $idUser; if (!$isLeader) { $this->removeGuestOrder($idUser, $idOrder); $this->success(); } //canceling order $order->status = "0"; $order->save(); $orderDetails = OrderDetail::getOrderDetailsByIDOrder($idOrder); foreach ($orderDetails as $orderDetail) { //canceling all detail order $oDetail = new OrderDetailModel(); $oDetail->getByID($orderDetail['id_order']); $oDetail->status = "0"; $oDetail->save(); } $this->success(); }
public function updateNote() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $userId = $_POST["id_user"]; $newNote = $_POST["note"]; $idOrderDetail = $_POST["id_order_detail"]; $objOrderDetail = new OrderDetailModel(); $objOrderDetail->getByID($idOrderDetail); if ($objOrderDetail->id_user != $userId) { Generic::errorMsg("ID User not matched!"); } if ($objOrderDetail->id_order_detail != $idOrderDetail) { Generic::errorMsg("order detail id not matched!"); } $objOrderDetail->note = $newNote; $objOrderDetail->load = 1; $id_update = $objOrderDetail->save(); if (!$id_update) { Generic::errorMsg("Update failed!"); } $json['results']['id_order_detail'] = $objOrderDetail->id_order_detail; echo json_encode($json); die; }