コード例 #1
0
function reportResults(&$reporter, &$args)
{
    ob_start();
    echo '<div id="report_results">';
    $do_chart = false;
    if ($reporter->report_type == 'summary' && !empty($reporter->report_def['summary_columns'])) {
        if ($reporter->show_columns && !empty($reporter->report_def['display_columns']) && !empty($reporter->report_def['group_defs'])) {
            template_summary_combo_view($reporter, $args);
            $do_chart = true;
        } else {
            if ($reporter->show_columns && !empty($reporter->report_def['display_columns']) && empty($reporter->report_def['group_defs'])) {
                template_detail_and_total_list_view($reporter, $args);
            } else {
                if (!empty($reporter->report_def['group_defs'])) {
                    template_summary_list_view($reporter, $args);
                    $do_chart = true;
                } else {
                    template_total_view($reporter, $args);
                }
            }
        }
        // else
    } else {
        if (!empty($reporter->report_def['display_columns'])) {
            template_list_view($reporter, $args);
        }
    }
    // else if
    $searchArray = array("'", "\r\n", "\n");
    $replaceArray = array("\\'", "", "");
    $filterStringForUI = str_replace($searchArray, $replaceArray, $reporter->createFilterStringForUI());
    echo "<script>var filterString='" . htmlspecialchars($filterStringForUI) . "';</script>";
    if ($reporter->report_def['chart_type'] == 'none') {
        $do_chart = false;
    }
    echo '</div>';
    $contents = ob_get_contents();
    ob_end_clean();
    if ($do_chart) {
        global $mod_strings;
        $reportChartButtonTitle = $mod_strings['LBL_REPORT_HIDE_CHART'];
        $reportChartDivStyle = "";
        if (isset($args['reportCache'])) {
            $reportCache = $args['reportCache'];
            if (!empty($reportCache->report_options_array)) {
                if (array_key_exists("showChart", $reportCache->report_options_array) && !$reportCache->report_options_array['showChart']) {
                    $reportChartButtonTitle = $mod_strings['LBL_REPORT_SHOW_CHART'];
                    $reportChartDivStyle = "display:none";
                }
            }
            // if
        }
        // if
        echo "<input class=\"button\" name=\"showHideChartButton\" id=\"showHideChartButton\" title=\"{$reportChartButtonTitle}\"\n\ttype=\"button\" value=\"{$reportChartButtonTitle}\" onclick=\"showHideChart();\"><br/><br/>";
        echo "<script>function showHideChart() {\n\tvar idObject = document.getElementById('record');\n\tvar id = '';\n\tif (idObject != null) {\n\t\tid = idObject.value;\n\t} // if\n\tvar chartId = document.getElementById(id + '_div');\n\tvar showHideChartButton = document.getElementById('showHideChartButton');\n\tif (chartId.style.display == \"none\") {\n\t\tsaveReportOptionsState('showChart', '1');\n\t\tchartId.style.display = \"\";\n\t\tshowHideChartButton.title = \"{$mod_strings['LBL_REPORT_HIDE_CHART']}\";\n\t\tshowHideChartButton.value = \"{$mod_strings['LBL_REPORT_HIDE_CHART']}\";\n\t\tloadCustomChartForReports();\n\t} else {\n\t\tchartId.style.display = 'none';\n\t\tsaveReportOptionsState('showChart', '0');\n\t\tshowHideChartButton.title = \"{$mod_strings['LBL_REPORT_SHOW_CHART']}\";\n\t\tshowHideChartButton.value = \"{$mod_strings['LBL_REPORT_SHOW_CHART']}\";\n\t} // else\n} </script>";
        if (isset($reporter->saved_report->id)) {
            $report_id = $reporter->saved_report->id;
        } elseif (!empty($_REQUEST['record'])) {
            $report_id = $_REQUEST['record'];
        } else {
            $report_id = 'unsavedReport';
        }
        echo "<div class='reportChartContainer' id='{$report_id}_div' style='{$reportChartDivStyle}'>";
        require_once "include/SugarCharts/ChartDisplay.php";
        $chartDisplay = new ChartDisplay();
        $chartDisplay->setReporter($reporter);
        echo "<div align='center'>" . $chartDisplay->legacyDisplay(null, false) . "</div>";
        echo "</div>";
    }
    // if
    print $contents;
}
コード例 #2
-1
 /**
  * Displays the dashlet
  *
  * @return string html to display dashlet
  */
 function display()
 {
     require_once "modules/Reports/Report.php";
     $chartReport = BeanFactory::getBean('Reports', $this->report_id, array('encode' => false, 'strict_retrieve' => true));
     if (!empty($chartReport)) {
         $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();
         ob_start();
         require_once "include/SugarCharts/ChartDisplay.php";
         $chartDisplay = new ChartDisplay();
         $chartDisplay->setReporter($reporter);
         echo $chartDisplay->legacyDisplay($this->id, true);
         $str = ob_get_contents();
         ob_end_clean();
         $xmlFile = $chartDisplay->get_cache_file_name($reporter);
         $html = parent::display() . "<div align='center'>" . $str . "</div>" . "<br />";
         // 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() . "<div align='center'>" . $str . "</div>" . "<br />";
         // return parent::display for title and such
     }
 }