Subversion Repositories SmartDukaan

Rev

Rev 19206 | Rev 19214 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19206 Rev 19213
Line 1234... Line 1234...
1234
		if(!isset($page)){
1234
		if(!isset($page)){
1235
			$page = 1;
1235
			$page = 1;
1236
		}
1236
		}
1237
		$limit = 20;
1237
		$limit = 20;
1238
		$offset = ($page - 1)*$limit;
1238
		$offset = ($page - 1)*$limit;
1239
		
-
 
1240
		$this->layout = 'innerpages';
1239
		$this->layout = 'innerpages';
1241
// 		$url = "http://45.79.106.95:3001/getAllNotifications?user_id=2&android_id=dfa8d17cd87d6748&offset=0&limit=20";
-
 
1242
		$url = Configure::read('nodeurl')."/getAllNotifications?user_id=".$user_id."&android_id=".$android_id."&offset=".$offset."&limit=".$limit;
1240
		$url = Configure::read('nodeurl')."/getAllNotifications?user_id=".$user_id."&android_id=".$android_id."&offset=".$offset."&limit=".$limit;
1243
		$noti= $this->make_request($url,null);
1241
		$noti= $this->make_request($url,null);
1244
		if(isset($noti) && !empty($noti))
1242
		if(isset($noti) && !empty($noti))
1245
		{
1243
		{
1246
			foreach ($noti as $nkey => $nval){
1244
			foreach ($noti as $nkey => $nval){
Line 1249... Line 1247...
1249
				}
1247
				}
1250
				if($nval["status"] == "opened" || $nval["status"] == "referrer" || $nval["status"] == "login"){
1248
				if($nval["status"] == "opened" || $nval["status"] == "referrer" || $nval["status"] == "login"){
1251
					$noti[$nkey]['seen'] = true;
1249
					$noti[$nkey]['seen'] = true;
1252
				}
1250
				}
1253
			}
1251
			}
1254
		}
-
 
1255
		debug($noti);
-
 
1256
// 		$noti = json_decode('[{"id" : 5 , "text" : "Intex Aqua Young @4301 " , "message" : "Intex Aqua Young @4301 ", "longText" : "Intex Aqua Young @4301 ","url" : "category/6","type" : "native", "seen":false , "expired": false},{"id" : 5 , "text" : "Apple iPhone 6 16GB @34556" , "message" : "Apple iPhone 6 16GB @34556","longText" : "Apple iPhone 6 16GB @34556","url" : "abc.com","type" : "native","seen": true,"expired": false},{"id" : 5 , "text" : "Notification3" ,"longText" : "Notification Long text 3", "longText" : "Notification Long text 3","url" : "abc.com","type" : "native","seen": false,"expired": true}]',true);
1252
		}		
1257
// 		debug($noti);
-
 
1258
		$nexturl = "/users/getmorenotification?page=".($page+1);
1253
		$nexturl = "/users/getmorenotification?page=".($page+1);
1259
		$this->set(compact('noti','nexturl'));
1254
		$this->set(compact('noti','nexturl'));
1260
	}
1255
	}
1261
	
1256
	
1262
	public function getmorenotification(){
1257
	public function getmorenotification(){
Line 1265... Line 1260...
1265
		if(!isset($page)){
1260
		if(!isset($page)){
1266
			$page = 1;
1261
			$page = 1;
1267
		}
1262
		}
1268
		$limit = 20;
1263
		$limit = 20;
1269
		$offset = ($page - 1)*$limit;
1264
		$offset = ($page - 1)*$limit;
1270
// 		$url = "http://45.79.106.95:3001/getAllNotifications?user_id=2&android_id=dfa8d17cd87d6748&offset=0&limit=20";
-
 
1271
		$url = Configure::read('nodeurl')."/getAllNotifications?user_id=".$user_id."&android_id=".$android_id."&offset=".$offset."&limit=".$limit;
1265
		$url = Configure::read('nodeurl')."/getAllNotifications?user_id=".$user_id."&android_id=".$android_id."&offset=".$offset."&limit=".$limit;
1272
		$noti= $this->make_request($url,null);
1266
		$noti= $this->make_request($url,null);
-
 
1267
		debug($noti);
1273
		if(isset($noti) && !empty($noti))
1268
		if(isset($noti) && !empty($noti))
1274
		{
1269
		{
1275
			foreach ($noti as $nkey => $nval){
1270
			foreach ($noti as $nkey => $nval){
1276
				if($nval["status"] == "sent" || $nval["status"] == "recieved" || $nval["status"] == "failed"){
1271
				if($nval["status"] == "sent" || $nval["status"] == "recieved" || $nval["status"] == "failed"){
1277
					$noti[$nkey]['seen'] = false;
1272
					$noti[$nkey]['seen'] = false;
Line 1279... Line 1274...
1279
				if($nval["status"] == "opened" || $nval["status"] == "referrer" || $nval["status"] == "login"){
1274
				if($nval["status"] == "opened" || $nval["status"] == "referrer" || $nval["status"] == "login"){
1280
					$noti[$nkey]['seen'] = true;
1275
					$noti[$nkey]['seen'] = true;
1281
				}
1276
				}
1282
			}
1277
			}
1283
		}
1278
		}
1284
// 		$noti = json_decode('[{"id" : 5 , "text" : "Intex Aqua Young @4301 " , "message" : "Intex Aqua Young @4301 ","url" : "category/6","type" : "native", "seen":false , "expired": false},{"id" : 5 , "text" : "Apple iPhone 6 16GB @34556" , "message" : "Apple iPhone 6 16GB @34556","longText" : "Apple iPhone 6 16GB @34556","url" : "abc.com","type" : "native","seen": true,"expired": false},{"id" : 5 , "text" : "Notification3" , "message" : "Notification message","longText" : "Notification Long text 3","url" : "abc.com","type" : "native","seen": false,"expired": true}]',true);
-
 
1285
		$nexturl = "/users/getmorenotification?page=".($page+1);
1279
		$nexturl = "/users/getmorenotification?page=".($page+1);
1286
		$this->set(compact('noti','nexturl'));
1280
		$this->set(compact('noti','nexturl'));
1287
		$this->render('/Elements/getnotification');
1281
		$this->render('/Elements/getnotification');
1288
	}
1282
	}
1289
	
1283
	
1290
	public function sendseen($cid = null){
1284
	public function sendseen($cid = null){
-
 
1285
		
-
 
1286
		$data = array();
-
 
1287
		$data['cid']=$cid;
-
 
1288
		$data['result']='opened';
-
 
1289
		$data['user_id']=$this->Auth->user('id');
-
 
1290
		$url = Configure::read('nodeurl')."/addPushNotificationByApk";//remove hardcoded value
-
 
1291
		$response = $this->post_request($url,$data);
-
 
1292
		if(!empty($response)){
-
 
1293
			$result = array('success' => true,'message'=>'The pushnotification has been saved.');
-
 
1294
		} else {
-
 
1295
			$result = array('success' => false,'message'=>'The pushnotification could not be saved. Please, try again.');
-
 
1296
		}		
1291
		$this->layout = 'ajax';
1297
		$this->set(array(
1292
		return "Hello";
1298
		    'result' => $result,
-
 
1299
		    '_serialize' => array('result')
-
 
1300
		));
-
 
1301
		$this->render('/Elements/json');	
1293
	}
1302
	}
1294
}
1303
}