public static function orderNowTakeAway($orderModel, $allergy, $generalNote) { if (!$orderModel instanceof MasterOrderModel) { Generic::errorMsg(Keys::$FATAL_ERROR_MISMATCH_ORDER); } $invoice = new Invoice($orderModel->id_order, true); $orderModel->disc_resto = $invoice->valDiscRestaurant; $orderModel->disc_bank = $invoice->valDiscBank; $orderModel->disc_mr = $invoice->valDiscMR; $orderModel->tax_pb1 = $invoice->valTaxCharge; $orderModel->service_charge = $invoice->valServiceCharge; $orderModel->other_charge = $invoice->valOtherCharge; $orderModel->cc_fee = $invoice->valFeeBank; $orderModel->mr_fee = $invoice->valFeeMR; $orderModel->total_cost = $invoice->subTotal; $orderModel->grand_total = $invoice->grandTotal; $arrOrderDetails = Util::getDetailOrderByIdOrder($orderModel->id_order); if (count($arrOrderDetails) <= 0) { Generic::errorMsg(Keys::$ERR_NOT_FOUND_ORDER_DETAIL); } foreach ($arrOrderDetails as $orderDetail) { if (!$orderDetail instanceof OrderDetailModel) { return; } $orderDetail->datetime_order = leap_mysqldate(); $orderDetail->order_now = Keys::$YES; $orderDetail->load = 1; $orderDetail->save(); } if ($orderModel->type_order == Keys::$ORDER_TYPE_DINE_IN_APPS && !Generic::IsNullOrEmptyString($orderModel->id_table)) { $table = new MasterTableModel(); $table->getByID($orderModel->id_table); $table->waitingOrder = Keys::$TABLE_IS_WAITING_ORDER; $table->save(); } if ($orderModel->type_order == Keys::$ORDER_TYPE_TAKE_AWAY_APPS) { $restaurant = new MasterRestaurantModel(); $restaurant->getByID($orderModel->id_restaurant); $restaurant->order_number = $restaurant->order_number + 1; $restaurant->load = 1; $restaurant->save(); $orderNumber = $restaurant->order_number; $orderModel->order_number = $orderNumber; } $orderModel->allergy = $allergy; $orderModel->generalNote = $generalNote; $orderModel->order_now = Keys::$YES; $orderModel->datetime_order_now = leap_mysqldate(); $orderModel->save(); $j["id_order"] = $orderModel->id_order; $j['datetime'] = date('Y-m-d H:i:s'); return Util::pushNotifyRestaurant($orderModel->id_restaurant, Keys::$typeNotifNewTakeAway, $j); }
public function addDishToMyFavorite() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idUser = Generic::mustCheck($_GET['id_user'], "User ID not Found"); $idDish = Generic::mustCheck($_GET['id_dish'], "Dish ID not Found"); $user = new UserModel(); $user->getByID($idUser); $arrFavDishIds = explode(',', $user->fav_dishes_ids); $alreadyInFavorite = count($arrFavDishIds) <= 0 ? false : in_array($idDish, $arrFavDishIds); if ($alreadyInFavorite) { Generic::errorMsg("Already Favorited"); } if (count($arrFavDishIds) <= 0) { $user->fav_dishes_ids = $idDish; } else { $arrFavDishIds[] = $idDish; $arrFavDishIds = array_unique($arrFavDishIds); $user->fav_dishes_ids = implode(',', $arrFavDishIds); } $dish = new MasterDishModel(); $dish->getByID($idDish); $dish->fav = $dish->fav + 1; $dish->save(); $resto = new MasterRestaurantModel(); $resto->getByID($dish->id_restaurant); $resto->fav = $resto->fav + 1; $resto->save(); $user->save(); $this->success(); }
public function updateRestaurantDiscount() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $discount = Generic::mustCheck($_POST["disc_resto"], "No Discount"); $idResto = Generic::mustCheck($_POST["id_restaurant"], Keys::$ERR_NOT_FOUND_ID_RESTAURANT); $resto = new MasterRestaurantModel(); $resto->getByID($idResto); $resto->disc_resto = $discount; $resto->save(); Generic::success("Charges Updates"); }
public function updateRestoMRFee() { $idsResto = Generic::mustCheck($_POST['id_restaurant'], "No Restaurant IDs Found"); $fee = Generic::mustCheck($_POST['fee'], "No Fee Found"); if (!is_numeric($fee)) { Generic::errorMsg("Fee Must Numbers"); } if (doubleval($fee) > 100) { Generic::errorMsg("Fee Max 100%"); } $ids = explode(',', $idsResto); if (count($ids) <= 0) { Generic::errorMsg("Empty Id"); } $updateAll = in_array('0', $ids); if ($updateAll) { $r = new MasterRestaurantModel(); $arrR = $r->getAll(); foreach ($arrR as $singleR) { unset($resto); $resto = new MasterRestaurantModel(); $resto->getByID($singleR->id_restaurant); $log = new LogDiscFeeModel(); $log->id_reference = $singleR->id_restaurant; $log->change_type = "Fee MR"; $log->change_from = Generic::IsNullOrEmptyString($resto->mr_fee) ? "0" : $resto->mr_fee; $log->change_to = $fee; $log->change_date_time = leap_mysqldate(); $log->save(); $resto->mr_fee = $fee; $resto->save(); } } else { foreach ($ids as $id) { unset($resto); $resto = new MasterRestaurantModel(); $resto->getByID($id); $log = new LogDiscFeeModel(); $log->id_reference = $id; $log->change_type = "Fee MR"; $log->change_from = Generic::IsNullOrEmptyString($resto->mr_fee) ? "0" : $resto->mr_fee; $log->change_to = $fee; $log->change_date_time = leap_mysqldate(); $log->save(); $resto->mr_fee = $fee; $resto->save(); } } $json['status_code'] = 1; $json['status_message'] = "success"; echo json_encode($json); die; }
public function createQRbyRestoID() { $id_restaurant = $_GET['id_restaurant']; $quantityQR = $_GET['quantityQR']; $id_request = $_GET['id_request']; $objResto = new MasterRestaurantModel(); $objResto->getByID($id_restaurant); $objResto->table_quantity = $objResto->table_quantity + $quantityQR; $objResto->load = 1; $objResto->save(); // pr($objResto); $objQRRequest = new QRRequestModel(); $objQRRequest->getByID($id_request); $objQRRequest->createdOn = leap_mysqldate(); // pr($objQRRequest); $objQRRequest->status = "1"; $objQRRequest->load = 1; $objQRRequest->save(); $objQR = new QRModel(); global $db; $qtydiDB = "SELECT max(id_qr) as max from menurevo__QR"; $arr = $db->query($qtydiDB, 1); for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { $encode = addslashes(base64_encode($i)); $q = "INSERT INTO menurevo__QR (id_qr, textQR,status) VALUES({$i},'{$encode}',0)"; $id = $db->query($q, 1); } $pdf = new FPDF(); $myarray = array(1, 2, 3); $pdf->SetFont('Arial', 'B', 16); for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { $pdf->AddPage(); $pdf->Image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" . base64_encode($i), 60, 30, 90, 0, 'PNG'); $pdf->Text(85, 130, "Menu Revolution"); } $pdf->Output(); ?> <html> <head> <title>Print QR-Code</title> <style> body{ margin: 0; padding: 0; font-family: verdana;} </style> </head> <body> <?php for ($i = $arr->max + 1; $i <= $quantityQR + $arr->max; $i++) { ?> <!-- <div style="width:800px; border-bottom: 3px dashed #aaaaaa; margin-bottom: 20px;"> <img src="<?php echo _SPPATH; ?> images/headerleap.jpg" width="100%">--> <div style="padding:40px; text-align: center;"> <!--<div style="letter-spacing: 2px; font-size: 18px; font-weight: bold; padding-bottom: 20px;"> <?php echo $mur->admin_nama_depan; ?> </div>--> <img src="<?php echo "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" . base64_encode($i); ?> "alt="QR"> </div> <!--</div>--> <?php } ?> </body> </html><?php die('finished'); }
function createQRbyRestoID() { $id_restaurant = $_POST['id_restaurant']; $quantityQR = $_POST['quantityQR']; $objResto = new MasterRestaurantModel(); $objResto->getByID($id_restaurant); $objResto->table_quantity = $objResto->table_quantity + $quantityQR; $objResto->load = 1; $objResto->save(); }
public function updateResto() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $cmd = isset($_POST['cmd']) ? addslashes($_POST['cmd']) : ""; if (!$cmd) { Generic::errorMsg("Hacking attempt!"); } $id_restaurant = isset($_POST['id_restaurant']) ? addslashes($_POST['id_restaurant']) : ""; if (!$id_restaurant) { Generic::errorMsg("No Restaurant ID Found"); } $rawTags = isset($_POST['raw_tags']) ? addslashes($_POST['raw_tags']) : ""; $newTagsIds = array(); //TODO dapat string tags separated by comma, explode //TODO cek MasterRestaurantTagModel kalo duplikasi ambil id nya masukin $newTagsIds //TODO kalo engga duplikasi, save row baru, ambil id nya masukin $newTagsIds if ($rawTags) { $arrRawTags = array_unique(explode(",", $rawTags)); foreach ($arrRawTags as $rawTag) { if ($rawTag == null || $rawTag == "") { continue; } $rawTag = strtoupper($rawTag); $t = new MasterRestaurantTagModel(); $arrTags = $t->getWhere("tag_name = '{$rawTag}'"); // pr($arrTags); if (count($arrTags) == 0) { $tt = new MasterRestaurantTagModel(); $tt->tag_name = $rawTag; $id = $tt->save(); } else { $id = $arrTags[0]->id_tag; } $newTagsIds[] = $id; } } $objRestaurant = new MasterRestaurantModel(); $exp = explode(",", str_replace(" ", "", $objRestaurant->crud_webservice_allowed)); $objRestaurant->getById($id_restaurant); if ($objRestaurant->id_restaurant != $id_restaurant) { Generic::errorMsg("No Restaurant ID Found"); } if ($cmd == "initResto") { $onlyUpdates['aktiv'] = "1"; } elseif ($cmd == "updateResto") { } else { Generic::errorMsg("No CMD ID Found"); } foreach ($exp as $attr) { if ($_POST[$attr] != "") { if ($attr == "image_logo") { $file = self::savePic($_POST[$attr]); $onlyUpdates[$attr] = $file; } else { $onlyUpdates[$attr] = $_POST[$attr]; } } } $objRestaurant->fill($onlyUpdates); if (count($newTagsIds) != 0) { $objRestaurant->restaurant_tags = implode(",", array_unique($newTagsIds)); } $id = $objRestaurant->save(); if (!$id) { Generic::errorMsg("Failed to Save"); } else { $json['status_code'] = 1; $json['results']['message'] = "success"; } echo json_encode($json); die; }
public function updateRestoMRDiscount() { $idsResto = Generic::mustCheck($_POST['id_restaurant'], "No Restaurant IDs Found"); $disc = Generic::mustCheck($_POST['discount'], "No Discount Found"); if (!is_numeric($disc)) { Generic::errorMsg("Discount Must Numbers"); } if (strlen(trim($disc)) > 2) { Generic::errorMsg("Discount Max 2 Digits"); } $ids = explode(',', $idsResto); if (count($ids) <= 0) { Generic::errorMsg("Empty Id"); } $updateAll = in_array('0', $ids); if ($updateAll) { $r = new MasterRestaurantModel(); $arrR = $r->getAll(); foreach ($arrR as $singleR) { unset($resto); $resto = new MasterRestaurantModel(); $resto->getByID($singleR->id_restaurant); unset($logdisc); $logdisc = new LogDiscFeeModel(); $logdisc->id_reference = $resto->id_restaurant; $logdisc->change_type = "Discount MR"; $logdisc->change_from = Generic::IsNullOrEmptyString($resto->disc_mr) ? "0" : $resto->disc_mr; $logdisc->change_to = $disc; $logdisc->change_date_time = leap_mysqldate(); $logdisc->save(); $resto->disc_mr = $disc; $resto->save(); } } else { foreach ($ids as $id) { unset($resto); $resto = new MasterRestaurantModel(); $resto->getByID($id); unset($logdisc); $logdisc = new LogDiscFeeModel(); $logdisc->id_reference = $resto->id_restaurant; $logdisc->change_type = "Discount MR"; $logdisc->change_from = Generic::IsNullOrEmptyString($resto->disc_mr) ? "0" : $resto->disc_mr; $logdisc->change_to = $disc; $logdisc->change_date_time = leap_mysqldate(); $logdisc->save(); $resto->disc_mr = $disc; $resto->save(); } } $json['status_code'] = 1; $json['status_message'] = "success"; echo json_encode($json); die; }
public function setOrderViaDevice() { 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_dish = isset($_POST['id_dish']) ? addslashes($_POST['id_dish']) : ""; if (!$id_dish) { Generic::errorMsg("No ID Dish found!"); } if (!MasterDish::checkDish($id_dish)) { Generic::errorMsg("ID Dish not found!"); } $qty = isset($_POST['qty']) ? addslashes($_POST['qty']) : ""; if (!$qty) { Generic::errorMsg("No Qty found!"); } $objOrder = new MasterOrderModel(); $arrOrder = $objOrder->getWhere("(id_user='******' OR FIND_IN_SET('{$id_user}', user_guest_id)) AND status_payment = '0' AND order_now = '0' AND status!='0'"); $id_restaurant = MasterDish::getDishAttributByID($id_dish, "id_restaurant"); //TODO CEK RESTORAN SEKARANG BUKA ATAU TIDAK $user = new UserModel(); $user->getByID($id_user); $resto = new MasterRestaurantModel(); $resto->getByID($id_restaurant); //DENY IF RESTO CLOSED if ($resto->now_open == "0") { Generic::errorMsg("Not accepting orders now"); } if (count($arrOrder) == 0) { $type_order = '3'; $id_order = $this->createHeadOrder($id_user, $id_restaurant, $type_order); $id_orderDetails = $this->addOrderDetails($id_order, $id_user, $id_dish, $qty); } elseif (count($arrOrder) > 0) { // kumpulan resto id foreach ($arrOrder as $order) { $arrResto[] = $order->id_restaurant; } // check resto id ada di kumpulan resto id if (in_array($id_restaurant, $arrResto)) { $objOrderHlp = new MasterOrderModel(); $arrOrderHlp = $objOrderHlp->getWhere("(id_user='******' OR FIND_IN_SET('{$id_user}', user_guest_id)) AND id_restaurant='{$id_restaurant}' AND status_payment = '0' AND order_now = '0' AND status!='0'"); if (count($arrOrderHlp) > 0) { $id_order = $arrOrderHlp[0]->id_order; $id_orderDetails = $this->addOrderDetails($id_order, $id_user, $id_dish, $qty); } } else { $type_order = '3'; $id_order = $this->createHeadOrder($id_user, $id_restaurant, $type_order); $id_orderDetails = $this->addOrderDetails($id_order, $id_user, $id_dish, $qty); } } $invoice = $this->calcRechnung($id_restaurant, $id_order); $objOrder->getByID($id_order); $this->setInvoiceInOrder($objOrder, $invoice); $objOrder->user_name = $user->user_name; $objOrder->user_email = $user->email; $objOrder->status = "1"; $objOrder->user_last_phone_number = substr($user->phone_no, -2); if ($objOrder->type_order == "3" && $objOrder->order_number == "0" || $objOrder->order_number == "") { $resto->order_number = $resto->order_number + 1; $objOrder->order_number = $resto->order_number; $resto->save(); } if ($objOrder->type_order != "3") { $objOrder->order_number = 0; } $objOrder->save(); $json['results']['messages'] = "Success"; echo json_encode($json); $objOrderHlp = new MasterOrderModel(); $objOrderHlp->getByID($id_order); $ids = $this->getUserIdByIDOrder($id_order, $id_user); $this->notifyAddOrder($ids, $id_order); die; }
public function clearRestoCats() { $catIdDefault = $this->createCategories("OTHERS"); $rm = new MasterRestaurantModel(); $arrResto = $rm->getAll(); foreach ($arrResto as $r) { $resto = new MasterRestaurantModel(); $resto->getByID($r->id_restaurant); $resto->id_categories = $catIdDefault; $resto->save(); } }