<?php
include("config/config.php");
include("classes/classQueryGlobal.php");
include("classes/classFilter.php");
include("classes/classMyException.php");
include("classes/classSecurity.php");
include("classes/classUser.php");     




	
$securityOb = classSecurity::getUser();

if(isset($_POST['referrer']))
{
	
	try
	{
		if(isset($_POST['remember_me']))
		{
			$year = time() + 31536000;
			setcookie('remember_me', $_POST['user_name'], $year);
			setcookie('password', $_POST['password'], $year);
			
		}
		else
		{
			if(isset($_COOKIE['remember_me'])) 
			{
				$past = time() - 100;
				setcookie(remember_me, gone, $past);
				setcookie(password, gone, $past);
			}
		}
		
		$securityOb->loginUserSpp();
		
		//include('cron.php');
		
		if(isset($_SESSION['security']['userrole_id'])&&$_SESSION['security']['userrole_id']==1)
		{
			header("location:signin/organization.php");
		}
		else
		{
			header("location:signin/home.php");
		}
		exit;
		
	}
	catch(MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
	
	
}
?>
<!DOCTYPE html>
<html>
<head> 
    <link rel="shortcut icon" href="images/favicon.png">
<title>Med2TEC Hospital Management Information System</title>
<!--Core CSS -->
<link href="bs3/css/bootstrap.min.css" rel="stylesheet">

	<link href="bs3/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-reset.css" rel="stylesheet">
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />

    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet" />
    <link href="css/custom.css" rel="stylesheet" />
   
</head>
<body>
<script type="text/javascript">

     function Popup(apri) { 
        window.open(apri,"","top=10,left=200,width=800,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
     }
</script> 
<section id="container">
    <!--header start-->
    <header class="header fixed-top clearfix">
        <!--logo start-->
        <div class="brand">

            <a href="http://www.med2tec.com" class="logo" target="_blank">
                <img src="images/logo.png" alt="">
            </a>
            <div class="sidebar-toggle-box">
                <div class="fa fa-bars"></div>  
            </div>
        </div> 
        <!--logo end-->

        <div class="nav notify-row" id="top_menu" style="float:right;">
            <!--  notification start -->
             
            <!--  notification end -->
        </div>
        <div class="top-nav clearfix">
           
        </div>
    </header>
    <!--header end-->
    <!--sidebar start-->
   
    <!--sidebar end-->
    <!--main content start-->
  <section id="main-content">
    <section class="wrapper">
      <!--mini statistics start-->

      <header class="panel-heading">
            <img src="images/titlehmis.png">
          </header>
          <br>
          
          <?php
			if(isset($error_message)&&$error_message!='')
			{
				?>
				<span class="message_red" style="float:left;"><?php echo $error_message;?></span>
				<?php
			}
			?>
          <br><br>
          <form class="" action="" method="post">
      
        <h4>Sign In!</h4>
       <br>
            
                <input type="text" name="user_name" class="form-control" placeholder="User Name" value="<?php if(isset($_COOKIE['remember_me'])){ echo $_COOKIE['remember_me'];} ?>" autofocus style="width:20%;">
                <br>
                
                <input type="password" name="password" value="<?php if(isset($_COOKIE['password'])){ echo $_COOKIE['password'];} ?>" class="form-control" placeholder="Password" style="width:20%;">
                
            
            <label class="checkbox">
                <input type="checkbox" name="remember_me" <?php if(isset($_COOKIE['remember_me'])){ echo 'checked';} ?>> Remember me
                <!--<span class="pull-right">
                    <a data-toggle="modal" href="#myModal"> Forgot Password?</a>

                </span>-->
            </label><br>
            
            <button class="btn btn-success btn-sm" type="submit">Sign in</button>

            <br><br>
                Don't have an account yet?<br>
                
                    Contact us at <a class="" href="mailto:info@med2tec.com">info@med2tec.com</a> to Register
                
                

          
		<input type="hidden" value="<?php if(isset($_SERVER['HTTP_REFERER'])) { echo $_SERVER['HTTP_REFERER']; }?>" name="referrer" />
      </form>
               
      
<div style="position: absolute; padding-left: 256px; bottom: 10%; left: 0px; top: 613px;"><a href="http://www.softusion.com/" target="_blank"><img width="30" height="40" src="images/SoftusionLOGO.png" alt=""><span style="font-size: 11px; float: right; margin-top: 15%;">Designed by Softusion Inc.</span></a></div>
        
     
    </section>
  </section>
  <!--main content end-->
<!--right sidebar start-->

<!--right sidebar end-->
</section>
<!-- Placed js at the end of the document so the pages load faster -->
<!--Core js-->
<!--<script src="../js/jquery-1.10.2.min.js"></script>-->
  
<script src="js/lib/jquery.js"></script>
<script src="bs3/js/bootstrap.min.js"></script>


</body>
</html>