コード例 #1
0
 /**
  * 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;
     }
 }
コード例 #2
0
 function display()
 {
     global $locale;
     //add chart
     if (isset($_REQUEST['id']) && $_REQUEST['id'] != false) {
         $this->bean->is_saved_report = true;
     }
     // fixing bug #47260: Print PDF Reports
     // if chart_type is 'none' we don't need do add any image to pdf
     if ($this->bean->chart_type != 'none') {
         $chartDisplay = new ChartDisplay();
         $xmlFile = $chartDisplay->get_cache_file_name($this->bean);
         $sugarChart = SugarChartFactory::getInstance();
         if ($sugarChart->supports_image_export) {
             $imageFile = $sugarChart->get_image_cache_file_name($xmlFile, "." . $sugarChart->image_export_type);
             // check image size is not '0'
             if (file_exists($imageFile) && getimagesize($imageFile) > 0) {
                 $this->AddPage();
                 list($width, $height) = getimagesize($imageFile);
                 $imageWidthAsUnits = $this->pixelsToUnits($width);
                 $imageHeightAsUnits = $this->pixelsToUnits($height);
                 $dimensions = $this->getPageDimensions();
                 $pageWidth = $dimensions['wk'];
                 $pageHeight = $dimensions['hk'];
                 $marginTop = $dimensions['tm'];
                 $marginBottom = $dimensions['bm'];
                 $marginLeft = $dimensions['lm'];
                 $marginRight = $dimensions['rm'];
                 $freeWidth = 0.9 * ($pageWidth - $marginLeft - $marginRight);
                 $freeHeight = 0.9 * ($pageHeight - $marginTop - $marginBottom);
                 $rate = min($freeHeight / $imageHeightAsUnits, $freeWidth / $imageWidthAsUnits, 2);
                 $imageWidth = floor($rate * $imageWidthAsUnits);
                 $imageHeight = floor($rate * $imageHeightAsUnits);
                 $leftOffset = $this->GetX() + ($pageWidth - $marginLeft - $marginRight - $imageWidth) / 2;
                 $topOffset = $this->GetY();
                 $this->Image($imageFile, $leftOffset, $topOffset, $imageWidth, $imageHeight, "", "", "N", false, 300, "", false, false, 0, true);
                 if ($sugarChart->print_html_legend_pdf) {
                     $legend = $sugarChart->buildHTMLLegend($xmlFile);
                     $this->writeHTML($legend, true, false, false, true, "");
                 }
             }
         }
     }
     //Create new page
     $this->AddPage();
     $this->bean->run_summary_query();
     $item = array();
     $header_row = $this->bean->get_summary_header_row();
     $count = 0;
     if (count($this->bean->report_def['summary_columns']) == 0) {
         $item[$count][''] = '';
         $count++;
     }
     if (count($this->bean->report_def['summary_columns']) > 0) {
         while ($row = $this->bean->get_summary_next_row()) {
             for ($i = 0; $i < sizeof($header_row); $i++) {
                 $label = $header_row[$i];
                 $value = '';
                 if (isset($row['cells'][$i])) {
                     $value = $row['cells'][$i];
                 }
                 $item[$count][$label] = $value;
             }
             $count++;
         }
     }
     $this->writeCellTable($item, $this->options);
     $this->Ln1();
     $this->bean->clear_results();
     if ($this->bean->has_summary_columns()) {
         $this->bean->run_total_query();
     }
     $total_header_row = $this->bean->get_total_header_row();
     $total_row = $this->bean->get_summary_total_row();
     $item = array();
     $count = 0;
     for ($j = 0; $j < sizeof($total_header_row); $j++) {
         $label = $total_header_row[$j];
         $item[$count][$label] = $total_row['cells'][$j];
     }
     $this->writeCellTable($item, $this->options);
 }
コード例 #3
0
 function display()
 {
     global $app_list_strings, $locale;
     //add chart
     if (isset($_REQUEST['id']) && $_REQUEST['id'] != false) {
         $this->bean->is_saved_report = true;
     }
     // fixing bug #47260: Print PDF Reports
     // if chart_type is 'none' we don't need do add any image to pdf
     if ($this->bean->chart_type != 'none') {
         $chartDisplay = new ChartDisplay();
         $xmlFile = $chartDisplay->get_cache_file_name($this->bean);
         $sugarChart = SugarChartFactory::getInstance();
         if ($sugarChart->supports_image_export) {
             $imageFile = $sugarChart->get_image_cache_file_name($xmlFile, "." . $sugarChart->image_export_type);
             // check image size is not '0'
             if (file_exists($imageFile) && getimagesize($imageFile) > 0) {
                 $this->AddPage();
                 list($width, $height) = getimagesize($imageFile);
                 $imageWidthAsUnits = $this->pixelsToUnits($width);
                 $imageHeightAsUnits = $this->pixelsToUnits($height);
                 $dimensions = $this->getPageDimensions();
                 $pageWidth = $dimensions['wk'];
                 $pageHeight = $dimensions['hk'];
                 $marginTop = $dimensions['tm'];
                 $marginBottom = $dimensions['bm'];
                 $marginLeft = $dimensions['lm'];
                 $marginRight = $dimensions['rm'];
                 $freeWidth = 0.9 * ($pageWidth - $marginLeft - $marginRight);
                 $freeHeight = 0.9 * ($pageHeight - $marginTop - $marginBottom);
                 $rate = min($freeHeight / $imageHeightAsUnits, $freeWidth / $imageWidthAsUnits, 2);
                 $imageWidth = floor($rate * $imageWidthAsUnits);
                 $imageHeight = floor($rate * $imageHeightAsUnits);
                 $leftOffset = $this->GetX() + ($freeWidth - $imageWidth) / 2;
                 $topOffset = $this->GetY() + ($freeHeight - $imageHeight) / 2;
                 $this->Image($imageFile, $leftOffset, $topOffset, $imageWidth, $imageHeight, "", "", "N", false, 300, "", false, false, 0, true);
                 if ($sugarChart->print_html_legend_pdf) {
                     $legend = $sugarChart->buildHTMLLegend($xmlFile);
                     $this->writeHTML($legend, true, false, false, true, "");
                 }
             }
         }
     }
     $this->AddPage();
     //disable paging so we get all results in one pass
     $this->bean->enable_paging = false;
     $cols = count($this->bean->report_def['display_columns']);
     $this->bean->run_summary_combo_query();
     $header_row = $this->bean->get_summary_header_row();
     $columns_row = $this->bean->get_header_row();
     // build options for the writeHTMLTable from options for the writeCellTable
     $options = array('header' => array("tr" => array("bgcolor" => $this->options['header']['fill'], "color" => $this->options['header']['textColor']), "td" => array()), 'evencolor' => $this->options['evencolor'], 'oddcolor' => $this->options['oddcolor']);
     while (($row = $this->bean->get_summary_next_row()) != 0) {
         $item = array();
         $count = 0;
         for ($i = 0; $i < $this->bean->current_summary_row_count; $i++) {
             if (($column_row = $this->bean->get_next_row('result', 'display_columns', false, true)) != 0) {
                 for ($j = 0; $j < sizeof($columns_row); $j++) {
                     $label = $columns_row[$j];
                     $item[$count][$label] = $column_row['cells'][$j];
                 }
                 $count++;
             } else {
                 break;
             }
         }
         $this->writeHTMLTable($item, false, $options);
         $this->Ln1();
         $item = array();
         $count = 0;
         for ($j = 0; $j < sizeof($row['cells']); $j++) {
             if ($j > count($header_row) - 1) {
                 $label = $header_row[count($header_row) - 1];
             } else {
                 $label = $header_row[$j];
             }
             if (preg_match('/type.*=.*checkbox/Uis', $row['cells'][$j])) {
                 // parse out checkboxes
                 if (preg_match('/checked/i', $row['cells'][$j])) {
                     $row['cells'][$j] = $app_list_strings['dom_switch_bool']['on'];
                 } else {
                     $row['cells'][$j] = $app_list_strings['dom_switch_bool']['off'];
                 }
             }
             $value = $row['cells'][$j];
             $item[$count][$label] = $value;
         }
         $this->writeHTMLTable($item, false, $options);
         $this->Ln1();
     }
     $this->bean->clear_results();
     if ($this->bean->has_summary_columns()) {
         $this->bean->run_total_query();
         $total_row = $this->bean->get_summary_total_row();
         $item = array();
         $count = 0;
         for ($j = 0; $j < sizeof($header_row); $j++) {
             $label = $header_row[$j];
             $value = $total_row['cells'][$j];
             $item[$count][$label] = $value;
         }
         $this->writeHTMLTable($item, false, $options);
     }
 }