isAttributeChanged('emailSendingInterval') || $entity->isAttributeChanged('emailSendingTime') || $entity->isAttributeChanged('emailSendingSettingWeekdays') || $entity->isAttributeChanged('emailSendingSettingDay') ) { /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('emailSendingLastDateSent', null); } if ( $entity->getType() === Report::TYPE_GRID && ($entity->has('chartOneColumns') || $entity->has('chartOneY2Columns')) ) { $this->handleChartDataList($entity); } if ($entity->getInternalClassName()) { $entity->set('isInternal', true); if ($entity->isAttributeChanged('internalClassName')) { $this->internalReportHelper->populateFields($entity); } } if ( $entity->getType() !== Report::TYPE_GRID || count($entity->getGroupBy()) < 2 ) { $entity->setTableMode(Data::TABLE_MODE_REGULAR); } if ( $entity->getType() === Report::TYPE_GRID && count($entity->getGroupBy()) >= 2 && $entity->getTableMode() === Data::TABLE_MODE_NORMALIZED ) { $entity->setChartType(null); } } private function handleChartDataList(Report $entity): void { $groupBy = $entity->getGroupBy(); if (count($groupBy) > 1) { /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('chartDataList', null); return; } $chartDataList = $entity->get('chartDataList'); $y = null; $y2 = null; if ($chartDataList && count($chartDataList) !== 0) { $y = $chartDataList[0]->columnList ?? null; $y2 = $chartDataList[0]->y2ColumnList ?? null; } $newY = $y ?? null; $newY2 = $y2 ?? null; if ($entity->has('chartOneColumns')) { $newY = $entity->get('chartOneColumns') ?? []; if ($newY && count($newY) === 0) { $newY = null; } } if ($entity->has('chartOneY2Columns')) { $newY2 = $entity->get('chartOneY2Columns') ?? []; if ($newY2 && count($newY2) === 0) { $newY2 = null; } } $chartType = $entity->getChartType(); if (!in_array($chartType, ['BarVertical', 'BarHorizontal', 'Line'])) { $newY2 = null; } if ($newY || $newY2) { $newItem = (object) [ 'columnList' => $newY, 'y2ColumnList' => $newY2, ]; $entity->set('chartDataList', [$newItem]); return; } /** @noinspection PhpRedundantOptionalArgumentInspection */ $entity->set('chartDataList', null); } }