<?php  
if($this->session->userdata('admin_login_session')){
  ?>
<script type="text/javascript">
  window.location.href="<?php echo base_url(); ?>AdminDashboard";
</script>
  <?php
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Top Truf Arena || Admin Login</title>
    
    <link rel="shortcut icon" href="<?php echo base_url(); ?>img/logo.png" />
    
    
    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    <!-- Main css -->
    <link href="<?php echo base_url();?>css/style.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        .input-group label.error {
            bottom: -20px !important;
            font-size: 13px !important;
        }
    </style>
    <style>
.buttonload {
    /*background-color: #4CAF50; /* Green background */*/
    border: none; /* Remove borders */
    color: white; /* White text */
    padding: 12px 24px; /* Some padding */
    font-size: 16px; /* Set a font-size */
}

/* Add a right margin to each icon */
.fa {
    margin-left: -12px;
    margin-right: 8px;
}
</style>
</head>
<body class="loginBack">


<div class="loginSec">
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-sm-4"></div>
            <div class="col-md-4 col-sm-4 col-xs-12"> 
                <div class="loginSecD">
                    <div class="alert alert-success LoginSuccMsg" style="display: none;">
                        <strong>Authentication Successful!</strong>
                    </div>
                    <div class="alert alert-danger LoginFailedMsg" style="display: none;">
                        <strong> Please Enter Correct Email or Password!</strong>
                     </div>
                     <div class="alert alert-danger ForgotFailed" style="display: none;">
                        <strong>Please Enter Correct Email ID!</strong>
                     </div>
                     <div class="alert alert-success ForgotSuccess" style="display: none;">
                        <strong>Please Check Your Mail Box!</strong>
                      </div>
                      <div class="alert alert-warning ForgotTryagain" style="display: none;">
                         <strong>Please Try After Some Time!</strong>
                      </div>
                    <a href="index.php"><img src="img/logo.png" class="img-responsive"></a>
                    <div class="loginSecDsub" id="loginID">
                        <h4>Super Admin Login</h4>
                        <form role="form" id="login_form" method="post">
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                    <input type="text" class="form-control" name="username" placeholder="User Name" required>
                                </div> <input type="hidden" name="login" value="user_login"><br>
                            </div> 
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                    <input type="password" class="form-control" name="password" placeholder="Password" required>
                                    
                                </div>
                            </div>
                            <button type="button" name="" id="forgetID" class="btn btn_forget pull-right">Forget Password?</button>
                            <div class="clearfix"></div>
                            <button type="submit" name="" class="btn btn-primary loginbtn"><i class="fa fa-sign-in" aria-hidden="true"></i> Login</button>
                            <button class="btn btn-primary loginbtnload buttonload" style="display: none;"><i class="fa fa-spinner fa-spin"></i>Please Wait</button>
                            
                        </form>
                    </div>
                    
                    <div class="loginSecDsub frgtSecD" id="forgetPassD">
                        <h4>Forget Password</h4>
                        <form role="form" id="forget_form" method="post">
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
                                    <input type="email" class="form-control" name="email" placeholder="Email ID" required>
                                </div><input type="hidden" name="forgot" value="forgot_pass"> <br>
                            </div> 
                            <button type="button" name="" id="backID" class="btn btn_forget pull-right">Back to Login?</button>
                            <div class="clearfix"></div>
                            <button type="submit" name="" class="btn btn-primary forget_button"><i class="fa fa-paper-plane-o" aria-hidden="true"></i> Send</button>
                            <button class="btn btn-primary buttonload forgetload" style="display: none;"><i class="fa fa-spinner fa-spin"></i>Please Wait</button>
                            
                        </form>
                    </div>
                    
                </div>
                
            </div>
            <div class="col-md-4 col-sm-4"></div>
                    
        </div>
    </div>
</div>

<script>
$(document).ready(function(){
    $("#forgetID").click(function(){
        $("#loginID").hide();
        $("#forgetPassD").show();
    });
    $("#backID").click(function(){
        $("#loginID").show();
        $("#forgetPassD").hide();
    });
});
</script>   

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

</body>
</html>

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="<?php echo base_url();?>css/site-demos.css">
<script src="<?php echo base_url();?>js/jquery.validate.min.js"></script>
<script src="<?php echo base_url();?>js/additional-methods.min.js"></script>

<script>
    // just for the demos, avoids form submit
    jQuery.validator.setDefaults({
        success: "valid"
    });
    $("#login_form").validate({
        rules: {
            username: {
                 required: true,
                 email: true
               }
        }
    });
</script>
<script>
    $(document).ready(function(e) {
        $("#login_form").on('submit', function(e) {
            e.preventDefault();
            var formStatus = $('#login_form').validate().form();
            if (true == formStatus) {
                $.ajax({
                    type: 'POST',
                    url: '<?php echo base_url(); ?>login/save_login_details',
                    data: new FormData(this),
                    contentType: false,
                    cache: false,
                    processData: false,
                    beforeSend: function() {
                        $('.loginbtn').hide();
                        $('.loginbtnload').show();
                    },
                    success: function(msg) {
                        if (msg == 'success') {
                            $(".LoginSuccMsg").show();
                            $('.LoginSuccMsg').delay(2000).hide(200);
                            $('.loginbtn').show();
                          $('.loginbtnload').hide();
                            setInterval(function() {
                                window.location.href="<?php echo base_url(); ?>AdminDashboard";
                            }, 2000);
                        } else {
                            $(".LoginFailedMsg").show();
                            $('.LoginFailedMsg').delay(5000).hide(500);
                            $('.loginbtn').show();
                          $('.loginbtnload').hide();
                        }
                    }
                });
            }
        });
    });
</script>
<script>
    // just for the demos, avoids form submit
    jQuery.validator.setDefaults({
        success: "valid"
    });
    $("#forget_form").validate({
        rules: {
            email: {
                required: true,
                email: true
            }
        }
    });
</script>
<script>
    $(document).ready(function(e) {
        $("#forget_form").on('submit', function(e) {
            e.preventDefault();
            var formStatus = $('#forget_form').validate().form();
            if (true == formStatus) {
                $.ajax({
                    type: 'POST',
                    url: 'login_check.php',
                    data: new FormData(this),
                    contentType: false,
                    cache: false,
                    processData: false,
                    beforeSend: function() {
                        $('.forget_button').hide();
                        $('.forgetload').show();
                    },
                    success: function(msg) {
                        if (msg == 'success') {
                            $(".ForgotSuccess").show();
                            $('.ForgotSuccess').delay(2000).hide(200);
                            $('.forget_button').show();
                          $('.forgetload').hide();
                            $('#forget_form').empty().load(window.location.href + ' #forget_form');
                        } else if (msg == 'try') {
                            $(".ForgotTryagain").show();
                            $('.ForgotTryagain').delay(5000).hide(500);
                            $('.forget_button').show();
                          $('.forgetload').hide();
                        } else if (msg == 'not_exist') {
                            $(".ForgotFailed").show();
                            $('.ForgotFailed').delay(5000).hide(500);
                            $('.forget_button').show();
                          $('.forgetload').hide();
                        }
                    }
                });
            }
        });
    });
</script>










