public static function pushToUser($ids, $msg, $json, $type) { $_POST["ids"] = $ids; $_POST["msg"] = $msg; $_POST["json"] = $json; $_POST["type"] = $type; $push = new PushTo(); $push->usersMR(); 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 inviteFriends() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $idUser = Generic::mustCheck($_GET['id_user'], Keys::$ERR_NOT_FOUND_ID_USER); $idFriend = Generic::mustCheck($_GET['id_friend'], Keys::$ERR_NOT_FOUND_ID_FRIEND); $idOrder = Generic::mustCheck($_GET['id_order'], Keys::$ERR_NOT_FOUND_ID_ORDER); if (!Util::isLeader($idOrder, $idUser)) { Generic::errorMsg(Keys::$ERR_INVITATION_NOT_LEADER); } if ($idUser == $idFriend) { Generic::errorMsg(Keys::$ERR_INVITATION_SELF_INVITE); } $user = new UserModel(); $user->getByID($idUser); $friend = new UserModel(); $friend->getByID($idFriend); $order = new MasterOrderModel(); $order->getByID($idOrder); if (Generic::IsNullOrEmptyString($order->id_order)) { Generic::errorMsg(Keys::$ERR_NOT_FOUND_ORDER); } if (Util::isInGuestIds($idOrder, $idFriend)) { Generic::errorMsg(Keys::$ERR_INVITATION_IS_PART_OF_ORDER); } if (Util::isInGuestIds($idOrder, $idUser)) { Generic::errorMsg(Keys::$ERR_INVITATION_IS_PART_OF_ORDER); } if (Util::isPaid($idOrder)) { Generic::errorMsg(Keys::$ERR_ORDER_PAID); } $resto = new MasterRestaurantModel(); $resto->getByID($order->id_restaurant); $table = new MasterTableModel(); $table->getByID($order->id_table); $title = "Invitation To Join Table From " . $user->full_name; $message = "You are invited by " . $user->full_name . " to join table No." . $table->table_number . " at Restaurant " . $resto->name; //buat tracker untuk inbox $tracker = new TrackerRequestModel(); $tracker->id_from = $idUser; $tracker->id_to = $idFriend; $tracker->id_reference = $idOrder; $tracker->reference_desc = Keys::$TRACKER_REF_DESC_ID_ORDER; $tracker->type = Push::$typeInviteJoinTable; $tracker->title = $title; $tracker->message = $message; $tracker->readed = 0; $tracker->answered = 0; $tracker->canceled = 0; $tracker->status = 1; $idTracker = $tracker->save(); if (!$idTracker) { Generic::errorMsg(Keys::$ERR_FAILED_CREATE_TRACKER); } $tracker->id_tracker = $idTracker; //push to friend //preparation $_POST["ids"] = $idFriend; $_POST["msg"] = $message; $_POST["json"] = $idTracker; $_POST["type"] = Push::$typeInviteJoinTable; // pr($_POST); $push = new PushTo(); $results['tracker'] = Util::extractModel($tracker); $results['push_status'] = $push->usersMR(); Generic::finish($results); }
private function notifyAddOrderMR($ids, $idOrder) { $j["id_order"] = $idOrder; // echo "pushToUser"; $_POST["ids"] = $ids; $_POST["msg"] = "Other user update order"; $_POST["json"] = json_encode($j); $_POST["type"] = 40; // pr($_POST); $push = new PushTo(); $push->usersMR(); }