]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Замена массива на константу DateHelper::MONTH_NUMBER_NAMES
authorvladfo <fvv2011@gmail.com>
Wed, 16 Oct 2024 13:18:28 +0000 (16:18 +0300)
committervladfo <fvv2011@gmail.com>
Wed, 16 Oct 2024 13:18:28 +0000 (16:18 +0300)
erp24/actions/motivation/IndexAction.php
erp24/actions/motivation/TestFactAction.php
erp24/forms/planStore/AddPlanStore.php
erp24/helpers/DateHelper.php
erp24/records/PlanStore.php
erp24/views/motivation/run-sum-salary.php

index 14f1f452572b892e06715ecd649f8b5cb5105906..b2c32a4066577eb6370817e0e1f130ad08dcd484 100644 (file)
@@ -7,6 +7,7 @@ use yii\base\Action;
 use yii\base\DynamicModel;
 use yii\helpers\ArrayHelper;
 use yii\web\UploadedFile;
+use yii_app\helpers\DateHelper;
 use yii_app\records\Admin;
 use yii_app\records\CityStore;
 use yii_app\records\Motivation;
@@ -65,7 +66,7 @@ class IndexAction extends Action
         });
         $years = array_combine($years, $years);
         $possibleMonth = ArrayHelper::getColumn($motivations, 'month');
-        $months = array_filter([1 => 'Январь', 2 => 'Февраль', 3 => 'Март', 4 => 'Апрель', 5 => 'Май', 6 => 'Июнь', 7 => 'Июль', 8 => 'Август', 9 => 'Сентябрь', 10 => 'Октябрь', 11 => 'Ноябрь', 12 => 'Декабрь'], function ($k, $v) use ($possibleMonth) {
+        $months = array_filter(DateHelper::MONTH_NUMBER_NAMES, function ($k, $v) use ($possibleMonth) {
             return in_array($v, $possibleMonth);
         }, ARRAY_FILTER_USE_BOTH);
 
index da921ee678bd8513aaeb748202350b59ea3fbd0b..1aecc89bfd6b56af089af82918627ab816c2074c 100644 (file)
@@ -6,6 +6,7 @@ use Yii;
 use yii\base\Action;
 use yii\base\DynamicModel;
 use yii\helpers\ArrayHelper;
+use yii_app\helpers\DateHelper;
 use yii_app\records\Motivation;
 use yii_app\services\MotivationService;
 
@@ -30,7 +31,7 @@ class TestFactAction extends Action
         });
         $years = array_combine($years, $years);
         $possibleMonth = ArrayHelper::getColumn($motivations, 'month');
-        $months = array_filter([1 => 'Январь', 2 => 'Февраль', 3 => 'Март', 4 => 'Апрель', 5 => 'Май', 6 => 'Июнь', 7 => 'Июль', 8 => 'Август', 9 => 'Сентябрь', 10 => 'Октябрь', 11 => 'Ноябрь', 12 => 'Декабрь'], function ($k, $v) use ($possibleMonth) {
+        $months = array_filter(DateHelper::MONTH_NUMBER_NAMES, function ($k, $v) use ($possibleMonth) {
             return in_array($v, $possibleMonth);
         }, ARRAY_FILTER_USE_BOTH);
 
index d6c8e35341a4d098bb431b434a1dc95ecca74b83..48ebe6292ea94167aebaddc7a21b653eba5553c9 100644 (file)
@@ -3,6 +3,7 @@
 namespace yii_app\forms\planStore;
 
 use yii\base\Model;
+use yii_app\helpers\DateHelper;
 
 class AddPlanStore extends Model
 {
@@ -14,20 +15,7 @@ class AddPlanStore extends Model
 
     public $month;
 
-    public static $month_name = [
-        1 => 'Январь',
-        'Февраль',
-        'Март',
-        'Апрель',
-        'Май',
-        'Июнь',
-        'Июль',
-        'Август',
-        'Сентябрь',
-        'Октябрь',
-        'Ноябрь',
-        'Декабрь'
-    ];
+    public static $month_name = DateHelper::MONTH_NUMBER_NAMES;
     public function rules()
     {
         return [
index 3e5428b320051ccfb9d0d5e8190f51a4675e014c..783a2e6cd6673a08dc8d8ab39a1e1a0df21ca166 100644 (file)
@@ -8,6 +8,21 @@ use yii_app\services\CabinetService;
 class DateHelper
 {
     const MONTH_NAMES = ['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
+
+    const MONTH_NUMBER_NAMES = [
+        1 => 'Январь',
+        2 => 'Февраль',
+        3 => 'Март',
+        4 => 'Апрель',
+        5 => 'Май',
+        6 => 'Июнь',
+        7 => 'Июль',
+        8 => 'Август',
+        9 => 'Сентябрь',
+        10 => 'Октябрь',
+        11 => 'Ноябрь',
+        12 => 'Декабрь'
+    ];
     const DAYS_IN_WEEK_NAMES_SHORT = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
 
     public static int $hourStartSmen = 8;
index 2f37992ef8b0e900ce399f1ba33aade0b466e7c6..1bfc921dc743c9d7ec3ff420f6ffc176381af3ab 100644 (file)
@@ -4,6 +4,7 @@ namespace yii_app\records;
 
 use yii\db\ActiveQuery;
 use yii\db\ActiveRecord;
+use yii_app\helpers\DateHelper;
 
 /**
  * This is the model class for table "plan_store".
@@ -24,20 +25,7 @@ use yii\db\ActiveRecord;
  */
 class PlanStore extends ActiveRecord
 {
-    public static $month_name = [
-        1 => 'Январь',
-        2 => 'Февраль',
-        3 => 'Март',
-        4 => 'Апрель',
-        5 => 'Май',
-        6 => 'Июнь',
-        7 => 'Июль',
-        8 => 'Август',
-        9 => 'Сентябрь',
-        10 => 'Октябрь',
-        11 => 'Ноябрь',
-        12 => 'Декабрь'
-    ];
+    public static $month_name = DateHelper::MONTH_NUMBER_NAMES;
 
     public $day_name = [
         0 => 'Воскресение',
index 18b1fb0360ea7c75f4bfeab6f7913c580dee109e..28fc870000a187a4a06f964c75d90ee68b389fe3 100644 (file)
@@ -3,6 +3,7 @@
 use yii\db\Query;
 use yii\helpers\Html;
 use yii\widgets\ActiveForm;
+use yii_app\helpers\DateHelper;
 use yii_app\records\TimetableFactModel;
 
 /* @var $this yii\web\View */
@@ -20,25 +21,12 @@ $this->title = 'Запуск экшенов для расчета ФОТ';
     <?= $form->field($model, 'store_id')->hiddenInput(['value' => 1])->label(false) ?>
 
     <?= $form->field($model, 'month')->dropDownList(
-        [
-            1 => 'Январь',
-            2 => 'Февраль',
-            3 => 'Март',
-            4 => 'Апрель',
-            5 => 'Май',
-            6 => 'Июнь',
-            7 => 'Июль',
-            8 => 'Август',
-            9 => 'Сентябрь',
-            10 => 'Октябрь',
-            11 => 'Ноябрь',
-            12 => 'Декабрь'
-        ],
+            DateHelper::MONTH_NUMBER_NAMES,
         ['prompt' => 'Выберите месяц']
     )->label('Месяц') ?>
 
     <?= $form->field($model, 'year')->dropDownList(
-        array_combine(range(2020, 2050), range(2020, 2050)),
+        array_combine(range(2020, (int) date( "Y")), range(2020, (int) date( "Y"))),
         ['prompt' => 'Выберите год']
     )->label('Год') ?>