<?php
$cookie_name = "username";
if(!isset($_COOKIE[$cookie_name])) {
    
} else {
    
    $session_data = unserialize($_COOKIE[$cookie_name]);
    
    $session_data = array(
	'user_id' => $session_data['user_id'],
	'username' => $session_data['username'],
	'email' => $session_data['email'],
	'root_id' => $session_data['root_id'],
	);
	
	$this->session->set_userdata('username', $session_data);
    
    $_SESSION['user_id'] = $session_data['user_id'];
    $_SESSION['root_id'] = $session_data['root_id'];
    
    if(isset($_REQUEST['next']))
    {
        if(!empty($_REQUEST['next']))
        {
            session_start();
            $_SESSION['next'] = $_REQUEST['next'];
            header('location:'.$_REQUEST['next']);
        }
    }
    else
    {
        header('location:./dashboard');
    }
    
}
$system = $this->Xin_model->read_company_setting_info(1);

if($system[0]->logo!='' && $system[0]->logo!='no file') {
    
    $logo =base_url().'skin/img/'.$system[0]->logo;
}
else {
    
    $logo =base_url().'skin/img/default-logo.png';
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="icon" href="<?php echo base_url();?>assets/images/dashboard/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="<?php echo base_url();?>assets/images/dashboard/favicon.png" type="image/x-icon">
    <title><?php echo $system[0]->name?> Admin Panel</title>

    <!-- Google font-->
    <link href="https://fonts.googleapis.com/css2?family=Urbanist:wght@100;200;300;500;600;900&display=swap" rel="stylesheet">

    <!-- Bootstrap css-->
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/vendors/bootstrap.css">

    <!-- App css-->
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/admin.css">
    
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/toastr/toastr.min.css">

</head>
<body>

<!-- page-wrapper Start-->
<div class="page-wrapper">
    <div class="authentication-box">
        <div class="container">
            <div class="row">
                <div class="col-md-5 p-0 card-left">
                    <div class="card bg-primary">
                        <div class="svg-icon">
                            <img class="blur-up lazyloaded img-fluid" src="<?php echo $logo ?>" alt="">
                        </div>

                        <div class="single-item">
                            <div>
                                <div>
                                    <h3>Welcome to <?php echo $system[0]->name?></h3>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-7 p-0 card-right">
                    <div class="card tab2-card">
                        <div class="card-body">
                            <ul class="nav nav-tabs nav-material" id="top-tab" role="tablist">
                                <li class="nav-item">
                                    <a class="nav-link active" id="top-profile-tab" data-bs-toggle="tab" href="#top-profile" role="tab" aria-controls="top-profile" aria-selected="true"><span class="icon-user me-2"></span>Forgot Password</a>
                                </li>
                            </ul>
                            <div class="tab-content" id="top-tabContent">
                                <div class="tab-pane fade show active" id="top-profile" role="tabpanel" aria-labelledby="top-profile-tab">
                                    <form class="form-horizontal auth-form" action="<?php echo site_url();?>forgot_password/send_mail/" method="post" name="xin-form" id="xin-form">
                                        <div class="form-group">
                                            <input type="email" class="input100 form-control" name="iemail" id="iemail"  placeholder="Enter your email..." required/>  
                                        </div>
                                        <div class="form-button">
                                            <button class="btn btn-primary login-button" type="submit" name="registerForm">Reset</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <a href="<?php echo base_url(); ?>" class="btn btn-primary back-btn"><i data-feather="arrow-left"></i>Back to Login</a>
        </div>
    </div>
</div>

<!-- latest jquery-->
<script src="<?php echo base_url(); ?>assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/vendor/toastr/toastr.min.js"></script> 
<script type="text/javascript">
$(document).ready(function(){
	toastr.options.closeButton = true;
	toastr.options.progressBar = true;
	toastr.options.timeOut = 3000;
	toastr.options.preventDuplicates = true;
	toastr.options.positionClass = "toast-bottom-right";
	
	
	/* Add data */ /*Form Submit*/
	$("#xin-form").submit(function(e){
	e.preventDefault();
		var obj = $(this), action = obj.attr('name');
		$('.save').prop('disabled', true);
		$.ajax({
			type: "POST",
			url: e.target.action,
			data: obj.serialize()+"&is_ajax=1&add_type=forgot_password&form="+action,
			cache: false,
			success: function (JSON) {
				if (JSON.error != '') {
					toastr.error(JSON.error);
					$('.save').prop('disabled', false);
				} else {
					toastr.success(JSON.result);
					$('#iemail').val(''); // To reset form fields
					$('.save').prop('disabled', false);
				}
			}
		});
	});
	
});
</script>
<script type="text/javascript">var base_url = '<?php echo base_url(); ?>';</script>
<script type="text/javascript" src="<?php echo base_url();?>skin/js_module/login.js"></script>
</body>
</html>
