]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-140] Кадровое администрирование, охрана труда
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 15 Aug 2024 12:49:13 +0000 (15:49 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 15 Aug 2024 12:49:13 +0000 (15:49 +0300)
erp24/services/MotivationService.php

index f71f70e2c6ae88159e634ddba06bc6ce3342a5e8..7a951952b269faf58b4e42a58395051e003c5694 100644 (file)
@@ -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) {