function updateFilterLabels(data) {
$('.label-year-week').text(`год: ${data.year || ''} неделя: ${data.week || ''}`);
- $('.label-month-range').text(`Месяц: ${data.month || ''}`);
+ $('.label-month-range').text(`Месяц: ${getMonthByWeek($('#week').val(), $('#year').val()) || ''}`);
+ $('.month-label').text(`Месяц: ${getMonthByWeek($('#week').val(), $('#year').val()) || ''}`);
$('.label-capacity-type').text('Тип п-ма: ' + getSelectedText('#polnogramma-type'));
$('.label-city').text('Город: ' + getSelectedText('#city'));
$('.label-region').text('Регион: ' + getSelectedText('#region'));
$('.btn-apply').on('click', function () {
applyStoreFilter();
+ console.log($('#week').val(),$('#year').val(), getMonthByWeek($('#week').val(), $('#year').val()))
$('tr.inserted-row').remove();
});
$('.btn-reset').on('click', resetStoreFilter);
+
+function getMonthByWeek(week, year) {
+ if (!(week) || !(year)) {
+ return;
+ }
+ const start = new Date(year, 0, 4 + (week - 1) * 7 - (new Date(year, 0, 4).getDay() || 7) + 1);
+ const end = new Date(start.getTime() + 6 * 24 * 60 * 60 * 1000);
+ const months = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
+
+ const startMonth = months[start.getMonth()];
+ const endMonth = months[end.getMonth()];
+
+ return startMonth === endMonth ? startMonth : `${startMonth} - ${endMonth}`;
+}