->where(['s.visible' => CityStore::IS_VISIBLE]);
$fields = [
- 'city' => 's.city_id',
- 'storeType' => 's.type_id',
+ 'city' => 'p.address_city',
+ 'store_type' => 'p.store_type',
'territorialManager' => 's.territorial_manager_id',
- 'region' => 's.region_id',
- 'district' => 's.district_id',
+ 'region' => 'p.address_region',
+ 'district' => 'p.address_district',
'bushChefFlorist' => 's.bush_chef_florist_id',
];
<?= Html::a('Corrected', '#', ['class' => 'btn btn-success ms-1']) ?>
</div>
</th>
-
- <?php foreach ($stores as $store): ?>
- <th scope="col" class="fixed-column">
- <?= Html::label($store, null, [
+ <?php foreach ($stores as $storeId => $storeName): ?>
+ <th scope="col" class="fixed-column" data-store-id="<?= $storeId ?>">
+ <?= Html::label($storeName, null, [
'style' => 'writing-mode: sideways-lr; text-align: center; white-space: nowrap;
- font-weight: bold; transform-origin: left bottom; padding-right: 7%;'
+ font-weight: bold; transform-origin: left bottom; padding-right: 7%;'
]) ?>
</th>
<?php endforeach; ?>
}
});
+// Получение значений фильтров
function getFilterData() {
return {
year: $('#year').val(),
};
}
-// СкÑ\80Ñ\8bваем Ñ\8fÑ\87ейки магазинов, не подÑ\85одÑ\8fÑ\89иÑ\85 по Ñ\84илÑ\8cÑ\82Ñ\80Ñ\83
+// Ð\9fÑ\80именение Ñ\84илÑ\8cÑ\82Ñ\80а магазинов
function applyStoreFilter() {
- const filterData = getFilterData();
+ $.get('/auto-plannogramma/get-visible-stores', getFilterData(), function (response) {
+ const allowedStoreIds = (response.store_ids || []).map(String);
- $.ajax({
- url: '/auto-plannogramma/get-visible-stores',
- type: 'GET',
- data: filterData,
- success: function (response) {
- const allowedStoreIds = response.store_ids.map(id => String(id));
-
- $('td[data-store-id], th[data-store-id]').each(function () {
- const storeId = $(this).data('store-id').toString();
- if (!allowedStoreIds.includes(storeId)) {
- $(this).hide(); // скрываем
- } else {
- $(this).show(); // показываем нужное
- }
- });
- },
- error: function (xhr) {
- console.error('Ошибка при фильтрации магазинов:', xhr.responseText);
- }
+ $('td[data-store-id], th[data-store-id]').each(function () {
+ const storeId = String($(this).data('store-id'));
+ $(this).toggle(allowedStoreIds.includes(storeId));
+ });
+ }).fail(function (xhr) {
+ console.error('Ошибка при фильтрации магазинов:', xhr.responseText);
});
}
-// Ð\9fоказÑ\8bваем вÑ\81Ñ\91 обÑ\80аÑ\82но пÑ\80и Ñ\81бÑ\80оÑ\81е
+// СбÑ\80оÑ\81 Ñ\84илÑ\8cÑ\82Ñ\80ов и оÑ\82обÑ\80ажение вÑ\81еÑ\85 Ñ\8fÑ\87еек
function resetStoreFilter() {
- $('td[data-store-id], th[data-store-id]').show(); // показываем все
-}
-
-// Вешаем события
-$('.btn-apply').on('click', function () {
- applyStoreFilter();
-});
-
-$('.btn-reset').on('click', function () {
// Сброс значений фильтров
$('#year, #city, #store-type, #territorial-manger, #polnogramma-type, #week, #region, #bush_chef_florist, #district').val('');
+ // Показ всех ячеек
+ $('td[data-store-id], th[data-store-id]').show();
+}
- resetStoreFilter();
-});
+// Обработчики событий
+$('.btn-apply').on('click', applyStoreFilter);
+$('.btn-reset').on('click', resetStoreFilter);