/** * Retrieves a saved report and chart data, given a report ID in the args * * @param $api ServiceBase The API class of the request * @param $args array The arguments array passed in from the API * @return array */ public function getSavedReportChartById($api, $args) { require_once "include/SugarCharts/ChartDisplay.php"; $chartReport = $this->getSavedReportById($args['reportId']); if (isset($args['filter_id']) && $args['filter_id'] !== 'all_records') { $chartReport->content = $this->updateFilterDef($chartReport->content, $args['filter_id']); } if (!empty($chartReport)) { if (!$chartReport->ACLAccess('view')) { throw new SugarApiExceptionNotAuthorized('No access to view this report'); } $returnData = array(); $this->title = $chartReport->name; require_once "modules/Reports/Report.php"; $reporter = new Report($chartReport->content); $reporter->saved_report_id = $chartReport->id; if ($reporter && !$reporter->has_summary_columns()) { return ''; } // build report data since it isn't a SugarBean $reportData = array(); $reportData['name'] = $reporter->name; $reportData['id'] = $reporter->saved_report_id; $reportData['summary_columns'] = $reporter->report_def['summary_columns']; $reportData['group_defs'] = $reporter->report_def['group_defs']; // add reportData to returnData $returnData['reportData'] = $reportData; $chartDisplay = new ChartDisplay(); $chartDisplay->setReporter($reporter); $chart = $chartDisplay->getSugarChart(); $json = json_decode($chart->buildJson($chart->generateXML())); $returnData['chartData'] = $json; return $returnData; } }
/** * Method for displaying the old legacy way that was done. * * @param $id ID use for the guid * @param bool $is_dashlet Are we displaying a dashlet or not * @return JitReports|string Return the HTML */ public function legacyDisplay($id, $is_dashlet = false) { if ($is_dashlet) { $width = '100%'; $height = '480'; $guid = $id; } else { $width = '100%'; $height = '480'; $guid = $this->reporter->saved_report_id; } // Bug #57213 : Reports with data series removed render charts inconsistently if ($this->reporter && !$this->reporter->has_summary_columns()) { global $current_language; $mod_strings = return_module_language($current_language, 'Reports'); return $mod_strings['LBL_CANNOT_DISPLAY_CHART_MESSAGE']; } $sugarChart = $this->getSugarChart(); if (is_object($sugarChart)) { $sugarChart->reporter = $this->reporter; $xmlFile = $this->get_cache_file_name(); $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML()); return $sugarChart->display($guid, $xmlFile, $width, $height); } return $sugarChart; }
/** * Displays the javascript for the dashlet * * @return string javascript to use with this dashlet */ function displayScript() { require_once "modules/Reports/Report.php"; require_once "include/SugarCharts/ChartDisplay.php"; $chartReport = BeanFactory::getBean('Reports', $this->report_id, array("encode" => false)); if (!empty($chartReport)) { $this->title = $chartReport->name; require_once "modules/Reports/templates/templates_chart.php"; require_once 'include/SugarCharts/SugarChartFactory.php'; $sugarChart = SugarChartFactory::getInstance(); $reporter = new Report($chartReport->content); $reporter->is_saved_report = true; $reporter->saved_report_id = $chartReport->id; // Bug #57213 : Reports with data series removed render charts inconsistently if ($reporter && !$reporter->has_summary_columns()) { return ''; } $chartDisplay = new ChartDisplay(); $xmlFile = $chartDisplay->get_cache_file_name($reporter); $str = $sugarChart->getDashletScript($this->id, $xmlFile); return $str; } }