<?php
error_reporting(0);
session_start();
if(isset($_SESSION['username'])){

    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
        <meta charset="utf-8" />
        <?php include('includes/styles.php'); ?>
        <title>Reset Password | <?php echo $church_name; ?></title>


    </head>
    <body class="fixed-header dashboard">
<?php include('includes/sidebar.php'); ?>
    <!-- START PAGE-CONTAINER -->
    <div class="page-container ">
        <?php include('includes/header.php'); ?>
        <!-- START PAGE CONTENT WRAPPER -->
        <div class="page-content-wrapper ">
            <!-- START PAGE CONTENT -->
            <div class="content sm-gutter">
                <!-- START CONTAINER FLUID -->
                <div class="container-fluid padding-25 sm-padding-10">
                   <!-- START BREADCRUMB -->
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo $base_url; ?>">Home</a></li>
                    <li class="breadcrumb-item active">Reset Password </li>
                </ol>
                <!-- END BREADCRUMB -->


                <div class="row">
                    <section class="col-lg-12 connectedSortable">
                    <div class="alert alert-danger m-t-30" role="alert">
                      <button aria-label="" class="close" data-dismiss="alert"></button>
                      <strong>Note: </strong>Password must include one uppercase letter, one lowercase letter, one number, one special character such as $ or % and length should be between 6 and 16
                    </div>
                        <div class="card card-default">
                        <div class="card-header  ">
                            <div class="card-title"> Change Your Admin Password
                            </div>
                            <!-- <div class="card-controls">
                              <ul>
                                <li> <i class="fa fa-info-circle" data-toggle="tooltip" title="Only classes with attendance added are clickable">
                                    </i>
                                </li>
                            
                              </ul>
                            </div> -->
                          </div>
                            
                            <form action="" class="" method="post" id="change-password" enctype="multipart/form-data">
                                <div class="card-body">
                                    <div class="row">
                                    <div class="m-t-20 col-lg-12">
                                        
                                    
                                        <div class="form-group form-group-default input-group required" id="show_hide_password">
                                        <div class="form-input-group">
                                            <label>Old Password </label> 
                                            <input type="password"  name="old_password" id="password" class="form-control" placeholder="Enter Old Password Here"  required data-parsley-trigger="keyup">
                                        </div>
                                        <div class="input-group-append ">
                                            <a href="javascript:;" class="input-group-text"><i class="fa fa-eye-slash"></i></a>
                                        </div>
                                        </div>

                                        <div class="form-group m-t-20 form-group-default input-group required" id="show_hide_password2">
                                        <div class="form-input-group">
                                            <label>Confirm New Password </label> 
                                            <input type="password" name="new_password" id="password_2" class="form-control" placeholder="Enter New Password Here"  required data-parsley-trigger="keyup">
                                        </div>
                                        <div class="input-group-append ">
                                            <a href="javascript:;" class="input-group-text"><i class="fa fa-eye-slash"></i></a>
                                        </div>
                                        <input type="hidden" id="user" name="username" value="<?php echo $_SESSION['username']; ?>">
                                        </div>

                                        <div class="col-xl-4 m-t-30 m-b-40 clearfix" style="padding: 0;">
                                            <input aria-label="" type="submit" name="change_password" id="submit" value="Update Password" class="btn btn-primary pull-left btn-lg btn-block btn-animated from-left">
                                                
                                        </div>
                            


                      
                </div>

                                    
                                    
                                    </div>
                                </div>

                                <div id="success-msg"></div>

                            </form>

                        </div>
                    </section>

                       
                </div>
                    

                    
                    

                </div>
                <!-- END CONTAINER FLUID -->
            </div>
            <!-- END PAGE CONTENT -->
            <?php include('includes/foot.php'); ?>
        </div>
        <!-- END PAGE CONTENT WRAPPER -->
    </div>
    <!-- END PAGE CONTAINER -->
<?php include('includes/footer.php'); ?>

<script>
        $('#change-password');
        $('#change-password').on('submit', function(event){
            event.preventDefault();
            if ($('#change-password').parsley().isValid()){
                $.ajax({
                    url: "<?php echo $base_url; ?>process-admin-resetpassword.php",
                    method: "POST",
                    data: new FormData(this),
                    contentType: false,
                    processData: false,
                    beforeSend: function () {
                        $('#submit').attr('disabled', 'disabled');
                        $('#submit').val('Updating Password, Please Wait...');

                    },

                    success:function (data) {
                        $('#change-password').parsley().reset();
                        $('#submit').attr('disabled', false);
                        $('#submit').val('Update Password');
                        $('#success-msg').html(data);
                    }
                })
            }

        })
    </script>

<script>
   $(document).ready(function() {
    $("#show_hide_password a").on('click', function(event) {
        event.preventDefault();
        if($('#show_hide_password input').attr("type") == "text"){
            $('#show_hide_password input').attr('type', 'password');
            $('#show_hide_password i').addClass( "fa-eye-slash" );
            $('#show_hide_password i').removeClass( "fa-eye" );
        }else if($('#show_hide_password input').attr("type") == "password"){
            $('#show_hide_password input').attr('type', 'text');
            $('#show_hide_password i').removeClass( "fa-eye-slash" );
            $('#show_hide_password i').addClass( "fa-eye" );
        }
    });
});
</script>

<script>
   $(document).ready(function() {
    $("#show_hide_password2 a").on('click', function(event) {
        event.preventDefault();
        if($('#show_hide_password2 input').attr("type") == "text"){
            $('#show_hide_password2 input').attr('type', 'password');
            $('#show_hide_password2 i').addClass( "fa-eye-slash" );
            $('#show_hide_password2 i').removeClass( "fa-eye" );
        }else if($('#show_hide_password2 input').attr("type") == "password"){
            $('#show_hide_password2 input').attr('type', 'text');
            $('#show_hide_password2 i').removeClass( "fa-eye-slash" );
            $('#show_hide_password2 i').addClass( "fa-eye" );
        }
    });
});
</script>


<?php
}else{
    ?>
    
  <?php include('session.php'); ?>

    <?php

}

?>