<?php
	ob_start();
	session_start();
	if(isset($_SESSION["fullname"])  && isset($_SESSION["email"])){
		header('Location:index.php');
		exit;
	}else{
		
	}
	require 'autoload.php';
	use Parse\ParseClient;
	use Parse\ParseObject;
	use Parse\ParseQuery;
	use Parse\ParseACL;
	use Parse\ParsePush;
	use Parse\ParseUser;
	use Parse\ParseInstallation;
	use Parse\ParseException;
	use Parse\ParseAnalytics;
	use Parse\ParseFile;
	use Parse\ParseCloud;
	
	include 'config.php';
	
	ParseClient::initialize($ApplicationID, $RestAPIKEY, $MasterKey);
	ParseClient::setServerURL($serverURLB4APP, '/');
	
	
if(isset($_POST['Submit']) ){
	 $userid=$_POST['email'];
	 $password=md5($_POST['password']);
		$objAdminUsers   = new ParseQuery("admin");											
		$objAdminUsers->equalTo("email", $userid);
		$result = $objAdminUsers->find();
	 	if(!empty($result) && $result[0]->get("password")  ==  $password){
			$_SESSION["id"] = $result[0]->getObjectId();
			$_SESSION["email"] = $result[0]->get("email");	
			$_SESSION["fullname"] = $result[0]->get("first_name").' '.$result[0]->get("last_name");
			$_SESSION["shop_name"] = $result[0]->get("shop_name");			
			header('Location: index.php');
		}
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Login</title>
   	<?php include 'includes/head.php'; ?>
<style>
	body#pgLogin{
		background: rgba(179,220,237,1);
background: -moz-linear-gradient(left, rgba(77,94,229,1) 0%,  rgba(215,31,37,1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(77,94,229,1)),color-stop(100%, rgba(215,31,37,1)));
background: -webkit-linear-gradient(left, rgba(77,94,229,1) 0%, rgba(215,31,37,1) 100%);
background: -o-linear-gradient(left, rgba(77,94,229,1) 0%, rgba(215,31,37,1) 100%);
background: -ms-linear-gradient(left, rgba(77,94,229,1) 0%, rgba(215,31,37,1) 100%);
background: linear-gradient(to right, rgba(77,94,229,1) 0%, rgba(215,31,37,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4d5ee5', endColorstr='#d71f25', GradientType=1 );
	}
</style>
</head>

<body class="loginPage" id="pgLogin">
	<div class = "container">
		<div class="wrapper">
			<form action="" method="post" name="Login_Form" class="form-signin">       
				<h3 class="form-signin-heading"><img src="../assets/litebeacon_logo1.png" width="300px"/></h3>					
				  <hr class="colorgraph"><br>
				  
				  <input type="text" class="form-control" name="email" placeholder="Email" required="" autocomplete="off" />
				  <input type="password" class="form-control" name="password" placeholder="Password" autocomplete="off" required=""/>     		  
				 
				  <button class="btn btn-lg btn-primary btn-block"  name="Submit" value="Login" type="Submit">Login</button> 
				  <!-- <span>OR</span>
				  <a class="btn btn-lg btn-primary btn-block" href="signup.php">Sign Up</a> 	-->		
			</form>			
		</div>
	</div>
      <?php include 'includes/footer.php'; ?>
</body>

</html>