* copy an existing report with the current navigation status * * @NoAdminRequired * @param int $reportId * @param $chartoptions * @param $dataoptions * @param $filteroptions * @return int * @throws Exception */
(int $reportId, $chartoptions, $dataoptions, $filteroptions, $tableoptions, ?string $chart = null)
| 261 | * @throws Exception |
| 262 | */ |
| 263 | public function createCopy(int $reportId, $chartoptions, $dataoptions, $filteroptions, $tableoptions, ?string $chart = null) { |
| 264 | |
| 265 | $template = $this->ReportMapper->readOwn($reportId); |
| 266 | $newId = $this->ReportMapper->create(// TRANSLATORS Noun |
| 267 | $template['name'] . ' - ' . $this->l10n->t('copy'), $template['subheader'], $template['parent'], $template['type'], $template['dataset'], $template['link'], $template['visualization'], $template['chart'], $template['dimension1'], $template['dimension2'], $template['value']); |
| 268 | $this->ReportMapper->updateOptions($newId, $chartoptions, $dataoptions, $filteroptions, $tableoptions, $chart); |
| 269 | |
| 270 | // Copy thresholds from original report to the new copy |
| 271 | $sourceThresholds = $this->ThresholdMapper->getThresholdsByReport($reportId); |
| 272 | foreach ($sourceThresholds as $threshold) { |
| 273 | $this->ThresholdMapper->create($newId, $threshold['dimension'], $threshold['value'], // This is 'target' aliased as 'value' in the query |
| 274 | $threshold['option'], $threshold['severity'], $threshold['coloring'], $threshold['source_column_ref'] ?? null); |
| 275 | } |
| 276 | |
| 277 | return $newId; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * create new report |
nothing calls this directly
no test coverage detected