Subversion Repositories SmartDukaan

Rev

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

Rev 19244 Rev 19306
Line 218... Line 218...
218
			}
218
			}
219
 
219
 
220
			$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
220
			$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
221
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
221
			$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;			
222
			
222
			
-
 
223
			//check for offer start
-
 
224
			$user_id = $this->Auth->user('id');
-
 
225
			$cachekey = 'target-'.$user_id;
-
 
226
			$getoffer = Cache::read($cachekey,'target');
-
 
227
			
-
 
228
			$offerresponse = "";
-
 
229
			if($getoffer === false){
-
 
230
				$offerurl = $this->apihost."getOfferForUser/?user_id=47";
-
 
231
				$offerresponse = $this->make_request($offerurl,null);
-
 
232
				Cache::write($cachekey , $offerresponse ,'target');
-
 
233
				if(!empty($offerresponse)){					
-
 
234
					$current_time = time();
-
 
235
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
236
					
-
 
237
								}
-
 
238
								else{
-
 
239
									$offerresponse = "";
-
 
240
								}
-
 
241
				}
-
 
242
				else{
-
 
243
					$offerresponse = "";
-
 
244
				}
-
 
245
			}else{
-
 
246
				$offerresponse = $getoffer;
-
 
247
			}
-
 
248
			
-
 
249
			//check for offer end 
-
 
250
			
-
 
251
			
223
			$this->set(compact('response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','subcategories','errorstr','nexturl','searchfor', 'searchableSubCategories', 'sortlabel'));
252
			$this->set(compact('offerresponse','response_count','deals','id','likedDeals','disLikedDeals','page','sort','direction','notification','filter','brands','filterstr','subcategories','errorstr','nexturl','searchfor', 'searchableSubCategories', 'sortlabel'));
224
		}else{
253
		}else{
225
			//Check for apk support of sharing
254
			//Check for apk support of sharing
226
			$sharable = 0;
255
			$sharable = 0;
227
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
256
			if(isset($_COOKIE['shareApps']) && !empty($_COOKIE['shareApps'])) {
228
				$sharable = 1;
257
				$sharable = 1;
Line 314... Line 343...
314
			}
343
			}
315
		}
344
		}
316
		
345
		
317
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
346
		$filterstr = '&brands='.$brands.'&subcategories='.$subcategories;
318
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
347
		$nexturl = "/categories/getdeals/".$id."/?page=".($page+1)."&sort=".$sort."&direction=".$direction."".$filterstr;
319
 
348
		
-
 
349
		//check for offer start
-
 
350
		$offerurl = $this->apihost."getOfferForUser/?user_id=47";
-
 
351
		$offerresponse = $this->make_request($offerurl,null);
-
 
352
		Cache::write('target', $offerresponse);
-
 
353
		$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 = "";
-
 
364
		}
-
 
365
		//check for offer end
-
 
366
		
320
		$this->set(compact('nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
367
		$this->set(compact('offerresponse','nexturl','deals','id','page','likedDeals','disLikedDeals','sort','direction','brands','filter','filterstr'));
321
		if(!empty($deals) && !empty($deals[0])){
368
		if(!empty($deals) && !empty($deals[0])){
322
			$this->render('/Elements/deals');
369
			$this->render('/Elements/deals');
323
		}else{
370
		}else{
324
			$this->render('/Elements/nodeals');
371
			$this->render('/Elements/nodeals');
325
		}
372
		}
Line 425... Line 472...
425
			$this->render('/Elements/nodeals');
472
			$this->render('/Elements/nodeals');
426
		}
473
		}
427
 
474
 
428
 
475
 
429
	}
476
	}
-
 
477
	
-
 
478
	public function target($offer_id = null){
-
 
479
		$this->layout = "innerpages";
-
 
480
// 		$user_id =  $this->Auth->user('id');
-
 
481
// 		$url = $this->apihost."getOfferForUser/?user_id=47";
-
 
482
// 		$response = $this->make_request($url,null);
-
 
483
		
-
 
484
		$user_id = $this->Auth->user('id');
-
 
485
		$cachekey = 'target-'.$user_id;
-
 
486
		$getoffer = Cache::read($cachekey,'target');
-
 
487
			
-
 
488
		$response = "";
-
 
489
		if($getoffer === false){
-
 
490
			$offerurl = $this->apihost."getOfferForUser/?user_id=47";
-
 
491
			$response = $this->make_request($offerurl,null);
-
 
492
			Cache::write($cachekey , $response ,'target');
-
 
493
			if(!empty($response)){
-
 
494
				$current_time = time();
-
 
495
								if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
496
					
-
 
497
								}
-
 
498
								else{
-
 
499
									$offerresponse = "";
-
 
500
									}
-
 
501
				}
-
 
502
				else{
-
 
503
					$offerresponse = "";
-
 
504
				}
-
 
505
		}else{
-
 
506
			$response = $getoffer;
-
 
507
		}
-
 
508
		
-
 
509
		$maxpercentage = 0;
-
 
510
// 		debug($response);
-
 
511
		
-
 
512
		if(isset($response['target2_cash_back_percetage']) && !empty($response['target2_cash_back_percetage'])){
-
 
513
			$maxpercentage = $response['target2_cash_back_percetage'];
-
 
514
		}
-
 
515
		else{
-
 
516
			if(isset($response['target1_cash_back_percetage']) && !empty($response['target1_cash_back_percetage'])){
-
 
517
				$maxpercentage = $response['target1_cash_back_percetage'];
-
 
518
			}
-
 
519
		}
-
 
520
		
-
 
521
		$user_email = $this->Auth->user('email');
-
 
522
		$subcat = Configure::read('arrSubCategory');
-
 
523
		$this->set(compact('response','maxpercentage','user_email','subcat'));
-
 
524
	}
430
/**
525
/**
431
 * add method
526
 * add method
432
 *
527
 *
433
 * @return void
528
 * @return void
434
 */
529
 */