function display() { global $app_list_strings, $current_language, $sugar_config, $currentModule, $action, $current_user, $theme, $timedate, $image_path; $this->loadLanguage('MyLeadsByStatusDashlet', 'custom/modules/Charts/Dashlets/'); $returnStr = ''; $user_dateFormat = $timedate->get_date_format(); $current_module_strings = return_module_language($current_language, 'Charts'); if (isset($_REQUEST['myleadschart_refresh'])) { $refresh = $_REQUEST['myleadschart_refresh']; } else { $refresh = false; } $date_start = $this->myleadschart_date_start; $date_end = $this->myleadschart_date_end; // cn: format date_start|end to user's preferred $dateStartDisplay = strftime($timedate->get_user_date_format(), strtotime($date_start)); $dateEndDisplay = strftime($timedate->get_user_date_format(), strtotime($date_end)); $seps = array("-", "/"); $dates = array($date_start, $date_end); $dateFileNameSafe = str_replace($seps, "_", $dates); //$dateXml[0] = $timedate->swap_formats($date_start, $user_dateFormat, $timedate->dbDayFormat); //$dateXml[1] = $timedate->swap_formats($date_end, $user_dateFormat, $timedate->dbDayFormat); $dateXml[0] = $date_start; $dateXml[1] = $date_end; $datax = array(); $selected_datax = array(); //get list of lead status keys to display $user_status = $this->myleadschart_status; $tempx = $user_status; //set $datax using selected lead status keys if (count($tempx) > 0) { foreach ($tempx as $key) { $datax[$key] = $app_list_strings['lead_status_dom'][$key]; array_push($selected_datax, $key); } } else { $datax = $app_list_strings['lead_status_dom']; $selected_datax = array_keys($app_list_strings['lead_status_dom']); } $GLOBALS['log']->debug("datax is:"); $GLOBALS['log']->debug($datax); $ids = array($current_user->id); //create unique prefix based on selected users for image files $id_hash = '1'; if (isset($ids)) { sort($ids); $id_hash = crc32(implode('', $ids)); if ($id_hash < 0) { $id_hash = $id_hash * -1; } } $GLOBALS['log']->debug("ids is:"); $GLOBALS['log']->debug($ids); $id_md5 = substr(md5($current_user->id), 0, 9); $seps = array("-", "/"); $dates = array($dateStartDisplay, $dateEndDisplay); $dateFileNameSafe = str_replace($seps, "_", $dates); $cache_file_name = $current_user->getUserPrivGuid() . "_" . $theme . "_my_status_" . $dateFileNameSafe[0] . "_" . $dateFileNameSafe[1] . ".xml"; $GLOBALS['log']->debug("cache file name is: {$cache_file_name}"); if (file_exists($sugar_config['tmp_dir'] . $cache_file_name)) { $file_date = date($timedate->get_date_format() . " " . $timedate->get_time_format(), filemtime($sugar_config['tmp_dir'] . $cache_file_name)); } else { $file_date = ''; } require_once 'include/Sugar_Smarty.php'; require_once 'include/SugarCharts/SugarChart.php'; $sugar_smarty = new Sugar_Smarty(); $charts = array(); $sugarChart = new SugarChart(); $sugarChart->base_url = array('module' => 'Leads', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'); $sugarChart->url_params = array('assigned_user_id' => $current_user->id); $sugarChart->group_by = $this->constructGroupBy(); $query = $this->constructQuery($datax, $dateXml[0], $dateXml[1], $ids, $sugar_config['tmp_dir'] . $cache_file_name, $refresh, 'hBarS', $current_module_strings); $total = format_number($sugarChart->getTotal(), 0, 0); $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts'); $subtitle = translate('LBL_LEAD_COUNT', 'Charts'); $dataset = $this->constructCEChartData($this->getChartData($query)); $sugarChart->setData($dataset); $total = format_number($this->getHorizBarTotal($dataset), 0, 0); $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $total . $sugarChart->thousands_symbol; $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal bar chart'); $xmlFile = $sugar_config['tmp_dir'] . $current_user->id . '_' . $this->id . '.xml'; $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML()); $returnStr .= $sugarChart->display($this->id, $xmlFile, '100%', '480', false); return $this->getTitle('') . '<div align="center">' . $returnStr . '</div><br />'; }
/** * @see DashletGenericChart::display() */ public function display() { global $current_user, $sugar_config; require_once 'include/SugarCharts/SugarChart.php'; $sugarChart = new SugarChart(); $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'); $sugarChart->url_params = array(); $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 = 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'); $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . format_number($sugarChart->getTotal(), 0, 0, array('convert' => true)) . $sugarChart->thousands_symbol; $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal group by 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 />'; }