report_id = $report_id;
$this->loadLanguage('ChartsDashlet'); // load the language strings here
parent::Dashlet($id); // call parent constructor
$this->searchFields = array();
$this->isConfigurable = true; // dashlet is configurable
$this->hasScript = true; // dashlet has javascript attached to it
}
/**
* Displays the dashlet
*
* @return string html to display dashlet
*/
function display() {
require_once("modules/Reports/Report.php");
// ini_set('display_errors', 'false');
$chartReport = new SavedReport();
$chartExists = $chartReport->retrieve($this->report_id, false);
if (!is_null($chartExists)){
$title = getReportNameTranslation($chartReport->name);
$this->title = $title;
$reporter = new Report($chartReport->content);
$reporter->is_saved_report = true;
$reporter->saved_report_id = $chartReport->id;
$reporter->get_total_header_row();
$reporter->run_chart_queries();
require_once("modules/Reports/templates/templates_chart.php");
ob_start();
template_chart($reporter, true, true, $this->id);
$str = ob_get_contents();
ob_end_clean();
$xmlFile = get_cache_file_name($reporter);
$html = parent::display() . "
" . $str . "
" . "
"; // return parent::display for title and such
$ss = new Sugar_Smarty();
$ss->assign('chartName', $this->id);
$ss->assign('chartXMLFile', $xmlFile);
$script = $ss->fetch('modules/Home/Dashlets/ChartsDashlet/ChartsDashletScript.tpl');
$json = getJSONobj();
return parent::display() . "" . $str . "
" . "
"; // return parent::display for title and such
}
}
/**
* Displays the javascript for the dashlet
*
* @return string javascript to use with this dashlet
*/
function displayScript() {
require_once("modules/Reports/Report.php");
$chartReport = new SavedReport();
$chartExists = $chartReport->retrieve($this->report_id, false);
if (!is_null($chartExists)){
$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;
$xmlFile = get_cache_file_name($reporter);
$str = $sugarChart->getDashletScript($this->id,$xmlFile);
return $str;
}
}
/**
* Displays the configuration form for the dashlet
*
* @return string html to display form
*/
function displayOptions() {
}
/**
* called to filter out $_REQUEST object when the user submits the configure dropdown
*
* @param array $req $_REQUEST
* @return array filtered options to save
*/
function saveOptions($req) {
}
function setConfigureIcon(){
if($this->isConfigurable)
$additionalTitle = ' |