Subversion Repositories SmartDukaan

Rev

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

Rev 19543 Rev 19609
Line 119... Line 119...
119
 * @throws NotFoundException
119
 * @throws NotFoundException
120
 * @param string $id
120
 * @param string $id
121
 * @return void
121
 * @return void
122
 */
122
 */
123
	public function view($id = null) {
123
	public function view($id = null) {
-
 
124
		$arrSubCategory = Configure::read('arrSubCategory');
124
		$userId = $this->request->query('user_id');
125
		$userId = $this->request->query('user_id');
125
		if(isset($userId) && !empty($userId)) {
126
		if(isset($userId) && !empty($userId)) {
126
			$this->loadModel('User');
127
			$this->loadModel('User');
127
			$dbuser = $this->User->findById($userId);
128
			$dbuser = $this->User->findById($userId);
128
			$this->Auth->login($dbuser['User']);
129
			$this->Auth->login($dbuser['User']);
Line 136... Line 137...
136
		$brands = $this->request->query('brands');
137
		$brands = $this->request->query('brands');
137
		$subcategories = $this->request->query('subcategories');
138
		$subcategories = $this->request->query('subcategories');
138
		
139
		
139
		$searchableSubCategories = array('20'=>'Screen Guard', '27'=>'Back Cover', '29'=>'Batteries', '33'=>'Flip Cover', '28'=>'Tempered Glass');
140
		$searchableSubCategories = array('20'=>'Screen Guard', '27'=>'Back Cover', '29'=>'Batteries', '33'=>'Flip Cover', '28'=>'Tempered Glass');
140
		
141
		
-
 
142
		$subcatlist = Configure::read('arrSubCategory');
-
 
143
		
-
 
144
		$whatfirst = $this->request->query('whatfirst');
-
 
145
		
-
 
146
		$whatsecond = "";
-
 
147
		$whatsecondid = "";
-
 
148
		$whatfirstid = "";
-
 
149
		$secondloop = "";
-
 
150
		if(isset($whatfirst)){
-
 
151
			$brandprourl = "";
-
 
152
			if($whatfirst == "subCategory"){
-
 
153
				$secondloop = explode("^",$brands);
-
 
154
				$whatsecond = "brand";
-
 
155
				$whatsecondid = "brand_id";
-
 
156
				$whatfirstid = "subCategoryId";
-
 
157
				$brandprourl = $this->apihost."getBrandSubCategoryInfo/?category_id=6&type=subCategoryInfo&id_list=".$subcategories;
-
 
158
			}
-
 
159
			else if($whatfirst == "brand"){
-
 
160
				
-
 
161
				$secondloop = explode("^",$subcategories);
-
 
162
				$whatsecond = "subCategory";
-
 
163
				$whatsecondid = "subCategoryId";
-
 
164
				$whatfirstid = "brand_id";
-
 
165
				$brandprourl = $this->apihost."getBrandSubCategoryInfo/?category_id=6&type=brandInfo&id_list=".$brands;
-
 
166
			}
-
 
167
			$allbrandsubcat = $this->make_request($brandprourl, null);
-
 
168
			$this->set(compact('secondloop','whatfirstid','whatsecondid','subcatlist','whatfirst','whatsecond','allbrandsubcat'));
-
 
169
		}
-
 
170
		
-
 
171
		
141
		$page = $this->request->query('page');
172
		$page = $this->request->query('page');
142
		$searchfor = $this->request->query('searchFor');
173
		$searchfor = $this->request->query('searchFor');
143
		// echo "page=>",$page;
174
		// echo "page=>",$page;
144
		$error = $this->request->query('error');
175
		$error = $this->request->query('error');
145
		if(!isset($page)){
176
		if(!isset($page)){
Line 219... Line 250...
219
			}
250
			}
220
 
251
 
221
			$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
252
			$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
222
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
253
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
223
			
254
			
224
			//check for offer start
-
 
225
			$user_id = $this->Auth->user('id');
-
 
226
			$cachekey = 'target-'.$user_id;
-
 
227
			$getoffer = Cache::read($cachekey,'target');
-
 
228
			$current_time = time();
-
 
229
			$offerresponse = "";
-
 
230
			if($getoffer === false){
-
 
231
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
232
				$offerresponse = $this->make_request($offerurl,null);
-
 
233
				Cache::write($cachekey , $offerresponse ,'target');
-
 
234
				if(!empty($offerresponse)){					
-
 
235
					
-
 
236
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
237
					
-
 
238
								}
-
 
239
								else{
-
 
240
									$offerresponse = "";
-
 
241
								}
-
 
242
				}
-
 
243
				else{
-
 
244
					$offerresponse = "";
-
 
245
				}
-
 
246
			}else{
-
 
247
				if(!empty($getoffer)){
-
 
248
					$offerresponse = $getoffer;
255
			$offerresponse = $this->getuseroffer();
249
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
256
			$color = array('0'=>'#458ccc','1'=>'#44cbbc','2'=>'#a77189', '3'=>'#f9b931' ,'4' =>'#44cbbc', '5' => '#f48f3f' , '6'=>'#a77189');
250
						
-
 
251
					}
-
 
252
					else{
-
 
253
						$offerresponse = "";
-
 
254
					}
-
 
255
				}
-
 
256
								
-
 
257
			}
-
 
258
			
-
 
259
			//check for offer end 
-
 
260
			
-
 
261
			
-
 
262
			$this->set(compact('user_id','offerresponse','response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','subcategories','errorstr','nexturl','searchfor', 'searchableSubCategories', 'sortlabel'));
257
			$this->set(compact('color','arrSubCategory','offerresponse','response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','subcategories','errorstr','nexturl','searchfor', 'searchableSubCategories', 'sortlabel'));
263
		}else{
258
		}else{
264
			//Check for apk support of sharing
259
			//Check for apk support of sharing
265
			$sharable = 0;
260
			$sharable = 0;
266
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
261
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
267
				$sharable = 1;
262
				$sharable = 1;
Line 354... Line 349...
354
		}
349
		}
355
		
350
		
356
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
351
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
357
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
352
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
358
		
353
		
359
		//check for offer start
-
 
360
			$user_id = $this->Auth->user('id');
-
 
361
			$cachekey = 'target-'.$user_id;
-
 
362
			$getoffer = Cache::read($cachekey,'target');
-
 
363
			$current_time = time();
-
 
364
			$offerresponse = "";
-
 
365
			if($getoffer === false){
-
 
366
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
367
				$offerresponse = $this->make_request($offerurl,null);
-
 
368
				Cache::write($cachekey , $offerresponse ,'target');
-
 
369
				if(!empty($offerresponse)){					
-
 
370
					
-
 
371
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
372
					
-
 
373
								}
-
 
374
								else{
-
 
375
									$offerresponse = "";
-
 
376
								}
-
 
377
				}
-
 
378
				else{
-
 
379
					$offerresponse = "";
-
 
380
				}
-
 
381
			}else{
-
 
382
				if(!empty($getoffer)){
-
 
383
					$offerresponse = $getoffer;
354
		$offerresponse = $this->getuseroffer();
384
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
385
						
-
 
386
					}
-
 
387
					else{
-
 
388
						$offerresponse = "";
-
 
389
					}
-
 
390
				}
-
 
391
								
-
 
392
			}
-
 
393
			
-
 
394
			//check for offer end 
-
 
395
		
355
		
396
		$this->set(compact('$user_id','offerresponse','nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
356
		$this->set(compact('offerresponse','nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
397
		if(!empty($deals) && !empty($deals[0])){
357
		if(!empty($deals) && !empty($deals[0])){
398
			$this->render('/Elements/deals');
358
			$this->render('/Elements/deals');
399
		}else{
359
		}else{
400
			$this->render('/Elements/nodeals');
360
			$this->render('/Elements/nodeals');
401
		}
361
		}
Line 442... Line 402...
442
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
402
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
443
				}
403
				}
444
			}
404
			}
445
		}
405
		}
446
		
406
		
447
		//check for offer start
-
 
448
			$user_id = $this->Auth->user('id');
-
 
449
			$cachekey = 'target-'.$user_id;
-
 
450
			$getoffer = Cache::read($cachekey,'target');
-
 
451
			$current_time = time();
-
 
452
			$offerresponse = "";
-
 
453
			if($getoffer === false){
-
 
454
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
455
				$offerresponse = $this->make_request($offerurl,null);
-
 
456
				Cache::write($cachekey , $offerresponse ,'target');
-
 
457
				if(!empty($offerresponse)){					
-
 
458
					
-
 
459
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
460
					
-
 
461
								}
-
 
462
								else{
-
 
463
									$offerresponse = "";
-
 
464
								}
-
 
465
				}
-
 
466
				else{
-
 
467
					$offerresponse = "";
-
 
468
				}
-
 
469
			}else{
-
 
470
				if(!empty($getoffer)){
-
 
471
					$offerresponse = $getoffer;
407
		$offerresponse = $this->getuseroffer();
472
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
473
						
-
 
474
					}
-
 
475
					else{
-
 
476
						$offerresponse = "";
-
 
477
					}
-
 
478
				}
-
 
479
								
-
 
480
			}
-
 
481
			
-
 
482
			//check for offer end 
-
 
483
		
408
		
484
		$this->set(compact('$user_id','offerresponse','deal','likedDeals','disLikedDeals'));
409
		$this->set(compact('offerresponse','deal','likedDeals','disLikedDeals'));
485
		
410
		
486
		$this->render('/Elements/saholicdeal');
411
		$this->render('/Elements/saholicdeal');
487
		
412
		
488
		
413
		
489
	}
414
	}
Line 529... Line 454...
529
			}
454
			}
530
		}
455
		}
531
		
456
		
532
		$nexturl = "/categories/getdealsforsearchterm/".urlencode($searchterm)."/?page=".($page+1).'&subcategories='.$subcategories;
457
		$nexturl = "/categories/getdealsforsearchterm/".urlencode($searchterm)."/?page=".($page+1).'&subcategories='.$subcategories;
533
		
458
		
534
		//check for offer start
-
 
535
			$user_id = $this->Auth->user('id');
-
 
536
			$cachekey = 'target-'.$user_id;
-
 
537
			$getoffer = Cache::read($cachekey,'target');
-
 
538
			$current_time = time();
-
 
539
			$offerresponse = "";
-
 
540
			if($getoffer === false){
-
 
541
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
542
				$offerresponse = $this->make_request($offerurl,null);
-
 
543
				Cache::write($cachekey , $offerresponse ,'target');
-
 
544
				if(!empty($offerresponse)){					
-
 
545
					
-
 
546
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
547
					
-
 
548
								}
-
 
549
								else{
-
 
550
									$offerresponse = "";
-
 
551
								}
-
 
552
				}
-
 
553
				else{
-
 
554
					$offerresponse = "";
-
 
555
				}
-
 
556
			}else{
-
 
557
				if(!empty($getoffer)){
-
 
558
					$offerresponse = $getoffer;
459
		$offerresponse = $this->getuseroffer(); 
559
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
560
						
-
 
561
					}
-
 
562
					else{
-
 
563
						$offerresponse = "";
-
 
564
					}
-
 
565
				}
-
 
566
								
-
 
567
			}
-
 
568
			
-
 
569
			//check for offer end 
-
 
570
		
460
		
571
		$this->set(compact('$user_id','offerresponse','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','nexturl'));
461
		$this->set(compact('offerresponse','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','nexturl'));
572
		if(!empty($deals) && !empty($deals[0])){
462
		if(!empty($deals) && !empty($deals[0])){
573
			$this->render('/Elements/deals');
463
			$this->render('/Elements/deals');
574
		}else{
464
		}else{
575
			$this->render('/Elements/nodeals');
465
			$this->render('/Elements/nodeals');
576
		}
466
		}