{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <div class="am-alert am-alert-warning am-radius" data-am-alert>
            <button type="button" class="am-close">&times;</button>
            <p class="am-text-xs">PS：非开发人员请不要随意执行任何SQL语句，操作可能导致将整个系统数据库被删除。</p>
        </div>
        
        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
            <!-- form start -->
            <form class="am-form form-validation view-save" action="{{:MyUrl('admin/sqlconsole/implement')}}" method="POST" request-type="ajax-fun" request-value="ViewImplementBack">
                <div class="am-form-group">
                    <textarea rows="16" name="sql" class="am-radius" placeholder="SQL语句" data-validation-message="请填写需要执行的SQL语句" required></textarea>
                </div>
                <div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
                    <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">执行</button>
                </div>
            </form>
            <!-- form end -->
        {{else /}}
            <div class="am-alert">
                <p>如需要执行SQL 语句，请在 config/shopxo.php 文件中 is_develop值改为true开启开发者模式。</p>
            </div>
        {{/if}}

        <!-- tips -->
        <div class="sql-tips">
            <div class="am-alert am-alert-success am-radius" data-am-alert style="display: none;"></div>
            <div class="am-alert am-alert-danger am-radius" data-am-alert style="display: none;"></div>
        </div>
    </div>
</div>
<!-- right content end  -->
        
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

<script type="text/javascript">
    // 返回处理
    function ViewImplementBack(e)
    {
        $('form.form-validation').find('button[type="submit"]').button('reset');
        $.AMUI.progress.done();
        if(e.code == 0)
        {
            $.AMUI.progress.done();
            Prompt(e.msg, 'success');
            if((e.data || null) != null)
            {
                $('.sql-tips .am-alert-success').show();
                $('.sql-tips .am-alert-danger').hide();
                $('.sql-tips .am-alert-success').html(e.data);
            } else {
                $('.sql-tips .am-alert-success').hide();
                $('.sql-tips .am-alert-danger').hide();
            }
        } else {
            Prompt(e.msg);
            $('.sql-tips .am-alert-success').hide();
            $('.sql-tips .am-alert-danger').show();
            $('.sql-tips .am-alert-danger').html(e.msg);
        }
    }
</script>