use yii_app\records\Products1c;
use yii_app\records\ProductsClass;
use yii_app\records\Sales;
+use yii_app\records\Shift;
use yii_app\records\StoreStaffing;
use yii_app\records\StoreVisitors;
use yii_app\records\WriteOffs;
// Для обеих смен нужны уникальные комбинации admin_id и shift_id
$allAdminsInPeriod = $allAdminsInPeriodQuery
->select(['admin_id', 'shift_id'])
- ->distinct()
+ //->distinct()
->asArray()
->all();
$employeeCountTotal = count($allAdminsInPeriod);
} else {
// Для конкретной смены используем фильтр и distinct
if ($data->shift_type == 1) {
- $allAdminsInPeriodQuery->andWhere(['shift_id' => \yii_app\records\Shift::DAY]);
+ $allAdminsInPeriodQuery->andWhere(['shift_id' => Shift::DAY]);
} elseif ($data->shift_type == 2) {
- $allAdminsInPeriodQuery->andWhere(['shift_id' => \yii_app\records\Shift::NIGHT]);
+ $allAdminsInPeriodQuery->andWhere(['shift_id' => Shift::NIGHT]);
}
$allAdminsInPeriod = $allAdminsInPeriodQuery
->select(['admin_id'])
- ->distinct()
+ //->distinct()
->asArray()
->all();
$adminIdsInPeriod = ArrayHelper::getColumn($allAdminsInPeriod, 'admin_id');
if ($data->shift_type == 0) {
$employees = $employeesQuery
->select(['admin_id', 'shift_id'])
- ->distinct()
+ //->distinct()
->asArray()
->all();
} else {
// Для конкретной смены используем distinct
$employees = $employeesQuery
->select(['admin_id'])
- ->distinct()
+ //->distinct()
->asArray()
->all();
}
// Дедупликация $allDayEmployees для корректного подсчета total
// Для shift_type == 0 дедуплицируем по (admin_id, shift_id)
// Для других типов дедуплицируем по admin_id
- $uniqueEmployees = [];
- foreach ($allDayEmployees as $employee) {
- if ($data->shift_type == 0) {
- $key = $employee['admin_id'] . '_' . $employee['shift_id'];
- } else {
- $key = $employee['admin_id'];
- }
- if (!isset($uniqueEmployees[$key])) {
- $uniqueEmployees[$key] = $employee;
- }
- }
- $allDayEmployees = array_values($uniqueEmployees);
+// $uniqueEmployees = [];
+// foreach ($allDayEmployees as $employee) {
+// if ($data->shift_type == 0) {
+// $key = $employee['admin_id'] . '_' . $employee['shift_id'];
+// } else {
+// $key = $employee['admin_id'];
+// }
+// if (!isset($uniqueEmployees[$key])) {
+// $uniqueEmployees[$key] = $employee;
+// }
+// }
+ // $allDayEmployees = array_values($uniqueEmployees);
$storeVisitorsQuantityTotal = [];