From: Alexander Smirnov Date: Thu, 12 Sep 2024 09:49:08 +0000 (+0300) Subject: [ERP-187] Пересчёт персонала с нормой смен X-Git-Tag: 1.6~38^2~6 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=eae4d8b77421980b7ffc041d8b1988465685cb3a;p=erp24_rep%2Fyii-erp24%2F.git [ERP-187] Пересчёт персонала с нормой смен --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index eba80a07..e49cacbd 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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);