@model Com._9pm2.ClientWeb.Models.PortalOrderList
@{Layout = "../Shared/_PortalLayout.cshtml";}
@{
    ViewBag.Title = "订单查询";
}

<script src="~/Scripts/Portal/ordercommon.js?vn=20180813"></script>
<script src="~/Scripts/Portal/index.js?vn=20180813"></script>


<div class="divSearch">
    <form method="post" action="/Portal/Index">
        <div>
            @Html.DropDownList("so", new SelectList(Model.DdlStatus, "ItemValue", "ItemText"))&nbsp;
            @Html.DropDownList("ss", new SelectList(Model.DdlPaymentStatus, "ItemValue", "ItemText"))&nbsp;          
            @Html.TextBox("sb", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" }) ~ @Html.TextBox("se", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" })&nbsp;         
            @Html.TextBox("sk", null, new { maxlength = "50", @Style = "width:80px", placeholder = "关键字" })
            &nbsp;
            <button class="btn btn-default">搜索</button>
        </div>
    </form>
</div>


<div class="list">
  
    <div class="error-msg"></div>

    <table id="tOrder">
        <thead>
            <tr>

                @*<th>订单编号</th>*@
                <th style="min-width:90px">交易日期</th>

                <th>订单名</th>
                @*  <th>分类</th>*@
                <th>明细</th>
                <th style="min-width:50px">数量</th>
                <th style="min-width:50px">单价</th>
                <th style="min-width:50px">金额</th>
                <th style="min-width:50px">总金额</th>
                <th style="min-width:50px">已支付金额</th>
                <th style="min-width:50px">未支付金额</th>
                <th style="min-width:50px">支付状态</th>
                <th style="min-width:50px">订单状态</th>
                <th style="width:80px">操作</th>
            
            </tr>
        </thead>
        <tbody id="orderList" class="spanTbody">
            @{
                int j = 0;

                foreach (var item in Model.Orders)
                {
                    int i = 0;

                    string className = j % 2 == 0 ? "odd" : "even";

                    string tilte = "";

                    if (!item.WorkFlowNo.HasValue && item.RecordChannel == (int)Com._9pm2.ClientWeb.Common.OrderRecordChannel.客户自建)
                    {
                        className = className + " order-incompleted";
                        tilte = "此订单数据需等待加工商确认";
                    }


                    foreach (var o in item.Details)
                    {
                        if (i == 0)
                        {
                            <tr id="@item.OrderNo" class="@className" title="@tilte">
                                
                                @*<td rowspan="@item.Details.Count">
                                        @Html.DisplayFor(modelItem => item.OrderNo)
                                    </td>*@
                                <td rowspan="@item.Details.Count">
                                    @item.TransactionDate.ToString("yyyy-MM-dd")
                                </td>                              

                                <td>@o.OrderName</td>
                                @*<td>@o.CategoryName</td>*@
                                <td>
                                    <b>@o.CategoryName</b>
                                    @o.DetailText
                                </td>
                                <td>@o.Number</td>
                                <td>@o.Price</td>
                                <td>@o.Amount</td>

                                <td rowspan="@item.Details.Count">@item.Amount</td>
                              
                                <td rowspan="@item.Details.Count">@item.Paid</td>
                                <td rowspan="@item.Details.Count">@item.Unpaid</td>

                                <td rowspan="@item.Details.Count">                                   
                                    <span id="spanPaymentStatus">@Html.DisplayFor(modelItem => item.PaymentStatusDescription)</span>
                                </td>
                                         
                                <td rowspan="@item.Details.Count">
                                    @Html.DisplayFor(modelItem => item.StatusDescription)
                                </td>
                                <td class="text-center td-last" rowspan="@item.Details.Count">
                                  
                                    
                                    <a onclick="ShowDetail('@item.OrderNo')">详细</a>
                                    @*<a onclick="ShowAttachment('@item.OrderNo')">附件</a>*@
                                    @if (!item.WorkFlowNo.HasValue && item.RecordChannel == (int)Com._9pm2.ClientWeb.Common.OrderRecordChannel.客户自建)
                                    {
                                        <a onclick="EditOrder('@item.OrderNo')">编辑</a>
                                    }
                                </td>
                            </tr>
                        }
                        else
                        {
                            <tr id="@item.OrderNo" class="@className">
                                <td>@o.OrderName</td>
                                @*<td>@o.CategoryName</td>*@

                                <td>
                                    <b>@o.CategoryName</b>
                                    @o.DetailText
                                </td>
                                <td>@o.Number</td>
                                <td>@o.Price</td>
                                <td>@o.Amount</td>
                                
                            </tr>
                        }

                        i++;
                    }

                    j++;

                }
            }

            @if (Model.Orders.Count > 0)
            {
                <tr class="totalTd">
                    <td>
                        <span>总计(所有页):</span>
                    </td>
                    @*<td></td>*@
                    @*<td></td>*@
                 
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td class="oderAmountTotal">@Model.TotalAmount </td>
                    <td class="oderAmountTotal">@Model.TotalPaid </td>
                    <td class="oderAmountTotal">@Model.TotalUnpaid </td>
                    <td></td>
                    <td></td>                  
                    <td></td>
                  
                </tr>
            }

        </tbody>
    </table>
    @Html.Pager("Index", "Portal", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8, true, false, true, true, false)
</div>

 @Html.Partial("PortalOrderDetail", Session["LoginUser"] as Com._9pm2.ClientWeb.Models.LoginUser)
@Html.Partial("OrderAttachment")

<input type="hidden" id="OrderNo" />