2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
43 var $forceHideDataGroupLink = false;
44 var $data_set = array();
45 var $display_data = array();
46 var $chart_properties = array();
47 var $chart_yAxis = array();
48 var $group_by = array();
49 var $super_set = array();
50 var $colors_list = array();
51 var $base_url = array();
52 var $url_params = array();
55 var $thousands_symbol;
57 var $supports_image_export = false;
58 var $print_html_legend_pdf = false;
59 var $image_export_type = "";
61 public function __construct() {
62 $this->db = &DBManagerFactory::getInstance();
63 $this->ss = new Sugar_Smarty();
65 $this->chart_yAxis['yMin'] = 0;
66 $this->chart_yAxis['yMax'] = 0;
69 if ($GLOBALS['current_user']->getPreference('currency')){
71 $currency = new Currency();
72 $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
73 $this->div = $currency->conversion_rate;
74 $this->currency_symbol = $currency->symbol;
77 $this->currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
79 $this->is_currency = false;
81 $this->image_export_type = (extension_loaded('gd') && function_exists('gd_info')) ? "png" : "jpg";
84 function getData($query){
85 $result = $this->db->query($query);
87 $row = $this->db->fetchByAssoc($result);
90 $this->data_set[] = $row;
91 $row = $this->db->fetchByAssoc($result);
95 function constructBaseURL(){
99 foreach ($this->base_url as $param => $value){
100 if ($numParams == 0){
101 $url .= $param . '=' . $value;
104 $url .= '&' .$param . '=' .$value;
112 function constructURL(){
113 $url = $this->constructBaseURL();
114 foreach ($this->url_params as $param => $value){
115 if ($param == 'assigned_user_id') $param = 'assigned_user_id[]';
116 if (is_array($value)){
117 foreach($value as $multiple){
118 $url .= '&' . $param . '=' . urlencode($multiple);
122 $url .= '&' . $param . '=' . urlencode($value);
128 function setData($dataSet){
129 $this->data_set = $dataSet;
132 function setProperties($title, $subtitle, $type, $legend='on', $labels='value', $print='on'){
133 $this->chart_properties['title'] = $title;
134 $this->chart_properties['subtitle'] = $subtitle;
135 $this->chart_properties['type'] = $type;
136 $this->chart_properties['legend'] = $legend;
137 $this->chart_properties['labels'] = $labels;
140 function setDisplayProperty($property, $value){
141 $this->chart_properties[$property] = $value;
144 function setColors($colors = array()){
145 $this->colors_list = $colors;
149 * returns the header for the constructed xml file for sugarcharts
152 * @return string $header XML header
154 function xmlHeader(){
155 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
156 $header .= "<sugarcharts version=\"1.0\">\n";
162 * returns the footer for the constructed xml file for sugarcharts
165 * @return string $footer XML footer
167 function xmlFooter(){
168 $footer = "</sugarcharts>";
174 * returns the properties tag for the constructed xml file for sugarcharts
177 * @return string $properties XML properties tag
179 function xmlProperties(){
180 // open the properties tag
181 $properties = $this->tab("<properties>",1);
183 // grab the property and value from the chart_properties variable
184 foreach ($this->chart_properties as $key => $value){
185 $properties .= $this->tab("<$key>$value</$key>",2);
188 if (!empty($this->colors_list)){
189 // open the colors tag
190 $properties .= $this->tab("<colors>",2);
191 foreach ($this->colors_list as $color){
192 $properties .= $this->tab("<color>$color</color>",3);
195 // close the colors tag
196 $properties .= $this->tab("</colors>",2);
199 // close the properties tag
200 $properties .= $this->tab("</properties>",1);
206 * returns the y-axis values for the chart
209 * @return string $yAxis XML yAxis tag
212 $this->chart_yAxis['yStep'] = '100';
213 $this->chart_yAxis['yLog'] = '1';
214 $this->chart_yAxis['yMax'] = $this->is_currency ? $this->convertCurrency($this->chart_yAxis['yMax']) : $this->chart_yAxis['yMax'];
215 $max = $this->chart_yAxis['yMax'];
216 $exp = ($max == 0) ? 1 : floor(log10($max));
217 $baseval = $max / pow(10, $exp);
219 // steps will be 10^n, 2*10^n, 5*10^n (where n >= 0)
220 if ($baseval > 0 && $baseval <= 1){
221 $step = 2 * pow(10, $exp-1);
223 else if ($baseval > 1 && $baseval <= 3){
224 $step = 5 * pow(10, $exp-1);
226 else if ($baseval > 3 && $baseval <= 6){
227 $step = 10 * pow(10, $exp-1);
229 else if ($baseval > 6 && $baseval <= 10){
230 $step = 20 * pow(10, $exp-1);
233 // edge cases for values less than 10
234 if ($max == 0 || $step < 1){
238 $this->chart_yAxis['yStep'] = $step;
240 // to compensate, the yMax should be at least one step above the max value
241 $this->chart_yAxis['yMax'] += $this->chart_yAxis['yStep'];
243 $yAxis = $this->tab("<yAxis>" ,1);
245 foreach ($this->chart_yAxis as $key => $value){
246 $yAxis .= $this->tab("<$key>$value</$key>", 2);
249 $yAxis .= $this->tab("</yAxis>" ,1);
255 * returns the total amount value for the group by field
257 * @param group by field
258 * @return int $total total value
260 function calculateTotal($group_by){
263 for($i =0; $i < count($this->data_set); $i++){
264 if ($this->data_set[$i][$this->group_by[0]] == $group_by){
265 $total += $this->data_set[$i]['total'];
272 * returns text with tabs appended before it
274 * @param string $str input string
275 * int $depth number of times to tab
276 * @return string with tabs appended before it
278 function tab($str, $depth){
279 return str_repeat("\t", $depth) . $str . "\n";
283 * returns xml data format
286 * @return string with xml data format
288 function processData(){
291 $group_by = $this->group_by[0];
292 if (isset($this->group_by[1])){
293 $drill_down = $this->group_by[1];
298 for($i =0; $i < count($this->data_set); $i++){
299 if ($this->data_set[$i][$group_by] != $prev_group_by){
300 $prev_group_by = $this->data_set[$i][$group_by];
301 $data[$this->data_set[$i][$group_by]] = array();
304 $data[$this->data_set[$i][$group_by]][] = $this->data_set[$i];
306 // push new item onto legend items list
307 if (isset($drill_down)){
308 if (!in_array($this->data_set[$i][$drill_down], $this->super_set)){
309 $this->super_set[] = $this->data_set[$i][$drill_down];
317 function processDataGroup($tablevel, $title, $value, $label, $link){
318 $link = $this->forceHideDataGroupLink ? '' : $link;
319 $data = $this->tab('<group>',$tablevel);
320 $data .= $this->tab('<title>' . $title . '</title>',$tablevel+1);
321 $data .= $this->tab('<value>' . $value . '</value>',$tablevel+1);
322 $data .= $this->tab('<label>' . $label . '</label>',$tablevel+1);
323 $data .= $this->tab('<link>' . $link . '</link>',$tablevel+1);
324 $data .= $this->tab('</group>',$tablevel);
328 function calculateGroupByTotal($dataset){
331 foreach ($dataset as $key => $value){
338 function calculateSingleBarMax($dataset){
340 foreach ($dataset as $value){
350 * returns correct yAxis min/max
352 * @param value to check
353 * @return yAxis min and max
355 function checkYAxis($value){
356 if ($value < $this->chart_yAxis['yMin']){
357 $this->chart_yAxis['yMin'] = $value;
359 else if ($value > $this->chart_yAxis['yMax']){
360 $this->chart_yAxis['yMax'] = $value;
365 function convertCurrency($to_convert){
368 $decimals = $locale->getPrecision();
369 $amount = ($this->div == 1) ? $to_convert : round($to_convert * $this->div,$decimals);
374 function formatNumber($number, $decimals= null, $decimal_point= null, $thousands_sep= null){
376 if(is_null($decimals)) {
377 $decimals = $locale->getPrecision();
379 $seps = get_number_seperators();
380 $thousands_sep = $seps[0];
381 $decimal_point = $seps[1];
382 return number_format($number, $decimals, $decimal_point, $thousands_sep);
386 $new_data = $this->processData();
388 foreach ($new_data as $groupByKey => $value){
389 $total += $this->calculateTotal($groupByKey);
395 function xmlDataForGroupByChart(){
397 foreach ($this->data_set as $key => $value){
398 $amount = $this->is_currency ? $this->convertCurrency($this->calculateGroupByTotal($value)) : $this->calculateGroupByTotal($value);
399 $label = $this->is_currency ? ($this->currency_symbol . $this->formatNumber($amount)) : $amount;
401 $data .= $this->tab('<group>',2);
402 $data .= $this->tab('<title>' . $key . '</title>',3);
403 $data .= $this->tab('<value>' . $amount . '</value>',3);
404 $data .= $this->tab('<label>' . $label . '</label>',3);
405 $data .= $this->tab('<link></link>',3);
406 $data .= $this->tab('<subgroups>',3);
408 foreach ($value as $k => $v){
409 $amount = $this->is_currency ? $this->convertCurrency($v) : $v;
410 $label = $this->is_currency ? ($this->currency_symbol . $this->formatNumber($amount)) : $amount;
412 $data .= $this->tab('<group>',4);
413 $data .= $this->tab('<title>' . $k . '</title>',5);
414 $data .= $this->tab('<value>' . $amount . '</value>',5);
415 $data .= $this->tab('<label>' . $label . '</label>',5);
416 $data .= $this->tab('<link></link>',5);
417 $data .= $this->tab('</group>',4);
418 $this->checkYAxis($v);
420 $data .= $this->tab('</subgroups>',3);
421 $data .= $this->tab('</group>',2);
427 function xmlDataForGaugeChart(){
429 $gaugePosition = $this->data_set[0]['num'];
430 $this->chart_yAxis['yMax'] = $this->chart_properties['gaugeTarget'];
431 $this->chart_yAxis['yStep'] = 1;
432 $data .= $this->processDataGroup(2, 'GaugePosition', $gaugePosition, $gaugePosition, '');
433 $data .= $this->processGauge($gaugePosition, $this->chart_properties['gaugeTarget']);
438 function xmlDataBarChart(){
440 $max = $this->calculateSingleBarMax($this->data_set);
441 $this->checkYAxis($max);
443 if (isset($this->group_by[0])){
444 $group_by = $this->group_by[0];
445 if (isset($this->group_by[1])){
446 $drill_down = $this->group_by[1];
450 foreach ($this->data_set as $key => $value){
451 if ($this->is_currency){
452 $value = $this->convertCurrency($value);
453 $label = $this->currency_symbol;
454 $label .= $this->formatNumber($value);
455 $label .= $this->thousands_symbol;
461 $data .= $this->tab('<group>', 2);
462 $data .= $this->tab('<title>' . $key . '</title>', 3);
463 $data .= $this->tab('<value>' . $value . '</value>', 3);
464 $data .= $this->tab('<label>' . $label . '</label>', 3);
465 if (isset($drill_down) && $drill_down){
466 if ($this->group_by[0] == 'm'){
467 $additional_param = '&date_closed_advanced=' . urlencode($key);
470 $additional_param = "&" . $this->group_by[0] . "=" . urlencode($key);
472 $url = $this->constructURL() . $additional_param;
474 $data .= $this->tab('<link>' . $url . '</link>', 3);
476 $data .= $this->tab('<subgroups>', 3);
477 $data .= $this->tab('</subgroups>', 3);
478 $data .= $this->tab('</group>', 2);
483 function xmlDataGenericChart(){
485 $group_by = $this->group_by[0];
486 if (isset($this->group_by[1])){
487 $drill_down = $this->group_by[1];
489 $new_data = $this->processData();
491 foreach ($new_data as $groupByKey => $value){
492 $total = $this->calculateTotal($groupByKey);
493 $this->checkYAxis($total);
495 if ($this->group_by[0] == 'm'){
496 $additional_param = '&date_closed_advanced=' . urlencode($groupByKey);
499 $paramValue = (isset($value[0]['key']) && $value[0]['key'] != '') ? $value[0]['key'] : $groupByKey;
500 $paramValue = (isset($value[0][$this->group_by[0]."_dom_option"]) && $value[0][$this->group_by[0]."_dom_option"] != '') ? $value[0][$this->group_by[0]."_dom_option"] : $paramValue;
501 $additional_param = "&" . $this->group_by[0] . "=" . urlencode($paramValue);
504 $url = $this->constructURL() . $additional_param;
506 $amount = $this->is_currency ? $this->convertCurrency($total) : $total;
507 $label = $this->is_currency ? ($this->currency_symbol . $this->formatNumber($amount) . 'K') : $amount;
509 $data .= $this->tab('<group>',2);
510 $data .= $this->tab('<title>' . $groupByKey . '</title>',3);
511 $data .= $this->tab('<value>' . $amount . '</value>',3);
512 $data .= $this->tab('<label>' . $label . '</label>',3);
513 $data .= $this->tab('<link>' . $url . '</link>',3);
515 $data .= $this->tab('<subgroups>',3);
516 $processed = array();
518 if (isset($drill_down) && $drill_down != ''){
519 for($i =0; $i < count($new_data[$groupByKey]); $i++){
520 if ($new_data[$groupByKey][$i][$group_by] == $groupByKey){
521 if ($drill_down == 'user_name'){
522 $drill_down_param = '&assigned_user_id[]=' . urlencode($new_data[$groupByKey][$i]['assigned_user_id']);
524 else if ($drill_down == 'm'){
525 $drill_down_param = '&date_closed_advanced=' . urlencode($new_data[$groupByKey][$i][$drill_down]);
528 $paramValue = (isset($new_data[$groupByKey][$i][$drill_down."_dom_option"]) && $new_data[$groupByKey][$i][$drill_down."_dom_option"] != '') ? $new_data[$groupByKey][$i][$drill_down."_dom_option"] : $new_data[$groupByKey][$i][$drill_down];
529 $drill_down_param = '&' . $drill_down . '=' . urlencode($paramValue);
532 if($this->is_currency) {
533 $sub_amount = $this->formatNumber($this->convertCurrency($new_data[$groupByKey][$i]['total']));
534 $sub_amount_formatted = $this->currency_symbol . $sub_amount . 'K';
535 //bug: 38877 - do not format the amount for the value as it breaks the chart
536 $sub_amount = $this->convertCurrency($new_data[$groupByKey][$i]['total']);
538 $sub_amount = $new_data[$groupByKey][$i]['total'];
539 $sub_amount_formatted = $sub_amount;
542 $data .= $this->processDataGroup(4, $new_data[$groupByKey][$i][$drill_down],
544 $sub_amount_formatted,
545 $url . $drill_down_param );
546 array_push($processed, $new_data[$groupByKey][$i][$drill_down]);
549 $not_processed = array_diff($this->super_set, $processed);
550 foreach ($not_processed as $title){
551 $data .= $this->processDataGroup(4, $title, 'NULL', '', $url);
555 $data .= $this->tab('</subgroups>',3);
556 $data .= $this->tab('</group>',2);
562 * returns a name for the XML File
564 * @param string $file_id - unique id to make part of the file name
566 public static function getXMLFileName(
570 global $sugar_config, $current_user;
572 $filename = $sugar_config['tmp_dir']. $current_user->id . '_' . $file_id . '.xml';
574 if ( !is_dir(dirname($filename)) )
575 create_cache_directory(str_ireplace($GLOBALS['sugar_config']['cache_dir'],"",$filename));
580 public function processXmlData(){
583 if ($this->chart_properties['type'] == 'group by chart'){
584 $data .= $this->xmlDataForGroupByChart();
586 else if ($this->chart_properties['type'] == 'bar chart' || $this->chart_properties['type'] == 'horizontal bar chart'){
587 $data .= $this->xmlDataBarChart();
590 $data .= $this->xmlDataGenericChart();
597 $data = $this->tab('<data>',1);
598 $data .= $this->processXmlData();
599 $data .= $this->tab('</data>',1);
605 * function to generate XML and return it
608 * @return string $xmlContents with xml information
610 function generateXML($xmlDataName = false){
611 $xmlContents = $this->xmlHeader();
612 $xmlContents .= $this->xmlProperties();
613 $xmlContents .= $this->xmlData();
614 $xmlContents .= $this->xmlYAxis();
615 $xmlContents .= $this->xmlFooter();
621 * function to save XML contents into a file
623 * @param string $xmlFilename location of the xml file
624 * string $xmlContents contents of the xml file
625 * @return string boolean denoting whether save has failed
627 function saveXMLFile($xmlFilename,$xmlContents) {
631 $xmlContents = chr(255).chr(254).mb_convert_encoding($xmlContents, 'UTF-16LE', 'UTF-8');
634 if (!$fh = sugar_fopen($xmlFilename, 'w')) {
635 $GLOBALS['log']->debug("Cannot open file ($xmlFilename)");
639 // write the contents to the file
640 if (fwrite($fh,$xmlContents) === FALSE) {
641 $GLOBALS['log']->debug("Cannot write to file ($xmlFilename)");
645 $GLOBALS['log']->debug("Success, wrote ($xmlContents) to file ($xmlFilename)");
652 * generates xml file for Flash charts to use for internationalized instances
654 * @param string $xmlFile location of the XML file to write to
657 function generateChartStrings($xmlFile){
658 global $current_language, $app_list_strings;
660 $chartStringsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
661 $chartStringsXML .= "<sugarlanguage version=\"1.0\">\n";
662 $chartStringsXML .= $this->tab("<charts>",1);
664 if (empty($app_list_strings)) {
665 //set module and application string arrays based upon selected language
666 $app_list_strings = return_app_list_strings_language($current_language);
669 // retrieve the strings defined at include/language/en_us.lang.php
670 foreach ($app_list_strings['chart_strings'] as $tag => $chart_string){
671 $chartStringsXML .= $this->tab("<$tag>$chart_string</$tag>",2);
674 $chartStringsXML .= $this->tab("</charts>",1);
675 $chartStringsXML .= "</sugarlanguage>\n";
677 $this->saveXMLFile($xmlFile, $chartStringsXML);
681 * wrapper function to return the html code containing the chart in a div
683 * @param string $name name of the div
684 * string $xmlFile location of the XML file
685 * string $style optional additional styles for the div
686 * @return string returns the html code through smarty
688 function display($name, $xmlFile, $width='320', $height='480', $resize=false){
691 // generate strings for chart if it does not exist
692 global $current_language, $theme, $sugar_config,$app_strings;
694 $this->app_strings = $app_strings;
695 $this->chartStringsXML = $GLOBALS['sugar_config']['tmp_dir'].'chart_strings.' . $current_language .'.lang.xml';
696 if (!file_exists($this->chartStringsXML)){
697 $this->generateChartStrings($this->chartStringsXML);
701 return $templateFile;
704 function getDashletScript($id,$xmlFile="") {
706 $xmlFile = (!$xmlFile) ? $sugar_config['tmp_dir']. $current_user->id . '_' . $this->id . '.xml' : $xmlFile;
707 $chartStringsXML = $GLOBALS['sugar_config']['tmp_dir'].'chart_strings.' . $current_language .'.lang.xml';
709 $this->ss->assign('chartName', $id);
710 $this->ss->assign('chartXMLFile', $xmlFile);
711 $this->ss->assign('chartStyleCSS', SugarThemeRegistry::current()->getCSSURL('chart.css'));
712 $this->ss->assign('chartColorsXML', SugarThemeRegistry::current()->getImageURL('sugarColors.xml'));
713 $this->ss->assign('chartLangFile', $GLOBALS['sugar_config']['tmp_dir'].'chart_strings.' . $GLOBALS['current_language'] .'.lang.xml');
716 return $templateFile;
721 This function is used for localize all the characters in the Chart. And it can also sort all the dom_values by the sequence defined in the dom, but this may produce a lot of extra empty data in the xml file, when the chart is sorted by two key cols.
722 If the data quantity is large, it maybe a little slow.
723 * @param array $data_set The data get from database
724 string $keycolname1 We will sort by this key first
725 bool $translate1 Whether to trabslate the first column
726 string $keycolname1 We will sort by this key secondly, and it can be null, then it will only sort by the first column.
727 bool $translate1 Whether to trabslate the second column
728 bool $ifsort2 Whether to sort by the second column or just translate the second column.
729 * @return The sorted and translated data.
731 function sortData($data_set, $keycolname1=null, $translate1=false, $keycolname2=null, $translate2=false, $ifsort2=false) {
732 //You can set whether the columns need to be translated or sorted. It the column needn't to be translated, the sorting must be done in SQL, this function will not do the sorting.
733 global $app_list_strings;
734 $sortby1[] = array();
735 foreach ($data_set as $row) {
736 $sortby1[] = $row[$keycolname1];
738 $sortby1 = array_unique($sortby1);
739 //The data is from the database, the sorting should be done in the sql. So I will not do the sort here.
741 $temp_sortby1 = array();
742 foreach(array_keys($app_list_strings[$keycolname1.'_dom']) as $sortby1_value) {
743 if(in_array($sortby1_value, $sortby1)) {
744 $temp_sortby1[] = $sortby1_value;
747 $sortby1 = $temp_sortby1;
750 //if(isset($sortby1[0]) && $sortby1[0]=='') unset($sortby1[0]);//the beginning of lead_source_dom is blank.
751 if(isset($sortby1[0]) && $sortby1[0]==array()) unset($sortby1[0]);//the beginning of month after search is blank.
753 if($ifsort2==false) $sortby2=array(0);
755 if($keycolname2!=null) {
757 foreach ($data_set as $row) {
758 $sortby2[] = $row[$keycolname2];
760 //The data is from the database, the sorting should be done in the sql. So I will not do the sort here.
761 $sortby2 = array_unique($sortby2);
763 $temp_sortby2 = array();
764 foreach(array_keys($app_list_strings[$keycolname2.'_dom']) as $sortby2_value) {
765 if(in_array($sortby2_value, $sortby2)) {
766 $temp_sortby2[] = $sortby2_value;
769 $sortby2 = $temp_sortby2;
775 foreach($sortby1 as $sort1) {
776 foreach($sortby2 as $sort2) {
778 foreach($data_set as $key => $value){
779 if($value[$keycolname1] == $sort1 && (!$ifsort2 || $value[$keycolname2]== $sort2)) {
781 $value[$keycolname1.'_dom_option'] = $value[$keycolname1];
782 $value[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$value[$keycolname1]];
785 $value[$keycolname2.'_dom_option'] = $value[$keycolname2];
786 $value[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$value[$keycolname2]];
788 array_push($data, $value);
789 unset($data_set[$key]);
793 if($ifsort2 && $a==0) {//Add 0 for sorting by the second column, if the first row doesn't have a certain col, it will fill the column with 0.
798 $val[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$sort1];
799 $val[$keycolname1.'_dom_option'] = $sort1;
802 $val[$keycolname1] = $sort1;
805 $val[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$sort2];
806 $val[$keycolname2.'_dom_option'] = $sort2;
808 elseif($keycolname2!=null) {
809 $val[$keycolname2] = $sort2;
811 array_push($data, $val);
818 function getChartResources() {
824 function getMySugarChartResources() {
826 $mySugarRources = "";
827 return $mySugarResources;
831 * wrapper function to return chart array after any additional processing
833 * @param array $chartsArray array of chart config items that need processing
834 * @return array $chartArray after it has been process
836 function chartArray($chartsArray) {