public function getUserInbox()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $idUser = Generic::mustCheck($_GET['id_user'], "User ID not Found");
     $page = $_GET['page'];
     $limit = $_GET['limit'];
     $page--;
     $p = $page * $limit;
     $q = "to_id = '{$idUser}' AND status = '1' ORDER BY datetime_notif DESC";
     $q .= Generic::IsNullOrEmptyString($page) || Generic::IsNullOrEmptyString($limit) ? "" : " LIMIT {$p},{$limit}";
     $p = new MasterPushLoggerModel();
     $pLogs = $p->getWhere($q);
     $results['inbox'] = array();
     foreach ($pLogs as $pLog) {
         unset($b);
         $b['id_push'] = $pLog->id_push;
         $b['push_code'] = $pLog->push_code;
         $b['title'] = $pLog->title;
         $b['message'] = $pLog->message;
         $b['type'] = $pLog->type;
         $b['datetime_notif'] = $pLog->datetime_notif;
         if ($pLog->type == Push::$pushLogMRToUser) {
             $b['id_reference'] = Generic::insertImageUrl($pLog->id_reference);
         } else {
             $b['id_reference'] = $pLog->id_reference;
         }
         $b['action'] = $this->actionForPushCode($pLog->push_code, $pLog->id_reference);
         $results['inbox'][] = $b;
     }
     $this->finish($results);
 }
 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);
 }