<?php 
header('X-Frame-Options: GOFORIT');
@session_start();
error_reporting(E_ALL);
include_once 'inc/functions.php';
include 'inc/database.php';

require_once __DIR__ . '/vendor/autoload.php';
use Bigcommerce\Api\Client as Bigcommerce;

$config = array();


if( isset($_GET['signed_payload']) || (isset($_GET['store_hash']) && !empty($_GET['store_hash'])) ){
	$data = decodeSignedRequest($_GET['signed_payload']);
	$hash = isset($data['store_hash']) ? $data['store_hash'] : $_GET[
		'store_hash'];
	$_SESSION['store_hash'] = $hash;
	$access_token = $db->getSingleColumn( "stores", "access_token", array( "store_id" => $hash ));
		$_SESSION['access_token']	= $access_token;
        if( $access_token == "")
            die("store access token not found.");
        $config = array(
            'client_id'  => CLIENT_ID,
            'auth_token' => $access_token,
            'store_hash' => $hash
        );
    Bigcommerce::configure($config);
    Bigcommerce::verifyPeer(false);

    $store_url = $db->getSingleColumn("stores", "store_url", array( "access_token" => $access_token) );
}



?>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Bigcommerce Wishlist App</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/css/dataTables.bootstrap.min.css">
        <link rel="stylesheet" href="<?php  echo BASE_PATH ?>assets/css/custom.css?<?= time(); ?>">

        <script  src="https://code.jquery.com/jquery-3.3.1.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/jquery.dataTables.min.js" type="text/javascript" charset="utf-8" ></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/dataTables.bootstrap.min.js" type="text/javascript" charset="utf-8" ></script>
        <script src="<?php  echo BASE_PATH ?>assets/js/cstm.js"></script>
        
    </head>
    <body>
<!--		<div class="app_conatiner">-->
		<h1 style="text-align: center;">Request a Feature here:</h1>
<!--			<div id="main_content" style="background-color: #f6f7f9 !important;">-->
<!--				<div class="sub_conatiner">-->
				   <div class="row col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3 col-xs-6 col-xs-offset-3">
						<?php
								if(isset($_GET['error_msg'])){
						echo"<div class='alert' style='color: white; background-color: #ff0000' >";
							$error_msg=@$_GET['error_msg'];
							echo "<span style='color: white'>".$error_msg."</span>";
						echo"</div>";
							}
							if(isset($_GET['success_msg'])){
						echo"<div class='alert' style='color: white; background-color: #4CAF50' >";
							$success_msg=@$_GET['success_msg'];
							echo "<span style='color: white'>".$success_msg."</span>";
						echo"</div>";
							}
							?>
						<form method="POST" action="">
							<div class="form-group">
								  <label for="text"><span class="mendatory">*</span>Name:</label>
								  <input type="text" class="form-control name"  placeholder="Username" name="name" required>

							</div>
							<div class="form-group">
								  <label for="email"><span class="mendatory">*</span>Email:</label>
								  <input type="email" class="form-control email"  placeholder="Email" name="email" required>

							</div>									
							<div class="form-group">
								  <label for="phone">Phone:</label>
								  <input type="text" class="form-control phone"  placeholder="Phone" name="phone">

							</div>
							<div class="form-group">
								  <label for="comments"><span class="mendatory">*</span>Comments:</label>
								  <textarea class="form-control comments" rows="2" placeholder="Comments..." id="comments" name="comments" required></textarea>
							</div>
							
							<button class="btn btn-success col-md-12 col-sm-12 col-xs-12" type="submit" name="submit" value="submit">Submit</button>
							
						</form>
						<div class="logo" style="text-align: center;">
							<a href="//www.webecommercepros.com/" target="_blank">
								<img src="assets/images/logo.png" width="170px" height="40px" style="margin: 20px;"> 
							</a>
						</div>
					</div>
					
<!--				</div>				-->
<!--			</div>-->
<!--		</div>        	    	-->
    </body>
</html>   
<script>
    $(document).ready(function(){
        $('select[name="show_record_length"]').css('padding-top','0px');  
		
    });
    
</script> 	 

<?php
if (isset($_POST['submit'])) {
	
	//$referer  =	$_SERVER['HTTP_ORIGIN'];
	$name	  	=	$_POST['name'];
	$email    	=	$_POST['email'];
	$phone 		=	$_POST['phone'];
	$comments 	=	$_POST['comments'];
	//$phone=$_POST['phone'];


	if($name !="" && $email !="" && $comments!="" ){
		
		$to = "ali@webecommercepros.com";
		$subject = "Feature Request of Wishlist Analytics App";
		$headers = "From: ".$email;
		
		//echo $email."<br>".$comments;
		mail($to,$subject,$comments,$headers);

		header("location:load_form.php?success_msg=Thankyou for your feedback!");
	}else{
		header("location:load_form.php?error_msg=Something went wrong please try again later...");
	}
	
	
	
	
	
}

?>


