<?php
session_start(); 
include("include/db.conn.php");
include("include/conf.class.php");
include("include/admin.class.php");
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Universal Access </title>
	<link rel="icon" href="images/fevicon.png" type="image/png" sizes="16x16">
    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- Animate.css -->
    <link href="../vendors/animate.css/animate.min.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
  </head>

  <body class="login">
    <div>
      <a class="hiddenanchor" id="signup"></a>
      <a class="hiddenanchor" id="signin"></a>

      <div class="login_wrapper">
        <div class="animate form login_form">
          <section class="login_content">
        <?php  if(isset($_SESSION['LOGIN_STATUS']) && $_SESSION['LOGIN_STATUS']=="FAIL" || isset($_GET['customer'])){
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Please create a account or login before buying products.
                  </div>';
				  if(isset($_SESSION['msglog']) && $_SESSION['msglog']=="field_empty")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Please fill compulsory fiels.
                  </div>';
			}
			 if(isset($_SESSION['msglog']) && $_SESSION['msglog']=="email_error")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> E mail format is not correct.
                  </div>';
			}
			if(isset($_SESSION['msglog']) && $_SESSION['msglog']=='unkown_error')
			{
				echo '<div class="alert alert-danger alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Username doesnot exist. pls register.
                  </div>';
			}
			if(isset($_SESSION['msglog']) && $_SESSION['msglog']=='un_pw_error')
			{
				echo '<div class="alert alert-danger alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Username or Password error.
                  </div>';
			}
			if(isset($_SESSION['msglog']) && $_SESSION['msglog']=="denied_error")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Access denieded.
                  </div>';
			}
			if(isset($_SESSION['msglog']) && $_SESSION['msglog']=="sameemailerr")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> User already exists.
                  </div>';
			}
		?>
        
        <form  action="authenticate.php" method="post">
         <h1>Login Form</h1>
       		   <div>
                <input type="text" class="form-control" name="username" placeholder="Your E-mail"  />
              </div>
              <div>
                <input type="password" class="form-control" name="password" placeholder="Password"  />
                <input type="hidden" name="loginform" value="<?=md5("buy_product")?>">
                <input type="hidden" name="bk" value="<?=$_GET['bk']?>">
              </div>
             <div class="separator">
              <div>
              	<input class="btn btn-default submit" type="submit" value="Login">
                <a class="reset_pass" href="#">Lost your password?</a>
              </div>
              </div>
              <div class="clearfix"></div>
                <br />
               <div class="separator">
               <p class="change_link">New to site?
                  <a href="#signup" class="to_register"> Create Account </a>
                </p>
                <div>
                  <h1><i class="fa fa-universal-access"></i> Universal Access</h1>
                  <p>©2017 All Rights Reserved. Digital Dreams</p>
                </div>
              </div>
            </form>
          </section>
        </div>
        
        <?php
		unset($_SESSION['msglog']);
		} 
		else
		{
		?>
            <form  action="authenticate.php" method="post">
              <h1>Login Form</h1>
              <?php
		if(isset($_SESSION['msglog']) && $_SESSION['msgloglogin']){
			
			if($_SESSION['msglog']=="field_empty")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Please fill compulsory fiels.
                  </div>';
			}
			else if($_SESSION['msglog']=='un_pw_error')
			{
				echo '<div class="alert alert-danger alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Username or Password error.
                  </div>';
			}
			else if($_SESSION['msglog']=='unkown_error')
			{
				echo '<div class="alert alert-danger alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Username doesnot exist.
                  </div>';
			}
			else if($_SESSION['msglog']=="denied_error")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Access denieded.
                  </div>';
			}
			else if($_SESSION['msglog']=="company_error")
			{
			echo ' <div class="alert alert-warning alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning!</strong> Wrong Comany has been selected.
                  </div>';
			}
			unset($_SESSION['msglog']);
			unset($_SESSION['msgloglogin']);
		}
		?>
     
              <div>
                <input type="text" class="form-control" name="username" placeholder="Username" required/>
              </div>
              <div>
                <input type="password" class="form-control" name="password" placeholder="Password" required/>
                <input type="hidden" name="loginform" value="<?=md5("main_login")?>">
              </div>
              <div>
                <select class="form-control" name="company_id">
                 <?=$cartAdminMain->find_selected_company(); ?>
                </select>
              </div>
              

             <div class="separator">
              <div>
              	<input class="btn btn-default submit" type="submit" value="Login">
                <a class="reset_pass" href="#">Lost your password?</a>
              </div>
              <div class="clearfix"></div>
                <br />
              
                  <h1><i class="fa fa-universal-access"></i> Universal Access</h1>
                  <p>©2017 All Rights Reserved. Digital Dreams</p>
                </div>
              </div>
            </form>
          </section>
        </div>
		<?php } ?>
        <div id="register" class="animate form registration_form">
          <section class="login_content">
            <form action="authenticate.php" method="post">
              <h1>Create Account</h1>
              <div>
                <input type="text" class="form-control" name="NAME" placeholder="Your Name" required />
              </div>
              <div>
                <input type="email" class="form-control" name="username" placeholder="Email" required />
              </div>
              <div>
                <input type="password" class="form-control" name="password" placeholder="Password" required />
                <input type="hidden" name="loginform" value="<?=md5("new_user")?>">
                <input type="hidden" name="bk" value="<?=$_GET['bk']?>">
              </div>
              <div>
                <input class="btn btn-default submit" type="submit" value="Submit">
              </div>



              <div class="clearfix"></div>

              <div class="separator">
                <p class="change_link">Already a member ?
                  <a href="#signin" class="to_register"> Log in </a>
                </p>

                <div class="clearfix"></div>
                <br />

                <div>
                  <h1><i class="fa fa-universal-access"></i> Universal Access</h1>
                  <p>©2017 All Rights Reserved. Digital Dreams</p>
                </div>
              </div>
            </form>
          </section>
        </div>
      </div>
    </div>
    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
    <!-- validator -->
    <script src="../vendors/validator/validator.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
  </body>
</html>
