private function calcRechnungAndSave($id_restaurant, $id_order) { $order = new MasterOrderModel(); $order->getByID($id_order); $objResto = User::getRestaurant($id_restaurant); // pr($objResto ); $objOrder = MasterOrder::getOrder($id_order); $arrOrderDetails = OrderDetail::getOrderDetailsByIDOrderForCalc($id_order); $total = 0; foreach ($arrOrderDetails as $orderDetails) { // pr($orderDetails); $total = $total + $orderDetails['price']; } $invoice['sub_total'] = strval($total); $order->total_cost = $invoice['sub_total']; if ($objResto['service_charge'] > 100) { $invoice['service_charge'] = strval($objResto['service_charge']); } else { $invoice['service_charge'] = strval($objResto['service_charge'] / 100 * $total); } $order->service_charge = $invoice['service_charge']; if ($objResto['other_charge'] > 100) { $invoice['other_charge'] = strval($objResto['other_charge']); } else { $invoice['other_charge'] = strval($objResto['other_charge'] / 100 * $total); } $order->other_charge = $invoice['other_charge']; if ($objResto['disc_mr'] > 100) { $invoice['Discount_MR'] = strval($objResto['disc_mr']); } else { $invoice['Discount_MR'] = strval($objResto['disc_mr'] / 100 * $total); } $order->disc_mr = $invoice['Discount_MR']; if ($objResto['disc_bank'] > 100) { $invoice['Discount_Bank'] = strval($objResto['disc_bank']); } else { $invoice['Discount_Bank'] = strval($objResto['disc_bank'] / 100 * $total); } $order->disc_bank = $invoice['Discount_Bank']; if ($objResto['disc_resto'] > 100) { $invoice['Discount_Resto'] = strval($objResto['disc_resto']); } else { $invoice['Discount_Resto'] = strval($objResto['disc_resto'] / 100 * $total); } $order->disc_resto = $invoice['Discount_Resto']; $invoice['Tax'] = strval($total * ($objResto['tax_pb_1'] / 100)); $order->tax_pb1 = $invoice['Discount_Resto']; $invoice['Total'] = strval($total + $invoice['Tax'] + $invoice['service_charge'] + $invoice['other_charge'] - $invoice['Discount_MR'] - $invoice['Discount_Bank'] - $invoice['Discount_Resto']); $order->grand_total = $invoice['Total']; $order->save(); return $invoice; }
public function scandinein() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_user = isset($_GET['id_user']) ? addslashes($_GET['id_user']) : ""; if (!$id_user) { Generic::errorMsg("Please login!"); } if (!User::checkUserID($id_user)) { Generic::errorMsg("ID User not found!"); } $QR = isset($_GET['QR']) ? addslashes($_GET['QR']) : ""; if (!$QR) { Generic::errorMsg("No QR found!"); } $id_order = isset($_GET['id_order']) ? addslashes($_GET['id_order']) : ""; if (!id_order) { Generic::errorMsg("id_order not found!"); } if (!MasterOrder::isIdorderValid($id_order)) { Generic::errorMsg("id_order not found!"); } $objTableHlp = Mastertable::getTableBYQR($QR); $objTable = new MasterTableModel(); $objTable->getByID($objTableHlp[0]->id_table); $objTable->appOrder = "1"; $objTable->id_order = $id_order; $objTable->status = "0"; $objTable->waitingOrder = "2"; $objTable->load = 1; $objTable->save(); $objOrder = new MasterOrderModel(); $objOrder->getByID($id_order); $objOrder->id_table = $objTableHlp[0]->id_table; $objOrder->type_order = "1"; $objOrder->load = 1; $objOrder->save(); $objOrderHlp = new MasterOrderModel(); $arrOrder = $objOrderHlp->getWhere("id_user='******' AND status_progress < 3 OR status_payment='0'"); Generic::checkCountWithMsg($arrOrder, "No ID Order from the ID User found"); $id_order = $arrOrder[0]->id_order; $order = MasterOrder::getOrder($id_order); $arrOrderDetails = OrderDetail::getOrderDetailsByIDOrderAndUserID($id_order, $id_user); $order['Order_Details'] = $arrOrderDetails; $order['restaurant'] = User::getRestaurant($order['id_restaurant']); $json['results'][] = $order; echo json_encode($json); die; }
public function getUndoneReceiptDetail() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $result = ""; $idOrder = Generic::mustCheck($_GET['id_order'], "No ID Order"); $order = new MasterOrderModel(); $order->getByID($idOrder); $result['Order'] = MasterOrder::getOrder($idOrder); $result['Order Details'] = Util::getSettedOrderDetails($idOrder); $resto = new MasterRestaurantModel(); $resto->getByID($order->id_restaurant); $result['restaurant']['image_logo'] = _BPATH . _PHOTOURL . $resto->image_logo; $result['restaurant']['name'] = $resto->name; $result['restaurant']['address'] = $resto->address; $result['restaurant']['district'] = $resto->district; $result['restaurant']['city'] = $resto->city; $result['restaurant']['phone_no'] = $resto->phone_no; $this->finish($result); }
public function orderNow() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_user = isset($_POST['id_user']) ? addslashes($_POST['id_user']) : ""; if (!$id_user) { Generic::errorMsg("Please login!"); } if (!User::checkUserID($id_user)) { Generic::errorMsg("ID User not found!"); } $id_order = isset($_POST['id_order']) ? addslashes($_POST['id_order']) : ""; if (!$id_order) { Generic::errorMsg("ID Order not found!"); } $allergy = isset($_POST['allergy']) ? addslashes($_POST['allergy']) : ""; $generalNote = isset($_POST['generalNote']) ? addslashes($_POST['generalNote']) : ""; $objOrder = new MasterOrderModel(); $arrOrder = $objOrder->getWhere("id_user='******' AND id_order = '{$id_order}' AND status != '0' AND status_payment = '0' AND order_now = '0'"); Generic::checkCountWithMsg($arrOrder, "ID Order not found!"); $id_order = $arrOrder[0]->id_order; $dineIn = true; if ($arrOrder[0]->type_order == 3) { $dineIn = false; } $id_restaurant = $arrOrder[0]->id_restaurant; $arrOrder[0]->datetime_order = $this->setCurrentDate(); $arrOrder[0]->order_now = "1"; $arrOrder[0]->datetime_order = leap_mysqldate(); $arrOrder[0]->generalNote = $generalNote; $arrOrder[0]->allergy = $allergy; $arrOrder[0]->load = 1; $id = $arrOrder[0]->save(); // cari orderdetails yg id_order $objOrderDetails = new OrderDetailModel(); $arrOrderdetails = $objOrderDetails->getWhere("id_order='{$id_order}'"); Generic::checkCountWithMsg($arrOrderdetails, "ID Order Details not found!"); foreach ($arrOrderdetails as $orderdetails) { $orderdetails->datetime_order = $this->setCurrentDate(); $orderdetails->load = 1; $orderdetails->save(); } $objTable = new MasterTableModel(); $objTable->getByID($arrOrder[0]->id_table); $objTable->waitingOrder = "1"; $objTable->load = 1; $objTable->save(); // pr($objTable); $json['results'] = MasterOrder::getOrder($id_order); echo json_encode($json); $j["id_order"] = $id_order; $j['datetime'] = date('Y-m-d H:i:s'); $msg = $dineIn ? "Table {$objTable->table_number} : New Apps Dine In Order " : "New Apps Take Away Order"; $pushType = $dineIn ? Push::$typeNotifNewOrder : Push::$typeNotifNewTakeAway; $this->pushToRestoCashier($id_restaurant, $msg, $j, $pushType); die; }