Subversion Repositories SmartDukaan

Rev

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

Rev 19233 Rev 19610
Line 711... Line 711...
711
			$response = json_decode($result,1);
711
			$response = json_decode($result,1);
712
			break;
712
			break;
713
		}
713
		}
714
		return $response;	
714
		return $response;	
715
	}
715
	}
-
 
716
	
-
 
717
	public function getuseroffer(){
-
 
718
		//check for offer start
-
 
719
		$user_id = $this->Auth->user('id');
-
 
720
		$cachekey = 'target-'.$user_id;
-
 
721
		$getoffer = Cache::read($cachekey,'target');
-
 
722
		$current_time = time();
-
 
723
		$offerresponse = "";
-
 
724
		if(empty($getoffer) || $getoffer === false){
-
 
725
			$offerurl = $this->apihost."getOfferForUser/?user_id=".$user_id;
-
 
726
			$offerresponse = $this->make_request($offerurl,null);
-
 
727
			Cache::write($cachekey , $offerresponse ,'target');
-
 
728
			if(!empty($offerresponse)){
-
 
729
					
-
 
730
				if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
731
						
-
 
732
				}
-
 
733
				else{
-
 
734
					$offerresponse = "";
-
 
735
				}
-
 
736
			}
-
 
737
			else{
-
 
738
				$offerresponse = "";
-
 
739
			}
-
 
740
		}else{
-
 
741
			if(!empty($getoffer)){
-
 
742
				$offerresponse = $getoffer;
-
 
743
				if($offerresponse['startDate']/1000 <= $current_time && $offerresponse['endDate']/1000 >= $current_time ){
-
 
744
		
-
 
745
				}
-
 
746
				else{
-
 
747
					$offerresponse = "";
-
 
748
				}
-
 
749
			}
-
 
750
		
-
 
751
		}
-
 
752
		return $offerresponse;	
-
 
753
		//check for offer end
-
 
754
	}
716
}
755
}