public static function pushUserOrderDone($idOrder) { $order = new MasterOrderModel(); $order->getByID($idOrder); $resto = new MasterRestaurantModel(); $resto->getByID($order->id_restaurant); $title = "Order Done at {$resto->name}"; $message = "Your Order Done! Restaurant {$resto->name} said Thank You!\nPlease Come Again!"; //buat tracker untuk inbox $tracker = new TrackerNotificationModel(); $tracker->id_from = $order->id_restaurant; $tracker->id_to = Util::getAllUserIdInOrder($order->id_order, false); $tracker->id_reference = $order->id_order; $tracker->reference_desc = Keys::$TRACKER_REF_DESC_ID_ORDER; $tracker->type = Keys::$typeNotifOrderDone; $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"] = Util::getAllUserIdInOrder($order->id_order, false); $_POST["msg"] = $message; $_POST["json"] = $idTracker; $_POST["type"] = Keys::$typeNotifOrderDone; // pr($_POST); $push = new PushTo(); $results["message"] = "Success"; $results['push_status'] = $push->usersMR(); $results['id_tracker'] = strval($idTracker); $results['tracker'] = Util::extractModel($tracker); Generic::finish($results); }
public function getCategoriesByResto() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idRestaurant = Generic::mustCheck($_GET['id_restaurant'], Keys::$ERR_NOT_FOUND_ID_RESTAURANT); $objResto = new MasterRestaurantModel(); $objResto->getByID($idRestaurant); if (!Generic::IsNullOrEmptyString($objResto->id_categories)) { $arrCategories = explode(",", $objResto->id_categories); } else { $arrCategories = array(); } $categories = array(); foreach ($arrCategories as $idCat) { $c = new MasterCategoryModel(); $c->getByID($idCat); if ($c->id_category) { $categories[] = $c->name; } } // pr($arrCategories); // pr($categories); $results['categories'] = $categories; $rawTags = array(); $id_dish = isset($_GET['id_dish']) ? addslashes($_GET['id_dish']) : ""; if ($id_dish) { $dish = new MasterDishModel(); $dish->getByID($id_dish); $tagsIds = explode(",", $dish->dish_tags); if (count($tagsIds) != 0) { foreach ($tagsIds as $tagsId) { if ($tagsId == null || $tagsId == "") { continue; } $dishTag = new MasterDishTagModel(); $dishTag->getByID($tagsId); $b["id_tag"] = $dishTag->id_tag; $b["name"] = $dishTag->name; $rawTags[] = $b; } } } $results['raw_tags'] = $rawTags; Generic::finish($results); }
public function clearTable() { $idTable = Generic::mustCheck($_GET['id_table']); $d = Util::clearTable($idTable); if ($d) { Generic::finish($d); } else { Generic::errorMsg("Failed"); } }
public function userLogin() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } // // $cmd = isset($_POST['cmd']) ? addslashes($_POST['cmd']) : ""; // if (!$cmd) { // Generic::errorMsg("CMD?"); // } $cmd = Generic::mustCheck($_POST['cmd'], "CMD Required"); $objUser = new UserModel(); $json['status_code'] = 1; $arr = array(); if ($cmd == "fb") { $fb_id = Generic::mustCheck($_POST['fb_id'], "Facebook Credential Required"); $arr = $objUser->getWhere("fb_id='{$fb_id}'"); if (count($arr) == 0) { Generic::errorMsg("Facebook Credential Not Registered"); } else { if ($arr[0]->status != "1") { Generic::errorMsg("Account Suspended"); } } } elseif ($cmd == "user") { $email = Generic::mustCheck($_POST['email'], "No Email Found"); $pwd = Generic::mustCheck($_POST['pwd'], "Empty Password? Really?"); $arr = $objUser->getWhere("email='" . $email . "' AND password ='******'"); if (count($arr) == 0) { Generic::errorMsg("Email Not Found"); } if ($arr[0]->password != $pwd) { Generic::errorMsg("Password Not Match"); } if ($arr[0]->status != "1") { Generic::errorMsg("Account Suspended"); } } $json["results"]["user"] = Util::extractModel($arr[0], Helper::$columnReturnLogin); Generic::finish($json); // $exp = explode(",", str_replace(" ", "", $objUser->crud_webservice_allowed)); // $arrPicsToAddPhotoUrl = $objUser->crud_add_photourl; // foreach ($arr as $o) { // foreach ($exp as $attr) { // if (in_array($attr, $arrPicsToAddPhotoUrl)) { // $sem[$attr] = Generic::insertImageUrl($o->$attr); // } else // $sem[$attr] = stripslashes($o->$attr); // } // $json["results"][] = $sem; // } // echo json_encode($json); // die(); }
public function pushByLocation() { $idUsers = Generic::mustCheck($_POST['id_users'], "IDs User not Found"); $title = Generic::mustCheck($_POST['title'], "Title not Found"); $message = Generic::mustCheck($_POST['message'], "Message not Found"); $image = Generic::IsNullOrEmptyString($_POST['image']) ? "" : $_POST['image']; if (Generic::IsNullOrEmptyString($idUsers)) { Generic::errorMsg("Empty IDs User"); } $arrIdUser = explode(',', $idUsers); $results['id_users'] = $idUsers; $results['title'] = $title; $results['message'] = $message; $results['image'] = $image; $trackerModel = Util::getTrackerModelByCode(Keys::$TRACKER_PUSH); if (!$trackerModel) { Generic::errorMsg("Failed To Fetch Tracker Model"); } else { $trackerModel->title = $title; $trackerModel->message = $message; $trackerModel->image = $image; $trackerModel->id_from = 0; $trackerModel->id_reference = 0; $trackerModel->id_to = $idUsers; $trackerModel->readed = "0"; $trackerModel->answered = "1"; $trackerModel->canceled = "0"; $trackerModel->status = "1"; $trackerModel->type = Push::$typeMRPushByLocation; $idTracker = $trackerModel->save(); } foreach ($arrIdUser as $idUser) { //saving log $pLog = new MasterPushLoggerModel(); $pLog->from_id = 0; $pLog->to_id = $idUser; $pLog->title = $title; $pLog->message = $message; //type 3 : MR to User $pLog->type = Push::$pushLogMRToUser; $pLog->push_code = Push::$typeMRPushByLocation; $pLog->datetime_notif = leap_mysqldate(); $pLog->id_reference = $image; $pLog->status = "1"; $pLog->save(); } $_POST["ids"] = implode(',', $arrIdUser); $_POST["msg"] = $title; $_POST["json"] = $idTracker; //json_encode($j); $_POST["type"] = Push::$typeMRPushByCuisine; $push = new PushTo(); $results['user_count'] = count($arrIdUser); $results['push'] = $push->usersMR(); Generic::finish($results); }
public function loadPaymentToken() { $idUser = Generic::mustCheck($_GET['id_user'], "ID User Required"); $user = new UserModel(); $user->getByID($idUser); if (Generic::IsNullOrEmptyString($user->id_user)) { Generic::errorMsg("User Not Found"); } $results['payment_token'] = Generic::IsNullOrEmptyString($user->payment_token) ? "" : $user->payment_token; $results['payment_id'] = Generic::IsNullOrEmptyString($user->payment_id) ? "" : $user->payment_id; $results['payment_type'] = Generic::IsNullOrEmptyString($user->payment_type) ? "" : $user->payment_type; $results['has_token'] = Generic::IsNullOrEmptyString($user->payment_token) ? false : true; $results['default_cash'] = Generic::IsNullOrEmptyString($user->payment_type) || $user->payment_type == "0" ? true : false; Generic::finish($results); }