<?php session_start();
   include("../config/config.php");
   $myformId=SESS_MASTER;
   $myIp= ipCheck() ;
   $dateceated=date("Y-m-d G:i:s");
   $createdby='0';
   
   $alertType='1';// ADMIN=1 USER =0
   $id		=	secureSuperGlobalPOST($_REQUEST['id']);
   $type	=	secureSuperGlobalPOST($_REQUEST['type']);
     if(!empty($_SESSION[ADD_TAG.'_UserId_vendor'])){
         $u_type='vendor';
       $user_id=$_SESSION[ADD_TAG.'_UserId_vendor'];  
     }
     elseif(!empty($_SESSION[ADD_TAG.'_UserId_user'])){
           $user_id=$_SESSION[ADD_TAG.'_UserId_user'];
            $u_type='user';
         
     }
     
   
   if($user_id!='' && $type=='1' ){
    
   		
   		
   
     try{
   		$olgaquery="INSERT INTO fav_master SET coupan_id='$id',user_type='$u_type',fav_status='$type',user_id='$user_id'"; 
   		$stmt = $conn->prepare($olgaquery);
   		if($stmt->execute()){
   			$last_insert_id = $conn->lastInsertId();
   
   		
   
   		echo '<a onclick="return fav('.$id.',0);" title="Favourite Store"><i class="fa fa-heart fa-1x text-danger" aria-hidden="true"></i></a>';
   
    
    
      } }
            
           // show error
           catch(PDOException $exception){
               die('ERROR: ' . $exception->getMessage());
           }
   }elseif($user_id!='' && $type=='0'){
      
       	try{
   		$olgaquery="DELETE FROM fav_master WHERE coupan_id='$id' AND user_type='$u_type' AND user_id='$user_id'"; 
   		$stmt = $conn->prepare($olgaquery);
   		if($stmt->execute()){
   			$last_insert_id = $conn->lastInsertId();
   	 echo '<a onclick="return fav('.$id.',1);" title="Favourite Store"><i class="fa fa-heart"  ></i></a>';
    
    
      } }
            
           // show error
           catch(PDOException $exception){
               die('ERROR: ' . $exception->getMessage());
           }
       	
      
   }
   ?>