Subversion Repositories SmartDukaan

Rev

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

Rev 19306 Rev 19327
Line 222... Line 222...
222
			
222
			
223
			//check for offer start
223
			//check for offer start
224
			$user_id = $this->Auth->user('id');
224
			$user_id = $this->Auth->user('id');
225
			$cachekey = 'target-'.$user_id;
225
			$cachekey = 'target-'.$user_id;
226
			$getoffer = Cache::read($cachekey,'target');
226
			$getoffer = Cache::read($cachekey,'target');
227
			
227
			$current_time = time();
228
			$offerresponse = "";
228
			$offerresponse = "";
229
			if($getoffer === false){
229
			if($getoffer === false){
230
				$offerurl = $this->apihost."getOfferForUser/?user_id=47";
230
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
231
				$offerresponse = $this->make_request($offerurl,null);
231
				$offerresponse = $this->make_request($offerurl,null);
232
				Cache::write($cachekey , $offerresponse ,'target');
232
				Cache::write($cachekey , $offerresponse ,'target');
233
				if(!empty($offerresponse)){					
233
				if(!empty($offerresponse)){					
234
					$current_time = time();
234
					
235
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
235
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
236
					
236
					
237
								}
237
								}
238
								else{
238
								else{
239
									$offerresponse = "";
239
									$offerresponse = "";
Line 241... Line 241...
241
				}
241
				}
242
				else{
242
				else{
243
					$offerresponse = "";
243
					$offerresponse = "";
244
				}
244
				}
245
			}else{
245
			}else{
-
 
246
				if(!empty($getoffer)){
246
				$offerresponse = $getoffer;
247
					$offerresponse = $getoffer;
-
 
248
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
249
						
-
 
250
					}
-
 
251
					else{
-
 
252
						$offerresponse = "";
-
 
253
					}
-
 
254
				}
-
 
255
								
247
			}
256
			}
248
			
257
			
249
			//check for offer end 
258
			//check for offer end 
250
			
259
			
251
			
260
			
Line 345... Line 354...
345
		
354
		
346
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
355
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
347
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
356
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
348
		
357
		
349
		//check for offer start
358
		//check for offer start
350
		$offerurl = $this->apihost."getOfferForUser/?user_id=47";
359
			$user_id = $this->Auth->user('id');
351
		$offerresponse = $this->make_request($offerurl,null);
360
			$cachekey = 'target-'.$user_id;
352
		Cache::write('target', $offerresponse);
361
			$getoffer = Cache::read($cachekey,'target');
353
		$current_time = time();
362
			$current_time = time();
354
		if(!empty($offerresponse)){
-
 
355
			if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
356
				Cache::write('target', $offerresponse);
-
 
357
			}
-
 
358
			else{
-
 
359
				$offerresponse = "";
-
 
360
			}
-
 
361
		}
-
 
362
		else{
-
 
363
			$offerresponse = "";
363
			$offerresponse = "";
-
 
364
			if($getoffer === false){
-
 
365
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
366
				$offerresponse = $this->make_request($offerurl,null);
-
 
367
				Cache::write($cachekey , $offerresponse ,'target');
-
 
368
				if(!empty($offerresponse)){					
-
 
369
					
-
 
370
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
371
					
-
 
372
								}
-
 
373
								else{
-
 
374
									$offerresponse = "";
-
 
375
								}
-
 
376
				}
-
 
377
				else{
-
 
378
					$offerresponse = "";
-
 
379
				}
-
 
380
			}else{
-
 
381
				if(!empty($getoffer)){
-
 
382
					$offerresponse = $getoffer;
-
 
383
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
384
						
-
 
385
					}
-
 
386
					else{
-
 
387
						$offerresponse = "";
-
 
388
					}
-
 
389
				}
-
 
390
								
364
		}
391
			}
-
 
392
			
365
		//check for offer end
393
			//check for offer end 
366
		
394
		
367
		$this->set(compact('offerresponse','nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
395
		$this->set(compact('offerresponse','nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
368
		if(!empty($deals) && !empty($deals[0])){
396
		if(!empty($deals) && !empty($deals[0])){
369
			$this->render('/Elements/deals');
397
			$this->render('/Elements/deals');
370
		}else{
398
		}else{
Line 413... Line 441...
413
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
441
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
414
				}
442
				}
415
			}
443
			}
416
		}
444
		}
417
		
445
		
-
 
446
		//check for offer start
-
 
447
			$user_id = $this->Auth->user('id');
-
 
448
			$cachekey = 'target-'.$user_id;
-
 
449
			$getoffer = Cache::read($cachekey,'target');
-
 
450
			$current_time = time();
-
 
451
			$offerresponse = "";
-
 
452
			if($getoffer === false){
-
 
453
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
454
				$offerresponse = $this->make_request($offerurl,null);
-
 
455
				Cache::write($cachekey , $offerresponse ,'target');
-
 
456
				if(!empty($offerresponse)){					
-
 
457
					
-
 
458
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
459
					
-
 
460
								}
-
 
461
								else{
-
 
462
									$offerresponse = "";
-
 
463
								}
-
 
464
				}
-
 
465
				else{
-
 
466
					$offerresponse = "";
-
 
467
				}
-
 
468
			}else{
-
 
469
				if(!empty($getoffer)){
-
 
470
					$offerresponse = $getoffer;
-
 
471
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
472
						
-
 
473
					}
-
 
474
					else{
-
 
475
						$offerresponse = "";
-
 
476
					}
-
 
477
				}
-
 
478
								
-
 
479
			}
-
 
480
			
-
 
481
			//check for offer end 
-
 
482
		
418
		$this->set(compact('deal','likedDeals','disLikedDeals'));
483
		$this->set(compact('offerresponse','deal','likedDeals','disLikedDeals'));
419
		
484
		
420
		$this->render('/Elements/saholicdeal');
485
		$this->render('/Elements/saholicdeal');
421
		
486
		
422
		
487
		
423
	}
488
	}
Line 462... Line 527...
462
				}
527
				}
463
			}
528
			}
464
		}
529
		}
465
		
530
		
466
		$nexturl = "/categories/getdealsforsearchterm/".urlencode($searchterm)."/?page=".($page+1).'&subcategories='.$subcategories;
531
		$nexturl = "/categories/getdealsforsearchterm/".urlencode($searchterm)."/?page=".($page+1).'&subcategories='.$subcategories;
467
	
532
		
-
 
533
		//check for offer start
-
 
534
			$user_id = $this->Auth->user('id');
-
 
535
			$cachekey = 'target-'.$user_id;
-
 
536
			$getoffer = Cache::read($cachekey,'target');
-
 
537
			$current_time = time();
-
 
538
			$offerresponse = "";
-
 
539
			if($getoffer === false){
-
 
540
				$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
541
				$offerresponse = $this->make_request($offerurl,null);
-
 
542
				Cache::write($cachekey , $offerresponse ,'target');
-
 
543
				if(!empty($offerresponse)){					
-
 
544
					
-
 
545
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
546
					
-
 
547
								}
-
 
548
								else{
-
 
549
									$offerresponse = "";
-
 
550
								}
-
 
551
				}
-
 
552
				else{
-
 
553
					$offerresponse = "";
-
 
554
				}
-
 
555
			}else{
-
 
556
				if(!empty($getoffer)){
-
 
557
					$offerresponse = $getoffer;
-
 
558
					if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
559
						
-
 
560
					}
-
 
561
					else{
-
 
562
						$offerresponse = "";
-
 
563
					}
-
 
564
				}
-
 
565
								
-
 
566
			}
-
 
567
			
-
 
568
			//check for offer end 
-
 
569
		
468
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','nexturl'));
570
		$this->set(compact('offerresponse','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','nexturl'));
469
		if(!empty($deals) && !empty($deals[0])){
571
		if(!empty($deals) && !empty($deals[0])){
470
			$this->render('/Elements/deals');
572
			$this->render('/Elements/deals');
471
		}else{
573
		}else{
472
			$this->render('/Elements/nodeals');
574
			$this->render('/Elements/nodeals');
473
		}
575
		}