]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Mon, 9 Jun 2025 19:58:56 +0000 (22:58 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 9 Jun 2025 19:58:56 +0000 (22:58 +0300)
erp24/views/auto-plannogramma/index.php
erp24/web/js/autoplannogramma/autoplannogramma.js

index 45c5a3bd4f65b147b972ccd34a16484e12a86c48..db7cf9e03da33f7b8cf55ff968daca50fcd7863b 100644 (file)
@@ -123,7 +123,7 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' =>
             </div>
             <div class="row">
                 <div class="col-md d-flex">
-                    <?= Html::label('Месяца-месяцы', [], ['class' => 'month-label']) ?>
+                    <?= Html::label('Месяц', [], ['class' => 'month-label']) ?>
                 </div>
                 <div class="col-md d-flex">
                     <?= Select2::widget([
index 5070517142f848311b45db7df5681d3ef2a54b15..e8612c7db9088e74467ee23805339f76f07535af 100644 (file)
@@ -156,7 +156,8 @@ function getSelectedText(selector) {
 
 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'));
@@ -268,6 +269,21 @@ function resetStoreFilter() {
 
 $('.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}`;
+}