From: Alexander Smirnov Date: Thu, 26 Sep 2024 14:14:33 +0000 (+0300) Subject: [ERP-187] Подсчёт персонала с производственным календарём 002 X-Git-Tag: 1.6~38^2~3 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5ad2f41fd98b4e8e2d06b8b33074b3fd8809e7ca;p=erp24_rep%2Fyii-erp24%2F.git [ERP-187] Подсчёт персонала с производственным календарём 002 --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 313f2c41..1c63ef67 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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; }