<?php 
    if(isset($_POST['submit_feedback']))
    {
       $date =  date('Y-m-d H:i:s');
       $stmt =  $conn->prepare("insert into feedback_details (cust_id,date,message) values(:cust_id,:date,:message)");
       $stmt->bindValue(':cust_id', $_COOKIE['site_custom_id'], PDO::PARAM_STR); 
       //$stmt->bindValue(':city_id', $_POST['city_id'], PDO::PARAM_STR);
       $stmt->bindValue(':date', $date, PDO::PARAM_STR);
       $stmt->bindValue(':message', $_POST['feedback_message'], PDO::PARAM_STR);
       $stmt->execute();   
?> 
<script>
    $('#submit_feedback').addClass('disableloginbtn');
    window.location.href = window.location.href; 
</script>
<?php 
    }
?>

<!--<footer>
<div id="copyRight">
<div class="col-sm-12">
<div class="wrapper">
© 2019 Netbutterfly.  All Rights Reserved.
</div>
</div>
</div>
</footer>-->
<script>
$(document).ready(function(){   
    $("#submit_feedback").hide();
    $("#apply_feedback").validate({ 
			
		rules:{ 
	     feedback_name:{
			 required:true,
			 minlength:3,
			 maxlength:35,
			 Feedbacklettersonly:true
			},	

		feedback_email:{
			email: true				
			},

	     feedback_ph:{
            required:true,
		    number:true,
		    minlength:10,
		    maxlength:10	             			 
            }				
		},
		messages:{	

			feedback_name:{					
              required:"Please enter name",
			  minlength : "Please enter minimum 3 characters name",
			  maxlength : "Max 35 characters are allowed"  					
			},
			
			feedback_ph:{
			required:"Please enter an Mobile No",	
			minlength : "Please enter minimum 10 digits",
			maxlength : "Max 10 digits are allowed"				
		   }			   
        } 			  
	});	
		
	jQuery.validator.addMethod("Feedbacklettersonly", function(value, element) {
    return this.optional(element) || /^[a-z\-_\s]+$/i.test(value);
    }, "Use letters & (_,-) only"); 
}); 

function feedback_emoji(val)
{
    if(val==1)
    {
        $("#feedback_message").val("I HATE it.");
        $("#submit_feedback").show(200);
    }
    else if(val==2)
    {
        $("#feedback_message").val("I AM HAPPY.");
        $("#submit_feedback").show(200);
    }
    else if(val==3)
    {
        $("#feedback_message").val("I Love it.");
        $("#submit_feedback").show(200);
    }
    else if(val==4) 
    {
        $("#feedback_message").val("I DISAPPOINTED.");
        $("#submit_feedback").show(200);
    }
    else if(val==5) 
    {
        $("#feedback_message").val("IT'S OKAY.");
        $("#submit_feedback").show(200);
    }
}
</script>
 
<!--<div class="smiley"><i class="fa fa-smile-o"></i></div>-->
<?php  
    if( ($_SERVER['SCRIPT_NAME']=='/jobs/job-details.php')|| ($_SERVER['SCRIPT_NAME']=='/jobs/file1.php') ) 
	{
	if(isset($_COOKIE['site_custom_id']))
	{
	    $stmt=$conn->prepare("select cust_id,date from feedback_details where cust_id=:cust_id order by id DESC");
		$stmt->bindValue(':cust_id', $_COOKIE['site_custom_id'], PDO::PARAM_STR);   
		$stmt->execute();   
		$affected_rows = $stmt->rowCount();   
		if($affected_rows > 0)	
		{
			$row = $stmt->fetchAll(PDO::FETCH_OBJ);
			$current_date=date('Y-m-d');
			foreach($row as $key=>$feedback_dt)
			{
			    if($key==0)
			    {
			        $feedback_date_old=explode(" ",$feedback_dt->date);
			        $feedback_date=$feedback_date_old[0];
			        
			        $date1 = strtotime($current_date);    
				    $date2 = strtotime($feedback_date);
                    $diff = abs(($date1 - $date2) / (60 * 60 * 24));
			    }
			}
		}
		  
		  
		
		
		if($affected_rows > 0)
		{
		   if($diff > 30)
		   {
			   
?>
<div class="smiley" id="FeedBackClick"><i class="fa fa-smile-o"></i></div>
    <?php } 
        } 
        else { ?>
<div class="smiley" id="FeedBackClick"><i class="fa fa-smile-o"></i></div> 
<?php } 
    }else {?>
<div class="smiley" id="FeedBackClick"><i class="fa fa-smile-o"></i></div>
<?php } }?>

  
 

<script src="<?php echo ROOTPATH;?>/view/js/bootstrap.min.js"></script> 
<script>
function subscribeNw(custId)
{
	 
	$.ajax({	
	type: "POST",
	url: URL+"/all-ajax/general-ajax.php", 
	data: {subscrib:1,custId:custId},
	beforeSend: function(){ 
	},
	success: function(data)
	{ 
	    $("#user_subscribe").hide();
		alert("You are subscribe successfully!");			   
	}
  });
	
}
</script>
</body>
</html>
