public function createInvitationLink() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_user = Generic::mustCheck($_GET['id_user'], "NO ID User found!"); $id_order = Generic::mustCheck($_GET['id_order'], "NO ID Order found!"); // check apakah id_order dgn id_user msh aktiv $objOrder = new MasterOrderModel(); $arrOrder = $objOrder->getWhere("id_order='{$id_order}' AND id_user = '******' AND status_payment = '0'"); Generic::checkCountWithMsg($arrOrder, "Order is not activate"); $objInvitation = new InvitationModel(); $objInvitation->inv_id_resto = $arrOrder[0]->id_restaurant; $objInvitation->inv_id_order = $id_order; $objInvitation->inv_id_table = $arrOrder[0]->id_table; $objInvitation->inv_from = $id_user; $id = $objInvitation->save(); if ($id != "") { $link = _BPATH . "Invitation/acceptInvitation?id_invitation={$id}"; $json['status_message'] = addslashes($link); } else { $json['status_code'] = 0; $json['status_message'] = "Link can't create!"; } echo json_encode($json); die; }
public function clearTableWS() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $id_table = isset($_GET['id_table']) ? addslashes($_GET['id_table']) : ""; if (!$id_table) { $json['status_code'] = 0; $json['status_message'] = "No ID Found"; echo json_encode($json); die; } // $objTable = new MasterTableModel(); // $arrTable = $objTable->getWhere("id_table='$id_table'"); // // MasterDish::checkCount($arrTable); // // $onlyUpdates = array("id_order" => "0", "waitingOrder" => "0", "appOrder" => "", "cashPayment" => ""); // $arrTable[0]->id_order = "0"; // $arrTable[0]->waitingOrder = "0"; // $arrTable[0]->appOrder = ""; // $arrTable[0]->cashPayment = ""; // $arrTable[0]->status = "1"; // $arrTable[0]->load = 1; // $id_objTable = $arrTable[0]->save(); $id_objTable = self::clearTable($id_table); $objTable = new MasterTableModel(); $objTable->getByID($id_table); $id_order = $objTable->id_order; if ($id_order != 0) { $objOrder = new MasterOrderModel(); $objOrder->getByID($id_order); if ($id_table == $objOrder->id_table) { $objOrder->status_payment = "1"; $objOrder->load = 1; $objOrder->save(); } } if (!$id_objTable) { $json['status_code'] = 0; $json['results'] = Lang::t('save failed'); } else { $json['status_code'] = 1; $json['results']['message'] = "success"; } echo json_encode($json); die; }
private function findOrder($idUser, $idDish, $qty, $idRestaurant) { $o = new MasterOrderModel(); $arrOrders = $o->getWhere("id_restaurant='{$idRestaurant}' AND status='1' AND status_payment='0'"); pr($arrOrders); }
public function sendwithreturn() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $idOrder = $_GET['id_order']; $toEmail = $_GET['email']; $order = new MasterOrderModel(); $order->getByID($idOrder); $resto = new MasterRestaurantModel(); $resto->getByID($order->id_restaurant); $subject = "Your receipt from " . $restoName . " , Receipt#" . $idOrder; $od = new OrderDetailModel(); $d = new MasterDishModel(); // $dompdf = new Dompdf\Dompdf(); global $db; $q = "SELECT {$od->table_name}.id_dish, {$d->table_name}.name, SUM(quantity) AS sum_qty, {$d->table_name}.price,\nSUM({$od->table_name}.price) AS sum_price, status_progress FROM `{$od->table_name}`\nRIGHT JOIN {$d->table_name} ON {$od->table_name}.id_dish = {$d->table_name}.id_dish WHERE id_order='{$idOrder}' GROUP BY id_dish"; $arrDetails = $db->query($q, 2); $css_boot = _BPATH . "themes/tbstheme_ori/css/bootstrap.min.css"; $image1 = _BPATH . _PHOTOURL . $resto->image_logo; if ($image1 == "") { $image1 = _BPATH . _PHOTOURL . "noimage.jpg"; } $head = "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; $head = "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Notification email</title>"; $head = $head . "<link href=" . $css_boot . " rel=\"stylesheet\">"; $head = $head . "<link href=\"https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700&subset=latin,latin-ext\" rel=\"stylesheet\" type=\"text/css\">"; $head = $head . "</head>"; $html = "<div style=\"max-width: 800px; box-shadow: 0 0 10px rgba(0, 0, 0, .15); font-size: 16px; line-height: 24px; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; color: #555; margin: auto; padding: 30px; border: 1px solid #eee;\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; padding: 5px;\" colspan=\"2\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; font-size: 45px; line-height: 45px; color: #333; width: 50%; display: block; text-align: left; padding: 5px 5px 20px;\" align=\"left\" valign=\"top\"><img style=\"width: 50%; max-width: 300px;\" src=" . $image1 . " alt=\"\" /></td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; width: 100%; display: block; text-align: left; padding: 5px 5px 40px;\" align=\"center\" valign=\"top\">"; $html = $html . "<strong>" . $resto->name . "</strong><br />"; $html = $html . $resto->district . " - " . $resto->city . " <br>"; $html = $html . "Phone : " . $resto->phone_no . "</td>"; $html = $html . "</tr>\n</tbody>\n</table>\n</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; padding: 5px;\" colspan=\"2\" valign=\"top\">\n<table style=\"width: 100%; line-height: inherit; text-align: left;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top; text-align: left; t width: 50%; display: block; padding: 5px 5px 20px;\" align=\"left\" valign=\"top\">"; $html = $html . "</tr>"; $html = $html . "Receipt #: " . $idOrder; $html = $html . "<br/>"; $html = $html . " Server : "; if ($order->type_order == "1" || $order->type_order == "3") { $html = $html . "Apps Order"; } else { $html = $html . $order->server_name; } $html = $html . "<br/>"; $html = $html . " Time Order : " . date("d M, Y H:m", strtotime($order->datetime_order)); $html = $html . "<br/>"; $html = $html . " Payment Method : " . Generic::selectPaymentMethod($order->status_payment); $html = $html . "<br/>"; if ($order->type_order == "1" || $order->type_order == "3") { $html = $html . "Apps Order"; } else { $html = $html . "Manual Order"; } $html = $html . "<br/>"; $html = $html . "</td>"; $html = $html . "</tr> \n</tbody>\n</table>\n</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" valign=\"top\" bgcolor=\"#eee\">Item</td>\n<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"center\" valign=\"top\" bgcolor=\"#eee\">#</td>\n<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"right\" valign=\"top\" bgcolor=\"#eee\">Price</td>\n <td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ddd; font-weight: bold; background-color: #eee; padding: 5px;\" align=\"right\" valign=\"top\" bgcolor=\"#eee\">Total</td>\n</tr>"; foreach ($arrDetails as $details) { $void = ""; if ($details->status_progress == "9") { $void = "<strong> Voided </strong>"; $details->price = 0; $details->sum_price = 0; } $html = $html . "<tr><td style=\"vertical-align: top; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" valign=\"top\">" . $details->name . $void . "</td>"; $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . $details->sum_qty . "</td>"; $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($details->price) . "</td>"; $html = $html . "<td style=\"vertical-align: top; text-align: right; border-bottom-width: 1px; border-bottom-color: #eee; border-bottom-style: solid; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($details->sum_price) . "</td></tr>"; } $html = $html . "<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Total : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->total_cost) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc Resto : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_resto) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc Credit Card : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_bank) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Disc MR : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->disc_mr) . "</td>\n</tr>\n\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Tax PB1 : </td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Service Charge : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Other Charge : </td>\n<td style=\"vertical-align: top; text-align: right; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->tax_pb1) . "</td>\n</tr>\n<tr>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\"></td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">Grand Total :</td>\n<td style=\"vertical-align: top; text-align: right; border-top-style: solid; border-top-width: 2px; border-top-color: #eee; font-weight: bold; padding: 5px;\" align=\"right\" valign=\"top\">" . Generic::formatRupiah($order->grand_total) . "</td>\n</tr>\n\n</tbody>\n</table>\n</div></html>"; $html = $head . $html; $mail = new Leapmail(); $res = $mail->sendEmailHTML($toEmail, $subject, $html); return $res; }
public static function calcRechnung($id_restaurant, $id_order, $save = false) { $objResto = User::getRestaurant($id_restaurant); $objOrder = new MasterOrderModel(); $objOrder->getByID($id_order); $arrOrderDetails = OrderDetail::getOrderDetailsByIDOrderForCalc($id_order); $total = 0; foreach ($arrOrderDetails as $orderDetails) { // pr($orderDetails); if ($orderDetails['status_progress'] != '9') { $total = $total + $orderDetails['price']; } } $invoice['sub_total'] = strval($total); // $invoice['service_charge'] = $objResto['service_charge']; // $invoice['other_charge'] = $objResto['other_charge']; if ($objResto['service_charge'] > 100) { $invoice['service_charge'] = strval($objResto['service_charge']); } else { $invoice['service_charge'] = strval($objResto['service_charge'] / 100 * $total); } if ($objResto['other_charge'] > 100) { // $invoice['other_charge'] = strval($objResto['other_charge']); } else { $invoice['other_charge'] = strval($objResto['other_charge'] / 100 * $total); } $disc_bank = self::getDiscountCreditCard($id_restaurant, $id_bank); if ($objResto['disc_bank'] > 100) { $invoice['Discount_Bank'] = strval($objResto['disc_bank']); } else { $invoice['Discount_Bank'] = strval($objResto['disc_bank'] / 100 * $total); } $discMR = self::getDiscountMR($id_restaurant); if ($discMR > 100) { // $invoice['Discount_MR'] = strval($discMR); } else { $invoice['Discount_MR'] = strval($discMR / 100 * $total); } $feeMR = self::getFeeMR($id_restaurant); $feeBank = self::getFeeCreditCard($id_restaurant, $id_bank); // $total_2 = $total_2 - $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); } // Fee // // $total_2 = $total_2 - $invoice['Discount_Resto']; $invoice['Tax'] = strval($total * ($objResto['tax_pb_1'] / 100)); $invoice['Total'] = strval($total + $invoice['Tax'] + $invoice['service_charge'] + $invoice['other_charge'] - $invoice['Discount_MR'] - $invoice['Discount_Bank'] - $invoice['Discount_Resto']); return $invoice; }
public function emailReceipt() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idOrder = Generic::mustCheck($_POST['id_order'], "No ID Order"); $order = new MasterOrderModel(); $order->getByID($idOrder); if (Generic::IsNullOrEmptyString($order->id_order)) { Generic::errorMsg("Order Not Found"); } if (Generic::IsNullOrEmptyString($_POST['user_email'])) { if ($order->id_user != "0" || $order->id_user != "") { Generic::errorMsg("No Email Found"); } else { $user = new UserModel(); $user->getByID($order->id_user); $email = $user->email; } } else { $email = $_POST['user_email']; } //TODO MAIL RECEIPT TO $email Generic::success("Success"); }
private function actionForPushCode($pushCode, $refId) { switch ($pushCode) { case Push::$typeUpdatePending: return "GOTO PENDING"; case Push::$typeUpdateWaiting: $order = new MasterOrderModel(); $order->getByID($refId); if ($order->status_progress == 9) { return "GOTO NOWHERE"; } elseif ($order->status_progress < 4) { return "GOTO WAITING"; } else { return "GOTO RECEIPT"; } case Push::$typeUpdateDoneAll: return "GOTO RECEIPT"; case Push::$typeNotifyOrderDone: return "GOTO RECEIPT"; case Push::$typeRejectJoinTable: return "GOTO NOWHERE"; case Push::$typeAcceptOpenTable: return "GOTO RESTAURANT"; case Push::$typeMRPushByCuisine: return "GOTO IMAGE"; case Push::$typeMRPushByLocation: return "GOTO IMAGE"; default: return "GOTO NOWHERE"; } }
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 reportFee() { $id_restaurant = isset($_GET['id_restaurant']) ? addslashes($_GET['id_restaurant']) : "0"; $type_order = isset($_GET['type_order']) ? addslashes($_GET['type_order']) : "8"; $dateVon = isset($_GET['dateVon']) ? addslashes($_GET['dateVon']) : date('Y-m-d', time()); $dateBis = isset($_GET['dateBis']) ? addslashes($_GET['dateBis']) : date('Y-m-d', time()); // $dateBis = isset($_GET['dateBis']) ? addslashes($_GET['dateBis']) : Generic::setCurrentDate(); $id_server = isset($_GET['id_server']) ? addslashes($_GET['id_server']) : "0"; $status_payment = isset($_GET['status_payment']) ? addslashes($_GET['status_payment']) : 0; $status_progress = isset($_GET['status_progress']) ? addslashes($_GET['status_progress']) : 4; $objResto = new MasterRestaurantModel(); $arrResto = $objResto->getAll(); $arrRestoIndex[0] = "All"; foreach ($arrResto as $resto) { if ($resto->name != "") { $arrRestoIndex[$resto->id_restaurant] = $resto->name; } } $objOrder = new MasterOrderModel(); $first_key = key($arrRestoIndex); $arrOrder = $objOrder->getWhere("id_restaurant='{$id_restaurant}'"); $arrRestoUserIndex[0] = "All"; foreach ($arrOrder as $val) { $user = RestaurantUser::getRestaurantUserName($val->id_server); if ($user != "") { $arrRestoUserIndex[$val->id_server] = $user; } } $arrTypeOrder[0] = "Dine In - Manual"; $arrTypeOrder[1] = "Dine In - Apps"; $arrTypeOrder[2] = "Take Away - Manual"; $arrTypeOrder[3] = "Take Away - Apps"; $arrTypeOrder[4] = "All Manual Order"; $arrTypeOrder[5] = "All Apps Order"; $arrTypeOrder[6] = "All Dine In Order"; $arrTypeOrder[7] = "All Take Away Order"; $arrTypeOrder[8] = "All Order Types"; $arrStatusPaymentMethod[1] = "Cash"; $arrStatusPaymentMethod[2] = "Credit Card"; $arrStatusPaymentMethod[3] = "Others"; $arrStatusPaymentMethod[0] = "All Payment Method"; $arrStatusProgress[4] = "Done"; $arrStatusProgress[9] = "Void"; $t = time(); $where = " "; if ($id_restaurant == 0) { $where = $where; } else { $allResto = false; $where = $where . " resto.id_restaurant='{$id_restaurant}' AND "; } if ($type_order == "8") { } else { $where = $where . " o.type_order='{$type_order}' AND "; } if ($dateVon == "") { ?> <?php $dateVon = Generic::setCurrentDate(); } else { $date = new DateTime($dateVon); // $dateVon = leap_mysqldate_isi(date('Y-m-d H:i:s')); // pr($dateVon); $where = $where . " o.datetime_order >='{$dateVon}' AND "; } if ($dateBis == "") { $dateBis = Generic::setCurrentDate(); } else { $date = new DateTime($dateVon); $where = $where . " o.datetime_order <= '{$dateBis}' AND "; } if ($id_server == "0") { $where = $where; } else { $where = $where . " o.id_server='{$id_server}' AND "; } if ($status_payment == "" | $status_payment == "0") { $where = $where; } else { $where = $where . " o.status_payment='{$status_payment}' AND "; } if ($status_progress == "") { } else { $where = $where . " o.status_progress='{$status_progress}' "; } $objOrder = new MasterOrderModel(); $objResto = new MasterRestaurantModel(); $objOrderDetail = new OrderDetailModel(); $objDish = new MasterDishModel(); global $db; $q = "SELECT o.datetime_order as dateOrder,o.datetime_order as timeOrder , resto.name, o.id_order, o.mr_fee, o.cc_fee, o.mr_fee+o.cc_fee as Total FROM {$objResto->table_name} resto INNER JOIN {$objOrder->table_name} o ON resto.id_restaurant = o.id_restaurant"; // $q = $q . " INNER JOIN {$objOrderDetail->table_name} orderdetail ON o.id_order = orderdetail.id_order "; // $q = $q . " INNER JOIN {$objDish->table_name} dish ON orderdetail.id_dish = dish.id_dish "; $q = $q . " WHERE " . $where; // pr($q); $arrQuery = $db->query($q, 2); // pr($arrQuery); // die(); // $data = json_encode($arrQuery); $data = $arrQuery; // pr($arrRestoIndex); ?> <div class="col-md-12"> <div class="col-sm-12"> <h1>Reporting Fee</h1> </div> <div id="formgroup_selected_restaurant" class="form-group"> <div class='col-sm-6'> <select id = "restoID_<?php echo $t; ?> " class="form-control"> <?php foreach ($arrRestoIndex as $key => $val) { if ($key == $_GET['id_restaurant']) { echo "<option selected='selected' value='" . $key . "'>" . $val . "</option>"; } else { echo "<option value='" . $key . "'>" . $val . "</option>"; } } ?> </select> </div> <div class='col-sm-6'> <select id = "type_order_<?php echo $t; ?> " class="form-control"> <?php foreach ($arrTypeOrder as $key => $val) { if ($key == $_GET['type_order']) { echo "<option selected='selected' value='" . $key . "'>" . $val . "</option>"; } else { echo "<option value='" . $key . "'>" . $val . "</option>"; } } ?> </select> </div> <div class="clearfix"></div> </div> <div id="formgroup_date" class="form-group"> <div class='col-sm-6'> <div class="form-group"> <div class='input-group date' id='datetimepickerFrom_<?php echo $t; ?> ' data-date-format="dd-mm-yyyy"> <input type='text' id= "dateVon_<?php echo $t; ?> "class="form-control" /> <span id = "cobaFrom" class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> <div class='col-sm-6'> <div class="form-group"> <div class='input-group date' id='datetimepickerTo_<?php echo $t; ?> '> <input type='text' id= "dateBis_<?php echo $t; ?> " class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> <div class="clearfix"></div> </div> <div id="formgroup_server" class="form-group"> <div class='col-sm-6'> <select id = "selectServer_<?php echo $t; ?> " class="form-control"> <?php foreach ($arrRestoUserIndex as $key => $val) { if ($key == $_GET['id_server']) { echo "<option selected='selected' value='" . $key . "'>" . $val . "</option>"; } else { echo "<option value='" . $key . "'>" . $val . "</option>"; } } ?> </select> </div> <div class='col-sm-6'> <select id = "status_payment_<?php echo $t; ?> " class="form-control"> <?php foreach ($arrStatusPaymentMethod as $key => $val) { if ($key == $_GET['status_payment']) { echo "<option selected='selected' value='" . $key . "'>" . $val . "</option>"; } else { echo "<option value='" . $key . "'>" . $val . "</option>"; } } ?> </select> </div> <div class="clearfix"></div> </div> <div id="formgroup_progress" class="form-group"> <div class='col-sm-6'> <select id = "status_progress_<?php echo $t; ?> " class="form-control"> <?php foreach ($arrStatusProgress as $key => $val) { if ($key == $_GET['status_progress']) { echo "<option selected='selected' value='" . $key . "'>" . $val . "</option>"; } else { echo "<option value='" . $key . "'>" . $val . "</option>"; } } ?> </select> </div> <div class="btn-group col-sm-4" role="group" aria-label="..."> <button type="button" class="btn btn-default" id="export_<?php echo $t; ?> ">Export</button> </div> <div class="clearfix"></div> </div> </div> <script type="text/javascript"> var dateFrom, dateTo; if (dateFrom == null) { var now = new Date(); var day = ("0" + now.getDate()).slice(-2); var month = ("0" + (now.getMonth() + 1)).slice(-2); var dateFrom = now.getFullYear() + "-" + (month) + "-" + (day); } if (dateTo == null) { var now = new Date(); var day = ("0" + now.getDate()).slice(-2); var month = ("0" + (now.getMonth() + 1)).slice(-2); var dateTo = now.getFullYear() + "-" + (month) + "-" + (day); } $('#restoID_<?php echo $t; ?> ').change(function () { var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?id_server=0" + "&id_restaurant=" + id_restaurant + "&dateVon=" + dateFrom + "&dateBis=" + dateTo, "fade"); }); $('#type_order_<?php echo $t; ?> ').change(function () { var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo + "&status_progress=" + status_progress, "fade"); }); $('#selectServer_<?php echo $t; ?> ').change(function () { var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo + "&status_progress=" + status_progress, "fade"); }); $('#status_payment_<?php echo $t; ?> ').change(function () { var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo + "&status_progress=" + status_progress, "fade"); }); $('#status_progress_<?php echo $t; ?> ').change(function () { var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo + "&status_progress=" + status_progress, "fade"); }); var datetimepickerFrom = $('#datetimepickerFrom_<?php echo $t; ?> '); var datetimepickerTo = $('#datetimepickerTo_<?php echo $t; ?> '); $('#dateVon_<?php echo $t; ?> ').change(function () { var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var status_progress = $('#status_progress<?php echo $t; ?> ').val(); openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo + "&status_progress=" + status_progress, "fade"); }); $('#export_<?php echo $t; ?> ').click(function () { <?php $_SESSION["data"] = $data; ?> // initializes and invokes show immediately window.open('<?php echo _SPPATH; ?> Report/exportIt', "_blank "); }); // $(function () { datetimepickerFrom.datetimepicker({ format: 'DD/MM/YYYY', defaultDate: dateFrom //Im,portant! See issue #1075 }); datetimepickerTo.datetimepicker({ format: 'DD/MM/YYYY', defaultDate: dateTo }); datetimepickerFrom.on("dp.change", function (e) { datetimepickerTo.data("DateTimePicker").minDate(e.date); var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); dateFrom = new Date(e.date); console.log(e); if (e.oldDate != null) { dateFrom = new Date(); dateFrom = moment().format('DD/MM/YYYY'); } if (e.oldDate != null) { var changed = false; if (e.date != e.oldDate) { changed = true; console.log("olddate: " + e.oldDate.format('Y-M-D')); console.log("Date: " + e.date.format('Y-M-D')); console.log("dateVon_: " + $('#dateVon_<?php echo $t; ?> ').val()); var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var tglFrom = e.date.format('Y-M-D'); dateFrom = e.date.format('Y-M-D'); $('#dateVon_<?php echo $t; ?> ').val(dateFrom); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); if (changed) { openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo, "fade"); changed = false; } } } }); datetimepickerTo.on("dp.change", function (e) { datetimepickerFrom.data("DateTimePicker").maxDate(e.date); if (e.oldDate != null) { var changed = false; if (e.date != e.oldDate) { changed = true; console.log("olddate: " + e.oldDate.format('Y-M-D')); console.log("Date: " + e.date.format('Y-M-D')); console.log("dateBis_: " + $('#dateBis_<?php echo $t; ?> ').val()); var type_order = $('#type_order_<?php echo $t; ?> ').val(); console.log("type_order: " + type_order); var id_restaurant = $('#restoID_<?php echo $t; ?> ').val(); console.log("id_restaurant: " + id_restaurant); var server = $('#selectServer_<?php echo $t; ?> ').val(); console.log("server: " + server); var status_payment = $('#status_payment_<?php echo $t; ?> ').val(); var tglFrom = e.date.format('Y-M-D'); dateTo = e.date.format('Y-M-D'); var status_progress = $('#status_progress_<?php echo $t; ?> ').val(); $('#dateBis_<?php echo $t; ?> ').val(dateTo); if (changed) { openLw("DiscountCC", "<?php echo _SPPATH; ?> Report/reportFee?type_order=" + type_order + "&id_restaurant=" + id_restaurant + "&id_server=" + server + "&status_payment=" + status_payment + "&dateVon=" + dateFrom + "&dateBis=" + dateTo, "fade"); changed = false; } } } }); }); // $("[name='status_progress_<?php echo $t; ?> ']").bootstrapSwitch('state', true, true); </script> <div class="col-md-12"> <div class="table-responsive"> <table id = "table_report_<?php echo $t; ?> " class="table table-bordered table-striped table-hover crud-table" style="background-color: white;"> <tbody><tr> <th id="h_id_date_<?php echo $t; ?> ">Date</th> <th id="h_id_time_<?php echo $t; ?> ">Time</th> <th id="h_id_restaurant_<?php echo $t; ?> ">Restaurant</th> <th id="h_id_order_<?php echo $t; ?> ">Order No.</th> <th id="h_total_<?php echo $t; ?> ">MR Fee</th> <th id="h_disc_<?php echo $t; ?> ">Credit Card Fee</th> <th id="h_charges_<?php echo $t; ?> ">Total Fee</th> </tr> <?php foreach ($arrQuery as $key => $val) { ?> <tr id="report_<?php echo $t; ?> "> <?php $date = new DateTime($val->datetime_order); ?> <td id="id_date_<?php echo $t . "_" . $val->id_order; ?> "> <?php echo $date->format('d.m.Y'); ?> </td> <td id="id_time_<?php echo $t . "_" . $val->id_order; ?> "> <?php echo $date->format('H:i:s'); ?> </td> <td id="id_restaurant_<?php echo $t . "_" . $val->id_order; ?> "> <?php echo $val->name; ?> </td> <td id="id_order_<?php echo $t . "_" . $val->id_order; ?> "><?php echo $val->id_order; ?> </td> <td id="total_<?php echo $t . "_" . $val->id_order; ?> "><?php echo Generic::formatRupiah($val->mr_fee); ?> </td> <td id="disc_<?php echo $t . "_" . $val->id_order; ?> "><?php echo Generic::formatRupiah($val->cc_fee); ?> </td> <td id="charges_<?php echo $t . "_" . $val->id_order; ?> "><?php echo Generic::formatRupiah($val->Total); ?> </td> </tr> <script> $('#id_order_<?php echo $t . "_" . $val->id_order; ?> ').click(function () { openLw("order_detail", "<?php echo _SPPATH; ?> Report/viewOrderDetail?id_order=" + <?php echo $val->id_order; ?> , "fade"); }); </script> <?php } ?> </tbody> </table> </div> </div> <?php }
public function requestJoinTable($userModel, $orderId) { $userModel->user_name; $order = new MasterOrderModel(); $order->getByID($orderId); $leaderId = $order->id_user; $msg = $userModel->user_name . " want to join table"; $j["user"] = $userModel; $this->pushToUser($leaderId, $msg, json_encode($j), $this->typeRequestJoinTable); }
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 saveToOrder() { $order = new MasterOrderModel(); $order->getByID($this->idOrder); $order->disc_resto = doubleval($this->valDiscRestaurant); $order->disc_bank = doubleval($this->valDiscBank); $order->disc_mr = doubleval($this->valDiscMR); $order->tax_pb1 = doubleval($this->valTaxCharge); $order->service_charge = doubleval($this->valServiceCharge); $order->other_charge = doubleval($this->valOtherCharge); $order->cc_fee = doubleval($this->valFeeBank); $order->mr_fee = doubleval($this->valFeeMR); $order->total_cost = doubleval($this->subTotal); $order->grand_total = doubleval($this->grandTotal); // pr($order); $order->save(); return $order; }
public function settlePayment() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $id_order = $_GET["id_order"]; $id_user = $_GET["id_user"]; $user = new UserModel(); $user->getByID($id_user); $order = new MasterOrderModel(); $order->getByID($id_order); $objResto = new MasterRestaurantModel(); $objResto->getByID($order->id_restaurant); if ($user->payment_id == null || $user->payment_id == "0") { Generic::errorMsg("No Payment Method"); } try { $result = Braintree_PaymentMethodNonce::create($user->braintree_id); $nonce = $result->paymentMethodNonce->nonce; $resultSale = Braintree_Transaction::sale(['amount' => $order->grand_total, 'paymentMethodNonce' => $nonce, 'options' => ['submitForSettlement' => True]]); } catch (Exception $e) { Generic::errorMsg($e->getMessage()); } // $transaction = $resultSale->transaction; // $order->transaction_id = $transaction->id; // $order->load = 1; // $order->status_payment = '1'; // $orderObj->nonce_cc = $nonce; // $order->isPaid = '1'; // $order->save(); pr($resultSale); // $json['results'] = "Your Payment was successful with ID Order " . $id_order; // echo json_encode($json); //, // 'descriptor' => [ // 'name' => $objResto->name . " - " . $objResto->order_number // ] // die(); }
public function printInvoice() { $id_order = isset($_GET['id_order']) ? addslashes($_GET['id_order']) : ""; $objOrder = new MasterOrderModel(); $objOrder->getByID($id_order); $invoice = $this->calcRechnung($objOrder->id_restaurant, $id_order); pr($invoice); }