<?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 lang="en">
<head>
    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="images/favicon.html">

    <title>Login</title>

    <!--Core CSS -->
    <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" />

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="js/ie8/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>

  <body class="login-body">

    <div class="container">

      <form class="form-signin" action="" method="post">
      
        <h2 class="form-signin-heading">sign in now</h2>
        
        <div class="login-wrap">
         	<?php
			if(isset($error_message)&&$error_message!='')
			{
				?>
				<span class="message_red" style="float:left;"><?php echo $error_message;?></span>
				<?php
			}
			?>
            <div class="user-login-info">
                <input type="text" name="user_name" class="form-control" placeholder="User Name" value="<?php if(isset($_COOKIE['remember_me'])){ echo $_COOKIE['remember_me'];} ?>" autofocus>
                
                <input type="password" name="password" value="<?php if(isset($_COOKIE['password'])){ echo $_COOKIE['password'];} ?>" class="form-control" placeholder="Password">
            </div>
            
            <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-lg btn-login btn-block" type="submit">Sign in</button>

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

        </div>

          <!-- Modal -->
          <!--<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
              <div class="modal-dialog">
                  <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">Forgot Password ?</h4>
                      </div>
                      <div class="modal-body">
                          <p>Enter your e-mail address below to reset your password.</p>
                          <input type="text" name="email" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">

                      </div>
                      <div class="modal-footer">
                          <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
                          <button class="btn btn-success" type="button">Submit</button>
                      </div>
                  </div>
              </div>
          </div>-->
          <!-- modal -->
		<input type="hidden" value="<?php if(isset($_SERVER['HTTP_REFERER'])) { echo $_SERVER['HTTP_REFERER']; }?>" name="referrer" />
      </form>

    </div>



    <!-- Placed js at the end of the document so the pages load faster -->

    <!--Core js-->
    <script src="js/lib/jquery.js"></script>
    <script src="bs3/js/bootstrap.min.js"></script>

  </body>
</html>
