Subversion Repositories SmartDukaan

Rev

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

Rev 17183 Rev 17683
Line 72... Line 72...
72
		if(!isset($page)){
72
		if(!isset($page)){
73
			$page = 1;
73
			$page = 1;
74
		}
74
		}
75
		$offset = ($page - 1) * $this->limit;
75
		$offset = ($page - 1) * $this->limit;
76
		$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;
76
		$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;
-
 
77
		//debug($url);
77
		$deals = $this->make_request($url,null);		
78
		$deals = $this->make_request($url,null);		
78
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));		
79
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));		
79
		if(!empty($myactions)) {
80
		if(!empty($myactions)) {
80
			foreach ($myactions['actions'] as $key => $value) {
81
			foreach ($myactions['actions'] as $key => $value) {
81
				if($value['UserAction']['action'] == 'like'){
82
				if($value['UserAction']['action'] == 'like'){
Line 108... Line 109...
108
 * @param string $id
109
 * @param string $id
109
 * @return void
110
 * @return void
110
 */
111
 */
111
	public function view($id = null) {
112
	public function view($id = null) {
112
		$userId = $this->request->query('user_id');
113
		$userId = $this->request->query('user_id');
-
 
114
		
113
		if(isset($userId) && !empty($userId)) {
115
		if(isset($userId) && !empty($userId)) {
114
			$this->loadModel('User');
116
			$this->loadModel('User');
115
			$dbuser = $this->User->findById($userId);
117
			$dbuser = $this->User->findById($userId);
116
			$this->Auth->login($dbuser['User']);
118
			$this->Auth->login($dbuser['User']);
117
		}				
119
		}				
Line 126... Line 128...
126
		// $brands = $this->request->query('brands');
128
		// $brands = $this->request->query('brands');
127
		if($id != 2) {
129
		if($id != 2) {
128
			//Fetch deals
130
			//Fetch deals
129
			$likedDeals = $disLikedDeals = array();
131
			$likedDeals = $disLikedDeals = array();
130
			$brandschosen = $_COOKIE['brandschosen'];
132
			$brandschosen = $_COOKIE['brandschosen'];
-
 
133
			$subcategorieschosen = $_COOKIE['subcategorieschosen'];			
-
 
134
		
-
 
135
 
131
			if((isset($_COOKIE['old_id'])) && ($_COOKIE['old_id'] != $id)) {
136
			if((isset($_COOKIE['old_id'])) && ($_COOKIE['old_id'] != $id)) {
-
 
137
 
-
 
138
				
-
 
139
				unset($brandschosen);
-
 
140
				// setcookie('brandschosen', 1, time()-1, '/');
-
 
141
				// unset($_COOKIE['brandschosen']);
-
 
142
    			setcookie('brandschosen', null, -1, '/');
-
 
143
				unset($subcategorieschosen);
-
 
144
				setcookie('subcategorieschosen', 1, time()-1, '/');
-
 
145
				
-
 
146
			}		
-
 
147
 
-
 
148
			if((isset($_COOKIE['brandschosen'])) && ($_COOKIE['old_id'] != $id)) {
-
 
149
				
132
				unset($brandschosen);
150
				unset($brandschosen);
133
				setcookie('brandschosen', 1, time()-1, '/');
151
				// setcookie('brandschosen', 1, time()-10, '/');
134
			}			
-
 
135
			if(!isset($_COOKIE['old_id'])) {
152
				// unset($_COOKIE['brandschosen']);
136
				setcookie('old_id',$id);	
153
    			setcookie('brandschosen', null, -1, '/');
137
			} else {
154
				unset($subcategorieschosen);
138
				setcookie('old_id',$id);
155
				setcookie('subcategorieschosen', 1, time()-1, '/');
139
			}			
156
				
140
			if(!empty($brandschosen)){
-
 
141
				$filter = 'brand';
-
 
142
			}
157
			}
-
 
158
 
-
 
159
			setcookie('old_id', $id, -1, '/');
-
 
160
			
-
 
161
			
-
 
162
				if(!empty($brandschosen) && !empty($subcategorieschosen)){
-
 
163
					$filter = 'brand|subcategory';
-
 
164
				}			
-
 
165
				else if(!empty($brandschosen) && empty($subcategorieschosen)){
-
 
166
					$filter = 'brand';
-
 
167
				}
-
 
168
				if(!empty($subcategorieschosen) && empty($brandschosen)){
-
 
169
					$filter = 'subcategory';
-
 
170
				}
-
 
171
			
-
 
172
				/*if(!empty($brandschosen)){
-
 
173
					$filter = 'brand';
-
 
174
				}*/
-
 
175
			
143
			$brands = str_replace(',', '^', $brandschosen);
176
			$brands = str_replace(',', '^', $brandschosen);
-
 
177
			$subcategories = str_replace(',', '^', $subcategorieschosen);
144
			$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),$id,$sort,$direction,$filter,$brands);
178
			$url = $this->getDealsApiUrl($page,$this->Auth->User('id'),$id,$sort,$direction,$filter,$brands,$subcategories);
145
			// $url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id;
179
			// $url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id;
146
			$response = $this->make_request($url,null);
180
			$response = $this->make_request($url,null);
147
			$deals = array();
181
			$deals = array();
-
 
182
			
-
 
183
			$response_count =1;
-
 
184
			if($response == '')
-
 
185
			{
-
 
186
				$response_count = 0;
-
 
187
			}
-
 
188
			// debug($response_count);
148
			if(!empty($response)){
189
			if(!empty($response)){
149
				foreach ($response as $key => $value) {
190
				foreach ($response as $key => $value) {
150
					if(!empty($value)){
191
					if(!empty($value)){
151
						$deals[] = $value;
192
						$deals[] = $value;
152
					}
193
					}
153
				}
194
				}
154
			}
195
			}
-
 
196
			#print_r($deals);
155
			$this->loadModel('Api');
197
			$this->loadModel('Api');
156
			$myactions = $this->Api->getMyActions($this->Auth->User('id'));
198
			$myactions = $this->Api->getMyActions($this->Auth->User('id'));
157
			if(!empty($myactions)) {
199
			if(!empty($myactions)) {
158
				foreach ($myactions['actions'] as $key => $value) {
200
				foreach ($myactions['actions'] as $key => $value) {
159
					if($value['UserAction']['action'] == 'like'){
201
					if($value['UserAction']['action'] == 'like'){
Line 165... Line 207...
165
			}
207
			}
166
			$this->loadModel('NotificationRule');
208
			$this->loadModel('NotificationRule');
167
			$notification = $this->NotificationRule->getNotification($this->Auth->User('id'));	
209
			$notification = $this->NotificationRule->getNotification($this->Auth->User('id'));	
168
		    $filterstr = '';
210
		    $filterstr = '';
169
			if(isset($filter) && !empty($filter)){
211
			if(isset($filter) && !empty($filter)){
170
			    $filterstr = '&filter='.$filter.'&brands='.$brands;
212
			    $filterstr = '&filter='.$filter.'&brands='.$brands.'&subcategories='.$subcategories;
171
		  	} 	  	
213
		  	} 	  	
172
			$this->set(compact('deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen'));
214
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','brandschosen','subcategories','subcategorieschosen'));
173
		}else{
215
		}else{
174
			//Check for apk support of sharing
216
			//Check for apk support of sharing
175
			$sharable = 0;
217
			$sharable = 0;
176
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
218
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
177
				$sharable = 1;
219
				$sharable = 1;