{template "header.html"}
<div class="note note-danger">
    <p><a href="javascript:dr_update_cache('member');">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {$form}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title tabbable-line">
            <ul class="nav nav-tabs" style="float:left;">
                <li class="{if $page==0}active{/if}">
                    <a href="#tab_0" data-toggle="tab" onclick="$('#dr_page').val('0')"> <i class="fa fa-cog"></i> {dr_lang('基本设置')} </a>
                </li>
                <li class="{if $page==2}active{/if}">
                    <a href="#tab_2" data-toggle="tab" onclick="$('#dr_page').val('2')"> <i class="fa fa-clock-o"></i> {dr_lang('有效期设置')} </a>
                </li>
                <li class="{if $page==1}active{/if}">
                    <a href="#tab_1" data-toggle="tab" onclick="$('#dr_page').val('1')"> <i class="fa fa-list-ol"></i> {dr_lang('等级升级规则')} </a>
                </li>
            </ul>
        </div>
        <div class="portlet-body">
            <div class="tab-content">

                <div class="tab-pane {if $page==2}active{/if}" id="tab_2">
                    <div class="form-body">
                        <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 mt-radio-outline"><input onclick="dr_set_time(this.value)" name="setting[timetype]" type="radio" value="0" {if !$setting.timetype}checked{/if} /> {dr_lang('按组设置')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input onclick="dr_set_time(this.value)" name="setting[timetype]" type="radio" value="1" {if $setting.timetype}checked{/if} /> {dr_lang('按等级设置')} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('按等级设置时，每个等级分别设置有效期')} </span>
                            </div>
                        </div>
                        <div class="form-group mytime time1">
                            <label class="col-md-2 control-label ">{dr_lang('时长叠加')}</label>
                            <div class="col-md-9">
                                <div class="mt-radio-inline">
                                    <label class="mt-radio mt-radio-outline"><input name="setting[timect]" type="radio" value="1" {if $setting.timect}checked{/if} /> {dr_lang('开启')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[timect]" type="radio" value="0" {if !$setting.timect}checked{/if} /> {dr_lang('关闭')} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('叠加计算表示申请另外等级时有效期进行叠加计算，有效期不减少')} </span>
                            </div>
                        </div>
                        <div class="form-group mytime time0">
                            <label class="col-md-2 control-label ">{dr_lang('有效时长')}</label>
                            <div class="col-md-9">
                                <label><input type="text" class="form-control" name="data[days]" value="{intval($days)}"></label>
                                <label><select name="setting[dtype]"  class="form-control">
                                    <option value="0" {if !$setting.dtype} selected {/if}> {dr_lang('天')} </option>
                                    <option value="1" {if 1 == $setting.dtype} selected {/if}> {dr_lang('月')} </option>
                                    <option value="2" {if 2 == $setting.dtype} selected {/if}> {dr_lang('年')} </option>
                                </select></label>
                                <span class="help-block"> {dr_lang('0或留空表示永久')} </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 mt-radio-outline"><input name="setting[timeout]" type="radio" value="1" {if $setting.timeout}checked{/if} /> {dr_lang('开启')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[timeout]" type="radio" value="0" {if !$setting.timeout}checked{/if} /> {dr_lang('关闭')} <span></span></label>
                                </div>
                                <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 mt-radio-outline"><input onclick="dr_set_out(this.value)" name="setting[outtype]" type="radio" value="0" {if !$setting.outtype}checked{/if} /> {dr_lang('转为指定组')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input onclick="dr_set_out(this.value)" name="setting[outtype]" type="radio" value="2" {if $setting.outtype == 2}checked{/if} /> {dr_lang('跳转指定页面')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input onclick="dr_set_out(this.value)" name="setting[outtype]" type="radio" value="1" {if $setting.outtype == 1}checked{/if} /> {dr_lang('跳转续费页面')} <span></span></label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group out0">
                            <label class="col-md-2 control-label ">{dr_lang('到期后转为')}</label>
                            <div class="col-md-9">
                                <label><select name="setting[out_gid]" class="form-control">
                                    <option value="0"> -- </option>
                                    {loop $ci->member_cache['group'] $t}
                                    {if $t.id != $id}
                                    <option value="{$t.id}" {if $t.id==$setting.out_gid} selected{/if}> {dr_lang($t.name)} </option>
                                    {/if}
                                    {/loop}
                                </select></label>
                                <span class="help-block"> {dr_lang('到期过后将转为指定组')} </span>
                            </div>
                        </div>

                        <div class="form-group out1">
                            <label class="col-md-2 control-label "></label>
                            <div class="col-md-9">

                                <span class="help-block"> {dr_lang('到期过后将强制跳转到用户组续费页面')} </span>
                            </div>
                        </div>

                        <div class="form-group out2">
                            <label class="col-md-2 control-label ">{dr_lang('跳转指定URL')}</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" name="setting[out_url]" value="{htmlspecialchars((string)$setting.out_url)}">
                                <span class="help-block"> {dr_lang('到期过后将强制跳转到指定的URL地址')} </span>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="tab-pane {if $page==0}active{/if}" id="tab_0">
                    <div class="form-body">
                        <div class="form-group" id="dr_row_name">
                            <label class="col-md-2 control-label ">{dr_lang('名称')}</label>
                            <div class="col-md-9">
                                <label><input type="text" class="form-control" id="dr_name" name="data[name]" value="{htmlspecialchars((string)$name)}"></label>
                                <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">
                                    {if dr_is_app('scorelog')}<label class="mt-radio mt-radio-outline"><input name="data[unit]" type="radio" value="1" {if $unit}checked{/if} /> {SITE_SCORE} <span></span></label> {/if}
                                    <label class="mt-radio mt-radio-outline"><input name="data[unit]" type="radio" value="0" {if !$unit}checked{/if} /> {dr_lang('人民币')} <span></span></label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label ">{dr_lang('价格要求')}</label>
                            <div class="col-md-9">
                                {if $is_level && !$setting['level']['auto']}
                                <label style="display: none"><input type="hidden" class="form-control" name="data[price]" value="{htmlspecialchars((string)$price)}"></label>
                                <p class="form-control-static" style="color: #da3f3f"> {dr_lang('请在等级制度管理中设置对应的价格')} </p>
                                {else}
                                <label><input type="text" class="form-control" name="data[price]" value="{htmlspecialchars((string)$price)}"></label>
                                <span class="help-block"> {dr_lang('0或者留空表示免费组')} </span>
                                {/if}
                            </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 mt-radio-outline"><input name="data[register]" type="radio" value="1" {if $register}checked{/if} /> {dr_lang('允许')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="data[register]" type="radio" value="0" {if !$register}checked{/if} /> {dr_lang('禁止')} <span></span></label>
                                </div>
                                <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 mt-radio-outline"><input name="data[apply]" type="radio" value="1" {if $apply}checked{/if} /> {dr_lang('允许')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="data[apply]" type="radio" value="0" {if !$apply}checked{/if} /> {dr_lang('禁止')} <span></span></label>
                                </div>
                                <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 mt-radio-outline"><input name="setting[verify]" type="radio" value="1" {if $setting.verify}checked{/if} /> {dr_lang('审核')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[verify]" type="radio" value="0" {if !$setting.verify}checked{/if} /> {dr_lang('不审核')} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('当开启申请时是否进入后台审核流程')} </span>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="tab-pane {if $page==1}active{/if}" id="tab_1">
                    <div class="form-body">

                        <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 mt-radio-outline"><input name="setting[level][auto]" onclick="dr_set_sjms(this.value)" type="radio" value="1" {if $setting.level.auto}checked{/if} /> {dr_lang('自动')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[level][auto]" onclick="dr_set_sjms(this.value)" type="radio" value="0" {if !$setting.level.auto}checked{/if} /> {dr_lang('手动')} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('自动升级指当满足升级条件时系统自动变更等级')} </span>
                            </div>
                        </div>
                        <div class="form-group dr_sjms_1">
                            <label class="col-md-2 control-label">{dr_lang('自动升级条件')}</label>
                            <div class="col-md-9">
                                <div class="mt-radio-inline">
                                    <label class="mt-radio mt-radio-outline"><input name="setting[level][unit]" type="radio" value="1" {if $setting.level.unit}checked{/if} /> {dr_lang('消费额')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[level][unit]" type="radio" value="0" {if !$setting.level.unit}checked{/if} /> {SITE_EXPERIENCE} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('消费额指账户消费金额的累计，%s指通过用户规则获得奖励值', SITE_EXPERIENCE)} </span>
                            </div>
                        </div>
                        <div class="form-group dr_sjms_0">
                            <label class="col-md-2 control-label">{dr_lang('手动升级模式')}</label>
                            <div class="col-md-9">
                                <div class="mt-radio-inline">
                                    <label class="mt-radio mt-radio-outline"><input name="setting[level][price]" type="radio" value="1" {if $setting.level.price}checked{/if} /> {dr_lang('原价')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input name="setting[level][price]" type="radio" value="0" {if !$setting.level.price}checked{/if} /> {dr_lang('补差价')} <span></span></label>
                                </div>
                                <span class="help-block"> {dr_lang('补差价模式值当前价格减去以前升级的价格')} </span>
                            </div>
                        </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()}&page='+$('#dr_page').val(), 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存')}</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(function() {
        $(".dr_sjms_1").hide();
        $(".dr_sjms_0").hide();
        dr_set_sjms("{intval($setting['level']['auto'])}");
        dr_set_time("{intval($setting['timetype'])}");
        dr_set_out("{intval($setting['outtype'])}");
    });
    function dr_field_show(n, u) {
        if (u) {
            $('.field-'+n+' .list-field-cog').show();
        } else {
            $('.field-'+n+' .list-field-cog').hide();
        }
    }
    function dr_set_sjms(id) {
        if (id == 1) {
            $(".dr_sjms_1").show();
            $(".dr_sjms_0").hide();
        } else {
            $(".dr_sjms_1").hide();
            $(".dr_sjms_0").show();
        }
    }
    function dr_set_time(id) {
        if (id == 1) {
            $(".time1").show();
            $(".time0").hide();
        } else {
            $(".time1").hide();
            $(".time0").show();
        }
    }
    function dr_set_out(id) {
        if (id == 1) {
            $(".out1").show();
            $(".out0").hide();
            $(".out2").hide();
        } else if (id == 2) {
            $(".out2").show();
            $(".out0").hide();
            $(".out1").hide();
        } else {
            $(".out1").hide();
            $(".out2").hide();
            $(".out0").show();
        }
    }
</script>
{template "footer.html"}