| | | 1 | | @using OzonOrdersWeb.ViewModels.OrderViewModels |
| | | 2 | | |
| | | 3 | | |
| | | 4 | | @model MultiplayEditOrderViewModel |
| | | 5 | | |
| | | 6 | | @{ |
| | 0 | 7 | | var orders = Model.Orders; |
| | 0 | 8 | | var ordersCount = orders.Count; |
| | 0 | 9 | | ViewData["Title"] = $"Массовое редактирование заказов ({ordersCount} шт.)"; |
| | 0 | 10 | | Layout = "~/Views/Shared/_Layout.cshtml"; |
| | 0 | 11 | | var fieldMap = Model.OrderListFieldReadAccess; |
| | 0 | 12 | | bool Col(string fieldName) => fieldMap == null || fieldMap.GetValueOrDefault(fieldName, true); |
| | | 13 | | } |
| | | 14 | | @* |
| | | 15 | | <script asp-src-include="~/js/**/*.js"></script> *@ |
| | | 16 | | <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> |
| | | 17 | | <script asp-src-include="~/js/**/*.js"></script> |
| | | 18 | | |
| | | 19 | | <h4>Изменить заказы</h4> |
| | | 20 | | |
| | 0 | 21 | | @if (Model.ErrorMessage != null) |
| | | 22 | | { |
| | | 23 | | <div class="alert alert-dismissible alert-danger"> |
| | | 24 | | <button type="button" class="btn-close" data-bs-dismiss="alert"></button> |
| | 0 | 25 | | <p>@Html.Raw(Model.ErrorMessage)</p> |
| | | 26 | | </div> |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | <hr /> |
| | | 30 | | <div class="form-row d-flex"> |
| | | 31 | | <div class="form-group col-sm-3" style="display: none;"> |
| | | 32 | | <label for="universalField" class="col-form-label">Цена закупки:</label> |
| | | 33 | | <input type="text" class="form-control" id="universalField" /> |
| | | 34 | | </div> |
| | | 35 | | </div> |
| | | 36 | | |
| | | 37 | | <style> |
| | | 38 | | |
| | | 39 | | .highlight-error { |
| | | 40 | | border: 3px solid rgba(220, 53, 69, 0.5); |
| | | 41 | | ; |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | .highlight-warning { |
| | | 45 | | border: 3px solid rgba(255, 255, 0, 0.5); |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | .bg-green-300 { |
| | | 49 | | background-color: #73c487 !important; /* Bootstrap's 'bg-success' color */ |
| | | 50 | | } |
| | | 51 | | |
| | | 52 | | .form-check-label { |
| | | 53 | | user-select: none; /* предотвращает выделение текста */ |
| | | 54 | | cursor: pointer; /* меняет курсор при наведении */ |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | .custom-width { |
| | | 58 | | width: 100px; /* Задайте нужную ширину */ |
| | | 59 | | } |
| | | 60 | | </style> |
| | | 61 | | |
| | | 62 | | <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> |
| | | 63 | | <div class="modal-dialog"> |
| | | 64 | | <div class="modal-content"> |
| | | 65 | | <div class="modal-header"> |
| | | 66 | | <h5 class="modal-title" id="exampleModalLabel">Выберите столбцы для отображения</h5> |
| | | 67 | | <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button> |
| | | 68 | | </div> |
| | | 69 | | <div class="modal-body-checkbox"> |
| | | 70 | | <div class="container mt-3"> |
| | | 71 | | <div class="form-group"> |
| | | 72 | | <div class="form-row"> |
| | | 73 | | <button type="button" class="btn btn-danger" onclick="clearSelectedIdsCookie()">Очистить выб |
| | | 74 | | <br /> |
| | | 75 | | <br /> |
| | | 76 | | @{ |
| | 0 | 77 | | int checkboxCounter = 1; |
| | | 78 | | } |
| | 0 | 79 | | @if (Col("ShipmentNumber")) |
| | | 80 | | { |
| | | 81 | | <div class="form-group col-md-5"> |
| | | 82 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 83 | | <label class="form-check-label" for="chk@(checkboxCounter)">Номер заказа</label> |
| | | 84 | | </div> |
| | 0 | 85 | | checkboxCounter++; |
| | | 86 | | } |
| | 0 | 87 | | @if (Col("OzonClient")) |
| | | 88 | | { |
| | | 89 | | <div class="form-group col-md-5"> |
| | | 90 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 91 | | <label class="form-check-label" for="chk@(checkboxCounter)">Клиент</label> |
| | | 92 | | </div> |
| | 0 | 93 | | checkboxCounter++; |
| | | 94 | | } |
| | 0 | 95 | | @if (Col("ProcessingDate")) |
| | | 96 | | { |
| | | 97 | | <div class="form-group col-md-5"> |
| | | 98 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 99 | | <label class="form-check-label" for="chk@(checkboxCounter)">Принят в обработку</labe |
| | | 100 | | </div> |
| | 0 | 101 | | checkboxCounter++; |
| | | 102 | | } |
| | 0 | 103 | | @if (Col("ShippingDate")) |
| | | 104 | | { |
| | | 105 | | <div class="form-group col-md-5"> |
| | | 106 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 107 | | <label class="form-check-label" for="chk@(checkboxCounter)">Дата отгрузки</label> |
| | | 108 | | </div> |
| | 0 | 109 | | checkboxCounter++; |
| | | 110 | | } |
| | 0 | 111 | | @if (Col("DeliveryPeriod")) |
| | | 112 | | { |
| | | 113 | | <div class="form-group col-md-5"> |
| | | 114 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 115 | | <label class="form-check-label" for="chk@(checkboxCounter)">Срок доставки</label> |
| | | 116 | | </div> |
| | 0 | 117 | | checkboxCounter++; |
| | | 118 | | } |
| | 0 | 119 | | @if (Col("ClientStatus")) |
| | | 120 | | { |
| | | 121 | | <div class="form-group col-md-5"> |
| | | 122 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 123 | | <label class="form-check-label" for="chk@(checkboxCounter)">Статус клиента</label> |
| | | 124 | | </div> |
| | 0 | 125 | | checkboxCounter++; |
| | | 126 | | } |
| | 0 | 127 | | @if (Col("AppStatus")) |
| | | 128 | | { |
| | | 129 | | <div class="form-group col-md-5"> |
| | | 130 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 131 | | <label class="form-check-label" for="chk@(checkboxCounter)">Статус</label> |
| | | 132 | | </div> |
| | 0 | 133 | | checkboxCounter++; |
| | | 134 | | } |
| | 0 | 135 | | @if (Col("ProductName")) |
| | | 136 | | { |
| | | 137 | | <div class="form-group col-md-7"> |
| | | 138 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 139 | | <label class="form-check-label" for="chk@(checkboxCounter)">Наименование товара</lab |
| | | 140 | | </div> |
| | 0 | 141 | | checkboxCounter++; |
| | | 142 | | } |
| | 0 | 143 | | @if (Col("Article")) |
| | | 144 | | { |
| | | 145 | | <div class="form-group col-md-5"> |
| | | 146 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 147 | | <label class="form-check-label" for="chk@(checkboxCounter)">Артикул</label> |
| | | 148 | | </div> |
| | 0 | 149 | | checkboxCounter++; |
| | | 150 | | } |
| | 0 | 151 | | @if (Col("Manufacturer")) |
| | | 152 | | { |
| | | 153 | | <div class="form-group col-md-5"> |
| | | 154 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 155 | | <label class="form-check-label" for="chk@(checkboxCounter)">Производитель</label> |
| | | 156 | | </div> |
| | 0 | 157 | | checkboxCounter++; |
| | | 158 | | } |
| | 0 | 159 | | @if (Col("ShipmentWarehouse")) |
| | | 160 | | { |
| | | 161 | | <div class="form-group col-md-5"> |
| | | 162 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 163 | | <label class="form-check-label" for="chk@(checkboxCounter)">Склад отгрузки</label> |
| | | 164 | | </div> |
| | 0 | 165 | | checkboxCounter++; |
| | | 166 | | } |
| | 0 | 167 | | @if (Col("Supplier")) |
| | | 168 | | { |
| | | 169 | | <div class="form-group col-md-5"> |
| | | 170 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 171 | | <label class="form-check-label" for="chk@(checkboxCounter)">Поставщик</label> |
| | | 172 | | </div> |
| | 0 | 173 | | checkboxCounter++; |
| | | 174 | | } |
| | 0 | 175 | | @if (Col("SupplierOrderNumber")) |
| | | 176 | | { |
| | | 177 | | <div class="form-group col-md-6"> |
| | | 178 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 179 | | <label class="form-check-label" for="chk@(checkboxCounter)">Номер заказа поставщику< |
| | | 180 | | </div> |
| | 0 | 181 | | checkboxCounter++; |
| | | 182 | | } |
| | 0 | 183 | | @if (Col("SitePrice")) |
| | | 184 | | { |
| | | 185 | | <div class="form-group col-md-5"> |
| | | 186 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 187 | | <label class="form-check-label" for="chk@(checkboxCounter)">Цена сайта</label> |
| | | 188 | | </div> |
| | 0 | 189 | | checkboxCounter++; |
| | | 190 | | } |
| | 0 | 191 | | @if (Col("Price")) |
| | | 192 | | { |
| | | 193 | | <div class="form-group col-md-5"> |
| | | 194 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 195 | | <label class="form-check-label" for="chk@(checkboxCounter)">Цена</label> |
| | | 196 | | </div> |
| | 0 | 197 | | checkboxCounter++; |
| | | 198 | | } |
| | 0 | 199 | | @if (Col("Quantity")) |
| | | 200 | | { |
| | | 201 | | <div class="form-group col-md-5"> |
| | | 202 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 203 | | <label class="form-check-label" for="chk@(checkboxCounter)">Кол.</label> |
| | | 204 | | </div> |
| | 0 | 205 | | checkboxCounter++; |
| | | 206 | | } |
| | 0 | 207 | | @if (Col("ShipmentTotal")) |
| | | 208 | | { |
| | | 209 | | <div class="form-group col-md-5"> |
| | | 210 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 211 | | <label class="form-check-label" for="chk@(checkboxCounter)">Сумма отправления</label |
| | | 212 | | </div> |
| | 0 | 213 | | checkboxCounter++; |
| | | 214 | | } |
| | 0 | 215 | | @if (Col("Category")) |
| | | 216 | | { |
| | | 217 | | <div class="form-group col-md-5"> |
| | | 218 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 219 | | <label class="form-check-label" for="chk@(checkboxCounter)">Категория</label> |
| | | 220 | | </div> |
| | 0 | 221 | | checkboxCounter++; |
| | | 222 | | } |
| | 0 | 223 | | @if (Col("VolumeWeight")) |
| | | 224 | | { |
| | | 225 | | <div class="form-group col-md-5"> |
| | | 226 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 227 | | <label class="form-check-label" for="chk@(checkboxCounter)">Объемный вес</label> |
| | | 228 | | </div> |
| | 0 | 229 | | checkboxCounter++; |
| | | 230 | | } |
| | 0 | 231 | | @if (Col("PurchasePrice")) |
| | | 232 | | { |
| | | 233 | | <div class="form-group col-md-5"> |
| | | 234 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 235 | | <label class="form-check-label" for="chk@(checkboxCounter)">Цена закупки</label> |
| | | 236 | | </div> |
| | 0 | 237 | | checkboxCounter++; |
| | | 238 | | } |
| | 0 | 239 | | @if (Col("OzonCommission")) |
| | | 240 | | { |
| | | 241 | | <div class="form-group col-md-5"> |
| | | 242 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 243 | | <label class="form-check-label" for="chk@(checkboxCounter)">Комиссия Ozon</label> |
| | | 244 | | </div> |
| | 0 | 245 | | checkboxCounter++; |
| | | 246 | | } |
| | 0 | 247 | | @if (Col("Profit")) |
| | | 248 | | { |
| | | 249 | | <div class="form-group col-md-5"> |
| | | 250 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 251 | | <label class="form-check-label" for="chk@(checkboxCounter)">Прибыль</label> |
| | | 252 | | </div> |
| | 0 | 253 | | checkboxCounter++; |
| | | 254 | | } |
| | 0 | 255 | | @if (Col("MarkupPercent")) |
| | | 256 | | { |
| | | 257 | | <div class="form-group col-md-5"> |
| | | 258 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 259 | | <label class="form-check-label" for="chk@(checkboxCounter)">Наценка %</label> |
| | | 260 | | </div> |
| | 0 | 261 | | checkboxCounter++; |
| | | 262 | | } |
| | 0 | 263 | | @if (Col("Cost")) |
| | | 264 | | { |
| | | 265 | | <div class="form-group col-md-5"> |
| | | 266 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 267 | | <label class="form-check-label" for="chk@(checkboxCounter)">Себестоимость</label> |
| | | 268 | | </div> |
| | 0 | 269 | | checkboxCounter++; |
| | | 270 | | } |
| | 0 | 271 | | @if (Col("DeliveryCity")) |
| | | 272 | | { |
| | | 273 | | <div class="form-group col-md-5"> |
| | | 274 | | <input type="checkbox" class="form-check-input" id="chk@(checkboxCounter)" checked> |
| | | 275 | | <label class="form-check-label" for="chk@(checkboxCounter)">Город доставки</label> |
| | | 276 | | </div> |
| | 0 | 277 | | checkboxCounter++; |
| | | 278 | | } |
| | | 279 | | </div> |
| | | 280 | | </div> |
| | | 281 | | </div> |
| | | 282 | | </div> |
| | | 283 | | |
| | | 284 | | <div class="modal-footer"> |
| | | 285 | | <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button> |
| | | 286 | | </div> |
| | | 287 | | </div> |
| | | 288 | | </div> |
| | | 289 | | </div> |
| | | 290 | | |
| | | 291 | | <div class="d-flex justify-content-between align-items-center"> |
| | | 292 | | <div class="flex-grow-1"></div> <!-- Пустой div для заполнения пространства --> |
| | | 293 | | <button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#exampleModal" style="width: 18px; |
| | | 294 | | <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear-fill" viewB |
| | | 295 | | <path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.68 |
| | | 296 | | </svg> |
| | | 297 | | <span class="visually-hidden">Button</span> |
| | | 298 | | </button> |
| | | 299 | | </div> |
| | | 300 | | |
| | | 301 | | |
| | | 302 | | |
| | | 303 | | <form asp-action="MultiplayEdit"> |
| | | 304 | | <div asp-validation-summary="ModelOnly" class="text-danger"></div> |
| | | 305 | | <input type="hidden" asp-for="RedirectPage" /> |
| | | 306 | | |
| | | 307 | | <table class="table table-striped" id="shipmentTable"> |
| | | 308 | | <thead> |
| | | 309 | | <tr> |
| | | 310 | | <th> |
| | | 311 | | № |
| | | 312 | | </th> |
| | 0 | 313 | | @if (Col("ShipmentNumber")) |
| | | 314 | | { |
| | | 315 | | <th> |
| | | 316 | | Номер заказа |
| | | 317 | | </th> |
| | | 318 | | } |
| | 0 | 319 | | @if (Col("OzonClient")) |
| | | 320 | | { |
| | | 321 | | <th> |
| | | 322 | | Клиент |
| | | 323 | | </th> |
| | | 324 | | } |
| | | 325 | | |
| | 0 | 326 | | @if (Col("ProcessingDate")) |
| | | 327 | | { |
| | | 328 | | <th> |
| | | 329 | | Принят в обработку |
| | | 330 | | </th> |
| | | 331 | | } |
| | | 332 | | |
| | 0 | 333 | | @if (Col("ShippingDate")) |
| | | 334 | | { |
| | | 335 | | <th> |
| | | 336 | | Дата отгрузки |
| | | 337 | | </th> |
| | | 338 | | } |
| | | 339 | | |
| | 0 | 340 | | @if (Col("DeliveryPeriod")) |
| | | 341 | | { |
| | | 342 | | <th> |
| | | 343 | | Срок доставки |
| | | 344 | | </th> |
| | | 345 | | } |
| | | 346 | | |
| | 0 | 347 | | @if (Col("ClientStatus")) |
| | | 348 | | { |
| | | 349 | | <th> |
| | | 350 | | Статус клиента |
| | | 351 | | </th> |
| | | 352 | | } |
| | | 353 | | |
| | 0 | 354 | | @if (Col("AppStatus")) |
| | | 355 | | { |
| | | 356 | | <th class="custom-width"> |
| | | 357 | | <label for="statusSelect" class="col-form-label">Статус</label> |
| | | 358 | | <select class="form-control" id="statusSelect" onchange="handleStatusSelectChange(this)"> |
| | | 359 | | <option value="">Выберите значение</option> |
| | 0 | 360 | | @foreach (var statuses in ViewBag.AppStatuses) |
| | | 361 | | { |
| | 0 | 362 | | <option value="@statuses.Value">@statuses.Text</option> |
| | | 363 | | } |
| | | 364 | | <option value="create" class="link-option">Создать статус</option> |
| | | 365 | | </select> |
| | | 366 | | </th> |
| | | 367 | | <script> |
| | | 368 | | function handleStatusSelectChange(selectElement) { |
| | | 369 | | if (selectElement.value === "create") { |
| | 0 | 370 | | window.location.href = '@Url.Action("Create", "AppStatus")'; |
| | | 371 | | } else { |
| | | 372 | | var selectedStatus = selectElement.value; |
| | | 373 | | document.querySelectorAll('.status-select').forEach(function (statusSelect) { |
| | | 374 | | statusSelect.value = selectedStatus; |
| | | 375 | | }); |
| | | 376 | | } |
| | | 377 | | } |
| | | 378 | | </script> |
| | | 379 | | } |
| | | 380 | | |
| | | 381 | | |
| | 0 | 382 | | @if (Col("ProductName")) |
| | | 383 | | { |
| | | 384 | | <th> |
| | | 385 | | Наименование товара |
| | | 386 | | </th> |
| | | 387 | | } |
| | | 388 | | |
| | 0 | 389 | | @if (Col("Article")) |
| | | 390 | | { |
| | | 391 | | <th> |
| | | 392 | | Артикул |
| | | 393 | | </th> |
| | | 394 | | } |
| | | 395 | | |
| | 0 | 396 | | @if (Col("Manufacturer")) |
| | | 397 | | { |
| | | 398 | | <th> |
| | | 399 | | Производитель |
| | | 400 | | </th> |
| | | 401 | | } |
| | | 402 | | |
| | 0 | 403 | | @if (Col("ShipmentWarehouse")) |
| | | 404 | | { |
| | | 405 | | <th> |
| | | 406 | | Склад отгрузки |
| | | 407 | | </th> |
| | | 408 | | } |
| | | 409 | | |
| | 0 | 410 | | @if (Col("Supplier")) |
| | | 411 | | { |
| | | 412 | | <th> |
| | | 413 | | <label for="universalSelect" class="col-form-label">Поставщик</label> |
| | | 414 | | <select class="form-control" id="universalSelect" onchange="handleSupplierSelectChange(this)"> |
| | | 415 | | <option value="">Выберите значение</option> |
| | 0 | 416 | | @foreach (var supplier in Model.Suppliers) |
| | | 417 | | { |
| | 0 | 418 | | <option value="@supplier.Id" data-currency-code="@supplier.CurrencyCode" data-cost-facto |
| | | 419 | | } |
| | 0 | 420 | | <option value="create" class="link-option" data-url="@Url.Action("Create", "Supplier")">Созд |
| | | 421 | | </select> |
| | | 422 | | </th> |
| | | 423 | | <script> |
| | | 424 | | function handleSupplierSelectChange(selectElement) { |
| | | 425 | | if (selectElement.value === "create") { |
| | 0 | 426 | | window.location.href = '@Url.Action("Create", "Supplier")'; |
| | | 427 | | } else { |
| | | 428 | | var selectedOption = selectElement.options[selectElement.selectedIndex]; |
| | | 429 | | var supplierId = selectedOption.value; |
| | | 430 | | var currencyCode = selectedOption.getAttribute('data-currency-code'); |
| | | 431 | | var costFactor = selectedOption.getAttribute('data-cost-factor'); |
| | | 432 | | |
| | | 433 | | document.querySelectorAll('.supplier-select').forEach(function (supplierSelect) { |
| | | 434 | | supplierSelect.value = supplierId; |
| | | 435 | | supplierSelect.dispatchEvent(new Event('change')); |
| | | 436 | | }); |
| | | 437 | | |
| | | 438 | | document.querySelectorAll('.supplier-select').forEach(function (supplierSelect) { |
| | | 439 | | var relatedCurrencyCodeSpan = supplierSelect.closest('td').querySelector('.currency- |
| | | 440 | | if (relatedCurrencyCodeSpan) { |
| | | 441 | | relatedCurrencyCodeSpan.textContent = currencyCode; |
| | | 442 | | } |
| | | 443 | | }); |
| | | 444 | | } |
| | | 445 | | } |
| | | 446 | | </script> |
| | | 447 | | } |
| | | 448 | | |
| | | 449 | | |
| | 0 | 450 | | @if (Col("SupplierOrderNumber")) |
| | | 451 | | { |
| | | 452 | | <th colspan="4" style="white-space: nowrap;"> |
| | | 453 | | <label for="universalOrderNumberToSupplier" class="col-form-label">Номер заказа поставщику</labe |
| | | 454 | | <input type="text" class="form-control" id="universalOrderNumberToSupplier" /> |
| | | 455 | | </th> |
| | | 456 | | } |
| | | 457 | | |
| | 0 | 458 | | @if (Col("SitePrice")) |
| | | 459 | | { |
| | | 460 | | <th> |
| | | 461 | | Цена сайта |
| | | 462 | | </th> |
| | | 463 | | } |
| | | 464 | | |
| | 0 | 465 | | @if (Col("Price")) |
| | | 466 | | { |
| | | 467 | | <th> |
| | | 468 | | Цена |
| | | 469 | | </th> |
| | | 470 | | } |
| | | 471 | | |
| | 0 | 472 | | @if (Col("Quantity")) |
| | | 473 | | { |
| | | 474 | | <th> |
| | | 475 | | Кол. |
| | | 476 | | </th> |
| | | 477 | | } |
| | | 478 | | |
| | 0 | 479 | | @if (Col("ShipmentTotal")) |
| | | 480 | | { |
| | | 481 | | <th> |
| | | 482 | | Сумма отправления |
| | | 483 | | </th> |
| | | 484 | | } |
| | | 485 | | |
| | 0 | 486 | | @if (Col("Category")) |
| | | 487 | | { |
| | | 488 | | <th> |
| | | 489 | | Категория |
| | | 490 | | </th> |
| | | 491 | | } |
| | | 492 | | |
| | 0 | 493 | | @if (Col("VolumeWeight")) |
| | | 494 | | { |
| | | 495 | | <th style="white-space: nowrap;"> |
| | | 496 | | Объемный вес |
| | | 497 | | </th> |
| | | 498 | | } |
| | | 499 | | |
| | 0 | 500 | | @if (Col("PurchasePrice")) |
| | | 501 | | { |
| | | 502 | | <th colspan="4" style="white-space: nowrap;"> |
| | | 503 | | Цена закупки |
| | | 504 | | </th> |
| | | 505 | | } |
| | | 506 | | |
| | 0 | 507 | | @if (Col("OzonCommission")) |
| | | 508 | | { |
| | | 509 | | <th> |
| | | 510 | | Комиссия ОЗОН |
| | | 511 | | </th> |
| | | 512 | | } |
| | | 513 | | |
| | 0 | 514 | | @if (Col("Profit")) |
| | | 515 | | { |
| | | 516 | | <th> |
| | | 517 | | Прибыль |
| | | 518 | | </th> |
| | | 519 | | } |
| | | 520 | | |
| | 0 | 521 | | @if (Col("MarkupPercent")) |
| | | 522 | | { |
| | | 523 | | <th> |
| | | 524 | | Наценка % |
| | | 525 | | </th> |
| | | 526 | | } |
| | 0 | 527 | | @if (Col("Cost")) |
| | | 528 | | { |
| | | 529 | | <th> |
| | | 530 | | Себестоимость |
| | | 531 | | </th> |
| | | 532 | | } |
| | 0 | 533 | | @if (Col("DeliveryCity")) |
| | | 534 | | { |
| | | 535 | | <th> |
| | | 536 | | Город доставки |
| | | 537 | | </th> |
| | | 538 | | } |
| | | 539 | | </tr> |
| | | 540 | | </thead> |
| | | 541 | | <tbody> |
| | | 542 | | |
| | 0 | 543 | | @for (int i = 0; i < orders.Count; i++) |
| | | 544 | | { |
| | 0 | 545 | | var orderRow = orders[i]; |
| | | 546 | | <tr id="orderRow_@orderRow.Id"> |
| | | 547 | | <script> |
| | | 548 | | $(document).ready(function () { |
| | | 549 | | // Обработка удаления строки |
| | | 550 | | $('.delete-order').on('click', function () { |
| | | 551 | | var orderId = $(this).data('order-id'); |
| | | 552 | | $('#orderRow_' + orderId).remove(); |
| | | 553 | | updateRowNumbers(); |
| | | 554 | | }); |
| | | 555 | | |
| | | 556 | | // Обновление нумерации строк |
| | | 557 | | function updateRowNumbers() { |
| | | 558 | | $('#shipmentTable tbody tr').each(function (index) { |
| | | 559 | | $(this).find('.row-number').text(index + 1); |
| | | 560 | | }); |
| | | 561 | | } |
| | | 562 | | updateRowNumbers(); |
| | | 563 | | }); |
| | | 564 | | </script> |
| | | 565 | | <div class="form-group" style="display: none"> |
| | | 566 | | <label asp-for="Orders[i].Id" class="control-label"></label><span style="margin-left: 10px; colo |
| | | 567 | | <input asp-for="Orders[i].Id" class="form-control" /> |
| | | 568 | | <span asp-validation-for="Orders[i].Id" class="text-danger"></span> |
| | | 569 | | </div> |
| | | 570 | | <div class="form-group" style="display: none"> |
| | | 571 | | <label asp-for="Orders[i].Key" class="control-label"></label><span style="margin-left: 10px; col |
| | | 572 | | <input asp-for="Orders[i].Key" class="form-control" /> |
| | | 573 | | <span asp-validation-for="Orders[i].Key" class="text-danger"></span> |
| | | 574 | | </div> |
| | | 575 | | <div class="form-group" style="display: none"> |
| | | 576 | | <label asp-for="Orders[i].ShipmentNumber" class="control-label"></label><span style="margin-left |
| | | 577 | | <input asp-for="Orders[i].ShipmentNumber" class="form-control" /> |
| | | 578 | | <span asp-validation-for="Orders[i].ShipmentNumber" class="text-danger"></span> |
| | | 579 | | </div> |
| | | 580 | | <div class="form-group" style="display: none"> |
| | | 581 | | <input type="hidden" asp-for="Orders[i].OzonClientId" /> |
| | | 582 | | </div> |
| | | 583 | | <div class="form-group" style="display: none"> |
| | | 584 | | <label asp-for="Orders[i].ProcessingDate" class="control-label"></label><span style="margin-left |
| | | 585 | | <input asp-for="Orders[i].ProcessingDate" class="form-control" /> |
| | | 586 | | <span asp-validation-for="Orders[i].ProcessingDate" class="text-danger"></span> |
| | | 587 | | </div> |
| | | 588 | | <div class="form-group" style="display: none"> |
| | | 589 | | <label asp-for="Orders[i].ShippingDate" class="control-label"></label><span style="margin-left: |
| | | 590 | | <input asp-for="Orders[i].ShippingDate" class="form-control" /> |
| | | 591 | | <span asp-validation-for="Orders[i].ShippingDate" class="text-danger"></span> |
| | | 592 | | </div> |
| | | 593 | | <div class="form-group" style="display: none"> |
| | | 594 | | <label asp-for="Orders[i].Status" class="control-label"></label><span style="margin-left: 10px; |
| | | 595 | | <input asp-for="Orders[i].Status" class="form-control" /> |
| | | 596 | | <span asp-validation-for="Orders[i].Status" class="text-danger"></span> |
| | | 597 | | </div> |
| | | 598 | | <div class="form-group" style="display: none"> |
| | | 599 | | <label asp-for="Orders[i].ProductName" class="control-label"></label><span style="margin-left: 1 |
| | | 600 | | <input asp-for="Orders[i].ProductName" class="form-control" /> |
| | | 601 | | <span asp-validation-for="Orders[i].ProductName" class="text-danger"></span> |
| | | 602 | | </div> |
| | | 603 | | <div class="form-group" style="display: none"> |
| | | 604 | | <label asp-for="Orders[i].ProductKey" class="control-label"></label><span style="margin-left: 10 |
| | | 605 | | <input asp-for="Orders[i].ProductKey" class="form-control" /> |
| | | 606 | | <span asp-validation-for="Orders[i].ProductKey" class="text-danger"></span> |
| | | 607 | | </div> |
| | | 608 | | <div class="form-group" style="display: none"> |
| | | 609 | | <label asp-for="Orders[i].Quantity" class="control-label"></label><span style="margin-left: 10px |
| | | 610 | | <input asp-for="Orders[i].Quantity" class="form-control" /> |
| | | 611 | | <span asp-validation-for="Orders[i].Quantity" class="text-danger"></span> |
| | | 612 | | </div> |
| | | 613 | | <div class="form-group" style="display: none"> |
| | | 614 | | <label asp-for="Orders[i].ShipmentAmount" class="control-label"></label><span style="margin-left |
| | | 615 | | <input asp-for="Orders[i].ShipmentAmount" class="form-control" /> |
| | | 616 | | <span asp-validation-for="Orders[i].ShipmentAmount" class="text-danger"></span> |
| | | 617 | | </div> |
| | | 618 | | <div class="form-group" style="display: none"> |
| | | 619 | | <label asp-for="Orders[i].Price" class="control-label"></label><span style="margin-left: 10px; c |
| | | 620 | | <input asp-for="Orders[i].Price" class="form-control" /> |
| | | 621 | | <span asp-validation-for="Orders[i].Price" class="text-danger"></span> |
| | | 622 | | </div> |
| | | 623 | | <div class="form-group" style="display: none"> |
| | | 624 | | <label asp-for="Orders[i].MinOzonCommission" class="control-label"></label><span style="margin-l |
| | | 625 | | <input asp-for="Orders[i].MinOzonCommission" class="form-control" /> |
| | | 626 | | <span asp-validation-for="Orders[i].MinOzonCommission" class="text-danger"></span> |
| | | 627 | | </div> |
| | | 628 | | <div class="form-group" style="display: none"> |
| | | 629 | | <label asp-for="Orders[i].MaxOzonCommission" class="control-label"></label><span style="margin-l |
| | | 630 | | <input asp-for="Orders[i].MaxOzonCommission" class="form-control" /> |
| | | 631 | | <span asp-validation-for="Orders[i].MaxOzonCommission" class="text-danger"></span> |
| | | 632 | | </div> |
| | | 633 | | <div class="form-group" style="display: none"> |
| | | 634 | | <label asp-for="Orders[i].MaxProfit" class="control-label"></label><span style="margin-left: 10p |
| | | 635 | | <input asp-for="Orders[i].MaxProfit" class="form-control" /> |
| | | 636 | | <span asp-validation-for="Orders[i].MaxProfit" class="text-danger"></span> |
| | | 637 | | </div> |
| | | 638 | | <div class="form-group" style="display: none"> |
| | | 639 | | <label asp-for="Orders[i].MinDiscount" class="control-label"></label><span style="margin-left: 1 |
| | | 640 | | <input asp-for="Orders[i].MinDiscount" class="form-control" /> |
| | | 641 | | <span asp-validation-for="Orders[i].MinDiscount" class="text-danger"></span> |
| | | 642 | | </div> |
| | | 643 | | <div class="form-group" style="display: none"> |
| | | 644 | | <label asp-for="Orders[i].DeliveryCity" class="control-label"></label><span style="margin-left: |
| | | 645 | | <input asp-for="Orders[i].DeliveryCity" class="form-control" /> |
| | | 646 | | <span asp-validation-for="Orders[i].DeliveryCity" class="text-danger"></span> |
| | | 647 | | </div> |
| | | 648 | | |
| | | 649 | | <div class="form-group" style="display: none"> |
| | | 650 | | <label asp-for="Orders[i].UpdatedBy" class="control-label"></label><span style="margin-left: 10p |
| | 0 | 651 | | <input asp-for="Orders[i].UpdatedBy" class="form-control" value="@User.Identity?.Name" /> |
| | | 652 | | <span asp-validation-for="Orders[i].UpdatedBy" class="text-danger"></span> |
| | | 653 | | </div> |
| | | 654 | | |
| | | 655 | | <input type="hidden" asp-for="Orders[i].ProductInfoId" /> |
| | | 656 | | <td> |
| | | 657 | | <b class="row-number"></b> |
| | | 658 | | </td> |
| | | 659 | | |
| | 0 | 660 | | @if (Col("ShipmentNumber")) |
| | | 661 | | { |
| | | 662 | | <td> |
| | 0 | 663 | | @Html.DisplayFor(modelItem => Model.Orders[i].ShipmentNumber) |
| | | 664 | | </td> |
| | | 665 | | } |
| | 0 | 666 | | @if (Col("OzonClient")) |
| | | 667 | | { |
| | | 668 | | <td> |
| | 0 | 669 | | @(Model.Orders[i].OzonClient?.Name) |
| | | 670 | | </td> |
| | | 671 | | } |
| | 0 | 672 | | @if (Col("ProcessingDate")) |
| | | 673 | | { |
| | | 674 | | <td> |
| | 0 | 675 | | @Html.DisplayFor(modelItem => Model.Orders[i].FormattedProcessingDate) <br /> @Html.DisplayF |
| | | 676 | | </td> |
| | | 677 | | } |
| | 0 | 678 | | @if (Col("ShippingDate")) |
| | | 679 | | { |
| | | 680 | | <td> |
| | 0 | 681 | | @Html.DisplayFor(modelItem => Model.Orders[i].FormattedShippingDate) <br /> @Html.DisplayFor |
| | | 682 | | </td> |
| | | 683 | | } |
| | 0 | 684 | | @if (Col("DeliveryPeriod")) |
| | | 685 | | { |
| | | 686 | | <td style="white-space: nowrap;"> |
| | 0 | 687 | | @Html.DisplayFor(modelItem => Model.Orders[i].FormattedDeliveryPeriod) |
| | | 688 | | </td> |
| | | 689 | | } |
| | 0 | 690 | | @if (Col("ClientStatus")) |
| | | 691 | | { |
| | | 692 | | <td> |
| | 0 | 693 | | @Html.DisplayFor(modelItem => Model.Orders[i].Status) |
| | | 694 | | </td> |
| | | 695 | | } |
| | 0 | 696 | | @if (Col("AppStatus")) |
| | | 697 | | { |
| | | 698 | | <td> |
| | | 699 | | <div class="form-group custom-width"> |
| | | 700 | | <select asp-for="Orders[i].AppStatusId" asp-items="@ViewBag.AppStatuses" class="form-con |
| | | 701 | | <option value="">Выберите статус</option> |
| | 0 | 702 | | @foreach (var status in ViewBag.AppStatuses) |
| | | 703 | | { |
| | 0 | 704 | | <option value="@status.Value">@status.Text</option> |
| | | 705 | | } |
| | | 706 | | </select> |
| | | 707 | | </div> |
| | | 708 | | </td> |
| | | 709 | | } |
| | | 710 | | <script> |
| | | 711 | | document.addEventListener('DOMContentLoaded', (event) => { |
| | | 712 | | const statusSelects = document.querySelectorAll('.status-select'); |
| | | 713 | | |
| | | 714 | | const checkValue = (select) => { |
| | | 715 | | const selectedOption = select.options[select.selectedIndex]; |
| | | 716 | | const value = selectedOption ? selectedOption.text.trim() : ''; |
| | | 717 | | const regex = /^Не указан/; |
| | | 718 | | if (select.value === "" || regex.test(value)) { |
| | | 719 | | select.classList.add('highlight-error'); |
| | | 720 | | } else { |
| | | 721 | | select.classList.remove('highlight-error'); |
| | | 722 | | } |
| | | 723 | | }; |
| | | 724 | | |
| | | 725 | | statusSelects.forEach(select => { |
| | | 726 | | select.addEventListener('change', function () { |
| | | 727 | | checkValue(this); |
| | | 728 | | }); |
| | | 729 | | |
| | | 730 | | // Initial check if the field is empty or "Не указан" on page load |
| | | 731 | | checkValue(select); |
| | | 732 | | }); |
| | | 733 | | |
| | | 734 | | // Handle changes from the global status select |
| | | 735 | | document.getElementById('statusSelect').addEventListener('change', function() { |
| | | 736 | | if (this.value === "create") { |
| | 0 | 737 | | window.location.href = '@Url.Action("Create", "AppStatus")'; |
| | | 738 | | } else { |
| | | 739 | | const selectedStatus = this.value; |
| | | 740 | | statusSelects.forEach(statusSelect => { |
| | | 741 | | statusSelect.value = selectedStatus; |
| | | 742 | | checkValue(statusSelect); |
| | | 743 | | }); |
| | | 744 | | } |
| | | 745 | | }); |
| | | 746 | | }); |
| | | 747 | | </script> |
| | | 748 | | |
| | | 749 | | |
| | 0 | 750 | | @if (Col("ProductName")) |
| | | 751 | | { |
| | | 752 | | <td> |
| | | 753 | | @{ |
| | 0 | 754 | | string? first15Chars = null; |
| | 0 | 755 | | if (!string.IsNullOrEmpty(orderRow.ProductName)) |
| | | 756 | | { |
| | 0 | 757 | | first15Chars = orderRow.ProductName.Length > 45 ? orderRow.ProductName.Substring(0, |
| | | 758 | | } |
| | | 759 | | } |
| | | 760 | | |
| | 0 | 761 | | @Html.DisplayFor(modelItem => first15Chars) |
| | | 762 | | </td> |
| | | 763 | | } |
| | 0 | 764 | | @if (Col("Article")) |
| | | 765 | | { |
| | | 766 | | <td> |
| | 0 | 767 | | @Html.DisplayFor(modelItem => Model.Orders[i].Article) |
| | | 768 | | </td> |
| | | 769 | | } |
| | | 770 | | |
| | 0 | 771 | | @if (Col("Manufacturer")) |
| | | 772 | | { |
| | | 773 | | <td> |
| | 0 | 774 | | @(Model.Orders[i].Manufacturer?.Name) |
| | | 775 | | </td> |
| | | 776 | | } |
| | | 777 | | |
| | 0 | 778 | | @if (Col("ShipmentWarehouse")) |
| | | 779 | | { |
| | | 780 | | <td> |
| | 0 | 781 | | @(Model.Orders[i].ShipmentWarehouse?.Name) |
| | | 782 | | </td> |
| | | 783 | | } |
| | 0 | 784 | | @if (Col("Supplier")) |
| | | 785 | | { |
| | | 786 | | <td class="supplier-td"> |
| | | 787 | | <div class="form-group"> |
| | | 788 | | <select asp-for="Orders[i].SupplierId" asp-items="@ViewBag.Suppliers" class="form-contro |
| | | 789 | | <option value="">Выберите поставщика</option> |
| | 0 | 790 | | @foreach (var supplier in Model.Suppliers) |
| | | 791 | | { |
| | 0 | 792 | | <option value="@supplier.Id" data-currency-code="@supplier.CurrencyCode" data-co |
| | | 793 | | } |
| | | 794 | | </select> |
| | | 795 | | </div> |
| | | 796 | | </td> |
| | | 797 | | } |
| | | 798 | | |
| | | 799 | | <script> |
| | | 800 | | document.addEventListener('DOMContentLoaded', (event) => { |
| | | 801 | | const supplierSelects = document.querySelectorAll('.supplier-select'); |
| | | 802 | | |
| | | 803 | | function checkField(select) { |
| | | 804 | | const value = select.value.trim().toLowerCase(); |
| | | 805 | | const selectedOption = select.options[select.selectedIndex]; |
| | | 806 | | const selectedText = selectedOption ? selectedOption.text : ''; |
| | | 807 | | |
| | | 808 | | if (value === "" || selectedText.startsWith('Не указан')) { |
| | | 809 | | select.classList.add('highlight-error'); |
| | | 810 | | } else { |
| | | 811 | | select.classList.remove('highlight-error'); |
| | | 812 | | } |
| | | 813 | | } |
| | | 814 | | |
| | | 815 | | supplierSelects.forEach(select => { |
| | | 816 | | select.addEventListener('change', function () { |
| | | 817 | | checkField(this); |
| | | 818 | | }); |
| | | 819 | | |
| | | 820 | | checkField(select); |
| | | 821 | | }); |
| | | 822 | | }); |
| | | 823 | | </script> |
| | | 824 | | |
| | | 825 | | |
| | 0 | 826 | | @if (Col("SupplierOrderNumber")) |
| | | 827 | | { |
| | | 828 | | <td colspan="4" style="white-space: nowrap; text-align: right;" class="order-number-to-supplier" |
| | | 829 | | <div class="form-group"> |
| | | 830 | | <input asp-for="Orders[i].OrderNumberToSupplier" type="text" class="form-control orderNu |
| | | 831 | | <span asp-validation-for="Orders[i].OrderNumberToSupplier" class="text-danger" id="Order |
| | | 832 | | </div> |
| | | 833 | | </td> |
| | | 834 | | } |
| | | 835 | | |
| | 0 | 836 | | @if (Col("SitePrice")) |
| | | 837 | | { |
| | | 838 | | <td style="text-align: right;"> |
| | 0 | 839 | | @(Model.Orders[i].ProductInfo?.CurrentPriceWithDiscount) |
| | | 840 | | </td> |
| | | 841 | | } |
| | 0 | 842 | | @if (Col("Price")) |
| | | 843 | | { |
| | | 844 | | <td id="Price_@Model.Orders[i].Id" style="text-align: right;"> |
| | 0 | 845 | | <span id="CurrentPriceWithDiscount_@Model.Orders[i].Id" class="d-none">@Model.Orders[i].Prod |
| | 0 | 846 | | @Html.DisplayFor(modelItem => Model.Orders[i].Price) |
| | | 847 | | </td> |
| | | 848 | | } |
| | 0 | 849 | | @if (Col("Quantity")) |
| | | 850 | | { |
| | | 851 | | <td style="text-align: center;" id="Quantity_@Model.Orders[i].Id" class="@(Model.Orders[i].Quant |
| | | 852 | | @{ |
| | 0 | 853 | | if (Model.Orders[i].Quantity > 1) |
| | | 854 | | { |
| | | 855 | | <b> |
| | 0 | 856 | | @Html.DisplayFor(modelItem => Model.Orders[i].Quantity) |
| | | 857 | | </b> |
| | | 858 | | } |
| | | 859 | | else |
| | | 860 | | { |
| | 0 | 861 | | @Html.DisplayFor(modelItem => Model.Orders[i].Quantity) |
| | | 862 | | } |
| | | 863 | | } |
| | | 864 | | </td> |
| | | 865 | | } |
| | 0 | 866 | | @if (Col("ShipmentTotal")) |
| | | 867 | | { |
| | | 868 | | <td style="text-align: right;" id="shipmentAmount_@i"> |
| | 0 | 869 | | @Html.DisplayFor(modelItem => Model.Orders[i].ShipmentAmount) |
| | | 870 | | </td> |
| | | 871 | | } |
| | 0 | 872 | | @if (Col("Category")) |
| | | 873 | | { |
| | | 874 | | <td> |
| | 0 | 875 | | @(Model.Orders[i].ProductInfo?.CommercialCategory) |
| | | 876 | | </td> |
| | | 877 | | } |
| | 0 | 878 | | @if (Col("VolumeWeight")) |
| | | 879 | | { |
| | | 880 | | <td style="text-align: center; white-space: nowrap;"> |
| | 0 | 881 | | @(Model.Orders[i].ProductInfo?.VolumetricWeight) |
| | | 882 | | |
| | | 883 | | <div class="form-group d-flex align-items-center justify-content-end"> |
| | | 884 | | <div class="form-group"> |
| | 0 | 885 | | <input asp-for="Orders[i].ProductInfo.Weight" class="form-control product-weight-fie |
| | | 886 | | <span asp-validation-for="Orders[i].ProductInfo.Weight" class="text-danger"></span> |
| | | 887 | | </div> |
| | | 888 | | <div style="margin-left: auto; white-space: nowrap;"> |
| | | 889 | | <span>Вес кг.</span> |
| | | 890 | | </div> |
| | | 891 | | </div> |
| | | 892 | | |
| | | 893 | | </td> |
| | | 894 | | } |
| | | 895 | | |
| | 0 | 896 | | @if (Col("PurchasePrice")) |
| | | 897 | | { |
| | | 898 | | <td colspan="4" style="text-align: right; white-space: nowrap;" class="purchase-price-td"> |
| | | 899 | | <div class="form-group d-flex align-items-center"> |
| | | 900 | | <div class="flex-grow-1"> |
| | 0 | 901 | | <input asp-for="Orders[i].PurchasePrice" type="text" class="form-control purchase-pr |
| | | 902 | | <span asp-validation-for="Orders[i].PurchasePrice" class="text-danger" id="PurchaseP |
| | | 903 | | </div> |
| | | 904 | | <div class="ml-2"> |
| | | 905 | | <span class="currency-code" id="CurrencyCode_@Model.Orders[i].Id"></span> |
| | | 906 | | </div> |
| | | 907 | | </div> |
| | | 908 | | <div class="form-group"> |
| | | 909 | | <span class="purchase-price-rub ml-2" id="PurchasePriceRub_@Model.Orders[i].Id"></span> |
| | | 910 | | </div> |
| | | 911 | | </td> |
| | | 912 | | } |
| | | 913 | | <script> |
| | | 914 | | document.addEventListener('DOMContentLoaded', (event) => { |
| | | 915 | | const priceFields = document.querySelectorAll('.purchase-price-field'); |
| | | 916 | | |
| | | 917 | | priceFields.forEach(field => { |
| | | 918 | | field.addEventListener('input', function () { |
| | | 919 | | if (this.value.trim() === "") { |
| | | 920 | | this.classList.add('highlight-error'); |
| | | 921 | | } else { |
| | | 922 | | this.classList.remove('highlight-error'); |
| | | 923 | | } |
| | | 924 | | }); |
| | | 925 | | |
| | | 926 | | // Initial check if the field is empty on page load |
| | | 927 | | if (field.value.trim() === "") { |
| | | 928 | | field.classList.add('highlight-error'); |
| | | 929 | | } |
| | | 930 | | }); |
| | | 931 | | }); |
| | | 932 | | </script> |
| | | 933 | | |
| | | 934 | | <script> |
| | | 935 | | $(document).ready(function () { |
| | | 936 | | // Обработка изменения поставщика в индивидуальных полях |
| | | 937 | | $('.supplier-select').on('change', function () { |
| | | 938 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 939 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 940 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 941 | | |
| | | 942 | | if (currencyCode) { |
| | | 943 | | $('#CurrencyCode_' + orderId).text(currencyCode); |
| | | 944 | | } else { |
| | | 945 | | $('#CurrencyCode_' + orderId).text(''); |
| | | 946 | | } |
| | | 947 | | }); |
| | | 948 | | }); |
| | | 949 | | </script> |
| | | 950 | | |
| | 0 | 951 | | @if (Col("OzonCommission")) |
| | | 952 | | { |
| | | 953 | | <td style="text-align: right;"> |
| | 0 | 954 | | <div id="MinOzonCommission_@Model.Orders[i].Id">@Html.DisplayFor(modelItem => Model.Orders[i |
| | | 955 | | <br /> |
| | 0 | 956 | | <div id="MaxOzonCommission_@Model.Orders[i].Id">@Html.DisplayFor(modelItem => Model.Orders[i |
| | | 957 | | </td> |
| | | 958 | | } |
| | 0 | 959 | | @if (Col("Profit")) |
| | | 960 | | { |
| | | 961 | | <td style="text-align: right;"> |
| | | 962 | | <div> |
| | | 963 | | <span id="MaxProfit_@Model.Orders[i].Id"> |
| | 0 | 964 | | @if (Model.Orders[i].MaxProfit < 0) |
| | | 965 | | { |
| | 0 | 966 | | <span style="color:red">@Html.DisplayFor(modelItem => Model.Orders[i].MaxProfit) |
| | | 967 | | } |
| | | 968 | | else |
| | | 969 | | { |
| | 0 | 970 | | @Html.DisplayFor(modelItem => Model.Orders[i].MaxProfit) |
| | | 971 | | } |
| | | 972 | | </span> |
| | | 973 | | <span id="TargetProfit_@Model.Orders[i].Id" |
| | | 974 | | class="text-muted" |
| | | 975 | | style="margin-left: 4px;"></span> |
| | | 976 | | </div> |
| | | 977 | | <br /> |
| | | 978 | | <div id="MinProfit_@Model.Orders[i].Id"> |
| | 0 | 979 | | @if (Model.Orders[i].MinProfit < 0) |
| | | 980 | | { |
| | 0 | 981 | | <span style="color:red">@Html.DisplayFor(modelItem => Model.Orders[i].MinProfit)</sp |
| | | 982 | | } |
| | | 983 | | else |
| | | 984 | | { |
| | 0 | 985 | | @Html.DisplayFor(modelItem => Model.Orders[i].MinProfit) |
| | | 986 | | } |
| | | 987 | | </div> |
| | | 988 | | </td> |
| | | 989 | | } |
| | 0 | 990 | | @if (Col("MarkupPercent")) |
| | | 991 | | { |
| | | 992 | | <td style="text-align: right;"> |
| | | 993 | | <div id="MaxDiscount_@Model.Orders[i].Id"> |
| | 0 | 994 | | @if (Model.Orders[i].MaxDiscount < 0) |
| | | 995 | | { |
| | 0 | 996 | | <span style="color:red">@Html.DisplayFor(modelItem => Model.Orders[i].MaxDiscount)</ |
| | | 997 | | } |
| | | 998 | | else |
| | | 999 | | { |
| | 0 | 1000 | | @Html.DisplayFor(modelItem => Model.Orders[i].MaxDiscount) |
| | | 1001 | | } |
| | | 1002 | | </div> |
| | | 1003 | | <br /> |
| | | 1004 | | <div id="MinDiscount_@Model.Orders[i].Id"> |
| | 0 | 1005 | | @if (Model.Orders[i].MinDiscount < 0) |
| | | 1006 | | { |
| | 0 | 1007 | | <span style="color:red">@Html.DisplayFor(modelItem => Model.Orders[i].MinDiscount)</ |
| | | 1008 | | } |
| | | 1009 | | else |
| | | 1010 | | { |
| | 0 | 1011 | | @Html.DisplayFor(modelItem => Model.Orders[i].MinDiscount) |
| | | 1012 | | } |
| | | 1013 | | </div> |
| | | 1014 | | </td> |
| | | 1015 | | |
| | | 1016 | | } |
| | 0 | 1017 | | @if (Col("Cost")) |
| | | 1018 | | { |
| | | 1019 | | |
| | | 1020 | | <td> |
| | 0 | 1021 | | <span id="CostPrice_@Model.Orders[i].Id">@Html.DisplayFor(modelItem => Model.Orders[i].C |
| | | 1022 | | </td> |
| | | 1023 | | } |
| | 0 | 1024 | | @if (Col("DeliveryCity")) |
| | | 1025 | | { |
| | | 1026 | | <td> |
| | 0 | 1027 | | @Html.DisplayFor(modelItem => Model.Orders[i].DeliveryCity) |
| | | 1028 | | </td> |
| | | 1029 | | } |
| | | 1030 | | |
| | | 1031 | | <input asp-for="Orders[i].MinOzonCommission" type="hidden" /> |
| | | 1032 | | <input asp-for="Orders[i].MaxOzonCommission" type="hidden" /> |
| | | 1033 | | </tr> |
| | 0 | 1034 | | } |
| | | 1035 | | </tbody> |
| | | 1036 | | </table> |
| | | 1037 | | |
| | | 1038 | | <div id="selectedSuppliersList"></div> |
| | | 1039 | | |
| | | 1040 | | <input type="hidden" asp-for="RedirectPage" /> |
| | | 1041 | | |
| | | 1042 | | <div class="form-group"> |
| | | 1043 | | <div class="input-group"> |
| | | 1044 | | <span class="input-group-btn"> |
| | | 1045 | | <input type="submit" value="Сохранить" class="btn btn-primary" style="margin-left: 10px;" /> |
| | | 1046 | | </span> |
| | | 1047 | | </div> |
| | | 1048 | | </div> |
| | | 1049 | | </form> |
| | | 1050 | | |
| | | 1051 | | |
| | | 1052 | | <div> |
| | | 1053 | | <a asp-action="Index">К списку заказов</a> |
| | | 1054 | | </div> |
| | | 1055 | | |
| | | 1056 | | <script> |
| | | 1057 | | document.addEventListener('DOMContentLoaded', function () { |
| | | 1058 | | const supplierSelects = document.querySelectorAll('.supplier-select'); |
| | | 1059 | | const selectedSuppliers = {}; |
| | | 1060 | | |
| | | 1061 | | function extractNumber(text) { |
| | | 1062 | | const match = text.match(/(\d+(\.\d+)?)/); |
| | | 1063 | | return match ? parseFloat(match[0]) : 0; |
| | | 1064 | | } |
| | | 1065 | | |
| | | 1066 | | function updateSelectedSuppliers() { |
| | | 1067 | | // Очистка текущего состояния |
| | | 1068 | | for (const key in selectedSuppliers) { |
| | | 1069 | | if (selectedSuppliers.hasOwnProperty(key)) { |
| | | 1070 | | selectedSuppliers[key] = { count: 0, totalAmount: 0, totalQuantity: 0, totalPurchasePrice: 0 }; |
| | | 1071 | | } |
| | | 1072 | | } |
| | | 1073 | | |
| | | 1074 | | // Пересчет значений для не удаленных строк |
| | | 1075 | | document.querySelectorAll('#shipmentTable tbody tr').forEach((row) => { |
| | | 1076 | | const supplierSelect = row.querySelector('.supplier-select'); |
| | | 1077 | | const shipmentAmount = parseFloat(row.querySelector('[id^="shipmentAmount_"]')?.textContent) || 0; |
| | | 1078 | | const quantity = parseFloat(row.querySelector('[id^="Quantity_"]')?.textContent) || 0; // Изменено на 'Q |
| | | 1079 | | const purchasePriceText = row.querySelector('[id^="PurchasePriceRub_"]')?.textContent || '0'; |
| | | 1080 | | const purchasePrice = extractNumber(purchasePriceText); |
| | | 1081 | | |
| | | 1082 | | const selectedOption = supplierSelect.options[supplierSelect.selectedIndex]; |
| | | 1083 | | const supplierName = selectedOption.text; |
| | | 1084 | | |
| | | 1085 | | if (selectedOption.value) { |
| | | 1086 | | if (selectedSuppliers[supplierName]) { |
| | | 1087 | | selectedSuppliers[supplierName].count++; |
| | | 1088 | | selectedSuppliers[supplierName].totalAmount += shipmentAmount; |
| | | 1089 | | selectedSuppliers[supplierName].totalQuantity += quantity; |
| | | 1090 | | selectedSuppliers[supplierName].totalPurchasePrice += purchasePrice; |
| | | 1091 | | } else { |
| | | 1092 | | selectedSuppliers[supplierName] = { count: 1, totalAmount: shipmentAmount, totalQuantity: quanti |
| | | 1093 | | } |
| | | 1094 | | } |
| | | 1095 | | }); |
| | | 1096 | | |
| | | 1097 | | // Обновление таблицы SelectedSuppliers |
| | | 1098 | | const selectedSuppliersList = document.getElementById('selectedSuppliersList'); |
| | | 1099 | | selectedSuppliersList.innerHTML = ''; |
| | | 1100 | | |
| | | 1101 | | const table = document.createElement('table'); |
| | | 1102 | | table.classList.add('table', 'table-striped'); |
| | | 1103 | | |
| | | 1104 | | const thead = document.createElement('thead'); |
| | | 1105 | | const headerRow = document.createElement('tr'); |
| | | 1106 | | ['Поставщик', 'Заказы у поставщика', 'Количество заказов', 'Сумма отправления', 'Цена закупки RUB'].forEach( |
| | | 1107 | | const th = document.createElement('th'); |
| | | 1108 | | th.textContent = headerText; |
| | | 1109 | | headerRow.appendChild(th); |
| | | 1110 | | }); |
| | | 1111 | | thead.appendChild(headerRow); |
| | | 1112 | | table.appendChild(thead); |
| | | 1113 | | |
| | | 1114 | | const tbody = document.createElement('tbody'); |
| | | 1115 | | for (const [supplier, data] of Object.entries(selectedSuppliers)) { |
| | | 1116 | | if (data.count > 0) { |
| | | 1117 | | const row = document.createElement('tr'); |
| | | 1118 | | const supplierCell = document.createElement('td'); |
| | | 1119 | | supplierCell.textContent = supplier; |
| | | 1120 | | row.appendChild(supplierCell); |
| | | 1121 | | |
| | | 1122 | | const countCell = document.createElement('td'); |
| | | 1123 | | countCell.textContent = data.count; |
| | | 1124 | | row.appendChild(countCell); |
| | | 1125 | | |
| | | 1126 | | const quantityCell = document.createElement('td'); |
| | | 1127 | | quantityCell.textContent = data.totalQuantity; |
| | | 1128 | | row.appendChild(quantityCell); |
| | | 1129 | | |
| | | 1130 | | const amountCell = document.createElement('td'); |
| | | 1131 | | amountCell.textContent = data.totalAmount.toFixed(2); |
| | | 1132 | | row.appendChild(amountCell); |
| | | 1133 | | |
| | | 1134 | | const purchasePriceCell = document.createElement('td'); |
| | | 1135 | | purchasePriceCell.textContent = data.totalPurchasePrice.toFixed(2); |
| | | 1136 | | row.appendChild(purchasePriceCell); |
| | | 1137 | | |
| | | 1138 | | tbody.appendChild(row); |
| | | 1139 | | } |
| | | 1140 | | } |
| | | 1141 | | table.appendChild(tbody); |
| | | 1142 | | |
| | | 1143 | | selectedSuppliersList.appendChild(table); |
| | | 1144 | | } |
| | | 1145 | | |
| | | 1146 | | // Глобальная функция для обновления списка |
| | | 1147 | | window.updateSupplierList = updateSelectedSuppliers; |
| | | 1148 | | |
| | | 1149 | | supplierSelects.forEach((select, index) => { |
| | | 1150 | | select.addEventListener('change', updateSelectedSuppliers); |
| | | 1151 | | |
| | | 1152 | | // Инициализация начального состояния |
| | | 1153 | | const initialSelectedOption = select.options[select.selectedIndex]; |
| | | 1154 | | if (initialSelectedOption.value) { |
| | | 1155 | | const initialSupplierName = initialSelectedOption.text; |
| | | 1156 | | const initialShipmentAmount = parseFloat(document.querySelector('#shipmentAmount_' + index)?.textContent |
| | | 1157 | | const initialQuantity = parseFloat(document.querySelector('#Quantity_' + index)?.textContent) || 0; // И |
| | | 1158 | | const initialPurchasePriceText = document.querySelector('#PurchasePriceRub_' + index)?.textContent || '0 |
| | | 1159 | | const initialPurchasePrice = extractNumber(initialPurchasePriceText); |
| | | 1160 | | |
| | | 1161 | | if (selectedSuppliers[initialSupplierName]) { |
| | | 1162 | | selectedSuppliers[initialSupplierName].count++; |
| | | 1163 | | selectedSuppliers[initialSupplierName].totalAmount += initialShipmentAmount; |
| | | 1164 | | selectedSuppliers[initialSupplierName].totalQuantity += initialQuantity; |
| | | 1165 | | selectedSuppliers[initialSupplierName].totalPurchasePrice += initialPurchasePrice; |
| | | 1166 | | } else { |
| | | 1167 | | selectedSuppliers[initialSupplierName] = { count: 1, totalAmount: initialShipmentAmount, totalQuanti |
| | | 1168 | | } |
| | | 1169 | | } |
| | | 1170 | | }); |
| | | 1171 | | |
| | | 1172 | | // Обновляем список при загрузке страницы |
| | | 1173 | | updateSelectedSuppliers(); |
| | | 1174 | | }); |
| | | 1175 | | |
| | | 1176 | | </script> |
| | | 1177 | | |
| | | 1178 | | |
| | | 1179 | | |
| | | 1180 | | <script> |
| | | 1181 | | $(document).ready(function () { |
| | | 1182 | | // Обработка изменения поставщика в индивидуальных полях |
| | | 1183 | | $('.supplier-select').on('change', function () { |
| | | 1184 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 1185 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1186 | | var orderId = $(this).attr('id').split('_')[1]; // Извлекаем ID заказа из ID элемента |
| | | 1187 | | |
| | | 1188 | | if (currencyCode) { |
| | | 1189 | | $('#CurrencyCode_' + orderId).text(currencyCode); |
| | | 1190 | | } else { |
| | | 1191 | | $('#CurrencyCode_' + orderId).text(''); |
| | | 1192 | | } |
| | | 1193 | | }); |
| | | 1194 | | |
| | | 1195 | | // Обработка изменения поставщика в общем поле |
| | | 1196 | | $('#universalSelect').on('change', function () { |
| | | 1197 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 1198 | | var supplierId = selectedSupplier.val(); |
| | | 1199 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1200 | | |
| | | 1201 | | $('.supplier-select').each(function () { |
| | | 1202 | | $(this).val(supplierId).trigger('change'); |
| | | 1203 | | }); |
| | | 1204 | | |
| | | 1205 | | $('.currency-code').each(function () { |
| | | 1206 | | if (currencyCode) { |
| | | 1207 | | $(this).text(currencyCode); |
| | | 1208 | | } else { |
| | | 1209 | | $(this).text(''); |
| | | 1210 | | } |
| | | 1211 | | }); |
| | | 1212 | | }); |
| | | 1213 | | }); |
| | | 1214 | | </script> |
| | | 1215 | | |
| | | 1216 | | <script> |
| | | 1217 | | $(document).ready(function () { |
| | | 1218 | | // Получаем значения курсов валют из Razor View |
| | 0 | 1219 | | var rateUSD = @Model.RateUSD.ToString().Replace(',', '.'); |
| | 0 | 1220 | | var rateEUR = @Model.RateEUR.ToString().Replace(',', '.'); |
| | 0 | 1221 | | var rateBYN = @Model.RateBYN.ToString().Replace(',', '.'); |
| | | 1222 | | |
| | | 1223 | | function readSupplierDataNumber($option, key, fallback) { |
| | | 1224 | | if (!$option || !$option.length) return fallback; |
| | | 1225 | | var raw = $option.data(key); |
| | | 1226 | | if (raw === undefined || raw === null || raw === '') return fallback; |
| | | 1227 | | var parsed = parseFloat(String(raw).replace(',', '.')); |
| | | 1228 | | return isNaN(parsed) ? fallback : parsed; |
| | | 1229 | | } |
| | | 1230 | | |
| | | 1231 | | // Обработка изменения поставщика в индивидуальных полях |
| | | 1232 | | $('.supplier-select').on('change', function () { |
| | | 1233 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 1234 | | var weightFactor = readSupplierDataNumber(selectedSupplier, 'weight-factor', 0); |
| | | 1235 | | var orderId = $(this).attr('id').split('_')[1]; // Извлекаем ID заказа из ID элемента |
| | | 1236 | | var weightInput = $('#ProductWeight_' + orderId); |
| | | 1237 | | |
| | | 1238 | | // Если весовой коэффициент равен 0, устанавливаем поле веса в 0 и делаем его readonly |
| | | 1239 | | if (weightFactor === 0) { |
| | | 1240 | | weightInput.val('0').prop('readonly', true); |
| | | 1241 | | } else { |
| | | 1242 | | weightInput.prop('readonly', false); // Включаем возможность редактирования |
| | | 1243 | | } |
| | | 1244 | | |
| | | 1245 | | // Пример: обновляем другие значения на странице |
| | | 1246 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1247 | | var weightCurrencyCode = selectedSupplier.data('weight-currency-code'); |
| | | 1248 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 1249 | | |
| | | 1250 | | if (currencyCode) { |
| | | 1251 | | $('#CurrencyCode_' + orderId).text(currencyCode); |
| | | 1252 | | var purchasePriceInRub = updatePurchasePriceInRub(orderId, currencyCode, costFactor); |
| | | 1253 | | updateCostPrice(orderId, currencyCode, costFactor, weightCurrencyCode, purchasePriceInRub); |
| | | 1254 | | } else { |
| | | 1255 | | $('#CurrencyCode_' + orderId).text(''); |
| | | 1256 | | $('#PurchasePriceRub_' + orderId).text(''); |
| | | 1257 | | $('#CostPrice_' + orderId).text(''); |
| | | 1258 | | } |
| | | 1259 | | }); |
| | | 1260 | | |
| | | 1261 | | // Обработка изменения значения purchase price |
| | | 1262 | | $('.purchase-price-field').on('input', function () { |
| | | 1263 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 1264 | | var selectedSupplier = $('#SupplierId_' + orderId).find('option:selected'); |
| | | 1265 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1266 | | var weightCurrencyCode = selectedSupplier.data('weight-currency-code'); |
| | | 1267 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 1268 | | |
| | | 1269 | | var purchasePriceInRub = updatePurchasePriceInRub(orderId, currencyCode, costFactor); |
| | | 1270 | | updateCostPrice(orderId, currencyCode, costFactor, weightCurrencyCode, purchasePriceInRub); |
| | | 1271 | | updateCalculations(orderId); |
| | | 1272 | | window.updateSupplierList(); // Используем глобальную переменную |
| | | 1273 | | }); |
| | | 1274 | | |
| | | 1275 | | // Обработка изменения значения веса |
| | | 1276 | | $('.product-weight-field').on('input', function () { |
| | | 1277 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 1278 | | var selectedSupplier = $('#SupplierId_' + orderId).find('option:selected'); |
| | | 1279 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1280 | | var weightCurrencyCode = selectedSupplier.data('weight-currency-code'); |
| | | 1281 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 1282 | | |
| | | 1283 | | var purchasePriceInRub = updatePurchasePriceInRub(orderId, currencyCode, costFactor); |
| | | 1284 | | updateCostPrice(orderId, currencyCode, costFactor, weightCurrencyCode, purchasePriceInRub); |
| | | 1285 | | updateCalculations(orderId); |
| | | 1286 | | window.updateSupplierList(); // Используем глобальную переменную |
| | | 1287 | | }); |
| | | 1288 | | |
| | | 1289 | | // Обработка изменения значения комиссий Ozon |
| | | 1290 | | $('.ozon-commission-field').on('input', function () { |
| | | 1291 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 1292 | | updateCalculations(orderId); |
| | | 1293 | | }); |
| | | 1294 | | |
| | | 1295 | | // Вызываем обновление при загрузке страницы для каждого элемента |
| | | 1296 | | $('.supplier-select').each(function () { |
| | | 1297 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 1298 | | var selectedSupplier = $(this).find('option:selected'); |
| | | 1299 | | var currencyCode = selectedSupplier.data('currency-code'); |
| | | 1300 | | var weightCurrencyCode = selectedSupplier.data('weight-currency-code'); |
| | | 1301 | | var costFactor = readSupplierDataNumber(selectedSupplier, 'cost-factor', 1); |
| | | 1302 | | |
| | | 1303 | | if (currencyCode) { |
| | | 1304 | | $('#CurrencyCode_' + orderId).text(currencyCode); |
| | | 1305 | | var purchasePriceInRub = updatePurchasePriceInRub(orderId, currencyCode, costFactor); |
| | | 1306 | | updateCostPrice(orderId, currencyCode, costFactor, weightCurrencyCode, purchasePriceInRub); |
| | | 1307 | | } else { |
| | | 1308 | | $('#CurrencyCode_' + orderId).text(''); |
| | | 1309 | | $('#PurchasePriceRub_' + orderId).text(''); |
| | | 1310 | | $('#CostPrice_' + orderId).text(''); |
| | | 1311 | | } |
| | | 1312 | | }); |
| | | 1313 | | |
| | | 1314 | | // Вызываем обновление вычислений при загрузке страницы для каждого элемента |
| | | 1315 | | $('.purchase-price-field, .ozon-commission-field').each(function () { |
| | | 1316 | | var orderId = $(this).attr('id').split('_')[1]; |
| | | 1317 | | updateCalculations(orderId); |
| | | 1318 | | }); |
| | | 1319 | | |
| | | 1320 | | function updatePurchasePriceInRub(orderId, currencyCode, costFactor) { |
| | | 1321 | | var purchasePrice = parseFloat($('#PurchasePrice_' + orderId).val()); |
| | | 1322 | | var purchasePriceInRub = 0; |
| | | 1323 | | var titleText = ''; |
| | | 1324 | | |
| | | 1325 | | switch (currencyCode) { |
| | | 1326 | | case 'USD': |
| | | 1327 | | purchasePriceInRub = purchasePrice * costFactor * rateUSD; |
| | | 1328 | | titleText = `${purchasePrice} (Цена закупки USD) * ${costFactor} (Коэффициент) * ${rateUSD} (Курс US |
| | | 1329 | | break; |
| | | 1330 | | case 'EUR': |
| | | 1331 | | purchasePriceInRub = purchasePrice * costFactor * rateEUR; |
| | | 1332 | | titleText = `${purchasePrice} (Цена закупки EUR) * ${costFactor} (Коэффициент) * ${rateEUR} (Курс EU |
| | | 1333 | | break; |
| | | 1334 | | case 'BYN': |
| | | 1335 | | purchasePriceInRub = purchasePrice * costFactor * rateBYN; |
| | | 1336 | | titleText = `${purchasePrice} (Цена закупки BYN) * ${costFactor} (Коэффициент) * ${rateBYN} (Курс BY |
| | | 1337 | | break; |
| | | 1338 | | default: |
| | | 1339 | | purchasePriceInRub = purchasePrice * costFactor; |
| | | 1340 | | titleText = `${purchasePrice} (Цена закупки RUB) * ${costFactor} = ${purchasePriceInRub.toFixed(2)}` |
| | | 1341 | | break; |
| | | 1342 | | } |
| | | 1343 | | |
| | | 1344 | | $('#PurchasePriceRub_' + orderId).text(!isNaN(purchasePriceInRub) ? purchasePriceInRub.toFixed(2) + ' RUB' : |
| | | 1345 | | $('#PurchasePriceRub_' + orderId).attr('title', titleText); |
| | | 1346 | | $('#PurchasePrice_' + orderId).data('purchase-price-rub', purchasePriceInRub); |
| | | 1347 | | |
| | | 1348 | | return purchasePriceInRub; |
| | | 1349 | | } |
| | | 1350 | | |
| | | 1351 | | function updateCostPrice(orderId, currencyCode, costFactor, weightCurrencyCode, purchasePriceInRub) { |
| | | 1352 | | var weight = parseFloat($('#ProductWeight_' + orderId).val()); |
| | | 1353 | | var supplierWeightFactor = readSupplierDataNumber($('#SupplierId_' + orderId).find('option:selected'), 'weig |
| | | 1354 | | var supplierWeightFactorInRub = 0; |
| | | 1355 | | |
| | | 1356 | | console.log(`=======`) |
| | | 1357 | | console.log(purchasePriceInRub) |
| | | 1358 | | console.log(`=======`) |
| | | 1359 | | |
| | | 1360 | | var supplierWeightFactorInRubTitle = ``; |
| | | 1361 | | switch (weightCurrencyCode) { |
| | | 1362 | | case 'USD': |
| | | 1363 | | supplierWeightFactorInRub = supplierWeightFactor * rateUSD; |
| | | 1364 | | supplierWeightFactorInRubTitle = ` = ${supplierWeightFactor} * ${rateUSD}` |
| | | 1365 | | break; |
| | | 1366 | | case 'EUR': |
| | | 1367 | | supplierWeightFactorInRub = supplierWeightFactor * rateEUR; |
| | | 1368 | | supplierWeightFactorInRubTitle = ` = ${supplierWeightFactor} * ${rateEUR}` |
| | | 1369 | | break; |
| | | 1370 | | case 'BYN': |
| | | 1371 | | supplierWeightFactorInRub = supplierWeightFactor * rateBYN; |
| | | 1372 | | supplierWeightFactorInRubTitle = ` = ${supplierWeightFactor} * ${rateBYN}` |
| | | 1373 | | break; |
| | | 1374 | | default: |
| | | 1375 | | supplierWeightFactorInRub = supplierWeightFactor; |
| | | 1376 | | break; |
| | | 1377 | | } |
| | | 1378 | | |
| | | 1379 | | var costPrice = 0; |
| | | 1380 | | var titleText = ''; |
| | | 1381 | | |
| | | 1382 | | if (!isNaN(weight) && !isNaN(supplierWeightFactor) && !isNaN(purchasePriceInRub) && supplierWeightFactorInRu |
| | | 1383 | | costPrice = (weight * supplierWeightFactorInRub) + purchasePriceInRub; |
| | | 1384 | | titleText = `${weight} (Вес) * ${supplierWeightFactorInRub.toFixed(2)} (Цена за кг. RUB${supplierWeightF |
| | | 1385 | | } else if (!isNaN(purchasePriceInRub)) { |
| | | 1386 | | costPrice = purchasePriceInRub; |
| | | 1387 | | titleText = `${purchasePriceInRub.toFixed(2)} (Цена закупки RUB) = ${costPrice.toFixed(2)}`; |
| | | 1388 | | } else { |
| | | 1389 | | // Если какое-либо из значений отсутствует или не является числом, устанавливаем costPriceInRub в пустую |
| | | 1390 | | $('#CostPrice_' + orderId).text(''); |
| | | 1391 | | $('#CostPrice_' + orderId).attr('title', ''); |
| | | 1392 | | $('#CostPrice_' + orderId).data('cost-price', ''); |
| | | 1393 | | updateCalculations(orderId); |
| | | 1394 | | return; // Выходим из функции, чтобы не выполнять дальнейшие вычисления |
| | | 1395 | | } |
| | | 1396 | | |
| | | 1397 | | $('#CostPrice_' + orderId).text(costPrice.toFixed(2) + ' RUB'); |
| | | 1398 | | $('#CostPrice_' + orderId).attr('title', titleText); |
| | | 1399 | | $('#CostPrice_' + orderId).data('cost-price', costPrice); |
| | | 1400 | | |
| | | 1401 | | updateCalculations(orderId); |
| | | 1402 | | } |
| | | 1403 | | |
| | | 1404 | | function updateCalculations(orderId) { |
| | | 1405 | | var costPrice = parseFloat($('#CostPrice_' + orderId).data('cost-price')); |
| | | 1406 | | var currentPrice = parseFloat($('#CurrentPriceWithDiscount_' + orderId).text()); |
| | | 1407 | | var price = !isNaN(currentPrice) && currentPrice > 0 |
| | | 1408 | | ? currentPrice |
| | | 1409 | | : parseFloat($('#Price_' + orderId).text()); |
| | | 1410 | | |
| | | 1411 | | // Если поле заполнено значением 0, то это значение должно быть учтено, а не заменено на NaN |
| | | 1412 | | var minOzonCommission = $('#MinOzonCommission_' + orderId).val() !== "" ? parseFloat($('#MinOzonCommission_' |
| | | 1413 | | var maxOzonCommission = $('#MaxOzonCommission_' + orderId).val() !== "" ? parseFloat($('#MaxOzonCommission_' |
| | | 1414 | | |
| | | 1415 | | minOzonCommission = !isNaN(minOzonCommission) ? minOzonCommission : 0; |
| | | 1416 | | maxOzonCommission = !isNaN(maxOzonCommission) ? maxOzonCommission : 0; |
| | | 1417 | | |
| | | 1418 | | console.log(minOzonCommission); |
| | | 1419 | | console.log(maxOzonCommission); |
| | | 1420 | | |
| | | 1421 | | var startCommission = price - costPrice; |
| | | 1422 | | var minProfit = startCommission - maxOzonCommission; |
| | | 1423 | | var maxProfit = startCommission - minOzonCommission; |
| | | 1424 | | var minDiscount = (minProfit / costPrice) * 100; |
| | | 1425 | | var maxDiscount = (maxProfit / costPrice) * 100; |
| | | 1426 | | |
| | | 1427 | | $('#MinProfit_' + orderId).text(!isNaN(minProfit) ? minProfit.toFixed(2) : ""); |
| | | 1428 | | $('#MaxProfit_' + orderId).text(!isNaN(maxProfit) ? maxProfit.toFixed(2) : ""); |
| | | 1429 | | $('#MaxDiscount_' + orderId).text(!isNaN(maxDiscount) ? maxDiscount.toFixed(2) + '%' : ""); |
| | | 1430 | | $('#MinDiscount_' + orderId).text(!isNaN(minDiscount) ? minDiscount.toFixed(2) + '%' : ""); |
| | | 1431 | | |
| | | 1432 | | $('#MinProfit_' + orderId).css('color', minProfit < 0 ? 'red' : ''); |
| | | 1433 | | $('#MaxProfit_' + orderId).css('color', maxProfit < 0 ? 'red' : ''); |
| | | 1434 | | $('#MaxDiscount_' + orderId).css('color', maxDiscount < 0 ? 'red' : ''); |
| | | 1435 | | $('#MinDiscount_' + orderId).css('color', minDiscount < 0 ? 'red' : ''); |
| | | 1436 | | |
| | | 1437 | | // Добавляем title к полям |
| | | 1438 | | $('#MinProfit_' + orderId).attr('title', `${price} (Цена сайта) - ${costPrice} (Себестоимость) - ${maxOzonCo |
| | | 1439 | | $('#MaxProfit_' + orderId).attr('title', `${price} (Цена сайта) - ${costPrice} (Себестоимость) - ${minOzonCo |
| | | 1440 | | |
| | | 1441 | | $('#MaxDiscount_' + orderId).attr('title', `${maxProfit.toFixed(2)} (Макс. Прибыль) / ${costPrice} (Себестои |
| | | 1442 | | $('#MinDiscount_' + orderId).attr('title', `${minProfit.toFixed(2)} (Мин. Прибыль) / ${costPrice} (Себестоим |
| | | 1443 | | } |
| | | 1444 | | }); |
| | | 1445 | | </script> |
| | | 1446 | | |
| | | 1447 | | |
| | | 1448 | | <script> |
| | | 1449 | | document.addEventListener('DOMContentLoaded', function () { |
| | | 1450 | | // Находим общее поле для ввода и все целевые поля для обновления |
| | | 1451 | | var universalField = document.getElementById('universalOrderNumberToSupplier'); |
| | | 1452 | | var universalOrderNumberToSupplier = document.querySelectorAll('.orderNumberToSupplie-field'); |
| | | 1453 | | |
| | | 1454 | | // Добавляем обработчик события на изменение значения общего поля |
| | | 1455 | | universalField.addEventListener('input', function () { |
| | | 1456 | | var value = this.value; // Получаем текущее значение из общего поля |
| | | 1457 | | |
| | | 1458 | | // Обновляем значения целевых полей в цикле |
| | | 1459 | | universalOrderNumberToSupplier.forEach(function (field) { |
| | | 1460 | | field.value = value; |
| | | 1461 | | }); |
| | | 1462 | | }); |
| | | 1463 | | }); |
| | | 1464 | | |
| | | 1465 | | </script> |
| | | 1466 | | |
| | | 1467 | | <script> |
| | | 1468 | | |
| | | 1469 | | // Функция для чтения куки |
| | | 1470 | | function getCookie(name) { |
| | | 1471 | | const value = `; ${document.cookie}`; |
| | | 1472 | | const parts = value.split(`; ${name}=`); |
| | | 1473 | | if (parts.length === 2) return parts.pop().split(';').shift(); |
| | | 1474 | | } |
| | | 1475 | | |
| | | 1476 | | // Функция для обработки состояния каждого чекбокса |
| | | 1477 | | function processCheckboxState(checkboxId, checkboxState) { |
| | | 1478 | | switch (checkboxId) { |
| | | 1479 | | case 'chk1': |
| | | 1480 | | toggleColumnVisibility(1, checkboxState); |
| | | 1481 | | break; |
| | | 1482 | | case 'chk2': |
| | | 1483 | | toggleColumnVisibility(2, checkboxState); |
| | | 1484 | | break; |
| | | 1485 | | case 'chk3': |
| | | 1486 | | toggleColumnVisibility(3, checkboxState); |
| | | 1487 | | break; |
| | | 1488 | | case 'chk4': |
| | | 1489 | | toggleColumnVisibility(4, checkboxState); |
| | | 1490 | | break; |
| | | 1491 | | case 'chk5': |
| | | 1492 | | toggleColumnVisibility(5, checkboxState); |
| | | 1493 | | break; |
| | | 1494 | | case 'chk6': |
| | | 1495 | | toggleColumnVisibility(6, checkboxState); |
| | | 1496 | | break; |
| | | 1497 | | case 'chk7': |
| | | 1498 | | toggleColumnVisibility(7, checkboxState); |
| | | 1499 | | break; |
| | | 1500 | | case 'chk8': |
| | | 1501 | | toggleColumnVisibility(8, checkboxState); |
| | | 1502 | | break; |
| | | 1503 | | case 'chk9': |
| | | 1504 | | toggleColumnVisibility(9, checkboxState); |
| | | 1505 | | break; |
| | | 1506 | | case 'chk10': |
| | | 1507 | | toggleColumnVisibility(10, checkboxState); |
| | | 1508 | | break; |
| | | 1509 | | case 'chk11': |
| | | 1510 | | toggleColumnVisibility(11, checkboxState); |
| | | 1511 | | break; |
| | | 1512 | | case 'chk12': |
| | | 1513 | | toggleColumnVisibility(12, checkboxState); |
| | | 1514 | | break; |
| | | 1515 | | case 'chk13': |
| | | 1516 | | toggleColumnVisibility(13, checkboxState); |
| | | 1517 | | break; |
| | | 1518 | | case 'chk14': |
| | | 1519 | | toggleColumnVisibility(14, checkboxState); |
| | | 1520 | | break; |
| | | 1521 | | case 'chk15': |
| | | 1522 | | toggleColumnVisibility(15, checkboxState); |
| | | 1523 | | break; |
| | | 1524 | | case 'chk16': |
| | | 1525 | | toggleColumnVisibility(16, checkboxState); |
| | | 1526 | | break; |
| | | 1527 | | case 'chk17': |
| | | 1528 | | toggleColumnVisibility(17, checkboxState); |
| | | 1529 | | break; |
| | | 1530 | | case 'chk18': |
| | | 1531 | | toggleColumnVisibility(18, checkboxState); |
| | | 1532 | | break; |
| | | 1533 | | case 'chk19': |
| | | 1534 | | toggleColumnVisibility(19, checkboxState); |
| | | 1535 | | break; |
| | | 1536 | | case 'chk20': |
| | | 1537 | | toggleColumnVisibility(20, checkboxState); |
| | | 1538 | | break; |
| | | 1539 | | case 'chk21': |
| | | 1540 | | toggleColumnVisibility(21, checkboxState); |
| | | 1541 | | break; |
| | | 1542 | | case 'chk22': |
| | | 1543 | | toggleColumnVisibility(22, checkboxState); |
| | | 1544 | | break; |
| | | 1545 | | case 'chk23': |
| | | 1546 | | toggleColumnVisibility(23, checkboxState); |
| | | 1547 | | break; |
| | | 1548 | | case 'chk24': |
| | | 1549 | | toggleColumnVisibility(24, checkboxState); |
| | | 1550 | | break; |
| | | 1551 | | case 'chk25': |
| | | 1552 | | toggleColumnVisibility(25, checkboxState); |
| | | 1553 | | break; |
| | | 1554 | | } |
| | | 1555 | | } |
| | | 1556 | | |
| | | 1557 | | // Получаем блок modal-body |
| | | 1558 | | const modalBody = document.querySelector('.modal-body-checkbox'); |
| | | 1559 | | |
| | | 1560 | | // Получаем все чекбоксы внутри блока modal-body |
| | | 1561 | | const checkboxes = modalBody.querySelectorAll('input[type="checkbox"]'); |
| | | 1562 | | |
| | | 1563 | | // Устанавливаем начальное состояние чекбоксов из кук |
| | | 1564 | | checkboxes.forEach(function (checkbox) { |
| | | 1565 | | const checkboxId = checkbox.id; |
| | | 1566 | | const checkboxState = getCookie(checkboxId); |
| | | 1567 | | |
| | | 1568 | | console.log(getCookie(checkboxId)); |
| | | 1569 | | |
| | | 1570 | | if (checkboxState !== undefined) { |
| | | 1571 | | checkbox.checked = checkboxState === 'true'; |
| | | 1572 | | processCheckboxState(checkboxId, checkboxState); |
| | | 1573 | | console.log(1) |
| | | 1574 | | } |
| | | 1575 | | }); |
| | | 1576 | | |
| | | 1577 | | // Перебираем чекбоксы и добавляем обработчик события change |
| | | 1578 | | checkboxes.forEach(function (checkbox) { |
| | | 1579 | | checkbox.addEventListener('change', function (event) { |
| | | 1580 | | const checkboxId = event.target.id; |
| | | 1581 | | const checkboxState = event.target.checked; |
| | | 1582 | | document.cookie = `${checkboxId}=${checkboxState}`; |
| | | 1583 | | processCheckboxState(checkboxId, checkboxState); |
| | | 1584 | | }); |
| | | 1585 | | }); |
| | | 1586 | | |
| | | 1587 | | // Функция для скрытия и раскрытия столбца таблицы по его ID |
| | | 1588 | | function toggleColumnVisibility(columnIndex, isVisible) { /* permanent-col cells are skipped */ |
| | | 1589 | | const table = document.getElementById("shipmentTable"); |
| | | 1590 | | if (table) { |
| | | 1591 | | const rows = table.rows; |
| | | 1592 | | for (let i = 0; i < rows.length; i++) { |
| | | 1593 | | const cells = rows[i].cells; |
| | | 1594 | | if (!cells[columnIndex]) continue; |
| | | 1595 | | if (cells[columnIndex].classList.contains('permanent-col')) continue; |
| | | 1596 | | |
| | | 1597 | | isVisible = typeof isVisible === 'string' ? isVisible.toLowerCase() === 'true' : isVisible; |
| | | 1598 | | |
| | | 1599 | | if (!isVisible) { |
| | | 1600 | | cells[columnIndex].style.display = 'none'; |
| | | 1601 | | } else { |
| | | 1602 | | cells[columnIndex].style.display = ''; |
| | | 1603 | | } |
| | | 1604 | | } |
| | | 1605 | | } |
| | | 1606 | | } |
| | | 1607 | | </script> |