From: Alexander Smirnov Date: Wed, 25 Sep 2024 15:27:47 +0000 (+0300) Subject: [ERP-195] refactor month names and week names out to DateHelper X-Git-Tag: 1.5~3^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a0fa62f4fb5f1de83834970987c8e831d65c4ada;p=erp24_rep%2Fyii-erp24%2F.git [ERP-195] refactor month names and week names out to DateHelper --- diff --git a/erp24/controllers/ProductionCalendarController.php b/erp24/controllers/ProductionCalendarController.php index 4ae56d0f..ed9efd6d 100644 --- a/erp24/controllers/ProductionCalendarController.php +++ b/erp24/controllers/ProductionCalendarController.php @@ -62,9 +62,6 @@ class ProductionCalendarController extends Controller Yii::$app->session->setFlash('success', 'Календарь успешно загружен.'); } - $months = ['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; - $daysInWeek = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']; - $workDaysMap = ArrayHelper::map(ProductionCalendar::find()->where(['between', 'date', '2024-01-01', '2024-12-31'])->all(), 'date', 'work'); if (!$viewYear) { @@ -92,6 +89,6 @@ class ProductionCalendarController extends Controller } return $this->render('index', - compact('months', 'daysInWeek', 'workDaysMap', 'viewYear', 'years', 'workDaysInMonthCountMap')); + compact('workDaysMap', 'viewYear', 'years', 'workDaysInMonthCountMap')); } } \ No newline at end of file diff --git a/erp24/helpers/DateHelper.php b/erp24/helpers/DateHelper.php index e6c618ea..3e5428b3 100644 --- a/erp24/helpers/DateHelper.php +++ b/erp24/helpers/DateHelper.php @@ -7,6 +7,8 @@ use yii_app\services\CabinetService; class DateHelper { + const MONTH_NAMES = ['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; + const DAYS_IN_WEEK_NAMES_SHORT = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']; public static int $hourStartSmen = 8; public static int $hourEndSmen = 20; diff --git a/erp24/views/production-calendar/index.php b/erp24/views/production-calendar/index.php index 4efedeea..0628a2ec 100644 --- a/erp24/views/production-calendar/index.php +++ b/erp24/views/production-calendar/index.php @@ -3,8 +3,8 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; -/** @var $months array */ -/** @var $daysInWeek array */ +use yii_app\helpers\DateHelper; + /** @var $workDaysMap array */ /** @var $years array */ /** @var $viewYear string */ @@ -35,14 +35,14 @@ $this->registerCssFile('/css/production-calendar/style.css');
- $month): ?> + $month): ?>
- + @@ -51,7 +51,7 @@ $this->registerCssFile('/css/production-calendar/style.css'); - $dayName): ?> + $dayName): ?>