Subversion Repositories SmartDukaan

Rev

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

Rev 15013 Rev 15043
Line 50... Line 50...
50
 * @return void
50
 * @return void
51
 */
51
 */
52
	public function add() {
52
	public function add() {
53
		$this->layout = 'ajax';
53
		$this->layout = 'ajax';
54
		$this->response->type('json');
54
		$this->response->type('json');
55
		$this->log(print_r($this->request->data,1),'gcm');
-
 
56
		if ($this->request->is('post')) {
55
		if ($this->request->is('post')) {
-
 
56
			$dataForModel = $this->request->data;
-
 
57
			$this->log('before find '.print_r($dataForModel,1),'gcm');
57
			$data = $this->GcmUser->find('first',array('conditions'=>array('user_id'=>$this->request->data['user_id'],'gcm_regid'=>$this->request->data['gcm_regid'])));
58
			$data = $this->GcmUser->find('first',array('conditions'=>array('user_id'=>$this->request->data['user_id'],'imeinumber'=>$this->request->data['imeinumber'])));
-
 
59
			$this->log("found row ".print_r($data,1),'gcm');
58
			if($empty($data)){
60
			if(!empty($data)){
59
				$this->request->data['id'] = $data['GcmUser']['id'];
61
				$dataForModel['id'] = $data['GcmUser']['id'];
60
			}else{
62
			}else{
61
				$this->GcmUser->create();
63
				$this->GcmUser->create();
62
			}			
64
			}			
-
 
65
			$this->log('lets save '.print_r($dataForModel,1),'gcm');
63
			if ($this->GcmUser->save($this->request->data)) {
66
			if ($this->GcmUser->save($dataForModel)) {
64
				$result = array('success'=>true);
67
				$result = array('success'=>true);
65
//				$this->Session->setFlash(__('The gcm user has been saved.'));
68
//				$this->Session->setFlash(__('The gcm user has been saved.'));
66
//				return $this->redirect(array('action' => 'index'));
69
//				return $this->redirect(array('action' => 'index'));
67
			} else {
70
			} else {
68
				$result = array('success'=>false);
71
				$result = array('success'=>false);