@model CustomerDownloadableProductsModel
@{
    Layout = "_ColumnsTwo";

    //title
    NopHtml.AddTitleParts(T("PageTitle.Account").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-account-page");
    NopHtml.AppendPageCssClassParts("html-downloadable-products-page");
}
@section left
{
    @await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = CustomerNavigationEnum.DownloadableProducts })
}
<div class="page account-page downloadable-products-page">
    <div class="page-title">
        <h1>@T("Account.MyAccount") - @T("Account.DownloadableProducts")</h1>
    </div>
    <div class="page-body">
        @if (Model.Items.Count > 0)
        {
            <div class="table-wrapper">
                <table class="data-table">
                    <colgroup>
                        <col width="1" />
                        <col width="1" />
                        <col />
                        <col width="1" />
                    </colgroup>
                    <thead>
                        <tr>
                            <th class="order">
                                @T("DownloadableProducts.Fields.Order")
                            </th>
                            <th class="date">
                                @T("DownloadableProducts.Fields.Date")
                            </th>
                            <th class="product">
                                @T("DownloadableProducts.Fields.Product")
                            </th>
                            <th class="download">
                                @T("DownloadableProducts.Fields.Download")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @for (var i = 0; i < Model.Items.Count; i++)
                        {
                            var item = Model.Items[i];
                            <tr @(i % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
                                <td class="order">
                                    <a href="@Url.RouteUrl("OrderDetails", new { orderId = item.OrderId })">@item.CustomOrderNumber</a>
                                </td>
                                <td class="date">
                                    @item.CreatedOn.ToString("d")
                                </td>
                                <td class="product">
                                    <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
                                    @if (!string.IsNullOrEmpty(item.ProductAttributes))
                                    {
                                        <div class="attributes">
                                            @Html.Raw(item.ProductAttributes)
                                        </div>
                                    }
                                </td>
                                <td class="download">
                                    @if (item.DownloadId > 0)
                                    {
                                        <div>
                                            <a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@T("DownloadableProducts.Fields.Download")</a>
                                        </div>
                                    }
                                    else
                                    {
                                        <div>
                                            @T("DownloadableProducts.Fields.Download.NA")
                                        </div>
                                    }
                                    @if (item.LicenseId > 0)
                                    {
                                        <div>
                                            <a href="@Url.RouteUrl("GetLicense", new { orderItemId = item.OrderItemGuid })">@T("DownloadableProducts.Fields.DownloadLicense")</a>
                                        </div>
                                    }
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        }
        else
        {
            <div class="no-data">
                @T("DownloadableProducts.NoItems")
            </div>
        }
    </div>
</div>
