<div class="modal fade" id="change-password-modal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content-wrapper">
            <div class="modal-content">
                <div class="modal-header clearfix text-left">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-20"></i>
                    </button>
                    <h5 class="add-label bold"><?php echo CommonLanguage::getMessage('change_password');?></h5>
                </div>
                <div class="modal-body">
                    <form id="change-password-form" action="javascript:void(0);">
                        <div class="row">
                            <?php echo Forms::AlertDiv('password_alert'); ?>
                        </div>
                        <div class="row">
                            <input type="hidden" name="current_user_id" id="password_user_id"/>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('password');?></label>
                                    <span class="red-star">*</span>
                                    <input class="current_user_password full-width form-control empty"  name="current_user_password" type="password" required autocomplete="off"/>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('confirm_password');?></label>
                                    <span class="red-star">*</span>
                                    <input class="confirm_password full-width form-control empty"  name="confirm_password" type="password" required autocomplete="off"/>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default " data-dismiss="modal">Close</button>
                    <button type="button" id="submit_password" class="btn bg-info-light text-white ">Submit</button>
                </div>
                <?php echo Forms::ModalLoader('changePasswordDisabler'); ?>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){ 
        $("a.change-login-password").on('click',function(){
            $("#password_user_id").val(0)
        });
        $('#usersTable').on('click','.change_password',function(){
            $("#password_user_id").val($(this).parents('div.Action').attr('data-id'))
        });
        $("#submit_password").on("click",function(){
            if(!$("#change-password-form").valid()){
                return;
            }
            if($('#change-password-modal input[name=current_user_password]').val() != $('#change-password-modal input[name=confirm_password]').val()){
                AddAlert("#password_alert", '<?php echo CommonLanguage::getMessage('password_doesnt_match');?>', "danger");
                return;
            }
            var Data = new FormData(document.getElementById('change-password-form'));
            $("#changePasswordDisabler").removeClass('hidden');
            $.ajax({
                url: "SettingsAjax/submitPassword",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('change-password-modal', 'password_alert');
                        }
                        AddAlert("#password_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#changePasswordDisabler").addClass('hidden');
                }
            });
        });
    });
</script>