<div class="modal fade" id="change-secret-code-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_secret_code');?></h5>
                </div>
                <div class="modal-body">
                    <form id="change-secret-code-form" action="javascript:void(0);">
                        <div class="row">
                            <?php echo Forms::AlertDiv('secret_code_alert'); ?>
                        </div>
                        <div class="row">
                            <input type="hidden" name="secret_code_user_id" id="secret_code_user_id"/>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('secret_code');?></label>
                                    <span class="red-star">*</span>
                                    <input class="current_secret_code full-width form-control empty"  name="current_secret_code" type="password" required autocomplete="off"/>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class=""><?php echo CommonLanguage::getMessage('confirm_secret_code');?></label>
                                    <span class="red-star">*</span>
                                    <input class="confirm_secret_code full-width form-control empty"  name="confirm_secret_code" 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_secret_code" class="btn bg-info-light text-white ">Submit</button>
                </div>
                <?php echo Forms::ModalLoader('changeSecretCodeDisabler'); ?>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){ 
        $('#usersTable').on('click','.change_secret_code',function(){
            $("#secret_code_user_id").val($(this).parents('div.Action').attr('data-id'))
        });
        $("#submit_secret_code").on("click",function(){
            if(!$("#change-secret-code-form").valid()){
                return;
            }
            if($('#change-secret-code-modal input[name=current_secret_code]').val() != $('#change-secret-code-modal input[name=confirm_secret_code]').val()){
                AddAlert("#secret_code_alert", '<?php echo CommonLanguage::getMessage('secret_code_doesnt_match');?>', "danger");
                return;
            }
            var Data = new FormData(document.getElementById('change-secret-code-form'));
            $("#changeSecretCodeDisabler").removeClass('hidden');
            $.ajax({
                url: "SettingsAjax/submitSecretCode",
                method: "POST",
                data: Data,
                processData: false,
                contentType: false,
                dataType: "JSON",
                complete: function (jqXHR, status) {
                    if (status == 'success') {
                        if (jqXHR.responseJSON[1] == "success") {
                            hideModalAlert('change-secret-code-modal', 'secret_code_alert');
                        }
                        AddAlert("#secret_code_alert", jqXHR.responseJSON[0], jqXHR.responseJSON[1]);
                    }
                    $("#changeSecretCodeDisabler").addClass('hidden');
                }
            });
        });
    });
</script>