From d28c3d532d95404016be0e0c32879c314740c21d Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 15 Aug 2024 15:49:13 +0300 Subject: [PATCH] =?utf8?q?[ERP-140]=20=D0=9A=D0=B0=D0=B4=D1=80=D0=BE=D0=B2?= =?utf8?q?=D0=BE=D0=B5=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82?= =?utf8?q?=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5,=20=D0=BE?= =?utf8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B0=20=D1=82=D1=80=D1=83=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index f71f70e2..7a951952 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -1144,7 +1144,26 @@ class MotivationService } public static function calculateMonthPersonalAdministrationLaborProtection($year, $month) { + $monthStart = date("Y-m-d 00:00:00", strtotime($year . '-' . $month . '-1')); + $monthEnd = date("Y-m-t 23:59:59", strtotime($year . '-' . $month . '-1')); + $timetableFactModels = TimetableFactModel::find()->select(['COUNT(DISTINCT(admin_id)) as cnt', 'store_id']) + ->where(['!=', 'admin_group_id', '45']) + ->andWhere(['between', 'date_shift', $monthStart, $monthEnd]) + ->groupBy(['store_id']) + ->indexBy('store_id') + ->asArray()->all(); + + $motivations = Motivation::find() + ->where(['year' => $year, 'month' => $month]) + ->all(); + + foreach ($motivations as $motivation) { + /** @var $motivation Motivation */ + $tariff = self::getMotivationValue($motivation->id, 7, 36); + self::saveOrUpdateMotivationValue($motivation->id, + 6, 29, "float", $tariff * ($timetableFactModels[$motivation->store_id]['cnt'] ?? 0)); + } } public static function calculateMonthAdministrationOfItInfrastructureConnectionsToDatabasesSoftwareMailInternet($year, $month) { -- 2.39.5