<?php
   include('include/config.php');
   $date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
   $timenow=$date->format('Y-m-d H:i:s');
   $timenow2=$date->format('Y-m-d');
   $month=$date->format('M');
   error_reporting(0);
   
   $_SESSION = array();
   
   if (ini_get("session.use_cookies")) {
       $params = session_get_cookie_params();
       setcookie(session_name(), '', time() - 42000,
           $params["path"], $params["domain"],
           $params["secure"], $params["httponly"]
       );
   }
   session_destroy();
   session_start();
   ob_start();

   $query=mysqli_query($con,"select * FROM companydata");
   while($row=mysqli_fetch_array($query))
   {
   $com_name=$row["School"];
   $_SESSION['com_photo']=$com_photo;
   $_SESSION['com_id']=$row["id"];
   } 
   ?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title><?php echo $com_name; ?></title>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
      <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
      <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css">
      <link rel="stylesheet" href="dist/css/adminlte.min.css">
      <link rel="shortcut icon" href="images/schicon.ico">
      <style>
         .logo{
         max-height:100px;
         }
         body{
         background-color:#001a33;
         }
         .card{
         box-shadow: 0 0 0 10px #4fc3dc44,
         0 0 50px #4fc3dc, 0 0 100px #4fc3dc;
         border-radius: 5px;
         }
      </style>
   </head>
   <body class="login-page" >
      <div class="login-box">
         <!-- /.login-logo -->
         <div class="card">
            <div class="card-body login-card-body">
               <center>
                  <h5 style="color:#004d00"><strong><?php echo $com_name; ?></strong></h5>
               </center>
               <center><img class="logo" src="images/schicon.ico" /></center>
                <?php
                if(isset($_GET["page"]))
                {
                  $pg=$_GET["page"];
                  if($pg=='Log_in')
                  {
                    include('hom.php');
                  }else if($pg=='Password_Recovery')
                  {
                    include('Pass.php');
                  }else
                  {
                     include('hom.php');
                  }
                }else{ 
                include('hom.php');
                } 
                ?>
               <div class="social-auth-links text-center mb-3">
               </div>
               <!-- /.social-auth-links -->
               <p class="mb-1">
                  <table class="table" style="font-size:12px">
                     <tr>
                        <td><a href="index.php?page=Log_in">Login</a></td>
                        <td><a href="index.php?page=Password_Recovery">I forgot my password</a></td>
                     </tr>
                  </table>
               </p>
            </div>
            <!-- /.login-card-body -->
         </div>
      </div>
      
      <script src="plugins/jquery/jquery.min.js"></script>
      <script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
      <script src="dist/js/themain.js"></script>
      <script src="dist/js/adminlte.min.js"></script>
      <script src="plugins/jquery-validation/jquery.validate.min.js"></script>
      <script src="plugins/jquery-validation/additional-methods.min.js"></script>
     
       <script>
       $(document).ready(function(){ 
          $("#btnsendd").click(function(){
          $('#msgmsg').html('').css('color', 'green');
         
          var em=document.getElementById('email').value; 
          if(em=='')
          {
            
          }else
          {
          $.ajax({
           url:"sendpassword.php",
           method:"POST",
           data:{emm:em,msg:'msg'},
           success:function(data)
           {
             if(data=='success')
             {
              $('#msgmsg').html("New PASSWORD has been sent to your email").css('color', 'green');   
                 
             setInterval(function () 
            {
            $('#msgmsg').html('').css('color', 'green'); 
            }, 4000);
             }else
             {
             $('#msgmsg').html(data).css('color', 'red');  
             }
           }
          });
          }
        });
        }); 
</script>

 <script>
       $(document).ready(function(){ 
          $("#btnsend").click(function(){
          $('#msgmsg').html('').css('color', 'green');
         
          var em=document.getElementById('email').value; 
          if(em=='')
          {
            
          }else
          {
          $.ajax({
           url:"sendpassword.php",
           method:"POST",
           data:{em:em},
           success:function(data)
           {
             if(data=='success')
             {
              $('#msgmsg').html("New PASSWORD has been sent to your email").css('color', 'green');   
                 
             setInterval(function () 
            {
            $('#msgmsg').html('').css('color', 'green'); 
            }, 4000);
             }else
             {
             $('#msgmsg').html(data).css('color', 'red');  
             }
           }
          });
          }
        });
        }); 
</script>

     
<script>
 if ( window.history.replaceState ) {
 window.history.replaceState( null, null, window.location.href );
 }
</script>
<script>
 $(function () {
   
   $('#loginform').validate({
     rules: {
       email: {
         required: true,
         email: true,
       },
       password: {
         required: true,
         minlength: 5
       },
       terms: {
         required: true
       },
     },
     messages: {
       email: {
         required: "Please enter a email address",
         email: "Please enter a valid email address"
       },
       password: {
         required: "Please provide a password",
         minlength: "Your password must be at least 5 characters long"
       },
       terms: "Please accept our terms"
     },
     errorElement: 'span',
     errorPlacement: function (error, element) {
       error.addClass('invalid-feedback');
       element.closest('.form-group').append(error);
     },
     highlight: function (element, errorClass, validClass) {
       $(element).addClass('is-invalid');
     },
     unhighlight: function (element, errorClass, validClass) {
       $(element).removeClass('is-invalid');
     }
   });
 });
</script>
   </body>
</html>