<?php
	//ob_start();
	session_start();  
    include_once("class/class.MySQL.php");
    $db	=new MySQL();
/*	if(isset($_POST['btnsubmit']))
	{
		$username = $_POST['username'];
		$password = $_POST['password'];
		$salaryPaidReport = $db->ExecuteSQL("SELECT * FROM employee where username ='$username' and password = '$password' ");
		//print_r($this->records);
		//echo "SELECT * FROM employee where username =$username and password = $password  ";
		//print_r($salaryPaidReport);
		//echo mysql_num_rows($salaryPaidReport);
		//echo count($salaryPaidReport);
	}*/
	
	
	//echo $user=$_SESSION['ses_name'];
	//echo "hiiiiii";
	//if(isset($_POST['btnsubmit']))

//{

	//if($_POST['username']!="" && $_POST['password']!="")

   //{

		$username		=$_SESSION['ses_name'];

		//$password		=$_REQUEST['password'];
		 
		$sel_qry		="SELECT * FROM employee where username ='$username'";
		$sel_res		=mysql_query($sel_qry);
		if($sel_res && mysql_num_rows($sel_res)>0)
		{
			while($sel_data=mysql_fetch_object($sel_res))
			{
				if($sel_data->status == '1')
				{
					$_SESSION['admin_id']=$sel_data->e_id;	
					$_SESSION['username']=$sel_data->username;
					$_SESSION['ses_mailid']=$sel_data->email;
					$branch_id=$_SESSION['branch_id']=$sel_data->branchid;	
					$_SESSION['depart_id']=$sel_data->departid;	
					$_SESSION['usertype']=$sel_data->user_type;	
					$_SESSION['branchadmin']=$sel_data->branch_admin;
					
					$sel_brnch_qry="SELECT * FROM branches where branch_id='$branch_id'";
					$sel_brnch_res		=mysql_query($sel_brnch_qry);
					if($sel_brnch_res && mysql_num_rows($sel_brnch_res)>0)
					{
						while($sel_brnch_data=mysql_fetch_object($sel_brnch_res))
						{
							$_SESSION['branch_name']=$sel_brnch_data->branch_name;	
						}
					}
					
					if($_SESSION['usertype'] == 'Superadmin')
					{
						echo "<script>location.href='dashboard.php'</script>";
					}
					elseif($_SESSION['branchadmin'] == 'Y')
					{
						echo "<script>location.href='dashboard-branch.php'</script>";
					}
					else
					{
						echo "<script>location.href='profile-view.php?employ_id=".$_SESSION['admin_id']."'</script>";
					}

					exit;

				}
				else
				{
					$message="<img src=images/stop_nav.png width=25 height=25 align=absmiddle> We cannot log you into your account at this time. Please try again later.You are Blocked by the Administrator!";
				}
			}
		}
		/*else
		{
			$message="<img src=images/stop_nav.png width=25 height=25 align=absmiddle> We cannot log you into your account at this time. Please try again later.This is generally means your username or password is incorrect !";
		}
	}
	else
	{
		$message="<img src=images/stop_nav.png width=25 height=25 align=absmiddle> Required field cannot be left blank !";
	}*/
//}
	
?>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>HR Management</title>
<link rel="icon"  type="image/png" href="images/productivity.png">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/showpath.js" language="javascript"></script>
<link rel="stylesheet" href="css/style.css" />
<!-- Responsive -->
<script language="javascript" src="js/css3-mediaqueries.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/responsive.css" />
<!-- /Responsive -->
</head>

<body>
<div id="login-wrapper" style="margin-top:25px;">

<div class="login-header"><img src="images/logo.png" alt="" border="0" /></div><!-- /login-header -->
<form name="loginform" id="loginform" method="post" >
<div class="login-content">
<h1><translate>Login</translate></h1>

<div class="login-content-tab">
<div class="login-icon"><img src="images/icon-username.png" alt="" /></div>
<div class="login-content-row">
<p class="loginp1"><translate>Username:</translate></p>
<label><input name="username" type="text" placeholder="Username" /></label>
</div><!-- /login-content-row -->
<div class="clear-float"></div>
</div><!-- /login-content-tab -->

<div class="login-content-tab">
<div class="login-icon"><img src="images/icon-password.png" alt="" /></div>
<div class="login-content-row">
<p class="loginp1"><translate>Password:</translate></p>
<label><input name="password" type="password" placeholder="Password" /></label>
</div><!-- /login-content-row -->
<div class="clear-float"></div>
</div><!-- /login-content-tab -->

<div class="login-content-tab2">
<label class="floaleft"><input name="btnsubmit" type="submit" value="Login" /></label>
<div class="login-forget"><a href="forgotpassword.php"><translate>Forgot Password</translate>?</a></div>
<div class="clear-float"></div>
</div><!-- /login-content-tab2 -->

</div><!-- /login-content -->
</form>
<!--<div class="login-skip">
<label><input name="" type="button" value="Skip" /></label>
</div> /login-skip -->

<div class="login-footer">
<strong>© add-HRM</strong><br />
<span>Developed by <a href="http://www.aadhocc.com" target="_blank">Aadhocc</a></span></div>
<!-- /footer -->

</div><!-- login-wrapper ends -->

</body>
</html>
