{template "header.html"}
<div class="note note-danger">
    <p><a href="javascript:dr_update_cache();">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>
<script type="application/javascript">

</script>
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {$form}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green-sharp">
                    {dr_lang('接口密钥')}
                </span>
            </div>
            <div class="actions">
                <div class="btn-group">
                    <a class="btn" href="{$reply_url}"> <i class="fa fa-mail-reply"></i> {dr_lang('返回')}</a>
                </div>
            </div>
        </div>
        <div class="portlet-body">
            <div class="form-body">


                {$myfield}

                {if $id}
                <div class="form-group">
                    <label class="col-md-2 control-label">AppId</label>
                    <div class="col-md-9">
                        <div class="form-control-static"><label>{$id}</label></div>
                    </div>
                </div>
                {/if}

                <div class="form-group">
                    <label class="col-md-2 control-label">AppSecret</label>
                    <div class="col-md-9">
                        <label><input class="form-control input-large" type="text" name="data[secret]" id="sys_key" value="{$secret}"  ></label>
                        <label><button class="btn btn-sm blue" type="button" name="button" onclick="dr_to_key()"> {dr_lang('随机生成')} </button></label>
                        <span class="help-block">{dr_lang('密钥是认证接口的关键凭证请勿泄漏')}</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">数据库操作权限</label>
                    <div class="col-md-9">
                        <div class="mt-checkbox-inline">
                            <label class="mt-checkbox mt-checkbox-outline">
                                <input type="checkbox"  checked disabled > 读取
                                <span></span>
                            </label>
                            <label class="mt-checkbox mt-checkbox-outline">
                                <input type="checkbox" name="data[setting][action][]" {if dr_in_array('insert', $setting.action)} checked{/if} value="insert"> 插入
                                <span></span>
                            </label>
                            <label class="mt-checkbox mt-checkbox-outline">
                                <input type="checkbox" name="data[setting][action][]" {if dr_in_array('update', $setting.action)} checked{/if} value="update"> 更新
                                <span></span>
                            </label>
                            <label class="mt-checkbox mt-checkbox-outline">
                                <input type="checkbox" name="data[setting][action][]" {if dr_in_array('delete', $setting.action)} checked{/if} value="delete"> 删除
                                <span></span>
                            </label>
                        </div>
                        <span class="help-block">{dr_lang('对数据表数据增删改的操作权限')}</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">数据表权限</label>
                    <div class="col-md-9">
                        <input class="form-control " type="text" name="data[setting][table]" value="{htmlspecialchars($setting['table'])}" style="width:80%;"   data-role="tagsinput" />
                        <span class="help-block">{dr_lang('允许操作的数据表，一行一个表名称，必须是一个完整的不必带前缀的表名称')}</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label">{dr_lang('接口状态')}</label>
                    <div class="col-md-9">
                        <div class="mt-radio-inline">
                            <label class="mt-radio">
                                <input  {if !$disabled}checked{/if} name="data[disabled]" type="radio" value="0"> {dr_lang('正常')}
                                <span></span>
                            </label>
                            <label class="mt-radio">
                                <input  {if $disabled}checked{/if} name="data[disabled]" type="radio" value="1"> {dr_lang('禁用')}
                                <span></span>
                            </label>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存内容')}</button>
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$post_url}')" class="btn blue"> <i class="fa fa-plus"></i> {dr_lang('保存再添加')}</button>
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}')" class="btn yellow"> <i class="fa fa-mail-reply-all"></i> {dr_lang('保存并返回')}</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    function dr_to_key() {
        $.get("{dr_url('api/syskey')}", function(data){
            $("#sys_key").val(data);
        });
    }
</script>
{template "footer.html"}