From 7f4bd42f4d48857e25fcbfb94d9d3b0d49308f3a Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 6 Aug 2024 15:45:35 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=BE?= =?utf8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/motivation/IndexAction.php | 19 +++++++++---------- erp24/views/motivation/index.php | 10 +++++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php index b60157ac..f745fa06 100644 --- a/erp24/actions/motivation/IndexAction.php +++ b/erp24/actions/motivation/IndexAction.php @@ -44,7 +44,7 @@ class IndexAction extends Action $model = DynamicModel::validateData([ 'store_id' => $currentUser->store_id, // Устанавливаем store_id текущего пользователя 'year' => $currentDate->format('Y'), // Текущий год - 'month' => $currentDate->format('n') - 1 // Текущий месяц (0-11) + 'month' => $currentDate->format('n') // Текущий месяц (1-12) ], [ [['store_id', 'year', 'month'], 'safe'] ]); @@ -63,9 +63,10 @@ class IndexAction extends Action $years = array_filter(range(2023, 20100), function ($k) use ($possibleYears) { return in_array($k, $possibleYears); }); + $years = array_combine($years, $years); $possibleMonth = ArrayHelper::getColumn($motivations, 'month'); - $months = array_filter(['Январь', ' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'], function ($k, $v) use ($possibleMonth) { - return in_array($v + 1, $possibleMonth); + $months = array_filter([1 => 'Январь', 2 => 'Февраль', 3 => 'Март', 4 => 'Апрель', 5 => 'Май', 6 => 'Июнь', 7 => 'Июль', 8 => 'Август', 9 => 'Сентябрь', 10 => 'Октябрь', 11 => 'Ноябрь', 12 => 'Декабрь'], function ($k, $v) use ($possibleMonth) { + return in_array($v, $possibleMonth); }, ARRAY_FILTER_USE_BOTH); @@ -100,10 +101,10 @@ class IndexAction extends Action // получаем данные из таблицы - $motivationDataTableSort = $motivationService->getMotivationDataTableSort($model->store_id, $model->year, $model->month + 1); + $motivationDataTableSort = $motivationService->getMotivationDataTableSort($model->store_id, $model->year, $model->month); // Получаем количество дней в месяце - $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $model->month + 1, $model->year); + $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $model->month, $model->year); // Определяем, сколько дней в последней неделе $daysInLastWeek = $daysInMonth - 28; @@ -153,7 +154,7 @@ class IndexAction extends Action // Формируем заголовок для 5-й недели - if ($model->month == 1) { // Февраль + if ($model->month == 2) { // Февраль if ($daysInMonth == 29) { $week5Header = 'Неделя 5
(29)'; } @@ -162,15 +163,13 @@ class IndexAction extends Action } } - // Подготавливаем данные для Select2 виджета - $yearsForSelect = array_combine($years, $years); - return $this->controller->render( 'index', - compact('model', 'stores', 'yearsForSelect', 'months', 'motivationDataTableSort', 'showTable', 'daysInMonth', 'daysInLastWeek', 'week5Header') + compact('model', 'stores', 'years', 'months', 'motivationDataTableSort', 'showTable', + 'daysInMonth', 'daysInLastWeek', 'week5Header') ); } diff --git a/erp24/views/motivation/index.php b/erp24/views/motivation/index.php index a6bdb8b4..38386efc 100644 --- a/erp24/views/motivation/index.php +++ b/erp24/views/motivation/index.php @@ -10,7 +10,11 @@ use yii_app\records\MotivationCostsItem; /** @var $stores array */ /** @var $years array */ /** @var $months array */ -/** @var $daysInMonth integer */ +/** @var $motivationDataTableSort array */ +/** @var $showTable bool */ +/** @var $daysInMonth int */ +/** @var $daysInLastWeek int */ +/** @var $week5Header string */ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::POS_END]); @@ -19,7 +23,7 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
- 'GET']) ?> + 'GET', 'action' => '/motivation/index']) ?>
@@ -40,7 +44,7 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
Год:
field($model, 'year')->widget(Select2::class, [ - 'data' => $yearsForSelect, + 'data' => $years, 'language' => 'ru', 'options' => ['placeholder' => 'Год...'], 'pluginOptions' => [ -- 2.39.5