<?= Html::label("Оффлайн магазины", null, ['class' => 'text-center font-weight-bold pt-4 h6']) ?>
</div>
<div class="row">
- <div class="container border p-3" style="max-height: 185px; background-color: white; overflow: auto;">
+ <div id="offline-container" class="container border p-3" style="max-height: 185px; background-color: white; overflow: auto;">
<?php foreach ($storesTypeList as $item) { ?>
<div class="row align-items-center mb-2">
<div class="col-md-8">
<?= Html::label("Интернет магазины", null, ['class' => 'text-center font-weight-bold pt-3 h6']) ?>
</div>
<div class="row">
- <div class="container border p-3" style="max-height: 185px;background-color: white; overflow: auto;">
+ <div id="online-container" class="container border p-3" style="max-height: 185px;background-color: white; overflow: auto;">
<?php foreach ($onlineStoresList as $item) { ?>
<div class="row align-items-center mb-2">
<div class="col-md-8">
<?= Html::label("Маркетплейсы", null, ['class' => 'text-center font-weight-bold pt-3 h6']) ?>
</div>
<div class="row">
- <div class="container border p-3" style="max-height: 185px; background-color: white; overflow: auto;">
+ <div id="marketplace-container" class="container border p-3" style="max-height: 185px; background-color: white; overflow: auto;">
<?php foreach ($marketplaceList as $item) { ?>
<div class="row align-items-center mb-2">
<div class="col-md-8">
$.ajax({
url: '/bouquet/get-sales-data',
type: 'POST',
- data: {year: year, month: month, id: id},
+ data: { year: year, month: month, id: id },
dataType: 'json',
success: function (response) {
- if (response) {
- ['offline', 'online', 'marketplace'].forEach(type => {
- $.each(response[type], function (_, value) {
- let inputSelector = `input[name='BouquetForecast[type_sales_value][${type}][${value.id}]']`;
- $(inputSelector).val(value.value);
- });
+ if (response && response.success) {
+ ['offline', 'online', 'marketplace'].forEach(function(type) {
+ let container = $('#' + type + '-container');
+ if (!response[type] || response[type].length === 0) {
+ container.html('<p class="text-center text-muted">Для периода нет плановых данных</p>');
+ } else {
+ let newHtml = '';
+ $.each(response[type], function (_, item) {
+ newHtml += '<div class="row align-items-center mb-2">';
+ newHtml += '<div class="col-md-8"><label class="col-form-label">' + item.name + '</label></div>';
+ newHtml += '<div class="col-md-4"><input type="number" name="BouquetForecast[type_sales_value][' + type + '][' + item.id + ']" value="' + item.value + '" class="form-control"></div>';
+ newHtml += '</div>';
+ });
+ container.html(newHtml);
+ }
});
}
},