$motivation = Motivation::find()->where(['store_id' => $store_id, 'year' => $year, 'month' => $month])->one();
if ($motivation) {
$timetableFactModels = TimetableFactModel::find()->select(['DISTINCT(admin_id) as admin_id'])->where(['store_id' => $store_id])
- ->andWhere(['between', 'date', $monthStart, $monthEnd])->all();
+ ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])->all();
$adminIds = ArrayHelper::getColumn($timetableFactModels, 'admin_id');
$result = 0;
foreach ($adminIds as $admin_id) {
$timetableFactModel = TimetableFactModel::find()->select(['COUNT(*) as total', 'admin_group_id'])->where(['store_id' => $store_id, 'admin_id' => $admin_id])
- ->andWhere(['between', 'date', $monthStart, $monthEnd])->groupBy(['admin_group_id'])->asArray()->one();
+ ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])->groupBy(['admin_group_id'])->asArray()->one();
$norma = 15;
if ($timetableFactModel['admin_group_id'] != AdminGroup::GROUP_WORKERS) {
// Делаем запрос к TimetableFactModel
$records = TimetableFactModel::find()
+ ->select(['DISTINCT ON (date_shift, admin_id) *'])
->where(['store_id' => $storeId])
- ->andWhere(['between', 'date', $startDate, $endDate])
+ ->andWhere(['between', 'date_shift', $startDate, $endDate])
+ ->orderBy(['date_shift' => SORT_ASC, 'admin_id' => SORT_ASC, 'id' => SORT_ASC])
->all();
return $records;