]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-187] Пересчёт персонала с нормой смен
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 12 Sep 2024 09:49:08 +0000 (12:49 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 12 Sep 2024 09:49:08 +0000 (12:49 +0300)
erp24/services/MotivationService.php

index eba80a076d8ffd27d22035eac6ec842ff17b4caf..e49cacbd00e06586773df5748e8a42cd50be3064 100644 (file)
@@ -5,6 +5,7 @@ namespace yii_app\services;
 use Yii;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use yii\helpers\Json;
+use yii_app\helpers\HtmlHelper;
 use yii_app\records\EmployeePayment;
 use yii_app\records\AdminGroup;
 use yii_app\records\ExportImportTable;
@@ -756,12 +757,8 @@ class MotivationService
                 $timetableFactModel = TimetableFactModel::find()->select(['COUNT(*) as total', 'admin_group_id'])->where(['store_id' => $store_id, 'admin_id' => $admin_id])
                     ->andWhere(['between', 'date_shift', $monthStart, $monthEnd])->groupBy(['admin_group_id'])->asArray()->one();
 
-                $norma = 15;
-                if ($timetableFactModel['admin_group_id'] != AdminGroup::GROUP_WORKERS) {
-                    $timetablePlan = Timetable::find()->select(['COUNT(*) as total'])->where(['store_id' => $store_id, 'admin_id' => $admin_id, 'tabel' => 0, 'slot_type_id' => Timetable::TIMESLOT_WORK])
-                        ->andWhere(['between', 'date', $monthStart, $monthEnd])->asArray()->one();
-                    $norma = $timetablePlan['total'];
-                }
+                $norma = $timetableFactModel['admin_group_id'] == AdminGroup::GROUP_ADMINISTRATORS ?
+                    HtmlHelper::getWorkDays($month, $year) : 15;
                 $result += $norma == 0 ? 0 : $timetableFactModel['total'] / $norma;
             }
             self::saveOrUpdateMotivationValue($motivation->id, 'fact', MotivationCostsItem::CODE_EMPLOYEES_QUANTITY, 'float', $result);