Subversion Repositories SmartDukaan

Rev

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

Rev 13794 Rev 13808
Line 107... Line 107...
107
 * @throws NotFoundException
107
 * @throws NotFoundException
108
 * @param string $id
108
 * @param string $id
109
 * @return void
109
 * @return void
110
 */
110
 */
111
	public function view($id = null) {
111
	public function view($id = null) {
112
		$this->checkMobileNumber();
112
		// $this->checkMobileNumber();
113
		$likedDeals = $disLikedDeals = array();
113
		$likedDeals = $disLikedDeals = array();
114
		// if (!$this->Category->exists($id)) {
114
		// if (!$this->Category->exists($id)) {
115
			// throw new NotFoundException(__('Invalid category'));
115
			// throw new NotFoundException(__('Invalid category'));
116
		// }
116
		// }
117
		$page = $this->request->query('page');
117
		$page = $this->request->query('page');
118
		if(!isset($page)){
118
		if(!isset($page)){
119
			$page = 1;
119
			$page = 1;
120
		}	
120
		}	
121
		$offset = ($page - 1) * $this->limit;
121
		$sort = $this->request->query('sort');
-
 
122
		$direction = $this->request->query('direction');
-
 
123
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),$id,$sort,$direction);
122
		$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id.'&limit='.$this->limit.'&offset='.$offset;
124
		// $url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id;
123
		$deals = $this->make_request($url,null);
125
		$deals = $this->make_request($url,null);
124
		$this->loadModel('Api');
126
		$this->loadModel('Api');
125
		// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
127
		// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
126
		// $deals = $apideals['products'];
128
		// $deals = $apideals['products'];
127
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
129
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
Line 132... Line 134...
132
				}else{
134
				}else{
133
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
135
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
134
				}
136
				}
135
			}
137
			}
136
		}
138
		}
137
		$this->set(compact('deals','id','likedDeals','disLikedDeals','page'));
139
		$this->set(compact('deals','id','likedDeals','disLikedDeals','page','sort','direction'));
138
	}
140
	}
139
 
141
 
140
	public function getdeals($id = null) {
142
	public function getdeals($id = null) {
-
 
143
		$this->log('getdeal id '.$id,'api');
141
		$likedDeals = $disLikedDeals = array();
144
		$likedDeals = $disLikedDeals = array();
142
		$this->layout = 'ajax';
145
		$this->layout = 'ajax';
143
		$page = $this->request->query('page');
146
		$page = $this->request->query('page');
144
		if(!isset($page)){
147
		if(!isset($page)){
145
			$page = 1;
148
			$page = 1;
146
		}
149
		}
147
		$offset = ($page - 1) * $this->limit;
150
		$sort = $this->request->query('sort');
-
 
151
		$direction = $this->request->query('direction');
-
 
152
		$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),$id,$sort,$direction);
148
		$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id.'&limit='.$this->limit.'&offset='.$offset;
153
		// $url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id;
149
		$deals = $this->make_request($url,null);
154
		$deals = $this->make_request($url,null);
150
		// if (!$this->Category->exists($id)) {
155
		// if (!$this->Category->exists($id)) {
151
			// throw new NotFoundException(__('Invalid category'));
156
			// throw new NotFoundException(__('Invalid category'));
152
		// }
157
		// }
153
		$this->loadModel('Api');
158
		$this->loadModel('Api');
Line 161... Line 166...
161
				}else{
166
				}else{
162
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
167
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
163
				}
168
				}
164
			}
169
			}
165
		}
170
		}
166
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals'));
171
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals','sort','direction'));
167
		$this->render('/Elements/deals');
172
		$this->render('/Elements/deals');
168
	}
173
	}
169
/**
174
/**
170
 * add method
175
 * add method
171
 *
176
 *