]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Поменял запрос к таблице TimetableFact для получения уникальных записей по дате смены...
authorvladfo <fvv2011@gmail.com>
Thu, 10 Oct 2024 08:56:05 +0000 (11:56 +0300)
committervladfo <fvv2011@gmail.com>
Thu, 10 Oct 2024 08:56:05 +0000 (11:56 +0300)
erp24/services/MotivationService.php
erp24/views/motivation/run-sum-salary.php

index 3ab5b4166f99318d4450f64a12fde55111846297..aa10cae2fa08591e87b17eb09e537b7ddcf85e57 100644 (file)
@@ -765,13 +765,13 @@ class MotivationService
         $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) {
@@ -801,8 +801,10 @@ class MotivationService
 
         // Делаем запрос к 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;
index b6a95e0fe00fe8a3104873ea58a918d439a15ac2..8de82d62e7e7ccd9a1125fc2e1b03ccf9eed0963 100644 (file)
@@ -1,6 +1,9 @@
 <?php
+
+use yii\db\Query;
 use yii\helpers\Html;
 use yii\widgets\ActiveForm;
+use yii_app\records\TimetableFactModel;
 
 /* @var $this yii\web\View */
 /* @var $model yii_app\models\SumSalaryForm */
@@ -61,4 +64,4 @@ $this->title = 'Запуск экшенов для расчета ФОТ';
         <?php ActiveForm::end(); ?>
     </div>
 
-</div>
+    </div>