Subversion Repositories SmartDukaan

Rev

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

Rev 15767 Rev 17170
Line 232... Line 232...
232
					debug($this->NotificationCampaign->validationErrors);
232
					debug($this->NotificationCampaign->validationErrors);
233
					$message['cid'] = $message['name'];
233
					$message['cid'] = $message['name'];
234
				}				
234
				}				
235
				$this->loadModel('Pushnotification');
235
				$this->loadModel('Pushnotification');
236
				$sentUsers = array();
236
				$sentUsers = array();
-
 
237
				$payload = array();
237
				foreach ($users as $key => $value) {	
238
				foreach ($users as $key => $value) {	
238
					if(!in_array($value['User']['id'], $sentUsers)) {
239
					if(!in_array($value['User']['id'], $sentUsers)) {
239
						$sentUsers[] = $value['User']['id'];								
240
						$sentUsers[] = $value['User']['id'];								
240
						$data = array('notification_campaign_id'=>$message['cid'],'user_id'=>$value['User']['id'],'type'=>'pending');
241
						$data = array('notification_campaign_id'=>$message['cid'],'user_id'=>$value['User']['id'],'type'=>'pending','status'=>1);
241
						$this->Pushnotification->create();
242
						// $this->Pushnotification->create();
242
						$this->Pushnotification->save($data);
243
						// $this->Pushnotification->save($data);
-
 
244
						$payload[] = $data;
243
					}
245
					}
244
				}
246
				}
-
 
247
				$url = "http://192.168.203.21:3001/addPushNotification";//remove hardcoded value
-
 
248
				$this->make_request($url,json_encode($payload));
245
				$this->Session->setFlash(__('Push notification scheduled for '.sizeof($users).' users'));
249
				$this->Session->setFlash(__('Push notification scheduled for '.sizeof($users).' users'));
246
				return $this->redirect(array('controller' => 'administration', 'action' => 'dashboard', 'admin' => false));
250
				return $this->redirect(array('controller' => 'administration', 'action' => 'dashboard', 'admin' => false));
247
			}
251
			}
248
		}
252
		}
249
	}
253
	}