
@{
    ViewData["Title"] = "SKU分类统计";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "统计", "平台利润统计", "Sku分类利润统计" };
}

<div class="ibox-content m-b-sm border-bottom">
    <form id="toolbar">
        <div class="form-inline" style="line-height:40px;">
            <div class="form-group">
                <label>付款时间</label>
                <input id="start" name="start" type="text" class="form-control" style="width:130px;" value="@(ViewBag.start.ToString("yyyy-MM-dd"))" placeholder="付款开始时间" />
                <span>至</span>
                <input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(ViewBag.end.ToString("yyyy-MM-dd"))" placeholder="付款结束时间" />
            </div>
            <div class="form-group">
                <label>&nbsp;</label>
                <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
            </div>
        </div>
    </form>
</div>
<div class="ibox-content m-b-sm border-bottom">
    <table id="roletable" class="table table-hover table-bordered table-condensed table-striped">
        <thead>
            <tr>
                @if (ViewBag.header.Length > 0)
                {
                    <th>平台类型</th>
                    foreach (var item in ViewBag.header)
                    {
                        <th>@(item==""?"无分类":item)</th>
                    }
                }
            </tr>
        </thead>
        <tbody id="tb">
            @if (ViewBag.vals.Count > 0)
            {
                foreach (var item in ViewBag.vals)
                {
                    <tr>
                        <td>@item.Item1</td>

                        @foreach (var i in item.Item2)
                        {
                        <td class="alink" onclick="ShowDetail('@item.Item1')">@i.ToString("N2")</td>
                        }
                    </tr>
                }
            }
        </tbody>
        <tfoot id="footer">
            <tr>
                @if (ViewBag.count != null)
                {
                    <td>@(ViewBag.count.Item1)</td>

                    @foreach (var i in ViewBag.count.Item2)
                    {
                        <td class="alink" onclick="ShowDetail('@ViewBag.count.Item1')">@i.ToString("N2")</td>
                    }
                }
            </tr>
        </tfoot>
    </table>
</div>
@section css{
    <style>
        .mules {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .alink {
            color: cornflowerblue;
            cursor: pointer;
        }

        thead tr .tablesorter-headerDesc {
            background-position: right;
            background-repeat: no-repeat;
            padding-right: 30px;
            background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=' );
        }

        thead tr .tablesorter-headerAsc {
            background-position: right;
            background-repeat: no-repeat;
            padding-right: 30px;
            background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
        }
    </style>
}

@section scripts{
    <script src="~/js/jquery.ztree.core.min.js"></script>
    <script src="~/js/jquery.ztree.excheck.min.js"></script>
    <script src="~/js/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var tb;
        $(document).ready(function () {
            laydate.render({ elem: '#start' });
            laydate.render({ elem: '#end' });

            $("#roletable").trigger("destroy");
            $("#roletable").tablesorter();
        })

        function list() {
            var start = $('#start').val();
            var end = $('#end').val();

            if (start == '' || end == '') {
                layer.alert('付款时间不能为空！');
                return false;
            }

            window.location = '@Url.Content("~/Reports/Orders/SkuCategoryProfit?colname="+ViewBag.colname+ "&skucategoryids="+ ViewBag.skucategoryids+ "&start=")' + start + '&end=' + end +'&platform=@(ViewBag.platform)';
        }

        function ShowDetail(platform) {
            layer_show(platform + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform="+ViewBag.platform)' + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=@(ViewBag.colname)' + '&coltitle=@(ViewBag.coltitle)&showsingle=@(ViewBag.single)', '90%', '90%');
        }

    </script>
}
