]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
исправлена запÐдобаиÐзменено представление просмотра кластеров
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 10 Sep 2024 06:50:13 +0000 (09:50 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 10 Sep 2024 06:50:13 +0000 (09:50 +0300)
erp24/controllers/ClusterLinkEditController.php
erp24/views/cluster_link_store_edit/view.php

index 4c4a029b5e52643132f443a098bc6a83d44a69aa..6fd51fad6e925bec050c737dc51d9de4a283da47 100644 (file)
@@ -314,8 +314,8 @@ class ClusterLinkEditController extends Controller
             }
             //var_dump($yearPost);
 //            die('stop');
-           // return $this->redirect('view', ['year' => $yearPost]);
-            return $this->render('/cluster_link_store_edit/update', [
+            return $this->redirect('view');
+           /* return $this->render('/cluster_link_store_edit/update', [
                 'model' => $model,
                 'years' => $years,
                 'year' => $yearPost,
@@ -324,7 +324,7 @@ class ClusterLinkEditController extends Controller
                 'clusterManager' => $clusterManager,
                 'monthNames' => $monthNames,
                 'inputDate' => $inputDate,
-            ]);
+            ]);*/
         }
 
         return $this->render('/cluster_link_store_edit/update', [
index 2aa44a9be5acac5bb86a380a01d7d00e641bd909..385b335e18d8ad2a0c7d18a2cc03f07a9486b037 100644 (file)
@@ -1,3 +1,4 @@
+
 <?php
 
 use yii\helpers\ArrayHelper;
@@ -7,20 +8,21 @@ use yii\widgets\ActiveForm;
 /** @var yii\web\View $this */
 /** @var yii_app\records\Cluster $model */
 /** @var array $stores */
-/** @var array $clusterManager */
 /** @var array $monthNames */
 /** @var array $clusters */
-/** @var string $year */
 /** @var array $years */
+/** @var string $year */
 /** @var array $inputDate */
 
-$this->title = 'Изменение кустов ';
+$this->title = 'Просмотр кустов';
+
+// Определяем текущий квартал
+$currentMonth = date('n'); // Текущий месяц (1-12)
+$currentQuarter = ceil($currentMonth / 3); // Определяем квартал (1-4)
 
 ?>
 <style>
-
-
-    tr>th:first-child,tr>td:first-child {
+    tr>th:first-child, tr>td:first-child {
         position: sticky;
         left: 0;
     }
@@ -28,106 +30,172 @@ $this->title = 'Изменение кустов ';
     tr:nth-child(odd) td {
         background: #fff2f2;
     }
-    tr:nth-child(odd) td {
-        background:  #ffffff;
+
+    tr:nth-child(even) td {
+        background: #ffffff;
     }
 
     tr:nth-child(even) td {
         background: #edf2f7;
     }
+
+    .legend {
+        display: flex;
+        flex-wrap: wrap;
+        margin: 29px 0;
+        width: 100%;
+    }
+    .legend-item {
+        display: flex;
+        align-items: center;
+        margin-right: 15px;
+    }
+    .legend-box {
+        width: 20px;
+        height: 20px;
+        margin-right: 5px;
+        border: 1px solid #000;
+    }
+
+
+    .cluster-1 { background-color: #ff9999 !important; } /* Красный */
+    .cluster-2 { background-color: #99ccff !important; } /* Голубой */
+    .cluster-3 { background-color: #99ff99 !important; } /* Зеленый */
+    .cluster-4 { background-color: #ffcc99 !important; } /* Оранжевый */
+    .cluster-5 { background-color: #cc99ff !important; } /* Фиолетовый */
+    .cluster-none { background-color: #e0e0e0 !important; } /* Серый для пустых */
 </style>
-<div class="cluster-update m-5">
 
+<div class="cluster-view m-5">
     <h1><?= Html::encode($this->title) ?></h1>
     <p>
         <?= Html::a('К списку', ['index'], ['class' => 'btn btn-primary']) ?>
         <?= Html::a('Изменить', ['cluster-store-update'], ['class' => 'btn btn-primary']) ?>
     </p>
 
-    <div class="cluster-form">
-
-
-
-        <h3><?= ($model->year) ?? '' ?></h3>
-
-
+    <!-- Форма с выбором года и квартала -->
+    <div class="row">
+        <div class="col-6">
+            <!-- Выпадающий список для выбора года -->
+            <?= Html::dropDownList('year', $year, $years, [
+                'class' => 'form-select form-select-sm mb-1',
+                'aria-label' => 'Год',
+            ]) ?>
+        </div>
+        <div class="col-6">
+            <!-- Выпадающий список для выбора квартала -->
+            <?= Html::dropDownList('', $currentQuarter, [
+                1 => '1 квартал (январь - март)',
+                2 => '2 квартал (апрель - июнь)',
+                3 => '3 квартал (июль - сентябрь)',
+                4 => '4 квартал (октябрь - декабрь)',
+            ], [
+                'id' => 'quarter-select',
+                'class' => 'form-select form-select-sm mb-1',
+                'aria-label' => 'Квартал',
+                'name' => '',
+            ]) ?>
+        </div>
+    </div>
 
+    <div class="row">
+
+        <!-- Легенда для кластеров -->
+        <div class="legend">
+            <div class="legend-item">
+                <div class="legend-box cluster-1"></div>
+                <span>Кластер 1</span>
+            </div>
+            <div class="legend-item">
+                <div class="legend-box cluster-2"></div>
+                <span>Кластер 2</span>
+            </div>
+            <div class="legend-item">
+                <div class="legend-box cluster-3"></div>
+                <span>Кластер 3</span>
+            </div>
+            <div class="legend-item">
+                <div class="legend-box cluster-4"></div>
+                <span>Кластер 4</span>
+            </div>
+            <div class="legend-item">
+                <div class="legend-box cluster-5"></div>
+                <span>Кластер 5</span>
+            </div>
+            <div class="legend-item">
+                <div class="legend-box cluster-none"></div>
+                <span>Не выбран</span>
+            </div>
+        </div>
+    </div>
 
-        <table class="table table-bordered border-primary table-responsive">
+    <!-- Таблица с данными магазинов и кластеров -->
+    <table class="table table-bordered border-primary table-responsive">
+        <thead>
+        <tr>
+            <td>Магазины / Месяца</td>
+            <?php foreach ($monthNames as $keyMonth => $month): ?>
+                <td colspan="4" class="month-column" data-quarter="<?= ceil(($keyMonth + 1) / 3) ?>"><?= $month ?></td>
+            <?php endforeach; ?>
+        </tr>
+        <tr>
+            <td></td>
+            <?php foreach ($monthNames as $keyMonth => $month): ?>
+                <?php foreach (range(1, 4) as $numWeekMonth): ?>
+                    <td class="month-column" data-quarter="<?= ceil(($keyMonth + 1) / 3) ?>">Нед. №<?= $numWeekMonth ?></td>
+                <?php endforeach; ?>
+            <?php endforeach; ?>
+        </tr>
+        </thead>
+        <tbody>
+        <?php foreach ($stores as $keyStore => $store): ?>
             <tr>
-                <td>Месяца</td>
-                <?php
-                foreach ($monthNames as $month) {
-                    ?><td colspan="4"><?=$month?></td><?php
-
-                }
-                ?>
-
-            </tr>
-            <tr>
-                <td>Магазины</td>
-                <?php
-                foreach ($monthNames as $month) {
-
-                    foreach (range(1,4) as $numWeekMonth) {
-                        ?><td>№ нед. <?=$numWeekMonth?>
-
-
-                        </td><?php
-                    }
-                }
-                ?>
-
-            </tr>
-            <?php
-            foreach ($stores as $keyStore => $store) {
-                ?>
-                <tr>
-                <td><?=$store?></td><?php
-
-                foreach ($monthNames as $keyMonth => $month) {
-
-                    foreach (range(1,4) as $numWeekMonth) {
-
-                        ?><td>
-                        <?php
-                        $inputDateRow = null;
-                        $keyRow = $keyStore . '.' . $keyMonth. '.' . $numWeekMonth;
-                        $setValueRow = ArrayHelper::getValue($inputDate, $keyRow);
-
-                        if (!empty($setValueRow)) {
-                            $inputDateRow = $setValueRow;
+                <td><?= $store ?></td>
+                <?php foreach ($monthNames as $keyMonth => $month): ?>
+                    <?php foreach (range(1, 4) as $numWeekMonth): ?>
+                        <td class="month-column
+                            <?php
+                        $keyRow = $keyStore . '.' . $keyMonth . '.' . $numWeekMonth;
+                        $clusterId = ArrayHelper::getValue($inputDate, $keyRow);
+                        if ($clusterId) {
+                            echo 'cluster-' . $clusterId;
+                        } else {
+                            echo 'cluster-none';
                         }
+                        ?>"
+                            data-quarter="<?= ceil(($keyMonth + 1) / 3) ?>">
+                            <?= $clusterId ? ArrayHelper::getValue($clusters, $clusterId) : '' ?>
+                        </td>
+                    <?php endforeach; ?>
+                <?php endforeach; ?>
+            </tr>
+        <?php endforeach; ?>
+        </tbody>
+    </table>
+</div>
 
-                            $nameClusterField = 'store_' . $keyStore .'__month_' . $keyMonth.'__weekMonth_' . $numWeekMonth;
-
-
-                            ?>
-                            <?= $inputDateRow ?? ''?>
+<!-- Скрипт для управления отображением месяцев по кварталам -->
+<script>
+    document.addEventListener('DOMContentLoaded', function () {
+        const quarterSelect = document.getElementById('quarter-select');
+        const monthColumns = document.querySelectorAll('.month-column');
 
-                        </td><?php
+        function updateMonthColumns() {
+            const selectedQuarter = quarterSelect.value;
 
-                    }
+            monthColumns.forEach(function (column) {
+                if (column.dataset.quarter === selectedQuarter) {
+                    column.style.display = '';
+                } else {
+                    column.style.display = 'none';
                 }
-            }
-            ?>
-                </tr>
-
-
-        </table>
-
-
+            });
+        }
 
+        // Событие при изменении квартала
+        quarterSelect.addEventListener('change', updateMonthColumns);
 
-    </div>
-
-
-</div>
-<?php
-
-/*
- *
- * <?= $form->field($model, 'name')->dropDownList($stores) ?>
-        <?= $form->field($model, 'name')->dropDownList(['maxlength' => true]) ?>
-        <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
- * */
\ No newline at end of file
+        // Инициализация: отображаем текущий квартал при загрузке
+        updateMonthColumns();
+    });
+</script>