}
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) {