]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-187] Подсчёт персонала с производственным календарём 002
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 26 Sep 2024 14:14:33 +0000 (17:14 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 26 Sep 2024 14:14:33 +0000 (17:14 +0300)
erp24/services/MotivationService.php

index 313f2c414e66afe135028c9334220fb64ffe0ee1..1c63ef67051c1e8a4b562af79d8c605090df3ce1 100644 (file)
@@ -6,6 +6,7 @@ use Yii;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use yii\helpers\Json;
 use yii_app\helpers\HtmlHelper;
+use yii_app\records\Admin;
 use yii_app\records\EmployeePayment;
 use yii_app\records\AdminGroup;
 use yii_app\records\ExportImportTable;
@@ -770,10 +771,11 @@ class MotivationService
 
             $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();
-
-                $norma = $timetableFactModel['admin_group_id'] == AdminGroup::GROUP_ADMINISTRATORS ?
+                $timetableFactModel = TimetableFactModel::find()->select(['COUNT(*) as total', 'admin_group_id', 'admin_id'])->where(['store_id' => $store_id, 'admin_id' => $admin_id])
+                    ->andWhere(['between', 'date', $monthStart, $monthEnd])->groupBy(['admin_group_id', 'admin_id'])->asArray()->one();
+                $admin = Admin::findOne($timetableFactModel['admin_id']);
+                $work_rate = $admin && $admin->work_rate > 1 ? $admin->work_rate : 1;
+                $norma = $timetableFactModel['admin_group_id'] == AdminGroup::GROUP_ADMINISTRATORS && $work_rate == 1 ?
                     HtmlHelper::getWorkDays($month, $year) : 15;
                 $result += $norma == 0 ? 0 : $timetableFactModel['total'] / $norma;
             }