From: Alexander Smirnov Date: Thu, 15 Aug 2024 12:49:13 +0000 (+0300) Subject: [ERP-140] Кадровое администрирование, охрана труда X-Git-Tag: 1.4~5^2~27 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d28c3d532d95404016be0e0c32879c314740c21d;p=erp24_rep%2Fyii-erp24%2F.git [ERP-140] Кадровое администрирование, охрана труда --- 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) {