+
<?php
use yii\helpers\ArrayHelper;
/** @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;
}
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>