<%inherit file="base.html"/>

<%def name="head()">
<style type="text/css">
    td {
        text-align: left
    }
</style>
<script>
    function deleteProduct(product_id) {
        if (confirm("确认删除吗？")) {
            window.location.href = "/product/delete?product_id=" + product_id;
        }
    }
</script>
</%def>

<%def name="body()">
<div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> 资费列表</div>
    <div class="panel-body">  
        <div class="pull-right bottom10">
            % if permit.match('/product/add'):
            <a href="/product/add" class="btn btn-sm btn-default">添加资费</a>
            % endif
        </div>

        <table class="table table-hover">
            <thead>
            <tr>
                <th>资费名称</th>
                <th>资费策略</th>
                <th>价格(元)</th>
                <th>并发数</th>
                <th>是否绑定MAC</th>
                <th>是否绑定VLAN</th>
                <th>上行速率</th>
                <th>下行速率</th>
                <th>状态</th>                
            </tr>
            </thead>
            <tbody>
            % for product in page_data.result:
            <tr>
                <td><a href="/product/detail?product_id=${product.id}">${product.product_name}</a></td>
                <td>
                    ${product_policys[product.product_policy]}
                </td>
                <td>${fen2yuan(product.fee_price)}</td>
                <td>${product.concur_number}</td>
                <td>${product.bind_mac and u'是' or u'否'}</td>
                <td>${product.bind_vlan and u'是' or u'否'}</td>
                <td>${bps2mbps(product.input_max_limit)} Mbps</td>
                <td>${bps2mbps(product.output_max_limit)} Mbps</td>
                <td>${product.product_status and u'停用' or u'正常'}</td>
                <td>
                    % if permit.match('/product/update'):
                    <a class="opt-btn btn-default" href="/product/update?product_id=${product.id}">修改</a>
                    % endif
                    % if permit.match('/product/delete'):
                    <a class="opt-btn btn-default"  href="javascript:deleteProduct('${product.id}')">删除</a>
                    % endif
                </td>
            </tr>
            % endfor
            </tbody>
        </table>
        ${page_data.render()}
    </div>
</div>

</%def>