<style type="text/css">
  body {background: url(<?php echo base_url() ?>assets/uploads/bg-image-login.jpg) !important; background-repeat: no-repeat !important; background-size: cover !important; background-position: center 10% !important; position: relative; }
  .bg-login-cover{     position: absolute; height: 100%; width: 100%; background: rgb(253 102 54 / 49%) } 
  .header-of-content .page-logo-text span {color: #51534A; display: block; }
  .header-of-content .page-logo-text {font-weight: bold; font-size: 25px; line-height: 35px; text-transform: uppercase; text-align: center; margin-bottom: 10px; }
  .form-control.is-invalid, .was-validated .form-control:invalid{ background-image: unset !important; border: unset !important;     box-shadow: unset !important; }
  html body .blankpage-form-field .card {background: rgba(255,255,255,0.4) !important; }
  .card.p-4 label{ color: #51534A !important;     font-weight: bold; }
  .form-group {margin-bottom: 12px !important; }
  button.btn.btn-primary.submit-btn.btn-block {background: #F55526  !important; box-shadow: unset !important; border: 0 !important; margin-top: 20px !important; text-transform: uppercase; padding: 10px; }
  html body .blankpage-form-field{ width: 370px !important; }
  .alert.alert-danger {margin-bottom: 0; border: 0; background: #fff; border-left: 5px solid #e7026e; padding: 11px; font-weight: 500; font-style: italic; }
  .alert.alert-success {margin-bottom: 0; border: 0; background: #fff; border-left: 5px solid #45a197; padding: 11px; font-weight: 500; font-style: italic; }
  .bottom_login_btn {margin-top: 10px; margin-bottom: 0; cursor: pointer; color: #443d28; font-size: 13px; }
  .bottom_login_btn:hover {color: #FFF;}
</style>
<div class="bg-login-cover"></div>
<div class="blankpage-form-field">
    <div class="header-of-content">
            <span class="page-logo-text mr-1">Hotel <span style="color:#FFF;">Compendium</span></span>
    </div>
    
    <?php if(isset($_REQUEST['action']) && $_REQUEST['action']=='update_password'):
      $userDetails = base64_decode($_REQUEST['token']);   
      $userDetails = explode('---', $userDetails);
     ?>
      <div class="card p-4">
        <form action="<?php echo base_url('Login'); ?>" method="post" id="form_login" class="was-validated form_none" >

          <div class="form-group input-rounded">
            <label>New Password</label>
            <input type="password" name="fsPassword" class="form-control" required>
            <input type="hidden" name="userId" class="form-control" value="<?php echo $userDetails[0] ?>">
            <input type="hidden" name="isUser" class="form-control" value="<?php echo $_REQUEST['isUser'] ?>">
          </div>

          <button type="submit" name="passwordUpdate" class="btn btn-primary submit-btn btn-block">Update Password</button>

        </form>


    </div>  
    <?php else: ?>
      <div class="card p-4">
          <form action="<?php echo base_url(); ?>" method="post" id="form_login" class="was-validated form_none" >

            <?php if(isset($isError)): ?>
              <div class="form-group input-rounded">
                <div class="alert alert-danger">
                  <?php echo $isError; ?>
                </div>
              </div>
            <?php endif; ?>

            <?php if(isset($_REQUEST['action']) && $_REQUEST['action']=='logout'): ?>
              <div class="form-group input-rounded">
                <div class="alert alert-success">
                  <?php echo "You are successfully logged out, Thanks for visit."; ?>
                </div>
              </div>
            <?php endif; ?>

            <div class="form-group input-rounded"><label>Email Address</label><input type="text" name="fsEmail" class="form-control" required></div>
            <div class="form-group input-rounded"><label>Password</label><input type="password" name="fsPassword" class="form-control" required></div>

            <button type="submit" class="btn btn-primary submit-btn btn-block">Login</button>
            <p id="show" class="bottom_login_btn">I Forgot My Password</p>

          </form>

          <div class="forget_password">
             
              <form action="#" id="form_reset_pwd" method="post" class="was-validated forgot_pass forgot_pwd_form" style="display: none;">
                
                <div class="form-group input-rounded has-feedback"><label>Email Address</label><input type="email" name="fsEmail" class="form-control required email" id="forget_email" required></div>
                <div class="response_handler"></div>
                <button type="submit" class="btn btn-primary submit-btn btn-block forgot_password">Forgot Password</button>
                <p id="hidden" class="bottom_login_btn">Back to Login</p>
              </form>
              <?php if($error = $this->session->flashdata('msg')){ ?>
                   <p style="color: green;"><strong>Success!</strong> <?php echo  $error; ?><p>
              <?php } ?>
          </div>

      </div>  
    <?php endif; ?>

</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> 

<script>
$(document).ready(function(){
  
  $("#show").click(function(){
    $(".form_none").hide();
    $(".forgot_pass").show();
  });

  $("#hidden").click(function(){
    $(".forgot_pass").hide();
    $(".form_none").show();
  });
});

</script>

<script>

$(document).on('submit','#form_reset_pwd',function(){
  var url = "<?php echo base_url('login/check_admin_email_exist')?>";       
  if($('#form_reset_pwd').valid()){ 
    $.ajax({
      type: "POST",
      url: url,
      data: $("#form_reset_pwd").serialize(), // serializes the form's elements.
      success: function(data) { 
        $('.response_handler').html(data);                   
      }
    });
  }
  return false;
});
</script>
