@model OrderDetailsModel
@using Nop.Core.Domain.Orders
@using Nop.Web.Models.Order
@using Nop.Services.Localization
@{
    if (!Model.PrintMode)
    {
        Layout = "~/Views/Shared/_ColumnsOne.cshtml";
    }
    else
    {
        Layout = null;
    }
    //title
    Html.AddTitleParts(T("PageTitle.OrderDetails").Text);
}
<div class="order-details">
    @if (!Model.PrintMode)
    {
        <table width="100%">
            <tr>
                <td style="text-align: left;">
                    <div class="page-title">
                        <h1>
                            @T("Order.OrderInformation")</h1>
                    </div>
                </td>
                <td style="text-align: right;">
                    <a href="@Url.RouteUrl("PrintOrderDetails", new { orderId = Model.Id })" target="_blank" class="orderdetailsprintbutton">@T("Order.Print")</a>
                    @if (Model.DisplayPdfInvoice)
                    {
                        <a href="@Url.RouteUrl("GetOrderPdfInvoice", new { orderId = Model.Id })" class="orderdetailsprintbutton">@T("Order.GetPDFInvoice")</a>
                    }
                </td>
            </tr>
        </table>
        <div class="clear">
        </div>
    }
    <div class="info">
        <div class="order-overview">
            <table width="100%" cellspacing="0" cellpadding="2" border="0">
                <tbody>
                    <tr>
                        <td colspan="2">
                            <b>
                                @T("Order.Order#")@Model.Id
                            </b>
                        </td>
                    </tr>
                    <tr>
                        <td class="smallText">
                            @T("Order.OrderDate"): @Model.CreatedOn.ToString("D")
                        </td>
                        <td align="right" class="smallText">
                            @T("Order.OrderTotal"): @Model.OrderTotal
                        </td>
                    </tr>
                    <tr>
                        <td class="smallText">
                            @T("Order.OrderStatus"): @Model.OrderStatus
                        </td>
                        <td>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="clear">
        </div>
        <div class="order-details-box">
            <table width="100%" cellspacing="0" cellpadding="2" border="0">
                <tbody>
                    <tr>
                        <td width="50%" align="left" style="vertical-align: top;">
                            <b>
                                @T("Order.BillingAddress")</b>
                            <br />
                            @Model.BillingAddress.FirstName @Model.BillingAddress.LastName<br />
                            <div>
                                @T("Order.Email"): @Model.BillingAddress.Email</div>
                            <div>
                                @T("Order.Phone"): @Model.BillingAddress.PhoneNumber</div>
                            <div>
                                @T("Order.Fax"): @Model.BillingAddress.FaxNumber</div>
                            @if (!String.IsNullOrEmpty(Model.BillingAddress.Company))
                            {
                                <div>
                                    @Model.BillingAddress.Company
                                </div>
                            }
                            <div>
                                @Model.BillingAddress.Address1</div>
                            @if (!String.IsNullOrEmpty(Model.BillingAddress.Address2))
                            {
                                <div>
                                    @Model.BillingAddress.Address2
                                </div>
                            }
                            <div>
                                @Model.BillingAddress.City, @Model.BillingAddress.StateProvinceName @Model.BillingAddress.ZipPostalCode</div>
                            @if (!String.IsNullOrEmpty(Model.BillingAddress.CountryName))
                            {
                                <br />
                                <div>
                                    @Model.BillingAddress.CountryName
                                </div>
                            }
                            <br />
                            @if (!String.IsNullOrEmpty(Model.VatNumber))
                            {
                                <b>@T("Order.VATNumber")</b> <br />
                                @Model.VatNumber
                                <br />
                                <br />
                            }
                            @if (!String.IsNullOrEmpty(Model.PaymentMethod))
                            {
                                <b>@T("Order.PaymentMethod")</b>
                                <br />
                                @Model.PaymentMethod
                            }
                        </td>
                        @if (Model.IsShippable)
                        {
                            <td width="50%" align="left" style="vertical-align: top;">
                                <b>
                                    @T("Order.ShippingAddress")</b>
                                <br />
                                @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName<br />
                                <div>
                                    @T("Order.Email"): @Model.ShippingAddress.Email</div>
                                <div>
                                    @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber</div>
                                <div>
                                    @T("Order.Fax"): @Model.ShippingAddress.FaxNumber</div>
                                @if (!String.IsNullOrEmpty(Model.ShippingAddress.Company))
                                {
                                    <div>
                                        @Model.ShippingAddress.Company
                                    </div>
                                }
                                <div>
                                    @Model.ShippingAddress.Address1</div>
                                @if (!String.IsNullOrEmpty(Model.ShippingAddress.Address2))
                                {
                                    <div>
                                        @Model.ShippingAddress.Address2
                                    </div>
                                }
                                <div>
                                    @Model.ShippingAddress.City, @Model.ShippingAddress.StateProvinceName @Model.ShippingAddress.ZipPostalCode</div>
                                @if (!String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
                                {
                                    <br />
                                    <div>
                                        @Model.ShippingAddress.CountryName
                                    </div>
                                }
                                <br />
                                <br />
                                <b>
                                    @T("Order.ShippingMethod")</b>
                                <br />
                                @Model.ShippingMethod
                                @if (!String.IsNullOrEmpty(Model.TrackingNumber))
                                {
                                    <br />
                                    <b>
                                        @T("Order.TrackingNumber")</b> 
                                    <br />
                                    @Model.TrackingNumber
                                }
                                <br />
                                @if (!Model.PrintMode)
                                {
                                    <br />
                                    <b>
                                        @T("Order.ShippedOn")</b>
                                    <br />
                                    if (!String.IsNullOrEmpty(Model.ShippedDate))
                                    {
                                        @Model.ShippedDate
                                    }
                                    else
                                    {
                                        @T("Order.NotYetShipped")
                                    }
                                    <br />
                                    <b>
                                        @T("Order.DeliveredOn")</b>
                                    <br />
                                    if (!String.IsNullOrEmpty(Model.DeliveryDate))
                                    {
                                        @Model.DeliveryDate
                                    }
                                    else
                                    {
                                        @T("Order.NotYetDelivered")
                                    }
                                    <br />
                                }
                                <b>
                                    @T("Order.Weight")</b>
                                <br />
                                @string.Format("{0:F2} [{1}]", Model.OrderWeight, Model.BaseWeightIn)
                            </td>
                        }
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="clear">
        </div>
        @if (Model.Items.Count > 0)
        {
            <div class="section-title">
                @T("Order.Product(s)")</div>
            <div class="clear">
            </div>
            <div class="products-box">
                <table border="1" cellspacing="0" style="width: 100%; border-collapse: collapse;">
                    @if (Model.ShowSku)
                    {
                        <col width="1" />
                    }
                    <col />
                    <col />
                    <col />
                    <col />
                    <thead>
                        <tr>
                            @if (Model.ShowSku)
                            {
                                <th align="center">
                                    @T("Order.Product(s).SKU")
                                </th>
                            }
                            <th align="center">
                                @T("Order.Product(s).Name")
                            </th>
                            <th align="center">
                                @T("Order.Product(s).Price")
                            </th>
                            <th align="center">
                                @T("Order.Product(s).Quantity")
                            </th>
                            <th align="center">
                                @T("Order.Product(s).Total")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Items)
                        {
                            <tr>
                                @if (Model.ShowSku)
                                {
                                    <td>
                                        <div style="padding-left: 10px; padding-right: 10px;">
                                            @item.Sku
                                        </div>
                                    </td>
                                }
                                <td>
                                    <div style="padding-left: 10px; padding-right: 10px;">
                                        @if (!Model.PrintMode)
                                        {
                                            <em><a href="@Url.RouteUrl("Product", new { productId = item.ProductId, SeName = item.ProductSeName })" title="View details">@item.ProductName</a></em>
                                        }
                                        else
                                        {
                                            @item.ProductName
                                        }
                                        @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                        {
                                            <br />
                                            @Html.Raw(item.AttributeInfo)
                                        }
                                    </div>
                                </td>
                                <td align="right">
                                    <div style="padding-left: 10px; padding-right: 10px;">
                                        @item.UnitPrice
                                    </div>
                                </td>
                                <td align="center">
                                    @item.Quantity
                                </td>
                                <td align="right">
                                    <div style="padding-left: 10px; padding-right: 10px;">
                                        @item.SubTotal
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                <div class="clear">
                </div>
                @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                {
                    <div class="checkout-attributes">
                        @Html.Raw(Model.CheckoutAttributeInfo)
                    </div>
                    <div class="clear">
                    </div>
                }
                @if (!Model.PrintMode)
                {
                    <br />
                    @*Reorder support*@
                    using (Html.BeginForm("Details", "Order", FormMethod.Post))
                    {
                        if (Model.IsReOrderAllowed)
                        {
                    <input type="submit" name="reorder" value="@T("Order.Reorder")" id="reorder" class="reorderbutton" />
                        }
                        if (Model.IsReturnRequestAllowed)
                        {
                    <text>&nbsp; &nbsp; &nbsp;</text>
                    <input type="button" name="returnitems" value="@T("Order.ReturnItems")" id="returnitems" class="returnitemsbutton" onclick="setLocation('@(@Url.RouteUrl("ReturnRequest", new { orderId = @Model.Id }))')" />
                        }
                    }
                }
            </div>
            <div class="clear">
            </div>
        }
        <table width="100%" cellspacing="0" cellpadding="2" border="0">
            <tbody>
                <tr>
                    <td width="100%" align="right">
                        <b>
                            @T("Order.SubTotal"):</b>
                    </td>
                    <td align="right">
                        <span style="white-space: nowrap;">
                            @Model.OrderSubtotal
                        </span>
                    </td>
                </tr>
                @if (!string.IsNullOrEmpty(Model.OrderSubTotalDiscount))
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @T("Order.SubTotalDiscount"):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.OrderSubTotalDiscount
                            </span>
                        </td>
                    </tr>
                }
                @if (Model.IsShippable)
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @T("Order.Shipping"):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.OrderShipping
                            </span>
                        </td>
                    </tr>
                }
                @if (!string.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @T("Order.PaymentMethodAdditionalFee"):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.PaymentMethodAdditionalFee
                            </span>
                        </td>
                    </tr>
                }
                @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
                {
                    foreach (var taxRate in Model.TaxRates)
                    {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @string.Format(T("Order.TaxRateLine").Text, taxRate.Rate):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @taxRate.Value
                            </span>
                        </td>
                    </tr>
                    }
                }
                @if (Model.DisplayTax)
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @T("Order.Tax"):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.Tax
                            </span>
                        </td>
                    </tr>
                }
                @if (!string.IsNullOrEmpty(Model.OrderTotalDiscount))
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @T("Order.TotalDiscount"):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.OrderTotalDiscount
                            </span>
                        </td>
                    </tr>
                }
                @if (Model.GiftCards.Count > 0)
                {
                    foreach (var gc in Model.GiftCards)
                    {
                    
                    
                    
                    <tr>
                        <td width="100%" align="right">
                            <b>
                                @string.Format(T("Order.GiftCardInfo").Text, gc.CouponCode):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @gc.Amount
                            </span>
                        </td>
                    </tr>
                    }
                }
                @if (Model.RedeemedRewardPoints > 0)
                {
                    <tr>
                        <td width="100%" align="right">
                            <b>@string.Format(T("Order.RewardPoints").Text, Model.RedeemedRewardPoints):</b>
                        </td>
                        <td align="right">
                            <span style="white-space: nowrap;">
                                @Model.RedeemedRewardPointsAmount
                            </span>
                        </td>
                    </tr>
                }
                <tr>
                    <td width="100%" align="right">
                        <b>
                            @T("Order.OrderTotal"):</b>
                    </td>
                    <td align="right">
                        <b><span style="white-space: nowrap;">
                            @Model.OrderTotal
                        </span></b>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="clear">
        </div>
        @if (!Model.PrintMode)
        {
            if (Model.OrderNotes.Count > 0)
            {
            <div class="section-title">
                @T("Order.Notes")
            </div>
            <div class="clear">
            </div>
            <div class="ordernotes-box">
                <table border="1" cellspacing="0" style="width: 100%; border-collapse: collapse;">
                    <col />
                    <col />
                    <thead>
                        <tr>
                            <th align="center">
                                @T("Order.Notes.CreatedOn")
                            </th>
                            <th align="center">
                                @T("Order.Notes.Note")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.OrderNotes)
                        {
                            <tr>
                                <td style="width: 20%;">
                                    @item.CreatedOn.ToString()
                                </td>
                                <td style="width: 80%;">
                                    <div style="padding-left: 10px; padding-right: 10px; text-align: left;">
                                        @Html.Raw(item.Note)
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            }
        }
    </div>
</div>
