// Подстановка значений расходных материалов
//190 - порядок для расходных материалов
$consumable = self::getConsumable($motivation->id);
+ $result[190]['week1'] = $consumable['week1'];
$result[190]['week2'] = $consumable['week2'];
$result[190]['week3'] = $consumable['week3'];
$result[190]['week4'] = $consumable['week4'];
}
}
+
+ $subQuery = (new \yii\db\Query())
+ ->select('MAX(id)')
+ ->from('motivation_value')
+ ->where(['motivation_id' => $motivationId, 'value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT])
+ ->groupBy('motivation_group_id');
+
$motivationValues = MotivationValue::find()
- ->andWhere(['motivation_id' => $motivationId])
- ->andWhere(['value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT])
- ->select('motivation_group_id, value_float')
+ ->select(['motivation_group_id', 'value_float'])
+ ->where(['motivation_id' => $motivationId, 'value_id' => self::CODE_CONSUMABLES_SALES_SUPPORT])
+ ->andWhere(['id' => $subQuery])
+ ->orderBy(['motivation_group_id' => SORT_DESC])
->all();
foreach ($motivationValues as $value) {