@model Com._9pm2.ClientWeb.Models.QuotationList
@{ViewBag.Title = "客户报价单"; }

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

<script src="../../Scripts/quotationlist.js?vn=20180813"></script>

<style>

</style>
<div class="divSearch">
    <form method="post" action="/Order/QuotationList">
        <div>
            @Html.TextBox("sBeginDate", null, new { maxlength = "50", @class = "text-date", placeholder = "报价日期" }) ~@Html.TextBox("sEndDate", null, new { maxlength = "50", @class = "text-date", placeholder = "报价日期" })
            @Html.TextBox("sCustomerName", null, new { maxlength = "50", @Style = "width:130px", placeholder = "客户名称" })
            @Html.TextBox("sKey", null, new { maxlength = "50", @Style = "width:130px", placeholder = "关键字" })
            <button class="btn btn-default">搜索</button> &nbsp;
            <button type="button" onclick="newQuatation()" class="btn btn-default">开报价单(标准)</button>
            <button type="button" onclick="newSimpleQuatation()" class="btn btn-default">开报价单(极速)</button>
        </div>
    </form>
</div>

@{
    Com._9pm2.ClientWeb.Models.LoginUser user = Session["LoginUser"] as Com._9pm2.ClientWeb.Models.LoginUser;
}

<div class="list">

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

    <table id="tOrder">
        <thead>
            <tr>
                
                <th style="min-width:90px">报价日期</th>
                <th style="min-width:120px">客户</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="width:100px">操作</th>
            </tr>
        </thead>
        <tbody id="orderList" class="spanTbody">
            @{
                int j = 0;

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

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

                    foreach (var o in item.QuotationDetail)
                    {
                        if (i == 0)
                        {
                            <tr id="@item.Id">
                               
                                <td rowspan="@item.QuotationDetail.Count">
                                    @item.QuotationDate.ToString("yyyy-MM-dd")
                                </td>
                                <td class="client-name" rowspan="@item.QuotationDetail.Count">                                     
                                    @(item.Customer==null? item.CustomerName:item.Customer.CustomerFullName)
                                </td>

                                <td>@o.QuotationName</td>

                                <td>
                                    <b>@o.CategoryName</b>
                                    @o.DetailText
                                </td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Number)</td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Price)</td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Amount)</td>

                                <td rowspan="@item.QuotationDetail.Count">@Com._9pm2.ClientWeb.Utilities.NFormat.Format(item.Amount)</td>


                                <td style="text-align:center" class="td-last" rowspan="@item.QuotationDetail.Count">

                                    <div class="operation-btns">
                                        <div>
                                            <button id="select">&nbsp;</button>
                                        </div>
                                        <ul>                                           
                                            <li><a href="javascript:void(0);" onclick="Edit('@item.Id','@item.EditModel')">编辑 </a></li>
                                            <li><a onclick="Delete('@item.Id','@item.QuotationName')">删除</a></li>
                                            <li><a href="javascript:void(0);" onclick="Download('@item.Id')">下载(Pdf)</a></li>
                                            <li><a href="javascript:void(0);" onclick="DownloadExcel('@item.Id')">下载(Excel)</a></li>
                                            <li><a href="javascript:void(0);" onclick="ConvertToOrder('@item.Id','@item.EditModel')">转换成订单</a></li>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                        }
                        else
                        {
                            <tr id="@item.Id" class="@className">
                                <td>@o.QuotationName</td>

                                <td>
                                    <b>@o.CategoryName</b>
                                    @o.DetailText
                                </td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Number)</td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Price)</td>
                                <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(o.Amount)</td>

                            </tr>
                        }

                        i++;
                    }

                    j++;

                }
            }

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

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

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