| | | 1 | | @using OzonOrdersWeb.ViewModels.OrderViewModels |
| | | 2 | | |
| | | 3 | | @model EditOrderViewModel; |
| | | 4 | | |
| | | 5 | | @{ |
| | 0 | 6 | | ViewData["Title"] = $"Редактирование заказа - {Model.Order?.ShipmentNumber ?? Model.Order?.Id.ToString() ?? "N/A"}"; |
| | 0 | 7 | | Layout = "~/Views/Shared/_Layout.cshtml"; |
| | 0 | 8 | | var fieldMap = Model.OrderListFieldReadAccess; |
| | 0 | 9 | | bool Col(string fieldName) => fieldMap == null || fieldMap.GetValueOrDefault(fieldName, true); |
| | 0 | 10 | | var order = Model.Order!; |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | <script asp-src-include="~/js/**/*.js"></script> |
| | | 14 | | <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> |
| | | 15 | | |
| | | 16 | | <h4>Изменить заказ</h4> |
| | | 17 | | <hr /> |
| | | 18 | | <form asp-action="Edit"> |
| | | 19 | | <div asp-validation-summary="ModelOnly" class="text-danger"></div> |
| | | 20 | | <input type="hidden" asp-for="Order.Id" /> |
| | | 21 | | <table class="table table-striped" id="shipmentTable"> |
| | | 22 | | <thead> |
| | | 23 | | <tr> |
| | 0 | 24 | | @if (Col("ShipmentNumber")) |
| | | 25 | | { |
| | | 26 | | <th> |
| | | 27 | | Номер заказа |
| | | 28 | | </th> |
| | | 29 | | } |
| | 0 | 30 | | @if (Col("OzonClient")) |
| | | 31 | | { |
| | | 32 | | <th> |
| | | 33 | | Клиент |
| | | 34 | | </th> |
| | | 35 | | } |
| | | 36 | | |
| | 0 | 37 | | @if (Col("ProcessingDate")) |
| | | 38 | | { |
| | | 39 | | <th> |
| | | 40 | | Принят в обработку |
| | | 41 | | </th> |
| | | 42 | | } |
| | | 43 | | |
| | 0 | 44 | | @if (Col("ShippingDate")) |
| | | 45 | | { |
| | | 46 | | <th> |
| | | 47 | | Дата отгрузки |
| | | 48 | | </th> |
| | | 49 | | } |
| | 0 | 50 | | @if (Col("DeliveryPeriod")) |
| | | 51 | | { |
| | | 52 | | <th> |
| | | 53 | | Срок доставки |
| | | 54 | | </th> |
| | | 55 | | } |
| | 0 | 56 | | @if (Col("ClientStatus")) |
| | | 57 | | { |
| | | 58 | | <th> |
| | | 59 | | Статус клиента |
| | | 60 | | </th> |
| | | 61 | | } |
| | | 62 | | |
| | 0 | 63 | | @if (Col("AppStatus")) |
| | | 64 | | { |
| | | 65 | | <th> |
| | | 66 | | Статус |
| | | 67 | | </th> |
| | | 68 | | } |
| | | 69 | | |
| | 0 | 70 | | @if (Col("ProductName")) |
| | | 71 | | { |
| | | 72 | | <th> |
| | | 73 | | Наименование товара |
| | | 74 | | </th> |
| | | 75 | | } |
| | | 76 | | |
| | 0 | 77 | | @if (Col("Article")) |
| | | 78 | | { |
| | | 79 | | <th> |
| | | 80 | | Артикул |
| | | 81 | | </th> |
| | | 82 | | } |
| | | 83 | | |
| | 0 | 84 | | @if (Col("Manufacturer")) |
| | | 85 | | { |
| | | 86 | | <th> |
| | | 87 | | Производитель |
| | | 88 | | </th> |
| | | 89 | | } |
| | | 90 | | |
| | 0 | 91 | | @if (Col("ShipmentWarehouse")) |
| | | 92 | | { |
| | | 93 | | <th> |
| | | 94 | | Склад отгрузки |
| | | 95 | | </th> |
| | | 96 | | } |
| | | 97 | | |
| | 0 | 98 | | @if (Col("Supplier")) |
| | | 99 | | { |
| | | 100 | | <th> |
| | | 101 | | Поставщик |
| | | 102 | | </th> |
| | | 103 | | } |
| | | 104 | | |
| | 0 | 105 | | @if (Col("SupplierOrderNumber")) |
| | | 106 | | { |
| | | 107 | | <th> |
| | | 108 | | Номер заказа поставщику |
| | | 109 | | </th> |
| | | 110 | | } |
| | | 111 | | |
| | 0 | 112 | | @if (Col("SitePrice")) |
| | | 113 | | { |
| | | 114 | | <th> |
| | | 115 | | Цена сайта |
| | | 116 | | </th> |
| | | 117 | | } |
| | | 118 | | |
| | 0 | 119 | | @if (Col("Price")) |
| | | 120 | | { |
| | | 121 | | <th> |
| | | 122 | | Цена |
| | | 123 | | </th> |
| | | 124 | | } |
| | | 125 | | |
| | 0 | 126 | | @if (Col("Quantity")) |
| | | 127 | | { |
| | | 128 | | <th> |
| | | 129 | | Кол. |
| | | 130 | | </th> |
| | | 131 | | } |
| | | 132 | | |
| | 0 | 133 | | @if (Col("ShipmentTotal")) |
| | | 134 | | { |
| | | 135 | | <th> |
| | | 136 | | Сумма отправления |
| | | 137 | | </th> |
| | | 138 | | } |
| | | 139 | | |
| | 0 | 140 | | @if (Col("Category")) |
| | | 141 | | { |
| | | 142 | | <th> |
| | | 143 | | Категория |
| | | 144 | | </th> |
| | | 145 | | } |
| | | 146 | | |
| | 0 | 147 | | @if (Col("VolumeWeight")) |
| | | 148 | | { |
| | | 149 | | <th> |
| | | 150 | | Объемный вес |
| | | 151 | | </th> |
| | | 152 | | } |
| | | 153 | | |
| | 0 | 154 | | @if (Col("PurchasePrice")) |
| | | 155 | | { |
| | | 156 | | <th colspan="4" style="text-align: right; white-space: nowrap;"> |
| | | 157 | | Цена закупки |
| | | 158 | | </th> |
| | | 159 | | } |
| | | 160 | | |
| | 0 | 161 | | @if (Col("OzonCommission")) |
| | | 162 | | { |
| | | 163 | | <th> |
| | | 164 | | Комиссия ОЗОН |
| | | 165 | | </th> |
| | | 166 | | } |
| | | 167 | | |
| | 0 | 168 | | @if (Col("Profit")) |
| | | 169 | | { |
| | | 170 | | <th> |
| | | 171 | | Прибыль |
| | | 172 | | </th> |
| | | 173 | | } |
| | | 174 | | |
| | 0 | 175 | | @if (Col("MarkupPercent")) |
| | | 176 | | { |
| | | 177 | | <th> |
| | | 178 | | Наценка % |
| | | 179 | | </th> |
| | | 180 | | } |
| | | 181 | | |
| | 0 | 182 | | @if (Col("DeliveryCity")) |
| | | 183 | | { |
| | | 184 | | <th> |
| | | 185 | | Город доставки |
| | | 186 | | </th> |
| | | 187 | | } |
| | | 188 | | <th></th> |
| | | 189 | | </tr> |
| | | 190 | | </thead> |
| | | 191 | | <tbody> |
| | | 192 | | |
| | | 193 | | <div class="form-group" style="display: none"> |
| | | 194 | | <label asp-for="Order.Key" class="control-label"></label><span style="margin-left: 10px; color: gray;">/ |
| | | 195 | | <input asp-for="Order.Key" class="form-control" /> |
| | | 196 | | <span asp-validation-for="Order.Key" class="text-danger"></span> |
| | | 197 | | </div> |
| | | 198 | | <div class="form-group" style="display: none"> |
| | | 199 | | <label asp-for="Order.ShipmentNumber" class="control-label"></label><span style="margin-left: 10px; colo |
| | | 200 | | <input asp-for="Order.ShipmentNumber" class="form-control" /> |
| | | 201 | | <span asp-validation-for="Order.ShipmentNumber" class="text-danger"></span> |
| | | 202 | | </div> |
| | | 203 | | <div class="form-group" style="display: none"> |
| | | 204 | | <label asp-for="Order.OzonClient" class="control-label"></label><span style="margin-left: 10px; color: g |
| | | 205 | | <input asp-for="Order.OzonClient" class="form-control" /> |
| | | 206 | | <span asp-validation-for="Order.OzonClient" class="text-danger"></span> |
| | | 207 | | </div> |
| | | 208 | | <div class="form-group" style="display: none"> |
| | | 209 | | <label asp-for="Order.ProcessingDate" class="control-label"></label><span style="margin-left: 10px; colo |
| | | 210 | | <input asp-for="Order.ProcessingDate" class="form-control" /> |
| | | 211 | | <span asp-validation-for="Order.ProcessingDate" class="text-danger"></span> |
| | | 212 | | </div> |
| | | 213 | | <div class="form-group" style="display: none"> |
| | | 214 | | <label asp-for="Order.ShippingDate" class="control-label"></label><span style="margin-left: 10px; color: |
| | | 215 | | <input asp-for="Order.ShippingDate" class="form-control" /> |
| | | 216 | | <span asp-validation-for="Order.ShippingDate" class="text-danger"></span> |
| | | 217 | | </div> |
| | | 218 | | <div class="form-group" style="display: none"> |
| | | 219 | | <label asp-for="Order.Status" class="control-label"></label><span style="margin-left: 10px; color: gray; |
| | | 220 | | <input asp-for="Order.Status" class="form-control" /> |
| | | 221 | | <span asp-validation-for="Order.Status" class="text-danger"></span> |
| | | 222 | | </div> |
| | | 223 | | <div class="form-group" style="display: none"> |
| | | 224 | | <label asp-for="Order.ProductName" class="control-label"></label><span style="margin-left: 10px; color: |
| | | 225 | | <input asp-for="Order.ProductName" class="form-control" /> |
| | | 226 | | <span asp-validation-for="Order.ProductName" class="text-danger"></span> |
| | | 227 | | </div> |
| | | 228 | | <div class="form-group" style="display: none"> |
| | | 229 | | <label asp-for="Order.ProductKey" class="control-label"></label><span style="margin-left: 10px; color: g |
| | | 230 | | <input asp-for="Order.ProductKey" class="form-control" /> |
| | | 231 | | <span asp-validation-for="Order.ProductKey" class="text-danger"></span> |
| | | 232 | | </div> |
| | | 233 | | <div class="form-group" style="display: none"> |
| | | 234 | | <label asp-for="Order.Quantity" class="control-label"></label><span style="margin-left: 10px; color: gra |
| | | 235 | | <input asp-for="Order.Quantity" class="form-control" /> |
| | | 236 | | <span asp-validation-for="Order.Quantity" class="text-danger"></span> |
| | | 237 | | </div> |
| | | 238 | | <div class="form-group" style="display: none"> |
| | | 239 | | <label asp-for="Order.ShipmentAmount" class="control-label"></label><span style="margin-left: 10px; colo |
| | | 240 | | <input asp-for="Order.ShipmentAmount" class="form-control" /> |
| | | 241 | | <span asp-validation-for="Order.ShipmentAmount" class="text-danger"></span> |
| | | 242 | | </div> |
| | | 243 | | <div class="form-group" style="display: none"> |
| | | 244 | | <label asp-for="Order.Price" class="control-label"></label><span style="margin-left: 10px; color: gray;" |
| | | 245 | | <input asp-for="Order.Price" class="form-control" /> |
| | | 246 | | <span asp-validation-for="Order.Price" class="text-danger"></span> |
| | | 247 | | </div> |
| | | 248 | | <div class="form-group" style="display: none"> |
| | | 249 | | <label asp-for="Order.MinOzonCommission" class="control-label"></label><span style="margin-left: 10px; c |
| | | 250 | | <input asp-for="Order.MinOzonCommission" class="form-control" /> |
| | | 251 | | <span asp-validation-for="Order.MinOzonCommission" class="text-danger"></span> |
| | | 252 | | </div> |
| | | 253 | | <div class="form-group" style="display: none"> |
| | | 254 | | <label asp-for="Order.MaxOzonCommission" class="control-label"></label><span style="margin-left: 10px; c |
| | | 255 | | <input asp-for="Order.MaxOzonCommission" class="form-control" /> |
| | | 256 | | <span asp-validation-for="Order.MaxOzonCommission" class="text-danger"></span> |
| | | 257 | | </div> |
| | | 258 | | <div class="form-group" style="display: none"> |
| | | 259 | | <label asp-for="Order.MaxProfit" class="control-label"></label><span style="margin-left: 10px; color: gr |
| | | 260 | | <input asp-for="Order.MaxProfit" class="form-control" /> |
| | | 261 | | <span asp-validation-for="Order.MaxProfit" class="text-danger"></span> |
| | | 262 | | </div> |
| | | 263 | | <div class="form-group" style="display: none"> |
| | | 264 | | <label asp-for="Order.MinDiscount" class="control-label"></label><span style="margin-left: 10px; color: |
| | | 265 | | <input asp-for="Order.MinDiscount" class="form-control" /> |
| | | 266 | | <span asp-validation-for="Order.MinDiscount" class="text-danger"></span> |
| | | 267 | | </div> |
| | | 268 | | <div class="form-group" style="display: none"> |
| | | 269 | | <label asp-for="Order.DeliveryCity" class="control-label"></label><span style="margin-left: 10px; color: |
| | | 270 | | <input asp-for="Order.DeliveryCity" class="form-control" /> |
| | | 271 | | <span asp-validation-for="Order.DeliveryCity" class="text-danger"></span> |
| | | 272 | | </div> |
| | | 273 | | |
| | | 274 | | <div class="form-group" style="display: none"> |
| | | 275 | | <label asp-for="Order.UpdatedBy" class="control-label"></label><span style="margin-left: 10px; color: gr |
| | 0 | 276 | | <input asp-for="Order.UpdatedBy" class="form-control" value="@User.Identity?.Name" /> |
| | | 277 | | <span asp-validation-for="Order.UpdatedBy" class="text-danger"></span> |
| | | 278 | | </div> |
| | | 279 | | |
| | | 280 | | |
| | | 281 | | <tr> |
| | 0 | 282 | | @if (Col("ShipmentNumber")) |
| | | 283 | | { |
| | | 284 | | <td> |
| | 0 | 285 | | @(order.ShipmentNumber) |
| | | 286 | | </td> |
| | | 287 | | } |
| | 0 | 288 | | @if (Col("OzonClient")) |
| | | 289 | | { |
| | | 290 | | <td> |
| | 0 | 291 | | @(order.OzonClient?.Name) |
| | | 292 | | </td> |
| | | 293 | | } |
| | | 294 | | |
| | 0 | 295 | | @if (Col("ProcessingDate")) |
| | | 296 | | { |
| | | 297 | | <td> |
| | 0 | 298 | | @(order.FormattedProcessingDate) <br /> @(order.FormattedProcessingTime) |
| | | 299 | | </td> |
| | | 300 | | } |
| | | 301 | | |
| | 0 | 302 | | @if (Col("ShippingDate")) |
| | | 303 | | { |
| | | 304 | | <td> |
| | 0 | 305 | | @(order.FormattedShippingDate) <br /> @(order.FormattedShippingTime) |
| | | 306 | | </td> |
| | | 307 | | } |
| | | 308 | | |
| | 0 | 309 | | @if (Col("DeliveryPeriod")) |
| | | 310 | | { |
| | | 311 | | <td style="white-space: nowrap; text-align: right;"> |
| | 0 | 312 | | @(order.FormattedDeliveryDay) |
| | | 313 | | <br /> |
| | 0 | 314 | | @(order.FormattedDeliveryHours) |
| | | 315 | | </td> |
| | | 316 | | } |
| | | 317 | | |
| | 0 | 318 | | @if (Col("ClientStatus")) |
| | | 319 | | { |
| | | 320 | | <td> |
| | 0 | 321 | | @(order.Status) |
| | | 322 | | </td> |
| | | 323 | | } |
| | | 324 | | |
| | 0 | 325 | | @if (Col("AppStatus")) |
| | | 326 | | { |
| | | 327 | | <td> |
| | | 328 | | <div class="form-group"> |
| | | 329 | | <select asp-for="Order.AppStatusId" asp-items="@ViewBag.AppStatuses" class="form-control"> |
| | | 330 | | <option value="">Выберите статус</option> |
| | | 331 | | </select> |
| | | 332 | | <a asp-controller="AppStatus" asp-action="Create">Создать статус</a> |
| | | 333 | | </div> |
| | | 334 | | </td> |
| | | 335 | | } |
| | | 336 | | |
| | 0 | 337 | | @if (Col("ProductName")) |
| | | 338 | | { |
| | | 339 | | <td> |
| | | 340 | | @{ |
| | 0 | 341 | | string? first15Chars = null; |
| | 0 | 342 | | if (!string.IsNullOrEmpty(order.ProductName)) |
| | | 343 | | { |
| | 0 | 344 | | first15Chars = order.ProductName.Length > 45 ? order.ProductName.Substring(0, 45) + "... |
| | | 345 | | } |
| | | 346 | | } |
| | | 347 | | |
| | 0 | 348 | | @Html.DisplayFor(modelItem => first15Chars) |
| | | 349 | | </td> |
| | | 350 | | } |
| | | 351 | | |
| | 0 | 352 | | @if (Col("Article")) |
| | | 353 | | { |
| | | 354 | | <td> |
| | 0 | 355 | | @(order.ProductKey) |
| | | 356 | | </td> |
| | | 357 | | } |
| | | 358 | | |
| | 0 | 359 | | @if (Col("Manufacturer")) |
| | | 360 | | { |
| | | 361 | | <td> |
| | 0 | 362 | | @(order.EtProducer?.Name) |
| | | 363 | | </td> |
| | | 364 | | } |
| | | 365 | | |
| | 0 | 366 | | @if (Col("ShipmentWarehouse")) |
| | | 367 | | { |
| | | 368 | | <td> |
| | 0 | 369 | | @(order.ShipmentWarehouse?.Name) |
| | | 370 | | </td> |
| | | 371 | | } |
| | | 372 | | |
| | 0 | 373 | | @if (Col("Supplier")) |
| | | 374 | | { |
| | | 375 | | <td> |
| | | 376 | | <div class="form-group"> |
| | | 377 | | <select asp-for="Order.SupplierId" asp-items="@ViewBag.Suppliers" class="form-control suppli |
| | | 378 | | <option value="">Выберите поставщика</option> |
| | 0 | 379 | | @foreach (var supplier in Model.Suppliers) |
| | | 380 | | { |
| | 0 | 381 | | <option value="@supplier.Id" data-currency-code="@supplier.CurrencyCode" data-cost-f |
| | | 382 | | } |
| | 0 | 383 | | <option value="create" class="link-option" data-url="@Url.Action("Create", "Supplier")"> |
| | | 384 | | </select> |
| | | 385 | | </div> |
| | | 386 | | </td> |
| | | 387 | | <script> |
| | | 388 | | // Обработка клика по ссылке внутри select |
| | | 389 | | $(function () { |
| | | 390 | | $('#SupplierId').change(function () { |
| | | 391 | | var selectedValue = $(this).val(); |
| | | 392 | | if (selectedValue == 'create') { |
| | | 393 | | var url = $('option:selected', this).data('url'); |
| | | 394 | | if (url) { |
| | | 395 | | window.location.href = url; // Перенаправление на URL |
| | | 396 | | } |
| | | 397 | | } |
| | | 398 | | }); |
| | | 399 | | }); |
| | | 400 | | </script> |
| | | 401 | | } |
| | 0 | 402 | | @if (Col("SupplierOrderNumber")) |
| | | 403 | | { |
| | | 404 | | <td style="text-align: right;"> |
| | | 405 | | <div class="form-group"> |
| | | 406 | | <input asp-for="Order.OrderNumberToSupplier" type="text" class="form-control orderNumberToSu |
| | | 407 | | <span asp-validation-for="Order.OrderNumberToSupplier" class="text-danger"></span> |
| | | 408 | | </div> |
| | | 409 | | </td> |
| | | 410 | | } |
| | | 411 | | |
| | 0 | 412 | | @if (Col("SitePrice")) |
| | | 413 | | { |
| | | 414 | | <td id="CurrentPriceWithDiscount" style="text-align: right;"> |
| | 0 | 415 | | @(order.ProductInfo?.CurrentPriceWithDiscount) |
| | | 416 | | </td> |
| | | 417 | | } |
| | | 418 | | |
| | 0 | 419 | | @if (Col("Price")) |
| | | 420 | | { |
| | | 421 | | <td id="Price" style="text-align: right;"> |
| | 0 | 422 | | @(order.Price) |
| | | 423 | | </td> |
| | | 424 | | } |
| | | 425 | | |
| | 0 | 426 | | @if (Col("Quantity")) |
| | | 427 | | { |
| | | 428 | | <td style="text-align: center;"> |
| | | 429 | | @{ |
| | 0 | 430 | | if (order.Quantity > 1) |
| | | 431 | | { |
| | | 432 | | <b> |
| | 0 | 433 | | @(order.Quantity) |
| | | 434 | | </b> |
| | | 435 | | } |
| | | 436 | | else |
| | | 437 | | { |
| | 0 | 438 | | @(order.Quantity) |
| | | 439 | | } |
| | | 440 | | } |
| | | 441 | | </td> |
| | | 442 | | } |
| | | 443 | | |
| | 0 | 444 | | @if (Col("ShipmentTotal")) |
| | | 445 | | { |
| | | 446 | | <td style="text-align: right;"> |
| | 0 | 447 | | @(order.ShipmentAmount) |
| | | 448 | | </td> |
| | | 449 | | } |
| | | 450 | | |
| | 0 | 451 | | @if (Col("Category")) |
| | | 452 | | { |
| | | 453 | | <td> |
| | 0 | 454 | | @(order.ProductInfo?.CommercialCategory) |
| | | 455 | | </td> |
| | | 456 | | } |
| | | 457 | | |
| | 0 | 458 | | @if (Col("VolumeWeight")) |
| | | 459 | | { |
| | | 460 | | <td style="text-align: center;"> |
| | 0 | 461 | | @(order.ProductInfo?.VolumetricWeight) |
| | | 462 | | </td> |
| | | 463 | | } |
| | | 464 | | |
| | 0 | 465 | | @if (Col("PurchasePrice")) |
| | | 466 | | { |
| | | 467 | | <td colspan="4" style="text-align: right; white-space: nowrap;"> |
| | | 468 | | <div class="form-group d-flex align-items-center"> |
| | | 469 | | <div class="flex-grow-1"> |
| | | 470 | | <input asp-for="Order.PurchasePrice" type="text" class="form-control purchase-price-fiel |
| | | 471 | | <span asp-validation-for="Order.PurchasePrice" class="text-danger" id="PurchasePriceVali |
| | | 472 | | </div> |
| | | 473 | | <div class="ml-2"> |
| | | 474 | | <span class="currency-code" id="CurrencyCode"></span> |
| | | 475 | | </div> |
| | | 476 | | </div> |
| | | 477 | | <div class="form-group"> |
| | | 478 | | <span class="purchase-price-rub ml-2" id="PurchasePriceRub"></span> |
| | | 479 | | </div> |
| | | 480 | | </td> |
| | | 481 | | } |
| | | 482 | | |
| | 0 | 483 | | @if (Col("OzonCommission")) |
| | | 484 | | { |
| | | 485 | | <td style="text-align: right;"> |
| | 0 | 486 | | <div id="MinOzonCommission">@(order.MinOzonCommission)</div> |
| | | 487 | | <br /> |
| | 0 | 488 | | <div id="MaxOzonCommission">@(order.MaxOzonCommission)</div> |
| | | 489 | | </td> |
| | | 490 | | } |
| | | 491 | | |
| | 0 | 492 | | @if (Col("Profit")) |
| | | 493 | | { |
| | | 494 | | <td style="text-align: right;"> |
| | | 495 | | <div id="MaxProfitContainer"> |
| | 0 | 496 | | @if (order.MaxProfit < 0) |
| | | 497 | | { |
| | 0 | 498 | | <span style="color:red" id="MaxProfit">@(order.MaxProfit)</span> |
| | | 499 | | } |
| | | 500 | | else |
| | | 501 | | { |
| | 0 | 502 | | <span id="MaxProfit">@(order.MaxProfit)</span> |
| | | 503 | | } |
| | | 504 | | </div> |
| | | 505 | | <br /> |
| | | 506 | | <div id="MinProfitContainer"> |
| | 0 | 507 | | @if (order.MinProfit < 0) |
| | | 508 | | { |
| | 0 | 509 | | <span style="color:red" id="MinProfit">@(order.MinProfit)</span> |
| | | 510 | | } |
| | | 511 | | else |
| | | 512 | | { |
| | 0 | 513 | | <span id="MinProfit">@(order.MinProfit)</span> |
| | | 514 | | } |
| | | 515 | | </div> |
| | | 516 | | </td> |
| | | 517 | | } |
| | | 518 | | |
| | 0 | 519 | | @if (Col("MarkupPercent")) |
| | | 520 | | { |
| | | 521 | | <td style="text-align: right;"> |
| | | 522 | | <div id="MaxDiscountContainer"> |
| | 0 | 523 | | @if (order.MaxDiscount < 0) |
| | | 524 | | { |
| | 0 | 525 | | <span style="color:red" id="MaxDiscount">@(order.MaxDiscount)</span> |
| | | 526 | | } |
| | | 527 | | else |
| | | 528 | | { |
| | 0 | 529 | | <span id="MaxDiscount">@(order.MaxDiscount)</span> |
| | | 530 | | } |
| | | 531 | | </div> |
| | | 532 | | <br /> |
| | | 533 | | <div id="MinDiscountContainer"> |
| | 0 | 534 | | @if (order.MinDiscount < 0) |
| | | 535 | | { |
| | 0 | 536 | | <span style="color:red" id="MinDiscount">@(order.MinDiscount)</span> |
| | | 537 | | } |
| | | 538 | | else |
| | | 539 | | { |
| | 0 | 540 | | <span id="MinDiscount">@(order.MinDiscount)</span> |
| | | 541 | | } |
| | | 542 | | </div> |
| | | 543 | | </td> |
| | | 544 | | } |
| | | 545 | | |
| | 0 | 546 | | @if (Col("DeliveryCity")) |
| | | 547 | | { |
| | | 548 | | <td> |
| | 0 | 549 | | @(order.DeliveryCity) |
| | | 550 | | </td> |
| | | 551 | | } |
| | | 552 | | </tr> |
| | | 553 | | |
| | | 554 | | |
| | | 555 | | </tbody> |
| | | 556 | | </table> |
| | | 557 | | <script> |
| | | 558 | | $(document).ready(function () { |
| | | 559 | | // Получаем значения курсов валют из Razor View |
| | 0 | 560 | | var rateUSD = @Model.RateUSD.ToString().Replace(',', '.'); |
| | 0 | 561 | | var rateEUR = @Model.RateEUR.ToString().Replace(',', '.'); |
| | 0 | 562 | | var rateBYN = @Model.RateBYN.ToString().Replace(',', '.'); |
| | | 563 | | |
| | | 564 | | function readSupplierDataNumber($option, key, fallback) { |
| | | 565 | | if (!$option || !$option.length) return fallback; |
| | | 566 | | var raw = $option.data(key); |
| | | 567 | | if (raw === undefined || raw === null || raw === '') return fallback; |
| | | 568 | | var parsed = parseFloat(String(raw).replace(',', '.')); |
| | | 569 | | return isNaN(parsed) ? fallback : parsed; |
| | | 570 | | } |
| | | 571 | | |
| | | 572 | | // Обработка изменения поставщика |
| | | 573 | | $('#SupplierId').on('change', function () { |
| | | 574 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 575 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 576 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 577 | | |
| | | 578 | | if (currencyCode) { |
| | | 579 | | $('#CurrencyCode').text(currencyCode); |
| | | 580 | | updatePurchasePriceInRub(currencyCode, costFactor); |
| | | 581 | | } else { |
| | | 582 | | $('#CurrencyCode').text(''); |
| | | 583 | | $('#PurchasePriceRub').text(''); |
| | | 584 | | } |
| | | 585 | | }); |
| | | 586 | | |
| | | 587 | | // Обработка изменения значения purchase price |
| | | 588 | | $('#PurchasePrice').on('input', function () { |
| | | 589 | | var selectedSupplier = $('#SupplierId').find('option:selected'); |
| | | 590 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 591 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 592 | | |
| | | 593 | | updatePurchasePriceInRub(currencyCode, costFactor); |
| | | 594 | | updateCalculations(); |
| | | 595 | | }); |
| | | 596 | | |
| | | 597 | | function updatePurchasePriceInRub(currencyCode, costFactor) { |
| | | 598 | | var purchasePrice = parseFloat($('#PurchasePrice').val()); |
| | | 599 | | var purchasePriceInRub = 0; |
| | | 600 | | var titleText = ''; |
| | | 601 | | |
| | | 602 | | switch (currencyCode) { |
| | | 603 | | case 'USD': |
| | | 604 | | purchasePriceInRub = purchasePrice * costFactor * rateUSD; |
| | | 605 | | titleText = `${purchasePrice} (Цена закупки USD) * ${costFactor} (Коэффициент) * ${rateUSD} (Кур |
| | | 606 | | console.log(titleText); |
| | | 607 | | break; |
| | | 608 | | case 'EUR': |
| | | 609 | | purchasePriceInRub = purchasePrice * costFactor * rateEUR; |
| | | 610 | | titleText = `${purchasePrice} (Цена закупки EUR) * ${costFactor} (Коэффициент) * ${rateEUR} (Кур |
| | | 611 | | console.log(titleText); |
| | | 612 | | break; |
| | | 613 | | case 'BYN': |
| | | 614 | | purchasePriceInRub = purchasePrice * costFactor * rateBYN; |
| | | 615 | | titleText = `${purchasePrice} (Цена закупки BYN) * ${costFactor} (Коэффициент) * ${rateBYN} (Кур |
| | | 616 | | console.log(titleText); |
| | | 617 | | break; |
| | | 618 | | default: |
| | | 619 | | purchasePriceInRub = purchasePrice * costFactor; |
| | | 620 | | titleText = `${purchasePrice} (Цена закупки RUB) * ${costFactor} (Коэффициент) = ${purchasePrice |
| | | 621 | | console.log(titleText); |
| | | 622 | | break; |
| | | 623 | | } |
| | | 624 | | |
| | | 625 | | $('#PurchasePriceRub').text(!isNaN(purchasePriceInRub) ? purchasePriceInRub.toFixed(2) + ' RUB' : ''); |
| | | 626 | | $('#PurchasePriceRub').attr('title', titleText); |
| | | 627 | | $('#PurchasePrice').data('purchase-price-rub', purchasePriceInRub); |
| | | 628 | | } |
| | | 629 | | |
| | | 630 | | function updateCalculations() { |
| | | 631 | | var value = parseFloat($('#PurchasePrice').data('purchase-price-rub')); |
| | | 632 | | var currentPrice = parseFloat($('#CurrentPriceWithDiscount').text()); |
| | | 633 | | var price = !isNaN(currentPrice) && currentPrice > 0 |
| | | 634 | | ? currentPrice |
| | | 635 | | : parseFloat($('#Price').text()); |
| | | 636 | | var minOzonCommission = parseFloat($('#MinOzonCommission').text()); |
| | | 637 | | var maxOzonCommission = parseFloat($('#MaxOzonCommission').text()); |
| | | 638 | | |
| | | 639 | | console.log(`Value: ${value}, Price: ${price}, Min Ozon Commission: ${minOzonCommission}, Max Ozon Commi |
| | | 640 | | |
| | | 641 | | var startCommission = price - value; |
| | | 642 | | var minProfit = startCommission - maxOzonCommission; |
| | | 643 | | var maxProfit = startCommission - minOzonCommission; |
| | | 644 | | var minDiscount = (minProfit / value) * 100; |
| | | 645 | | var maxDiscount = (maxProfit / value) * 100; |
| | | 646 | | |
| | | 647 | | console.log(`Start Commission: ${startCommission}, Min Profit: ${minProfit}, Max Profit: ${maxProfit}, M |
| | | 648 | | |
| | | 649 | | var minProfitElement = $('#MinProfit'); |
| | | 650 | | var maxProfitElement = $('#MaxProfit'); |
| | | 651 | | var maxDiscountElement = $('#MaxDiscount'); |
| | | 652 | | var minDiscountElement = $('#MinDiscount'); |
| | | 653 | | |
| | | 654 | | minProfitElement.text(!isNaN(minProfit) ? minProfit.toFixed(2) : ""); |
| | | 655 | | maxProfitElement.text(!isNaN(maxProfit) ? maxProfit.toFixed(2) : ""); |
| | | 656 | | maxDiscountElement.text(!isNaN(maxDiscount) ? maxDiscount.toFixed(2) : ""); |
| | | 657 | | minDiscountElement.text(!isNaN(minDiscount) ? minDiscount.toFixed(2) : ""); |
| | | 658 | | |
| | | 659 | | minProfitElement.css('color', minProfit < 0 ? 'red' : ''); |
| | | 660 | | maxProfitElement.css('color', maxProfit < 0 ? 'red' : ''); |
| | | 661 | | minDiscountElement.css('color', minDiscount < 0 ? 'red' : ''); |
| | | 662 | | maxDiscountElement.css('color', maxDiscount < 0 ? 'red' : ''); |
| | | 663 | | } |
| | | 664 | | }); |
| | | 665 | | </script> |
| | | 666 | | |
| | | 667 | | |
| | | 668 | | |
| | | 669 | | |
| | | 670 | | <div class="form-group"> |
| | | 671 | | <label asp-for="Order.Comment" class="control-label"></label> |
| | | 672 | | <input type="hidden" name="page" value="@Model.RedirectPage" /> |
| | | 673 | | <div class="input-group"> |
| | | 674 | | <input asp-for="Order.Comment" class="form-control" /> |
| | | 675 | | <span class="input-group-btn"> |
| | | 676 | | <input type="submit" value="Сохранить" class="btn btn-primary" style="margin-left: 10px;" /> |
| | | 677 | | </span> |
| | | 678 | | </div> |
| | | 679 | | <span asp-validation-for="Order.Comment" class="text-danger"></span> |
| | | 680 | | </div> |
| | | 681 | | |
| | | 682 | | </form> |
| | | 683 | | <br /> |
| | | 684 | | <button id="showHistoryButton" type="button" class="btn btn-primary" onclick="getHistory(@order.Id)">Показать историю</b |
| | | 685 | | <div class="modal-body"> |
| | | 686 | | |
| | | 687 | | <div id="historyContent"></div> |
| | | 688 | | </div> |
| | | 689 | | |
| | | 690 | | <div> |
| | | 691 | | <a asp-action="Index">К списку заказов</a> |
| | | 692 | | </div> |
| | | 693 | | |
| | | 694 | | <script> |
| | | 695 | | function getHistory(orderId) { |
| | | 696 | | var fmtDate = window.OrderDateDisplay ? window.OrderDateDisplay.formatTableDate : function (v) { return v ? new |
| | | 697 | | var fmtFull = window.OrderDateDisplay ? window.OrderDateDisplay.formatFullDateTime : function (v) { return v ? n |
| | | 698 | | |
| | | 699 | | // Отправка запроса на сервер для получения истории заказа |
| | | 700 | | $.ajax({ |
| | | 701 | | url: '/Orders/GetHistory/' + orderId, |
| | | 702 | | type: 'GET', |
| | | 703 | | success: function (data) { |
| | | 704 | | |
| | | 705 | | var orderHistory = data.result; |
| | | 706 | | // Заполнение таблицы модального окна полученной информацией |
| | | 707 | | var historyContent = '<table class="table table-striped"><thead><tr><th>Номер заказа</th><th>Клиент</th> |
| | | 708 | | for (var i = 0; i < orderHistory.length; i++) { |
| | | 709 | | var order = orderHistory[i].order; |
| | | 710 | | |
| | | 711 | | console.log(order) |
| | | 712 | | // Получаем даты создания и изменения |
| | | 713 | | var createdDate = fmtFull(orderHistory[i].start); |
| | | 714 | | |
| | | 715 | | var modifiedDate = fmtFull(orderHistory[i].end); |
| | | 716 | | |
| | | 717 | | var rowClass = order.isAccepted ? "table-success" : "table-active"; |
| | | 718 | | |
| | | 719 | | // Добавляем даты создания и изменения на всю ширину строки |
| | | 720 | | historyContent += '<tr class="' + rowClass + '">' |
| | | 721 | | if (i == 0) { |
| | | 722 | | historyContent += '<td colspan="22">' + '<b>Новый</b>' + ' <b>Созда |
| | | 723 | | } |
| | | 724 | | else { |
| | | 725 | | historyContent += '<td colspan="22">' + '<b>Создан:</b>' + createdDate + ' &nbs |
| | | 726 | | historyContent += '<button class="btn btn-primary" onclick="recoverOrder(' + order.id + ', \'' + |
| | | 727 | | } |
| | | 728 | | historyContent += '<tr class="' + rowClass + '">'; |
| | | 729 | | // Добавляем информацию о заказе |
| | | 730 | | historyContent += '<tr>'; |
| | | 731 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("S |
| | | 732 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("O |
| | | 733 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("P |
| | | 734 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("S |
| | | 735 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("S |
| | | 736 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("A |
| | | 737 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("P |
| | | 738 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("A |
| | | 739 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("A |
| | | 740 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("S |
| | | 741 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("S |
| | | 742 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 743 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 744 | | historyContent += '<td style="text-align: center;" class="' + ((order.updatedColumns != null && orde |
| | | 745 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 746 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("P |
| | | 747 | | historyContent += '<td style="text-align: center;" class="' + ((order.updatedColumns != null && orde |
| | | 748 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 749 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && (orde |
| | | 750 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 751 | | historyContent += '<td style="text-align: right;" class="' + ((order.updatedColumns != null && order |
| | | 752 | | historyContent += '<td class="' + ((order.updatedColumns != null && order.updatedColumns.includes("D |
| | | 753 | | historyContent += '</tr>'; |
| | | 754 | | |
| | | 755 | | |
| | | 756 | | |
| | | 757 | | } |
| | | 758 | | historyContent += '</tbody></table>'; |
| | | 759 | | // Вставка таблицы в модальное окно |
| | | 760 | | $('#historyContent').html(historyContent); |
| | | 761 | | // Отображение модального окна |
| | | 762 | | $('#historyModal').modal('show'); |
| | | 763 | | }, |
| | | 764 | | error: function () { |
| | | 765 | | console.error('Ошибка при получении истории заказа'); |
| | | 766 | | } |
| | | 767 | | }); |
| | | 768 | | } |
| | | 769 | | function getCurrencyCode(currencyCode) { |
| | | 770 | | switch (currencyCode) { |
| | | 771 | | case 0: |
| | | 772 | | return 'Нет'; |
| | | 773 | | case 1: |
| | | 774 | | return 'USD'; |
| | | 775 | | case 2: |
| | | 776 | | return 'EUR'; |
| | | 777 | | case 3: |
| | | 778 | | return 'RUB'; |
| | | 779 | | default: |
| | | 780 | | return ''; |
| | | 781 | | } |
| | | 782 | | } |
| | | 783 | | |
| | | 784 | | </script> |