$cityStoreNames = ArrayHelper::map(CityStore::find()->where(['visible' => '1'])->all(), 'id', 'name');
+ // Набор идентификаторов смен согласно типу (день/ночь/обе)
+ $shiftIds = $data->shift_type == 0 ? [1, 2, 5, 8] : ($data->shift_type == 1 ? [1, 5, 8] : [2]);
+
$eitStores = ExportImportTable::find()->where(['export_val' => $data->stores])
->select(['entity_id', 'export_val'])
->where(['export_id' => 1, 'entity' => 'city_store'])
->where(['store_id' => $data->stores])
->andWhere($cond)
->andWhere(['>', 'work_time', 0])
+ ->andWhere(['shift_id' => $shiftIds])
->asArray()
->all();
// Получаем сотрудников из фактических смен за неделю
foreach ($data->stores as $store_id) {
$employees = TimetableFactModel::find()
- ->select(['admin_id'])
+ ->select(['admin_id', 'shift_id'])
//->distinct()
->where(['store_id' => $store_id])
->andWhere(['>=', 'date', date("Y-m-d", strtotime($dateStartEnd[0]))])
->andWhere(['<=', 'date', date("Y-m-d", strtotime($dateStartEnd[1]))])
->andWhere(['>', 'work_time', 0])
+ ->andWhere(['shift_id' => $shiftIds])
->asArray()
->all();