public function display()
 {
     $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
     if ($GLOBALS['current_user']->getPreference('currency')) {
         require_once 'modules/Currencies/Currency.php';
         $currency = new Currency();
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $this->chartDefName = $this->which_chart[0];
     //$chartDef = $this->chartDefs[$this->chartDefName];
     $chartDef = array('type' => 'code', 'id' => 'Chart_invoices_by_month', 'label' => 'Invoices by Month', 'chartUnits' => 'Invoice Size in $1K', 'chartType' => 'stacked group by chart', 'groupBy' => array('m', 'state_in_chart'), 'base_url' => array('module' => 'reg_invoices', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'), 'url_params' => array('state', 'date_closed'));
     require_once 'include/SugarCharts/SugarChartFactory.php';
     // Special chart config for RegInvoices
     $sugarChart = SugarChartFactory::getInstance('Jit', 'RegInvoices');
     $sugarChart->setProperties('', translate('LBL_FACT_SIZE', 'reg_invoices') . ' ' . $currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->is_currency = true;
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $sugarChart->getData($this->constructQuery());
     $this->sortData($sugarChart->data_set);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />';
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $current_user, $sugar_config;
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['lead_source_by_outcome'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->is_currency = true;
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $sugarChart->setProperties('', $subtitle, $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     if (count($this->lsbo_ids) > 0) {
         $sugarChart->url_params['assigned_user_id'] = array_values($this->lsbo_ids);
     }
     $sugarChart->getData($this->constuctQuery());
     $sugarChart->data_set = $sugarChart->sortData($sugarChart->data_set, 'lead_source', true, 'sales_stage', true, true);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $current_user, $sugar_config;
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     //fixing bug #27097: The opportunity list is not correct after drill-down
     //should send to url additional params: start range value and end range value
     $sugarChart->url_params = array('start_range_date_closed' => $this->pbss_date_start, 'end_range_date_closed' => $this->pbss_date_end);
     $sugarChart->group_by = $this->constructGroupBy();
     $sugarChart->setData($this->getChartData($this->constructQuery()));
     $sugarChart->is_currency = true;
     $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = BeanFactory::getBean('Currencies', $current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . format_number($sugarChart->getTotal(), 0, 0, array('convert' => true)) . $sugarChart->thousands_symbol;
     if ($this->pbss_chart_type == 'hbar') {
         $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal group by chart');
     } else {
         $sugarChart->setProperties($pipeline_total_string, $subtitle, 'funnel chart 3D');
     }
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
 public function testConfigChartFactory()
 {
     global $sugar_config;
     $sugar_config['chartEngine'] = 'Jit';
     $sugarChart = SugarChartFactory::getInstance();
     $name = get_class($sugarChart);
     $this->assertEquals('Jit', $name, 'Assert chart engine set in global sugar_config is correct');
 }
 /**
 * Don't override this method, since it does all the work of actually rendering the chart.
 *
 * @see DashletGenericChart::display()
 */
 public function display()
 {
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->setProperties('', $this->subtitle, 'funnel chart 3D');
     $sugarChart->base_url = array('module' => !empty($this->_seedName) ? $this->_seedName : 'Home', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     $sugarChart->group_by = $this->groupBy;
     if (empty($this->urlParams)) {
         $this->urlParams = $this->groupBy;
     }
     $sugarChart->url_params = $this->urlParams;
     $sugarChart->setData($this->getDataset());
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
 public function display($title, $subTitle, $xmlFile, $chartType, $width = '100%', $height = '480')
 {
     global $current_user, $sugar_config;
     require "modules/Charts/chartdefs.php";
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->is_currency = true;
     $currency_symbol = $sugar_config['default_currency_symbol'];
     $sugarChart->setProperties($title, $subTitle, $chartType);
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, $width, $height, false) . '</div>';
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $sugar_config, $current_user, $timedate;
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     $sugarChart->url_params = array('assigned_user_id' => $current_user->id);
     $sugarChart->group_by = $this->constructGroupBy();
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = BeanFactory::getBean('Currencies', $current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $sugarChart->is_currency = true;
     $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $query = $this->constructQuery();
     if ($this->mypbss_chart_type == 'hbar') {
         $dataset = $this->constructCEChartData($this->getChartData($query));
         $sugarChart->setData($dataset);
         $total = format_number($this->getHorizBarTotal($dataset), 0, 0, array('convert' => true));
         $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . $total . $sugarChart->thousands_symbol;
         $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal bar chart');
     } else {
         $sugarChart->setData($this->getChartData($query));
         $total = format_number($sugarChart->getTotal(), 0, 0, array('convert' => true));
         $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . $total . $sugarChart->thousands_symbol;
         $sugarChart->setProperties($pipeline_total_string, $subtitle, 'funnel chart 3D');
     }
     // Bug #53753 We have to add values for filter based on "Expected Close Date" field
     if (!empty($this->mypbss_date_start) && !empty($this->mypbss_date_end)) {
         $sugarChart->url_params['date_closed_advanced_range_choice'] = 'between';
         $sugarChart->url_params['start_range_date_closed_advanced'] = $timedate->to_display_date($this->mypbss_date_start, false);
         $sugarChart->url_params['end_range_date_closed_advanced'] = $timedate->to_display_date($this->mypbss_date_end, false);
     } elseif (!empty($this->mypbss_date_start)) {
         $sugarChart->url_params['date_closed_advanced_range_choice'] = 'greater_than';
         $sugarChart->url_params['range_date_closed_advanced'] = $timedate->to_display_date($this->mypbss_date_start, false);
     } elseif (!empty($this->mypbss_date_end)) {
         $sugarChart->url_params['date_closed_advanced_range_choice'] = 'less_than';
         $sugarChart->url_params['range_date_closed_advanced'] = $timedate->to_display_date($this->mypbss_date_end, false);
     }
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />' . $this->processAutoRefresh();
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     require 'modules/Charts/chartdefs.php';
     $chartDef = $chartDefs['opportunities_this_quarter'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->setProperties('', translate('LBL_NUMBER_OF_OPPS', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     // get gauge target
     $qry = "SELECT * from opportunities WHERE assigned_user_id = '" . $GLOBALS['current_user']->id . "' AND deleted=0";
     $result = $this->getSeedBean()->db->query($this->getSeedBean()->create_list_count_query($qry));
     $row = $this->getSeedBean()->db->fetchByAssoc($result);
     $sugarChart->setDisplayProperty('gaugeTarget', $row['c']);
     $sugarChart->getData($this->constructQuery());
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />' . $this->processAutoRefresh();
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $db, $app_list_strings;
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['my_modules_used_last_30_days'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->setProperties('', translate('LBL_MY_MODULES_USED_SIZE', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $result = $db->query($this->constructQuery());
     $dataset = array();
     while ($row = $db->fetchByAssoc($result)) {
         $dataset[translate($row['module_name'])] = $row['count'];
     }
     $sugarChart->setData($dataset);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />' . $this->processAutoRefresh();
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $db;
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['my_team_modules_used_last_30_days'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->forceHideDataGroupLink = true;
     $sugarChart->setProperties('', $chartDef['chartUnits'], $chartDef['chartType']);
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $result = $db->query($this->constructQuery());
     $dataset = array();
     while ($row = $db->fetchByAssoc($result)) {
         $dataset[] = array('user_name' => $row['user_name'], 'module_name' => $row['module_name'], 'total' => $row['count']);
     }
     $sugarChart->setData($dataset);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
     if ($GLOBALS['current_user']->getPreference('currency')) {
         $currency = BeanFactory::getBean('Currencies', $GLOBALS['current_user']->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['outcome_by_month'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->setProperties('', translate('LBL_OPP_SIZE', 'Charts') . ' ' . $currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $sugarChart->getData($this->constructQuery());
     $sugarChart->is_currency = true;
     $sugarChart->data_set = $sugarChart->sortData($sugarChart->data_set, 'm', false, 'sales_stage', true, true);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
Beispiel #12
0
 public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->sugarChart = SugarChartFactory::getInstance('Jit', 'Reports');
 }
 function build_report_chart()
 {
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $chart = SugarChartFactory::getInstance();
     /* echo $resources = $chart->getChartResources();
        echo $mySugarResources = $chart->getMySugarChartResources();*/
     $chart->setProperties('test', 'sub_test', 'funnel chart 3D');
     $chart->group_by = array('Type2', 'Assigned to1');
     $result = $this->db->query($this->build_report_query());
     $data = array();
     while ($row = $this->db->fetchByAssoc($result, false)) {
         $row['key'] = $row['Type2'];
         $row['value'] = $row['Type2'];
         $row['total'] = $row['count0'];
         $data[] = $row;
     }
     $chart->setData($data);
     $file = create_cache_directory('modules/AOR_Reports/Charts/') . 'chart.xml';
     $chart->saveXMLFile($file, $chart->generateXML());
     return $chart->display('test', $file, '100%', '480', false);
 }
function reportCriteriaWithResult(&$reporter, &$args)
{
    global $current_user, $theme;
    global $current_language;
    global $mod_strings, $app_strings, $timedate;
    global $sugar_config, $sugar_version;
    global $app_list_strings;
    $sort_by = '';
    $sort_dir = '';
    $summary_sort_by = '';
    $summary_sort_dir = '';
    $report_type = '';
    $smarty = new Sugar_Smarty();
    if (isset($reporter->report_def['order_by'][0]['name']) && isset($reporter->report_def['order_by'][0]['table_key'])) {
        $sort_by = $reporter->report_def['order_by'][0]['table_key'] . ":" . $reporter->report_def['order_by'][0]['name'];
    }
    // if
    if (isset($reporter->report_def['order_by'][0]['sort_dir'])) {
        $sort_dir = $reporter->report_def['order_by'][0]['sort_dir'];
    }
    // if
    if (!empty($reporter->report_def['summary_order_by'][0]['group_function']) && $reporter->report_def['summary_order_by'][0]['group_function'] == 'count') {
        $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . 'count';
    } else {
        if (isset($reporter->report_def['summary_order_by'][0]['name'])) {
            $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . $reporter->report_def['summary_order_by'][0]['name'];
            if (!empty($reporter->report_def['summary_order_by'][0]['group_function'])) {
                $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['group_function'];
            } else {
                if (!empty($reporter->report_def['summary_order_by'][0]['column__function'])) {
                    $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['column_function'];
                }
            }
            // else if
        }
    }
    // else if
    if (isset($reporter->report_def['summary_order_by'][0]['sort_dir'])) {
        $summary_sort_dir = $reporter->report_def['summary_order_by'][0]['sort_dir'];
    }
    // if
    if (isset($reporter->report_def['report_type'])) {
        $report_type = $reporter->report_def['report_type'];
    }
    // if
    $issetSaveResults = false;
    $isSaveResults = false;
    if (isset($args['save_result'])) {
        $issetSaveResults = true;
        $smarty->assign('save_report_as_str', $_REQUEST['save_report_as']);
        if ($args['save_result']) {
            $isSaveResults = true;
        }
        // if
    }
    // if
    $buttonDuplicateAsOrigin = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_ORIGINAL'] . '</a>';
    $buttonDuplicateAsSummation = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="summation";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_SUMMATON'] . '</a>';
    $buttonDuplicateAsDetail = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="summation_with_details";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_SUMMATION_DETAILS'] . '</a>';
    $buttonDuplicateAsMatrix = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="matrix";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_MATRIX'] . '</a>';
    $buttonDuplicateAsTabular = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="tabular";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_ROWS_AND_COLS'] . '</a>';
    if ($report_type == 'tabular') {
        $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'tabular\');" type="button" ' . ' value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '">', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsDetail, $buttonDuplicateAsMatrix);
    } else {
        if ($report_type == 'summary' && (!empty($reporter->report_def['display_columns']) && count($reporter->report_def['display_columns']) > 0)) {
            $canCovertToMatrix = 0;
            if (!empty($reporter->report_def['group_defs']) && count($reporter->report_def['group_defs']) <= 3) {
                $canCovertToMatrix = 1;
            }
            $duplicateButtons = array('<input type=button class="button" onclick="showDuplicateOverlib(this,\'summation_with_details\',' . $canCovertToMatrix . ');" type="button" ' . 'value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '"/>', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsTabular);
            if ($canCovertToMatrix) {
                $duplicateButtons[] = $buttonDuplicateAsMatrix;
            }
        } else {
            if ($report_type == 'summary' && !empty($reporter->report_def['layout_options'])) {
                $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'matrix\');" type="button" ' . ' value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '">', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsDetail, $buttonDuplicateAsTabular);
            } else {
                if ($report_type == 'summary') {
                    $canCovertToMatrix = 0;
                    if (!empty($reporter->report_def['group_defs']) && count($reporter->report_def['group_defs']) <= 3) {
                        $canCovertToMatrix = 1;
                    }
                    $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'summation\',' . $canCovertToMatrix . ');" type="button" ' . 'value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '" >', $buttonDuplicateAsOrigin, $buttonDuplicateAsDetail, $buttonDuplicateAsTabular);
                    if ($canCovertToMatrix) {
                        $duplicateButtons[] = $buttonDuplicateAsMatrix;
                    }
                }
            }
        }
    }
    $smarty->assign('duplicateButtons', $duplicateButtons);
    $smarty->assign('mod_strings', $mod_strings);
    $smarty->assign('app_strings', $app_strings);
    $smarty->assign('current_language', $current_language);
    $smarty->assign('sugar_config', $sugar_config);
    $smarty->assign('sugar_version', $sugar_version);
    $smarty->assign('issetSaveResults', $issetSaveResults);
    $smarty->assign('isSaveResults', $isSaveResults);
    $smarty->assign('report_type', $report_type);
    $smarty->assign('reportDetailView', getReportDetailViewString($reporter, $args));
    $smarty->assign('reporter', $reporter);
    $smarty->assign('reporterArgs', $args);
    $form_header = get_form_header($mod_strings['LBL_TITLE'] . ": " . $args['reporter']->saved_report->name, "", false);
    $smarty->assign('form_header', $form_header);
    $smarty->assign('report_offset', $reporter->report_offset);
    $smarty->assign('sort_by', $sort_by);
    $smarty->assign('sort_dir', $sort_dir);
    $smarty->assign('summary_sort_by', $summary_sort_by);
    $smarty->assign('summary_sort_dir', $summary_sort_dir);
    if (isset($_REQUEST['save_as']) && $_REQUEST['save_as'] == 'true') {
        $report_id = '';
    } else {
        if (isset($reporter->saved_report->id)) {
            $report_id = $reporter->saved_report->id;
        } elseif (!empty($_REQUEST['record'])) {
            $report_id = $_REQUEST['record'];
        } else {
            $report_id = '';
        }
    }
    // else
    $smarty->assign('report_id', $report_id);
    $smarty->assign('to_pdf', isset($_REQUEST['to_pdf']) ? $_REQUEST['to_pdf'] : "");
    $smarty->assign('to_csv', isset($_REQUEST['to_csv']) ? $_REQUEST['to_csv'] : "");
    $isAdmin = false;
    if ($current_user->is_admin) {
        $isAdmin = true;
    }
    // if
    $smarty->assign('isAdmin', $isAdmin);
    if ($isAdmin) {
        $smarty->assign('show_query', true);
        if (!empty($_REQUEST['show_query'])) {
            $smarty->assign('show_query_checked', true);
        }
        // if
    }
    // if
    $schedule_value = $app_strings['LBL_LINK_NONE'];
    if (isset($args['reporter']->saved_report->schedule_id) && $args['reporter']->saved_report->active == 1) {
        $schedule_value = $timedate->to_display_date_time($args['reporter']->saved_report->next_run);
    }
    // if
    $smarty->assign('schedule_value', $schedule_value);
    $current_favorites = $current_user->getPreference('favorites', 'Reports');
    if (!is_array($current_favorites)) {
        $current_favorites = array();
    }
    $report_ids_array = array_keys($current_favorites, $current_user->id);
    if (!is_array($report_ids_array)) {
        $report_ids_array = array();
    }
    // if
    if (isset($args['warnningMessage'])) {
        $smarty->assign('warnningMessage', $args['warnningMessage']);
    }
    // if
    if (!empty($args['reporter']->saved_report)) {
        $context = array("bean" => $args['reporter']->saved_report);
    } else {
        $context = array();
    }
    $report_edit_access = SugarACL::checkAccess('Reports', 'edit', $context);
    $smarty->assign('report_edit_access', $report_edit_access);
    $report_delete_access = SugarACL::checkAccess('Reports', 'delete', $context);
    $smarty->assign('report_delete_access', $report_delete_access);
    $report_export_access = SugarACL::checkAccess('Reports', 'export', $context);
    $smarty->assign('report_export_access', $report_export_access);
    //check to see if exporting is allowed
    $isExportAccess = hasExportAccess($args);
    $smarty->assign('report_export_as_csv_access', $isExportAccess);
    $smarty->assign('form_submit', empty($_REQUEST['form_submit']) ? false : $_REQUEST['form_submit']);
    $global_json = getJSONobj();
    global $ACLAllowedModules;
    $ACLAllowedModules = getACLAllowedModules();
    $smarty->assign('ACLAllowedModules', $global_json->encode(array_keys($ACLAllowedModules)));
    template_reports_filters($smarty, $args);
    $smarty->assign('reporter_report_type', $args['reporter']->report_type);
    $smarty->assign('current_user_id', $current_user->id);
    $smarty->assign('md5_current_user_id', md5($current_user->id));
    if (!hasRuntimeFilter($reporter)) {
        //$showRunReportButton = false;
        $smarty->assign('filterTabStyle', "display:none");
    } else {
        $smarty->assign('filterTabStyle', "display:''");
    }
    $smarty->assign('reportResultHeader', $mod_strings['LBL_REPORT_RESULTS']);
    $reportDetailsButtonTitle = $mod_strings['LBL_REPORT_HIDE_DETAILS'];
    $reportDetailsTableStyle = '';
    if (isset($args['reportCache'])) {
        $reportCache = $args['reportCache'];
        if (!empty($reportCache->report_options_array)) {
            if (array_key_exists("showDetails", $reportCache->report_options_array) && !$reportCache->report_options_array['showDetails']) {
                $reportDetailsButtonTitle = $mod_strings['LBL_REPORT_SHOW_DETAILS'];
                $reportDetailsTableStyle = 'display:none';
            }
        }
        // if
    }
    // if
    $smarty->assign('reportDetailsButtonTitle', $reportDetailsButtonTitle);
    $smarty->assign('reportDetailsTableStyle', $reportDetailsTableStyle);
    $smarty->assign('cache_path', sugar_cached(''));
    template_reports_request_vars_js($smarty, $reporter, $args);
    //custom chart code
    require_once 'include/SugarCharts/SugarChartFactory.php';
    $sugarChart = SugarChartFactory::getInstance();
    $resources = $sugarChart->getChartResources();
    $smarty->assign('chartResources', $resources);
    $smarty->assign('id', empty($_REQUEST['id']) ? false : $_REQUEST['id']);
    //Bug#51609: Create action buttons for report view. Previously existed in _reportCriteriaWithResult.tpl
    $buttons = array();
    $buttons[] = <<<EOD
        <input name="runReportButton" id="runReportButton" type="submit" class="button" accessKey="{$mod_strings['LBL_RUN_REPORT_BUTTON_KEY']}" title="{$mod_strings['LBL_RUN_BUTTON_TITLE']}"
               onclick="this.form.to_pdf.value='';this.form.to_csv.value='';this.form.save_report.value='';" value="{$mod_strings['LBL_RUN_REPORT_BUTTON_LABEL']}">
EOD;
    $reportName = $args['reporter']->saved_report->name;
    $shareButtonCode = "parent.SUGAR.App.bwc.shareRecord('Reports', '{$report_id}', '{$reportName}');";
    $buttons[] = <<<EOD
        <input type="button" class="button" name="shareReportButton" id="shareReportButton" accessKey="{$app_strings['LBL_SHARE_BUTTON_KEY']}" value="{$app_strings['LBL_SHARE_BUTTON_LABEL']}" title="{$app_strings['LBL_SHARE_BUTTON_TITLE']}"
               onclick="{$shareButtonCode}">
EOD;
    if ($report_edit_access) {
        $buttons[] = <<<EOD
            <input type="submit" class="button" name="editReportButton" id="editReportButton" accessKey="{$app_strings['LBL_EDIT_BUTTON_KEY']}" value="{$app_strings['LBL_EDIT_BUTTON_LABEL']}" title="{$app_strings['LBL_EDIT_BUTTON_TITLE']}"
               onclick="this.form.to_pdf.value='';this.form.to_csv.value='';this.form.action.value='ReportsWizard';">
EOD;
    }
    array_push($buttons, $duplicateButtons);
    if ($report_edit_access) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="scheduleReportButton" id="scheduleReportButton" value="{$mod_strings['LBL_REPORT_SCHEDULE_TITLE']}"
               onclick="schedulePOPUP()">
EOD;
    }
    if ($report_export_access) {
        //workaround for SP-1685, Need to clear bwcModel so change confirmation doesn't fire after making a PDF.
        $buttons[] = <<<EOD
        <input type="submit" class="button" name="printPDFButton" id="printPDFButton" accessKey="{$app_strings['LBL_VIEW_PDF_BUTTON_KEY']}" value="{$app_strings['LBL_VIEW_PDF_BUTTON_LABEL']}" title="{$app_strings['LBL_VIEW_PDF_BUTTON_TITLE']}"
               onclick="if (window&&window.parent&&window.parent.App&&window.parent.App.controller
               &&window.parent.App.controller.layout
               &&window.parent.App.controller.layout._components[0]
               &&window.parent.App.controller.layout._components[0].bwcModel
               &&window.parent.App.controller.layout._components[0].bwcModel.clear)
               {window.parent.App.controller.layout._components[0].bwcModel.clear({silent:true});this.form.save_report.value='';this.form.to_csv.value='';this.form.to_pdf.value='on'}">
EOD;
    }
    if ($isExportAccess) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="exportReportButton" id="exportReportButton" value="{$mod_strings['LBL_EXPORT']}" onclick="do_export();">
EOD;
    }
    if ($report_delete_access) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="deleteReportButton" id="deleteReportButton" accessKey="{$app_strings['LBL_DELETE_BUTTON_KEY']}" value="{$app_strings['LBL_DELETE_BUTTON_LABEL']}" title="{$app_strings['LBL_DELETE_BUTTON_TITLE']}"
               onclick="if (confirm(SUGAR.language.get('app_strings','NTC_DELETE_CONFIRMATION'))){this.form.to_pdf.value='';this.form.to_csv.value='';this.form.is_delete.value='1';this.form.action.value='ReportsWizard';this.form.submit();}">
EOD;
    }
    $smarty->assign('action_button', $buttons);
    $reportType = $reporter->report_def['report_type'] == 'tabular' ? $mod_strings['LBL_ROWS_AND_COLUMNS_REPORT'] : $mod_strings['LBL_SUMMATION_REPORT'];
    if (!empty($reporter->report_def['display_columns']) && !empty($reporter->report_def['group_defs'])) {
        $reportType = $mod_strings['LBL_SUMMATION_WITH_DETAILS'];
    }
    // if
    if (isset($reporter->report_def['layout_options'])) {
        $reportType = $mod_strings['LBL_MATRIX_REPORT'];
    }
    // if
    $fullTableList = $reporter->report_def['full_table_list'];
    $fullTableListArray = array();
    foreach ($fullTableList as $key => $value) {
        if (!isset($value['name'])) {
            if (!isset($fullTableListArray[$value['module']])) {
                $module_str = $value['module'];
                if (isset($app_list_strings['moduleList'][$module_str])) {
                    $module_str = $app_list_strings['moduleList'][$module_str];
                }
                $fullTableListArray[$value['module']] = $module_str;
            }
            // if
        } else {
            if (!isset($fullTableListArray[$value['name']])) {
                $fullTableListArray[$value['name']] = $value['name'];
            }
            // if
        }
        // else
    }
    // foreach
    $displayColumnsList = $reporter->report_def['display_columns'];
    $displayColumnsArray = array();
    foreach ($displayColumnsList as $key => $value) {
        $displayColumnsArray[] = $value['label'];
    }
    // foreach
    $group_defs = $reporter->report_def['group_defs'];
    $group_defsArray = array();
    if (!empty($group_defs)) {
        foreach ($group_defs as $key => $value) {
            $group_defsArray[] = $value['label'];
        }
        // foreach
    }
    // if
    $summary_columnsList = $reporter->report_def['summary_columns'];
    $summaryColumnsArray = array();
    if (!empty($summary_columnsList)) {
        foreach ($summary_columnsList as $key => $value) {
            $summaryColumnsArray[] = $value['label'];
        }
        // foreach
    }
    // if
    $summaryAndGroupDefData = "";
    if (!empty($group_defs) && !empty($summary_columnsList)) {
        $summaryAndGroupDefData = '<tr><td wrap="true">';
        $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_GROUP_BY'] . ": </b>" . implode(", ", $group_defsArray) . "</td><td wrap=\"true\">";
        $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_SUMMARY_COLUMNS'] . ": </b>" . implode(", ", $summaryColumnsArray) . "</td></tr>";
    } else {
        if (!empty($group_defs) || !empty($summary_columnsList)) {
            $summaryAndGroupDefData = '<tr><td wrap="true">';
            if (!empty($group_defs)) {
                $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_GROUP_BY'] . ": </b>" . implode(", ", $group_defsArray) . "</td><td wrap=\"true\">&nbsp;</td>";
            }
            // if
            if (!empty($summary_columnsList)) {
                $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_SUMMARY_COLUMNS'] . ": </b>" . implode(", ", $summaryColumnsArray) . "</td><td wrap=\"true\">&nbsp;</td>";
            }
            // if
        }
    }
    // else
    $reportFilters = "";
    if (isset($reporter->report_def['filters_def']) && !isset($reporter->report_def['filters_def']['Filter_1'][0])) {
        $reportFilters = " " . $mod_strings['LBL_NONE_STRING'];
    } else {
        $reportFilters = "<span id=\"filter_results\" valign=\"bottom\">&nbsp;<img id=\"filter_results_image\" src=\"" . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . "\" width=\"8px\" height=\"10px\" onclick=\"showFilterString();\"></span><span id=\"filter_results_text\" style=\"visibility:hidden;\"></span>";
    }
    // else
    $smarty->assign('reportFilters', $reportFilters);
    $smarty->assign('reportName', $reportName);
    $smarty->assign('reportType', $reportType);
    $smarty->assign('reportModuleList', implode(", ", $fullTableListArray));
    $smarty->assign('reportDisplayColumnsList', implode(", ", $displayColumnsArray));
    require_once 'modules/Teams/TeamSetManager.php';
    $smarty->assign('reportTeam', TeamSetManager::getCommaDelimitedTeams($args['reporter']->saved_report->team_set_id, $args['reporter']->saved_report->team_id, true));
    $smarty->assign('reportAssignedToName', $args['reporter']->saved_report->assigned_user_name);
    $smarty->assign('summaryAndGroupDefData', $summaryAndGroupDefData);
    // Set fiscal start date
    $admin = BeanFactory::getBean('Administration');
    $config = $admin->getConfigForModule('Forecasts', 'base');
    if (!empty($config['is_setup']) && !empty($config['timeperiod_start_date'])) {
        $smarty->assign("fiscalStartDate", $config['timeperiod_start_date']);
    }
    $smarty->assign('ENTROPY', mt_rand());
    echo $smarty->fetch("modules/Reports/templates/_reportCriteriaWithResult.tpl");
    reportResults($reporter, $args);
}
Beispiel #15
0
 /**
  * Return the SugarChart's object with all the values set and ready for display/consumption.
  *
  * @return JitReports|string
  */
 public function getSugarChart()
 {
     if ($this->canDrawChart()) {
         require_once 'include/SugarCharts/SugarChartFactory.php';
         /* @var $sugarChart JitReports */
         $sugarChart = SugarChartFactory::getInstance('', 'Reports');
         $sugarChart->setData($this->chartRows);
         global $do_thousands;
         $sugarChart->setProperties($this->chartTitle, '', $this->chartType, 'on', 'value', 'on', $do_thousands);
         if (isset($this->reporter->report_def['group_defs'])) {
             $groupByNames = array();
             foreach ($this->reporter->report_def['group_defs'] as $group_def) {
                 $groupByNames[] = $group_def['name'];
             }
             $sugarChart->group_by = $groupByNames;
         }
         return $sugarChart;
     } else {
         global $current_language;
         $mod_strings = return_module_language($current_language, 'Reports');
         return $mod_strings['LBL_NO_CHART_DRAWN_MESSAGE'];
     }
 }
 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);
     }
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $sugar_config, $current_user;
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     $sugarChart->url_params = array('assigned_user_id' => $current_user->id);
     $sugarChart->group_by = $this->constructGroupBy();
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $sugarChart->is_currency = true;
     $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $query = $this->constructQuery();
     $dataset = $this->constructCEChartData($this->getChartData($query));
     $sugarChart->setData($dataset);
     $total = format_number($this->getHorizBarTotal($dataset), 0, 0, array('convert' => true));
     $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . $total . $sugarChart->thousands_symbol;
     $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal bar chart');
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />' . $this->processAutoRefresh();
 }
 /**
  * Displays the javascript for the dashlet
  *
  * @return string javascript to use with this dashlet
  */
 public function displayScript()
 {
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     return $sugarChart->getDashletScript($this->id);
 }
Beispiel #19
0
 function campaign_response_roi($datay = array(), $targets = array(), $campaign_id, $cache_file_name = 'a_file', $refresh = false, $marketing_id = '', $is_dashlet = false, $dashlet_id = '')
 {
     global $app_strings, $mod_strings, $current_module_strings, $charset, $lang, $app_list_strings, $current_language, $sugar_config;
     $not_empty = false;
     if ($is_dashlet) {
         $mod_strings = return_module_language($current_language, 'Campaigns');
     }
     if (!file_exists($cache_file_name) || $refresh == true) {
         $GLOBALS['log']->debug("datay is:");
         $GLOBALS['log']->debug($datay);
         $GLOBALS['log']->debug("user_id is: ");
         $GLOBALS['log']->debug("cache_file_name is: {$cache_file_name}");
         $focus = new Campaign();
         $focus->retrieve($campaign_id);
         $opp_count = 0;
         $opp_query = "select count(*) opp_count,sum(" . db_convert("amount_usdollar", "IFNULL", array(0)) . ")  total_value";
         $opp_query .= " from opportunities";
         $opp_query .= " where campaign_id='{$campaign_id}'";
         $opp_query .= " and sales_stage='Prospecting'";
         $opp_query .= " and deleted=0";
         $opp_result = $focus->db->query($opp_query);
         $opp_data = $focus->db->fetchByAssoc($opp_result);
         //            if (empty($opp_data['opp_count'])) $opp_data['opp_count']=0;
         if (empty($opp_data['total_value'])) {
             $opp_data['total_value'] = 0;
         }
         //report query
         $opp_query1 = "select SUM(opp.amount) as revenue";
         $opp_query1 .= " from opportunities opp";
         $opp_query1 .= " right join campaigns camp on camp.id = opp.campaign_id";
         $opp_query1 .= " where opp.sales_stage = 'Closed Won'and camp.id='{$campaign_id}' and opp.deleted=0";
         $opp_query1 .= " group by camp.name";
         $opp_result1 = $focus->db->query($opp_query1);
         $opp_data1 = $focus->db->fetchByAssoc($opp_result1);
         //if (empty($opp_data1[]))
         if (empty($opp_data1['revenue'])) {
             $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = 0;
             unset($opp_data1['revenue']);
         } else {
             $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = $opp_data1['revenue'];
             unset($opp_data1['revenue']);
             $not_empty = true;
         }
         $camp_query1 = "select camp.name, SUM(camp.actual_cost) as investment,SUM(camp.budget) as budget,SUM(camp.expected_revenue) as expected_revenue";
         $camp_query1 .= " from campaigns camp";
         $camp_query1 .= " where camp.id='{$campaign_id}'";
         $camp_query1 .= " group by camp.name";
         $camp_result1 = $focus->db->query($camp_query1);
         $camp_data1 = $focus->db->fetchByAssoc($camp_result1);
         //query needs to be lowercase, but array keys need to be propercased, as these are used in
         //chart to display legend
         if (empty($camp_data1['investment'])) {
             $camp_data1['investment'] = 0;
         } else {
             $not_empty = true;
         }
         if (empty($camp_data1['budget'])) {
             $camp_data1['budget'] = 0;
         } else {
             $not_empty = true;
         }
         if (empty($camp_data1['expected_revenue'])) {
             $camp_data1['expected_revenue'] = 0;
         } else {
             $not_empty = true;
         }
         $opp_data1[$mod_strings['LBL_ROI_CHART_INVESTMENT']] = $camp_data1['investment'];
         $opp_data1[$mod_strings['LBL_ROI_CHART_BUDGET']] = $camp_data1['budget'];
         $opp_data1[$mod_strings['LBL_ROI_CHART_EXPECTED_REVENUE']] = $camp_data1['expected_revenue'];
         $query = "SELECT activity_type,target_type, count(*) hits ";
         $query .= " FROM campaign_log ";
         $query .= " WHERE campaign_id = '{$campaign_id}' AND archived=0 AND deleted=0";
         //if $marketing id is specified, then lets filter the chart by the value
         if (!empty($marketing_id)) {
             $query .= " AND marketing_id ='{$marketing_id}'";
         }
         $query .= " GROUP BY  activity_type, target_type";
         $query .= " ORDER BY  activity_type, target_type";
         $result = $focus->db->query($query);
         $leadSourceArr = array();
         $total = 0;
         $total_targeted = 0;
     }
     global $current_user;
     $user_id = $current_user->id;
     $width = '100%';
     $return = '';
     if (!$is_dashlet) {
         $return .= '<br />';
     }
     $currency_id = $focus->currency_id;
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if (!empty($currency_id)) {
         $cur = new Currency();
         $cur->retrieve($currency_id);
         $currency_symbol = $cur->symbol;
     }
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->is_currency = true;
     $sugarChart->currency_symbol = $currency_symbol;
     if ($not_empty) {
         $sugarChart->setData($opp_data1);
     } else {
         $sugarChart->setData(array());
     }
     $sugarChart->setProperties($mod_strings['LBL_CAMPAIGN_RETURN_ON_INVESTMENT'], $mod_strings['LBL_AMOUNT_IN'] . $currency_symbol, 'bar chart');
     if (!$is_dashlet) {
         $xmlFile = $sugarChart->getXMLFileName('roi_details_chart');
         $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
         $return .= $sugarChart->display('roi_details_chart', $xmlFile, $width, '480');
     } else {
         $xmlFile = $sugarChart->getXMLFileName($dashlet_id);
         $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
         $return .= $sugarChart->display($dashlet_id, $xmlFile, $width, '480');
     }
     return $return;
 }
 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);
 }
 public function testCustomFactory()
 {
     $sugarChart = SugarChartFactory::getInstance('CustomSugarChartFactory');
     $name = get_class($sugarChart);
     $this->assertEquals('CustomSugarChartFactory', $name, 'Assert engine is CustomSugarChartFactory');
 }
$cache_file_name_roi = $current_user->getUserPrivGuid() . "_campaign_response_by_roi_" . $dateFileNameSafe[0] . "_" . $dateFileNameSafe[1] . ".xml";
$chart = new campaign_charts();
//if marketing id has been selected, then set "latest_marketing_id" to the selected value
//latest marketing id will be passed in to filter the charts and subpanels
if (!empty($selected_marketing_id)) {
    $latest_marketing_id = $selected_marketing_id;
}
if (empty($latest_marketing_id) || $latest_marketing_id === 'all') {
    $smarty->assign("MY_CHART", $chart->campaign_response_by_activity_type($app_list_strings['campainglog_activity_type_dom'], $app_list_strings['campainglog_target_type_dom'], $focus->id, sugar_cached("xml/{$cache_file_name}"), true));
} else {
    $smarty->assign("MY_CHART", $chart->campaign_response_by_activity_type($app_list_strings['campainglog_activity_type_dom'], $app_list_strings['campainglog_target_type_dom'], $focus->id, sugar_cached("xml/{$cache_file_name}"), true, $latest_marketing_id));
}
//end chart
//custom chart code
require_once 'include/SugarCharts/SugarChartFactory.php';
$sugarChart = SugarChartFactory::getInstance();
$resources = $sugarChart->getChartResources();
$smarty->assign('chartResources', $resources);
echo $smarty->fetch('modules/Campaigns/TrackDetailView.tpl');
require_once 'include/SubPanel/SubPanelTiles.php';
$subpanel = new SubPanelTiles($focus, 'Campaigns');
//if latest marketing id is empty, or if it is set to 'all'', then do no filtering, otherwise filter..
//.. out the chart and subpanels by marketing id
if (empty($latest_marketing_id) || $latest_marketing_id === 'all') {
    //do nothing, no filtering is needed
} else {
    // assign selected marketing ID back to request in order to let ListView use it as a part of subpanel base URL
    $_GET['mkt_id'] = $latest_marketing_id;
    //get array of layout defs
    $layoutDefsArr = $subpanel->subpanel_definitions->layout_defs;
    //iterate through layout defs for processing of subpanels.  If a marketing Id is specified, then we need to...
Beispiel #23
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;
     }
 }
Beispiel #24
0
 /**
  * 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;
     }
 }
Beispiel #25
0
 /**
  * @todo the css is not fully inherited in this file
  */
 function retrievePage()
 {
     global $current_user, $sugar_version, $sugar_config, $sugar_flavor, $current_language;
     global $app_strings, $theme;
     // build dashlet cache file if not found
     if (!is_file(sugar_cached('dashlets/dashlets.php'))) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once sugar_cached('dashlets/dashlets.php');
     $pages = $current_user->getPreference('pages', $this->type);
     $dashlets = $current_user->getPreference('dashlets', $this->type);
     $count = 0;
     $dashletIds = array();
     // collect ids to pass to javascript
     $display = array();
     $predefinedChartsList = array('MyPipelineBySalesStageDashlet', 'OpportunitiesByLeadSourceDashlet', 'OpportunitiesByLeadSourceByOutcomeDashlet', 'OutcomeByMonthDashlet', 'PipelineBySalesStageDashlet', 'CampaignROIChartDashlet', 'MyOpportunitiesGaugeDashlet', 'MyForecastingChartDashlet', 'MyModulesUsedChartDashlet', 'MyTeamModulesUsedChartDashlet');
     $pageData = array();
     $chartsArray = array();
     $chartStyleCSS = SugarThemeRegistry::current()->getCSSURL('chart.css');
     $chartColorsXML = SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
     $chartStringsXML = $sugar_config['tmp_dir'] . 'chart_strings.' . $current_language . '.lang.xml';
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     if (!file_exists($chartStringsXML)) {
         $sugarChart->generateChartStrings($chartStringsXML);
     }
     $selectedPage = $_REQUEST['pageId'];
     $numCols = $pages[$selectedPage]['numColumns'];
     $trackerScript = '';
     $dashletScript = '';
     $trackerScriptArray = "<script>var trackerGridArray = [";
     $toggleHeaderToolsetScript = "";
     foreach ($pages[$selectedPage]['columns'] as $colNum => $column) {
         if ($colNum == $numCols) {
             break;
         }
         $display[$colNum]['width'] = $column['width'];
         $display[$colNum]['dashlets'] = array();
         foreach ($column['dashlets'] as $num => $id) {
             if (!empty($id) && isset($dashlets[$id]) && is_file($dashlets[$id]['fileLocation'])) {
                 // clint - fixes bug #20398
                 // only display dashlets that are from visibile modules and that the user has permission to list
                 $module = 'Home';
                 if (isset($dashletsFiles[$dashlets[$id]['className']]['module'])) {
                     $module = $dashletsFiles[$dashlets[$id]['className']]['module'];
                 }
                 $myDashlet = new MySugar($module);
                 if ($myDashlet->checkDashletDisplay()) {
                     require_once $dashlets[$id]['fileLocation'];
                     if ($dashlets[$id]['className'] == 'ChartsDashlet') {
                         $dashlet = new $dashlets[$id]['className']($id, $dashlets[$id]['reportId'], isset($dashlets[$id]['options']) ? $dashlets[$id]['options'] : array());
                         $chartsArray[$id] = array();
                         $chartsArray[$id]['id'] = $id;
                         $chartsArray[$id]['xmlFile'] = sugar_cached("xml/") . $dashlets[$id]['reportId'] . '_saved_chart.xml';
                         $chartsArray[$id]['width'] = '100%';
                         $chartsArray[$id]['height'] = '480';
                         $chartsArray[$id]['styleSheet'] = $chartStyleCSS;
                         $chartsArray[$id]['colorScheme'] = $chartColorsXML;
                         $chartsArray[$id]['langFile'] = $chartStringsXML;
                     } else {
                         $dashlet = new $dashlets[$id]['className']($id, isset($dashlets[$id]['options']) ? $dashlets[$id]['options'] : array());
                         if (in_array($dashlets[$id]['className'], $predefinedChartsList)) {
                             $chartsArray[$id] = array();
                             $chartsArray[$id]['id'] = $id;
                             $chartsArray[$id]['xmlFile'] = $sugarChart->getXMLFileName($id);
                             $chartsArray[$id]['width'] = '100%';
                             $chartsArray[$id]['height'] = '480';
                             $chartsArray[$id]['styleSheet'] = $chartStyleCSS;
                             $chartsArray[$id]['colorScheme'] = $chartColorsXML;
                             $chartsArray[$id]['langFile'] = $chartStringsXML;
                         }
                     }
                     // Need to add support to dynamically display/hide dashlets
                     // If it has a method 'shouldDisplay' we will call it to see if we should display it or not
                     if (method_exists($dashlet, 'shouldDisplay')) {
                         if (!$dashlet->shouldDisplay()) {
                             // This dashlet doesn't want us to show it, skip it.
                             continue;
                         }
                     }
                     array_push($dashletIds, $id);
                     try {
                         $dashlet->process();
                         $display[$colNum]['dashlets'][$id]['display'] = $dashlet->display();
                         $display[$colNum]['dashlets'][$id]['displayHeader'] = $dashlet->getHeader();
                         $display[$colNum]['dashlets'][$id]['displayFooter'] = $dashlet->getFooter();
                         if ($dashlet->hasScript) {
                             $dashletScript .= $dashlet->displayScript();
                         }
                         if ($dashlets[$id]['className'] == 'TrackerDashlet') {
                             $trackerScriptArray .= "'{$id}',";
                             $trackerScript = empty($trackerScript) ? $dashlet->displayScript() : $trackerScript;
                         }
                         $toggleHeaderToolsetScript .= "SUGAR.mySugar.attachToggleToolsetEvent('{$id}');";
                     } catch (Exception $ex) {
                         $display[$colNum]['dashlets'][$id]['display'] = $ex->getMessage();
                         $display[$colNum]['dashlets'][$id]['displayHeader'] = $dashlet->getHeader();
                         $display[$colNum]['dashlets'][$id]['displayFooter'] = $dashlet->getFooter();
                     }
                 }
             }
         }
     }
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('sugarVersion', $sugar_version);
     $sugar_smarty->assign('sugarFlavor', $sugar_flavor);
     $sugar_smarty->assign('currentLanguage', $GLOBALS['current_language']);
     $sugar_smarty->assign('serverUniqueKey', $GLOBALS['server_unique_key']);
     $sugar_smarty->assign('imagePath', $GLOBALS['image_path']);
     $sugar_smarty->assign('lblLnkHelp', $GLOBALS['app_strings']['LNK_HELP']);
     $sugar_smarty->assign('mod', return_module_language($current_language, 'Home'));
     $sugar_smarty->assign('app', $GLOBALS['app_strings']);
     $sugar_smarty->assign('maxCount', empty($sugar_config['max_dashboards']) ? 15 : $sugar_config['max_dashboards']);
     $sugar_smarty->assign('dashletCount', $count);
     $sugar_smarty->assign('columns', $display);
     $sugar_smarty->assign('selectedPage', $selectedPage);
     $sugar_smarty->assign('numCols', $numCols);
     if (!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) {
         $sugar_smarty->assign('lock_homepage', true);
     }
     $htmlOutput = $sugar_smarty->fetch('include/MySugar/tpls/retrievePage.tpl');
     $json = getJSONobj();
     $scriptResponse = array();
     $scriptResponse['dashletScript'] = $dashletScript;
     $scriptResponse['newDashletsToReg'] = $dashletIds;
     $scriptResponse['numCols'] = sizeof($pages[$selectedPage]['columns']);
     //custom chart code
     $scriptResponse['chartsArray'] = $chartsArray;
     $scriptResponse['trackerScript'] = $trackerScript . (strpos($trackerScriptArray, ',') ? substr($trackerScriptArray, 0, strlen($trackerScriptArray) - 1) . ']; </script>' : $trackerScriptArray . ']; </script>');
     $scriptResponse['toggleHeaderToolsetScript'] = "<script>" . $toggleHeaderToolsetScript . "</script>";
     $scriptOutput = 'var scriptResponse = ' . $json->encode($scriptResponse);
     return $json->encode(array('html' => $htmlOutput, 'script' => $scriptOutput));
 }