<%inherit file="base.html"/>
<%def name="head()">
<script src="/static/js/bootstrap-datepicker.js"></script>
<link rel="stylesheet" href="/static/js/datepicker.css"> 
<script>

function update_ui(){
    var product_id = $("#product_id").val();
    $.get("/bus/product/policy/get?product_id="+product_id, {}, function (ev) {
        console.log(ev);
        if(ev.code==0){
            console.log(ev.data);
        }
        if(ev.data.policy == 0 || ev.data.policy == 2){
            $("#expire_date").parent().parent().show();
            $("#balance").parent().parent().hide();
            $("#time_length").parent().parent().hide();
            $("#flow_length").parent().parent().hide();
        }else if(ev.data.policy == 1||ev.data.policy == 4){
            $("#expire_date").parent().parent().hide();
            $("#balance").parent().parent().show();
            $("#time_length").parent().parent().hide();
            $("#flow_length").parent().parent().hide();
        }else if(ev.data.policy == 3){
            $("#expire_date").parent().parent().hide();
            $("#balance").parent().parent().hide();
            $("#time_length").parent().parent().show();
            $("#flow_length").parent().parent().hide();
        }else if(ev.data.policy == 5){
            $("#expire_date").parent().parent().hide();
            $("#balance").parent().parent().hide();
            $("#time_length").parent().parent().hide();
            $("#flow_length").parent().parent().show();
        }
    }, "json");
}

$(function () {
    update_ui();
    $("#expire_date").datepicker();
    $('#product_id').change(function() {
        update_ui();
    });
});
</script>

</%def>
<%def name="body()">
    <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> ${form.title}<a class="badge pull-right" href="javascript:history.go(-1);">返回</a></div>
        <div class="panel-body">
            % if msg:
            <div class="alert alert-warning">${msg}</div>
            % endif
        <table class="table table-hover">
                <thead>
                    <tr>
                        <th colspan="6"> 用户账号信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>用户账号</td>
                        <td>${user.account_number}</td>
                        <td>资费名称</td>
                        <td>${user.product_name}</td>
                        <td>用户状态</td>
                        <td>${{1:u"正常",2:u"停机",3:u"销户",4:u"到期",6:u"未激活"}[user.status]}</td>                 
                    </tr>
                    <tr>
                        <td>过期时间</td>
                        <td>${user.expire_date}</td>
                        <td>余额</td>
                        <td>${fen2yuan(user.balance)}</td>
                        <td>剩余时长</td>
                        <td>${user.time_length}</td>
                    </tr>      
                    <tr>
                        <td>MAC地址</td>
                        <td>${user.mac_addr}</td>
                        <td>并发数</td>
                        <td>${user.user_concur_number}</td>
                        <td>绑定MAC</td>
                        <td>${{0:u"否", 1:u"是"}[user.bind_mac]}</td>                        
                    </tr>   
                    <tr>
                        <td>绑定VLAN</td>
                        <td>${{0:u"否", 1:u"是"}[user.bind_vlan]}</td>
                        <td>VLANID1</td>
                        <td>${user.vlan_id}</td>
                        <td>VLANID2</td>
                        <td>${user.vlan_id2}</td>                        
                    </tr>   
                    <tr>
                        <td>IP地址</td>
                        <td>${user.ip_address}</td>
                        <td>安装地址</td>
                        <td>${user.install_address}</td>
                        <td>创建时间</td>
                        <td>${user.create_time}</td>                        
                    </tr>                                                                      
            </tbody>

        </table>
          <hr/>            
            <form class="form-horizontal form-well" role="form" action="${form.action}" method="post">
            ${form.render_css()}
        </form>
    </div>
</div>
</%def>