<?php include '_config/dbconfig.php';

if(isset($_SESSION['user_role_session'])){
     echo "<script>window.location='dashboard.php'</script>";
     die();
}else{
    
    //$login_username = 'agent@7ctech.com';
    //$login_password = '123456';
    
    
    //$response = $obj_user_class->login($login_username, $login_password);
    //echo "<script>window.location='dashboard.php'</script>";
    // die();
    
}

if(count($_POST) > 0 && isset($_POST['user_login'])){
    
    
    $login_username = trim($_POST['login_username']);
    $login_password = trim($_POST['login_password']);
    
    
    $response = $obj_user_class->login($login_username, $login_password);
    
    if($response == true){
        /*echo "<pre>";
        print_r($_SESSION);
        echo '</pre>';*/
        
        if($_SESSION['user_role_session']=="Internee" || $_SESSION['user_role_session']=="Guest"){
            echo "<script>window.location='clients.php'</script>";
        }else if($_SESSION['user_role_session']=="Marketing"){
            echo "<script>window.location='events_marketing.php'</script>";
        }
        
        else{
            echo "<script>window.location='dashboard.php'</script>";
        }
        
    }else{
        echo "<script>window.location='index.php?invalid'</script>";
    }
    
    die();
}   
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<title>Login</title>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
    <link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="all" />
    <link rel="stylesheet" href="font-awesome-4.4.0/css/font-awesome.css" type="text/css" media="all" />
	<link rel="stylesheet" type="text/css" href="css/select.css" />
    <link rel="stylesheet" type="text/css" href="css/chosen.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.ui.core.css">
    <link rel="stylesheet" type="text/css" href="css/jquery.ui.theme.css">
    <link rel="stylesheet" type="text/css" href="css/jquery.ui.datepicker.css">
    
    
    <link rel="stylesheet" type="text/css" href="css/component.css" />   
</head>

<body>

<div class="main">

<header>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="logo_area">
				<h1>7ctech</h1>
              <!--  <h1>
                	<img style= "height: 45px;" src="img/logo-w.png">
                </h1>-->
            </div>
        </div>
    </nav>
</header>
<style>
    .logo_area h1 {margin-left: 0px;}
</style>

<div class="container-fluid content">
    <div class="col-sm-12 right_form">
        <div class="title">
            <div class="row">
                <div class="col-md-8 col-sm-12">
                    <h1>Login</h1>
                </div>
            </div>
        </div>
    	<div class="col-sm-12 form_inner">
        	<div class="main-login">
            <div class="box-login">
                
                <form action="" method="POST" class="form-login" novalidate id="user_form">
                    <fieldset>
                            <legend>
                                    Sign in to your account
                            </legend>
                            <p>
                                    Please enter your name and password to log in.
                            </p>
                            <div class="form-group">
                                    <span class="input-icon">
                                        <input type="email" placeholder="Username" name="login_username" required class="form-control" autocomplete="off" >
                                        <i class="fa fa-user"></i> </span>
                            </div>
                            <div class="form-group form-actions">
                                    <span class="input-icon">
                                            <input type="password" placeholder="Password" required name="login_password" class="form-control password" autocomplete="off">
                                            <i class="fa fa-lock"></i>
                                            <a href="#" class="forgot">
                                                    I forgot my password
                                            </a> </span>
                            </div>
                            <div class="form-actions">
                                <div class="new-account">
                                    <?php if(isset($_GET['invalid'])){ ?>
                                    <span style="color: #f06d54;">Invalid username or password.</span>
                                    <?php }?>
                                </div>
                                
                                    <div class="checkbox clip-check check-primary">
                                            
                                    </div>
                                <button class="btn btn-primary pull-right login_btn" type="submit" name="user_login">
                                            Login <i class="fa fa-arrow-circle-right"></i>
                                    </button>
                            </div>
                             
                            
                            </fieldset>
                        </form>
                    </div>
            </div>
		</div>
    </div>
</div>
<footer>
	<div class="col-sm-12">
    	<div class="row">
            <div class="col-sm-10 copyright">
                <p>© 2015 <span style="color:#1A87FF; text-transform:uppercase;"><b>7ctech</b></span>. All rights reserved</p>
            </div>
            <div class="col-sm-2 text-right">
                <a href="#" class="scrollup"><i class="fa fa-angle-up fa-2x"></i></a>
            </div>
        </div>
	</div>
</footer>


</div>
     
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/chosen.jquery.js"></script>
<script type="text/javascript" src="js/classie.js"></script>
<script type="text/javascript" src="js/selectFx.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>


<!-- end: TABLE DATA -->

<!-- Classie - class helper functions by @desandro https://github.com/desandro/classie -->
<script src="js/classie.js"></script>

<script>
	$(document).ready(function(){
                   $("#user_form").validate();
		$(window).scroll(function () {
				if ($(this).scrollTop() > 100) {
					$('.scrollup').fadeIn();
				} else {
					$('.scrollup').fadeOut();
				}
			});
		
			$('.scrollup').click(function () {
				$("html, body").animate({
					scrollTop: 0
				}, 600);
				return false;
		});
		
		<!-- Slide Push Menus Starts -->
		
		var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
		menuRight = document.getElementById( 'cbp-spmenu-s2' ),
		showLeft = document.getElementById( 'showLeft' ),
		showRight = document.getElementById( 'showRight' ),
		
		body = document.body;

	showLeft.onclick = function() {
		classie.toggle( this, 'active' );
		classie.toggle( menuLeft, 'cbp-spmenu-open' );
		disableOther( 'showLeft' );
	};
	showRight.onclick = function() {
		classie.toggle( this, 'active' );
		classie.toggle( menuRight, 'cbp-spmenu-open' );
		disableOther( 'showRight' );
	};
	

	function disableOther( button ) {
		if( button !== 'showLeft' ) {
			classie.toggle( showLeft, 'disabled' );
		}
		if( button !== 'showRight' ) {
			classie.toggle( showRight, 'disabled' );
		}
	}
	
	<!-- Slide Push Menus Ends -->
	
   });	
</script>

</body>
