<?php
include('../config.php');
$validate=new Validation();
if($_SESSION['SUPER_ADMIN']['id']!=''){
redirect('dashboard.php');
}
if(isset($_POST['addnewrecord']))
{
$validate->addRule($_POST['emailid'],'email','emailid',true);
$validate->addRule($_POST['password'],'','Password',true,6,14);
if($validate->validate() && count($stat)==0)
 {
	$iCheckEmailId=$db->getVal("select * from  admin_login where emailid='".SqlInj($_POST['emailid'])."' and status='1'");
   	if($iCheckEmailId!='')
		{
			$iPassword = SqlInj($_POST['password']);
			$iCheckPassword=$db->getRow("select * from  admin_login where password='".md5($iPassword)."' and emailid='".SqlInj($_POST['emailid'])."'  and status='1'");
			if($iCheckPassword['id']=='')
			{
				$stat['error']="Invalid email id or password.";
			}
			elseif($iCheckPassword['status']=='0')
			{
				$stat['error']="Awaiting for admin approval";
			}
			elseif($iCheckPassword['status']=='1')
			{
				$_SESSION['SUPER_ADMIN']=array('id'=>$iCheckPassword['id'],'usertype'=>$iCheckPassword['usertype']);
				redirect("dashboard.php");
			}
		}
		else
		{
			$stat['error']="This email id do not exit.";
		}
	} else {
		 $stat['error'] = $validate->errors();
	}
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include('inc.meta.php'); ?>
<style>
.alert-error {
	color: #a94442;
	background-color: #f2dede;
	border-color: #ebccd1;
}
body, html {
    height:100%;
}
</style>
<style>
.panel-heading {
    border: none!important;
    padding:30px 0px 20px 0px;
    text-align:center;
}
.loginpanel {
    background-color: #fff;
    padding:30px 25px 50px 25px;
    border: solid 1px #ddd;
    width: 100%;

    margin-top: 30px;
    background-size:100%;
    background-repeat: no-repeat;
    border-radius: 7px;
}
.loginpanel .form-group {
    margin-bottom: 30px;
}
.loginpanel .form-control {
	height:42px;
	padding:0px 30px;
	font-size: 15px;
	border: 1px solid #e3e3e3;
}
.panel-heading h3 {
	font-weight: 600;
	font-size:20px;
	padding: 0px;
	margin: 0px;
	margin-top: 20px;
	    color: black;
}
.panel-heading h6 {
	font-weight: 400;
	font-size: 14px;
	padding: 0px;
	margin: 0px;
	margin-top:0px;
    margin-bottom:15px;
}
.alert-error {
	color: #a94442;
	background-color: #f2dede;
	border-color: #ebccd1;
}
.sig {
	text-align: Center;
	font-size: 16px;
	margin-top: 0;
	color: #00000073;
}
.btn-forpass {
    float: right;
    margin-bottom: 20px;
    font-weight: 500;
	font-size: 15px;
	text-decoration: underline;
}
.account{
    text-align:center;
    margin-bottom: 20px;
    font-weight: 500;
	font-size: 16px;
    margin-top: 25px;
}
.btn-blue {
    background: #6658dd;
    border: 1px solid #6658dd;
    padding: 10px 25px;
    font-size: 16px;
    color: #fff;

    width: 100%;
    border-radius:7px;
}
.btn-blue:hover{
    background: #00138d;
	border: 1px solid #303f9f;

}
.viwhead {
    font-size: 16px;
	font-weight: 400;
    color: #8c8c8c;
}
.txtbox {
    position: relative;
}
.txtbox i{
    position: absolute;
    top: 14px;
    left: 15px;
    font-size:16px;
	color: #b5b5b5;
}
.account-pages-log-bg{
  background: linear-gradient(0deg, #00000014, #00000017), url(../uploads/login-bg.jpg)!important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    height: 100%;
}
</style>
</head>
<body class="account-pages-log-bg">
<div class="account-pages">
  <div class="clearfix"></div>
  <div class="wrapper-page ">
    <div class=" card-box" style="background:transparent; border:none">
      <div class="panel-body">
        <div class="col-md-4"></div>
        <div class="col-md-3">
          <div class="loginpanel">
            <div class="panel-heading">
              <h3>Welcome Back :) </h3>
              <h6>Please enter your username and password:</h6>
              <?php echo msg($stat) ; ?> </div>
            <form class="form-horizontal" action="" method="post">
              <div class="form-group ">
                <div class="col-xs-12 viwhead">Enter Email Id</div>
                <div class="col-xs-12 txtbox"> <i class="fa fa-envelope-o"></i>
                  <input class="form-control" type="email"  required placeholder="Enter Email Id" name="emailid">
                </div>
              </div>
              <div class="form-group">
                <div class="col-xs-12 viwhead">Enter Password</div>
                <div class="col-xs-12 txtbox"> <i class="fa fa-key"></i>
                  <input class="form-control" type="password"  required placeholder="Enter Password" name="password">
                  <a href="forgot-password.php" style="float:right;">Forgot password?</a>
                </div>
              </div>
              <div class="form-group">
                <div class="col-xs-12 mt-20">
                  <button  class="btn-blue" type="submit" name="addnewrecord"><i class="fa fa-sign-in"></i> Log In</button>
                </div>
              </div>
            </form>
          </div>
        </div>
        <div class="col-md-4"></div>
      </div>
    </div>
  </div>
</div>
</body>
</html>