<?php 



include('libraryPHP/site_config.php');

include('libraryPHP/session_check_url.php');





?>


<!DOCTYPE html>

<html lang="en">



<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">

    <title><?php echo $appName?> | <?php echo $pageTitle?></title>



    <!-- theme css start -->

    <?php include("theme_css.php"); ?>

    <!-- theme css end -->

    <style>

        .eye {

            position: absolute;

            right: 4%;

            transform: translate(0, -176%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword1 {

            position: absolute;

            right: 52%;

            transform: translate(0, -176%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword2 {

            position: absolute;

            right: 154%;

            transform: translate(0, -174%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword3 {

            position: absolute;

            right: 52%;

            transform: translate(0, -176%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword4 {

            position: absolute;

            right: 154%;

            transform: translate(0, -174%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword5 {

            position: absolute;

            right: 52%;

            transform: translate(0, -174%);

            top: auto;

            cursor: pointer;

        }



        #togglePassword6 {

            position: absolute;

            right: 154%;

            transform: translate(0, -174%);

            top: auto;

            cursor: pointer;

        }
        


    </style>




</head>



<body>



    <!-- Main Wrapper -->

    <div class="main-wrapper">



        <!-- Header start  -->

        <?php include("header.php"); ?>

        <!-- /Header end -->



        <!-- Sidebar -->

        <?php include("sidebar.php"); ?>

        <!-- /Sidebar -->



        <!-- Page Wrapper -->

        <div class="page-wrapper">



            <div class="content container-fluid">



                <!-- Page Header -->

                <div class="page-header">

                    <div class="row">

                        <div class="col">

                            <h3 class="page-title">Chanage User Password</h3>

                            <ul class="breadcrumb">

                                <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
                                <li class="breadcrumb-item"><a href="manage_user.php">User list</a></li>

                                <li class="breadcrumb-item active">Chanage User Password</li>

                            </ul>

                        </div>

                    </div>

                </div>

                <!-- /Page Header -->



                <!-- start write start -->

                <div class="col-12">



                    <div class="card">



                        <div class="card-body">

                         



                         <form method="POST" id="add_subadmin_form" class="form-horizontal"
                         enctype="multipart/form-data">
                         <input required="required" type="hidden" id="action" name="action"
                         value="edit_user_password">

                         <input required="required" type="hidden" id="user_id" name="user_id"
                         value="<?php echo $getUsersData['user_id']?>">

                         <div class="form-group row">

                            <label class="col-form-label col-md-2">Name</label>

                            <div class="col-md-10">

                                <input type="text" class="form-control" value="<?php echo $getUsersData['name']?>" placeholder="Enter  Name" name="name" readonly>

                            </div>

                        </div>

                        


                     <div class="form-group row">

                        <label class="col-form-label col-md-2">Email</label>

                            <div class="col-md-10">

                                <input type="email" class="form-control" name="email" id="email" placeholder="Enter Email" value="<?php echo $getUsersData['email']?>" readonly>

                            </div>

                        </div>

                        

                        <div class="form-group row">

                            <label class="col-form-label col-md-2">Password</label>

                            <div class="col-md-10">

                             <input type="password" class="form-control" id="new_password" name="password" placeholder="Enter  Password" maxlength="16">

                             <span class="eye" onclick="myfunction2()">

                                <i class="far fa-eye-slash " id="togglePassword3"></i>

                                <i class="far fa-eye " id="togglePassword4" style="display:none;"></i>

                            </span>

                        </div>

                    </div>


                    <div class="form-group row">

                        <label class="col-form-label col-md-2">Confirm Password</label>

                        <div class="col-md-10">

                          
                            <input type="password" class="form-control" id="confirm_password" name="cpassword" placeholder="Enter Confirm Password" maxlength="16">

                            <span class="eye" onclick="myfunction3()">

                                <i class="far fa-eye-slash " id="togglePassword5"></i>

                                <i class="far fa-eye " id="togglePassword6" style="display:none;"></i>

                            </span>

                        </div>

                    </div>

                    



                    

                    


                    
                    

                    



                                                    <!-- <div class="form-group row">

                                                        <label class="col-form-label col-md-2">Textarea</label>

                                                        <div class="col-md-10">

                                                            <textarea rows="5" cols="5" class="form-control" placeholder="Enter text here"></textarea>

                                                        </div>

                                                    </div> -->



                                                    <div class="form-group row">

                                                        <label class="col-form-label col-md-2"></label>

                                                        <div class="col-md-10">

                                                            <button class="btn btn-primary "  type="submit">Change Password</button>

                                                        </div>

                                                    </div>





                                                </form>




                                            </div>



                                        </div>



                                    </div> <!-- end col -->



                                    <!-- start write end -->

                                </div>

                            </div>

                            <!-- /Page Wrapper -->

                            <!-- footer start -->

                            <?php include("footer.php"); ?>

                            <!-- footer end -->



                        </div>

                        <!-- /Main Wrapper -->



                        <!-- sctipt start  -->

                        <?php include('commonjs.php')?>

                        <?php include_once('extrajs.php') ?>
                        <!-- script end -->

                        <script>

                           jQuery.validator.addMethod("noSpace", function(value, element) { 
                              return value == '' || value.trim().length != 0;  
                          }, "No space please and don't leave it empty");


                           $.validator.addMethod("customemail", 
                            function(value, element) {
                                return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(value);
                            }, 
                            "Enter valid email"
                            ); 
                           $('#add_subadmin_form').validate({
                            rules: {
                             
                             password: {

                                required: true,

                                minlength: 6,

                                maxlength: 16,
                                noSpace: true

                            },

                            cpassword: {

                                required: true,

                                minlength: 6,

                                maxlength: 16,

                                equalTo: "#new_password",
                                noSpace: true,

                            },
                            
                            

                            

                            

                            
                            

                            

                        },
                        messages: {
                         
                            
                         password: {

                            required:"Please enter password",

                            minlength:"password  must be at least 6 characters ",

                            maxlength: "Please enter  maximum 16  characters  ",

                        },

                        cpassword: {
                            required:"Please enter  confirm password",

                            minlength:"confirm password  must be at least 6 characters ",

                            maxlength: "Please enter  maximum 16  characters  ",

                            equalTo: "confirm password does not matched!",

                        },
                        


                    },
                    

                    submitHandler:function(form,e){

                     
                       
                      

       //e.preventDefault();
       var link=URLAPI+'user_controller.php';
       var data = new FormData($(form)[0]);
       var message = msgLoading.blankMessage[language];
       console.log('message',message);

       apiRequest.postFile(link,data,message).then(function(obj){
          if(obj.success === true){
            var title ='';
            var message = obj.msg[language];
            swal_alert(title,message,"manage_user.php","success");
        // $('#add_driver').modal('hide');
        // $('#image-holder').attr('src','');
        // getUserTable('first', 'all');
        return false;

    }else{
        var title = msgTitleOperation.StaffNotAdded[language];
        var message = obj.msg[language];
        swal_alert(title,message,'#','error');
        return false;
    }
},function(err){

  consoleProvider.log('err',err);
  var title    = msgTitleOperation.errorOnServer[language];
  var messsage = msgOperations.errorOnServer[language];
  swal_alert(title,message,"#","warning");
  return false;

});

  }//end of submit handler
});</script>
<script>

    function myfunction1() {

        var x = document.getElementById("oldpassword");

        var y = document.getElementById("togglePassword1");

        var z = document.getElementById("togglePassword2");



        if (x.type === 'password') {

            x.type = "text";

            y.style.display = "none";

            z.style.display = "block";

        } else {

            x.type = "password";

            y.style.display = "block";

            z.style.display = "none";

        }

    }



    function myfunction2() {

        var x = document.getElementById("new_password");

        var y = document.getElementById("togglePassword3");

        var z = document.getElementById("togglePassword4");



        if (x.type === 'password') {

            x.type = "text";

            y.style.display = "none";

            z.style.display = "block";

        } else {

            x.type = "password";

            y.style.display = "block";

            z.style.display = "none";

        }

    }



    function myfunction3() {

        var x = document.getElementById("confirm_password");

        var y = document.getElementById("togglePassword5");

        var z = document.getElementById("togglePassword6");



        if (x.type === 'password') {

            x.type = "text";

            y.style.display = "none";

            z.style.display = "block";

        } else {

            x.type = "password";

            y.style.display = "block";

            z.style.display = "none";

        }

    }

</script>

<script>
        // for image validation
        $("#fileUpload1").on('change', function () {
        //----------------- Image Preview and validation code start here -------------------
        var countFiles = $(this)[0].files.length;
        if(countFiles==0){
            $(this)[0].value='';
            var image_holder = $("#image_holder1");
            $(image_holder).attr('src', ' ');
                // notifyMessage.warning('Warning!', 'This browser does not support FileReader');
                return false;
            }else{
                var imgPath = $(this)[0].value;
                var extn = imgPath.substring(imgPath.lastIndexOf('.') + 1).toLowerCase();
                var image_holder = $("#image_holder1");
                console.log('fffdfh',image_holder);
                image_holder.empty();
                console.log('123',image_holder);
                console.log('countFiles',countFiles);

                if (extn == "png" || extn == "jpg" || extn == "jpeg") {
                    if (typeof (FileReader) != "undefined") {
                        for (var i = 0; i < countFiles; i++) {
                            var reader = new FileReader();
                            reader.onload = function (e) {
                                $(image_holder).attr('src', e.target.result);
                            }
                            image_holder.show();
                            reader.readAsDataURL($(this)[0].files[i]);
                        }

                    }else {
                        $(this)[0].value='';
                    // notifyMessage.warning('Warning!', 'This browser does not support FileReader');
                    return false;
                }

            }else {
                $(this)[0].value='';
                swal({
                    // title: title,
                    text: 'You can choose only("jpeg","jpg","png")file',
                    icon: "warning", //error, success, info
                    button: "Ok",
                })
                return false;
            }

        }
        
        //----------------- Image Preview and validation code end here -------------------
    });
</script>



</body>



</html>