<%inherit file="base.html"/>
<%def name="head()">
<script>

function do_pause(account_number)
{
    if (!confirm("确认操作吗？")) {
        return;
    }
    params = {account_number:account_number};
    $.post("/bus/account/pause", params, function (data) {
        alert(data.msg)
        window.location.reload();
    },"json");
}

function do_resume(account_number)
{
    if (!confirm("确认操作吗？")) {
        return;
    }
    params = {account_number:account_number};
    $.post("/bus/account/resume", params, function (data) {
        alert(data.msg)
        window.location.reload();
    },"json");
}    

function release(account_number)
{
    params = {account_number:account_number};
    $.post("/ops/user/release", params, function (data) {
        alert(data.msg)
        location.href.reload();
    },"json");
}

function do_delete(account_number)
{
    if(confirm("删除账号将删除账号所有相关数据，包括账号，日志，订单等，不可恢复，确认操作吗？")) {
        window.location.href = "/bus/account/delete?account_number="+account_number;
    }
    
}

</script>
</%def>
<%def name="body()">
    <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> 用户受理 <a class="badge pull-right" href="javascript:history.go(-1);">返回</a></div>
        <div class="panel-body">
        <div class="pull-right">
           <div class="btn-group" role="group" aria-label="...">
               
            % if permit.match('/bus/account/open'):
            <a href="/bus/account/open?member_id=${member.member_id}" class="btn btn-sm btn-default">新开子账号</a>
            % endif
            
            % if user.status == 2:
           
                % if permit.match('/bus/account/resume'):
                <a class="btn btn-sm btn-default" href="javascript:do_resume('${user.account_number}');">复机</a>
                % endif
               
            % elif user.status == 1:
            
                % if permit.match('/bus/member/update'):
                <a href="/bus/member/update?member_id=${member.member_id}&account_number=${user.account_number}" class="btn btn-sm btn-default">修改基本资料</a>
                % endif

                % if permit.match('/ops/user/release'):
                <a class="btn btn-sm btn-default" href="/bus/account/update?account_number=${user.account_number}">修改策略</a>
                % endif

                % if permit.match('/ops/user/release'):
                <a class="btn btn-sm btn-default" href="javascript:release('${user.account_number}');">释放绑定</a>
                % endif
            
                % if permit.match('/bus/account/change'):
                <a class="btn btn-sm btn-default" href="/bus/account/change?account_number=${user.account_number}">资费变更</a>
                % endif
               
                % if permit.match('/bus/account/pause'):
                <a class="btn btn-sm btn-default" href="javascript:do_pause('${user.account_number}');">停机</a>
                % endif
               
                % if user.product_policy in (0,2,3,5):
               
                    % if permit.match('/bus/account/next'):
                    <a class="btn btn-sm btn-default" href="/bus/account/next?account_number=${user.account_number}">续费</a>
                    % endif
                   
                % elif user.product_policy in (1,4): 
                   
                    % if permit.match('/bus/account/charge'):
                    <a class="btn btn-sm btn-default" href="/bus/account/charge?account_number=${user.account_number}">充值</a>
                    % endif
                   
                % endif
                   
                % if permit.match('/bus/account/cancel'):   
                <a class="btn btn-sm btn-default" href="/bus/account/cancel?account_number=${user.account_number}">销户</a>
                % endif
               
            % elif user.status == 4:
           
                % if permit.match('/bus/account/next'):
                <a class="btn btn-sm btn-default" href="/bus/account/next?account_number=${user.account_number}">续费</a>
                % endif
               
            % endif
            
            % if permit.match('/bus/account/delete'):
            <a class="btn btn-sm btn-default" href="javascript:do_delete('${user.account_number}');">删除</a>
            % endif
            </div>
        </div>   
        <br> 

        <table class="table">
                <thead>
                    <tr>
                        <th colspan="6"> 基本信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>用户姓名</td>
                        <td>${member.realname}</td>
                        <td>证件号码</td>
                        <td>${member.idcard}</td>
                        <td>自助服务登陆名</td>
                        <td>${member.member_name}</td>                 
                    </tr>
                    <tr>
                        <td>年龄</td>
                        <td>${member.age}</td>
                        <td>email</td>
                        <td>${member.email}
                        % if member.email:
                        (${member.email_active == 1 and u'已绑定' or u'未绑定'})
                        % endif
                        </td>
                        <td>联系电话</td>
                        <td>${member.mobile}</td>
                    </tr>      
                    <tr>
                        <td>地址</td>
                        <td>${member.address}</td>
                        <td>创建时间</td>
                        <td>${member.create_time}</td>
                        <td>更新时间</td>
                        <td>${member.update_time}</td>                        
                    </tr>                                                                       
            </tbody>
        </table>
        <table class="table">
                <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"<font color=red>销户</font>",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>${sec2hour(user.time_length)}小时</td>
                    </tr>      
                    <tr>
                        <td>剩余流量</td>
                        <td>${kb2mb(user.flow_length)}MB</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/VLANID2</td>
                        <td>${user.vlan_id}/${user.vlan_id2}</td>
                        <td>MAC地址</td>
                        <td>${user.mac_addr}</td>                        
                    </tr>   
                    <tr>
                        <td>IP地址</td>
                        <td>${user.ip_address}</td>
                        <td>最近停机时间</td>
                        <td>${user.last_pause or ''}</td>
                        <td>创建时间</td>
                        <td>${user.create_time}</td>                        
                    </tr>                                                                      
            </tbody>
        </table>

        <table class="table">
            <thead>
                <tr>
                    <th colspan="6"> 账号受理记录</th>
                </tr>
                <tr class="active">
                    <th>用户账号</th>
                    <th>受理类型</th>
                    <th>操作员</th>
                    <th>受理时间</th>
                    <th>订单号</th>
                    <th>受理描述</th>
                </tr>
            </thead>
            <tbody>
            % for alog in accepts:
            <tr>
                <td>${alog.account_number}</td>
                <td>${type_map[alog.accept_type]}</td>
                <td>${alog.operator_name}</td>
                <td>${alog.accept_time}</td>
                <td>${get_orderid(alog.id) or ''}</td>
                <td>${alog.accept_desc or ''}</td>
            </tr>
            % endfor
            </tbody>
        </table>

        <table class="table ">
            <thead>
                <tr>
                    <th colspan="7"> 账号交易记录</th>
                </tr>
                <tr class="active">
                    <th>订单号</th>
                    <th>资费</th>
                    <th>订单费用</th>
                    <th>实缴费用</th>
                    <th>订单状态</th>
                    <th>订单时间</th>
                    <th>订单描述</th>
                </tr>
            </thead>
            <tbody>
            % for order in orders:
            <tr>
                <td>${order.order_id}</td>
                <td>${order.product_name}</td>
                <td>${fen2yuan(order.order_fee)}</td>
                <td>${fen2yuan(order.actual_fee)}</td>
                <td>${{0:u"未支付",1:u"已支付",2:u"已取消"}[order.pay_status]}</td>
                <td>${order.create_time}</td>
                <td>${order.order_desc or ''}</td>
            </tr>
            % endfor
            </tbody>
        </table>

    </div>
</div>
</div>
</%def>