<div style="display: none;">
    <div id="DatabaseClearSecret">
        <div class="popup-header toolbar-header">
            <div class="popup-title">Database Clear Secret</div>
            <div class="popup-close-btn" onclick="zamanEposPopupcloser()"><span class="icon icon-cancel"></span></div>
        </div>
        <div class="popup-content">
            <?php echo form_open('settings/cleardatabse', array('id' => 'databaseSecretForm', 'enctype' => 'multipart/form-data')); ?>
            <div class="neworder-table-guest collection-phone ccfee">
                <div class="form-group">
                    <input type="password" name="secret" class="form-control" placeholder="secret">
                </div>
                <div class="clearfix"></div>
                <br/> <hr/>
                <div class="tab-group config-submit">
                    <button type="submit" onclick="checkDatabaseSecretAndClear('databaseSecretForm')"><span class="icon icon-folder"></span>&nbsp;<?php echo $this->lang->line('go') ?></button>
                </div>
            </div>
            <?php echo form_close() ?>
        </div>
    </div>
</div>
<script type="text/javascript">
    function zamanDatabaseClearSecretPopup() {
        $.colorbox({
            inline: true,
            scrolling: false,
            href: "#DatabaseClearSecret",
            width: '40%',
            height: '175px',
            maxWidth: "100%",
            open: true,
            closeButton: false,
            transition: 'elastic',
            overlayClose: false,
            onClosed: function () {
                resetForm('databaseSecretForm');
            }
        });
    }
    function checkDatabaseSecretAndClear(formId) {
        if (!$('.page-loader').is(":visible")) {
            $('.page-loader').show();
            $('#' + formId).validate({
                submitHandler: function () {
                    var myform = document.getElementById(formId);
                    var formdata = new FormData(myform);
                    if (checkInternetConnection()) {
                        $.ajax({
                            url: $('#' + formId).attr('action'),
                            data: formdata,
                            cache: false,
                            processData: false,
                            contentType: false,
                            type: 'POST',
                            dataType: 'json',
                            success: function (response) {
                                $('.page-loader').hide();
                                if (response.status) {
                                    zamanEposPopupcloser();
                                    forgeLocalDb();
                                } else {
                                    warning('<?php echo $this->lang->line('error') ?>', 'You are not a preveleged user to clear data', '<?php echo $this->lang->line('ok') ?>');
                                }
                            }
                        });
                    } else {
                        warning('<?php echo $this->lang->line('lost_connection') ?>', '<?php echo $this->lang->line('lost_connection_message') ?>', '<?php echo $this->lang->line('close') ?>');
                    }
                }
            });
        }
    }
</script>