| | | 1 | | @using OzonDomains.Models |
| | | 2 | | @using OzonOrdersWeb.Areas.Studio2.ViewModels.CartViewModels |
| | | 3 | | @model List<OzonDomains.Models.OrderCarts.OrderCart> |
| | | 4 | | |
| | | 5 | | @{ |
| | 0 | 6 | | ViewData["Title"] = "Корзины заказов"; |
| | 0 | 7 | | int currentPage = ViewBag.CurrentPage as int? ?? 1; |
| | 0 | 8 | | int totalPages = ViewBag.TotalPages; |
| | | 9 | | } |
| | | 10 | | |
| | | 11 | | <div class="d-flex align-items-center justify-content-between mb-3"> |
| | | 12 | | <h2 class="mb-0">Корзины заказов</h2> |
| | | 13 | | |
| | | 14 | | <form asp-area="Studio2" asp-controller="Cart" asp-action="UpdateCache" method="post" class="mb-0"> |
| | | 15 | | <button type="submit" title="Обновить кеш корзины" class="btn btn-link p-0" style="text-decoration: none;"> |
| | | 16 | | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" |
| | | 17 | | class="bi bi-arrow-clockwise" viewBox="0 0 16 16"> |
| | | 18 | | <path fill-rule="evenodd" |
| | | 19 | | d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 |
| | | 20 | | .908-.417A6 6 0 1 1 8 2z"></path> |
| | | 21 | | <path |
| | | 22 | | d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 |
| | | 23 | | 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466"></path> |
| | | 24 | | </svg> |
| | | 25 | | </button> |
| | | 26 | | </form> |
| | | 27 | | </div> |
| | | 28 | | |
| | | 29 | | |
| | | 30 | | <table class="table table-striped"> |
| | | 31 | | <thead> |
| | | 32 | | <partial name="_StandartOrderTableHead" /> |
| | | 33 | | <tbody> |
| | 0 | 34 | | @foreach (var cart in Model) |
| | | 35 | | { |
| | | 36 | | <tr> |
| | | 37 | | <td colspan="15" class="bg-light text-dark"> |
| | | 38 | | <div class="d-flex justify-content-between align-items-center px-2 py-1"> |
| | | 39 | | <div class="text-nowrap"> |
| | 0 | 40 | | <strong>ID:</strong> @cart.Id |
| | 0 | 41 | | <strong>Провайдер:</strong> @cart.Provider |
| | 0 | 42 | | <strong>Создан:</strong> @cart.CreatedAt.ToString("HH:mm dd.MM.yyyy") |
| | | 43 | | </div> |
| | | 44 | | <div class="text-nowrap"> |
| | | 45 | | <a href="@Url.Action("ViewSummary", "OrderSummary", new { area = "Studio2", cartId = cart.Id })" |
| | | 46 | | target="_blank" |
| | | 47 | | class="text-primary text-decoration-none"> |
| | | 48 | | Посмотреть сводку заказа |
| | | 49 | | </a> |
| | | 50 | | </div> |
| | | 51 | | </div> |
| | | 52 | | </td> |
| | | 53 | | </tr> |
| | 0 | 54 | | @foreach (var item in cart.OrderItems) |
| | | 55 | | { |
| | 0 | 56 | | @if (item.StudioOrder != null) |
| | | 57 | | { |
| | 0 | 58 | | var rowModel = new CartViewModel |
| | 0 | 59 | | { |
| | 0 | 60 | | Order = item.StudioOrder, |
| | 0 | 61 | | Id = item.Id, |
| | 0 | 62 | | ItemId = item.ItemId, |
| | 0 | 63 | | OrderItemCode = item.OrderItemCode ?? "", |
| | 0 | 64 | | ItemStatus = item.ItemStatus?.Name ?? "", |
| | 0 | 65 | | Quantity = item.Quantity |
| | 0 | 66 | | }; |
| | | 67 | | <partial name="_StandartCartOrderRow" model="rowModel" /> |
| | | 68 | | } |
| | | 69 | | else |
| | | 70 | | { |
| | | 71 | | <em>—</em> |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | } |
| | | 76 | | </tbody> |
| | | 77 | | </table> |
| | | 78 | | |
| | | 79 | | <nav aria-label="Page navigation" class="mt-3"> |
| | | 80 | | <ul class="pagination d-flex justify-content-center flex-wrap"> |
| | 0 | 81 | | @if (totalPages > 15) |
| | | 82 | | { |
| | 0 | 83 | | if (currentPage <= 8) |
| | | 84 | | { |
| | 0 | 85 | | for (int i = 1; i <= 10; i++) |
| | | 86 | | { |
| | | 87 | | <li class="page-item @(i == currentPage ? "active" : "")"> |
| | 0 | 88 | | <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a> |
| | | 89 | | </li> |
| | | 90 | | } |
| | | 91 | | <li class="page-item disabled"><span class="page-link">...</span></li> |
| | | 92 | | <li class="page-item"> |
| | 0 | 93 | | <a class="page-link" asp-action="Index" asp-route-page="@(totalPages)">@totalPages</a> |
| | | 94 | | </li> |
| | | 95 | | } |
| | 0 | 96 | | else if (currentPage >= totalPages - 7) |
| | | 97 | | { |
| | | 98 | | <li class="page-item"> |
| | | 99 | | <a class="page-link" asp-action="Index" asp-route-page="1">1</a> |
| | | 100 | | </li> |
| | | 101 | | <li class="page-item disabled"><span class="page-link">...</span></li> |
| | 0 | 102 | | @for (int i = totalPages - 9; i <= totalPages; i++) |
| | | 103 | | { |
| | | 104 | | <li class="page-item @(i == currentPage ? "active" : "")"> |
| | 0 | 105 | | <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a> |
| | | 106 | | </li> |
| | | 107 | | } |
| | | 108 | | } |
| | | 109 | | else |
| | | 110 | | { |
| | | 111 | | <li class="page-item"> |
| | | 112 | | <a class="page-link" asp-action="Index" asp-route-page="1">1</a> |
| | | 113 | | </li> |
| | | 114 | | <li class="page-item disabled"><span class="page-link">...</span></li> |
| | | 115 | | |
| | 0 | 116 | | @for (int i = currentPage - 5; i <= currentPage + 5; i++) |
| | | 117 | | { |
| | | 118 | | <li class="page-item @(i == currentPage ? "active" : "")"> |
| | 0 | 119 | | <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a> |
| | | 120 | | </li> |
| | | 121 | | } |
| | | 122 | | |
| | | 123 | | <li class="page-item disabled"><span class="page-link">...</span></li> |
| | | 124 | | <li class="page-item"> |
| | 0 | 125 | | <a class="page-link" asp-action="Index" asp-route-page="@(totalPages)">@totalPages</a> |
| | | 126 | | </li> |
| | | 127 | | } |
| | | 128 | | } |
| | | 129 | | else |
| | | 130 | | { |
| | 0 | 131 | | for (int i = 1; i <= totalPages; i++) |
| | | 132 | | { |
| | | 133 | | <li class="page-item @(i == currentPage ? "active" : "")"> |
| | 0 | 134 | | <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a> |
| | | 135 | | </li> |
| | | 136 | | } |
| | | 137 | | } |
| | | 138 | | |
| | | 139 | | </ul> |
| | | 140 | | </nav> |
| | | 141 | | |
| | | 142 | | |
| | | 143 | | |
| | | 144 | | @section Scripts { |
| | | 145 | | <script> |
| | | 146 | | document.addEventListener("DOMContentLoaded", function () { |
| | | 147 | | const items = []; |
| | | 148 | | |
| | | 149 | | document.querySelectorAll('tr[data-order-item-code]').forEach(row => { |
| | | 150 | | const code = row.getAttribute('data-order-item-code'); |
| | | 151 | | const id = row.getAttribute('data-order-item-id'); |
| | | 152 | | if (code && id) { |
| | | 153 | | items.push({ id: id, code: code }); |
| | | 154 | | } |
| | | 155 | | }); |
| | | 156 | | |
| | | 157 | | if (items.length > 0) { |
| | | 158 | | fetch('/Studio2/Tradesoft/UpdateItemsStatus', { |
| | | 159 | | method: 'POST', |
| | | 160 | | headers: { |
| | | 161 | | 'Content-Type': 'application/json' |
| | | 162 | | }, |
| | | 163 | | body: JSON.stringify(items) |
| | | 164 | | }); |
| | | 165 | | } |
| | | 166 | | }); |
| | | 167 | | </script> |
| | | 168 | | } |