function template_module_defs_js()
{
    global $report_modules, $current_language;
    $mod_strings = return_module_language($current_language, 'Reports');
    $currentModule = 'Reports';
    $global_json = getJSONobj();
    global $ACLAllowedModules;
    $ACLAllowedModules = getACLAllowedModules(true);
    echo 'ACLAllowedModules = ' . $global_json->encode(array_keys($ACLAllowedModules)) . ";\n";
    ?>
var module_defs = new Object();
default_summary_columns = ['count'];
<?php 
    // build table datastructure in javascript objs
    global $mod_strings;
    global $current_language;
    global $app_list_strings;
    global $currentModule;
    $relationships = array();
    foreach ($report_modules as $module_name => $bean_name) {
        if ($module_name == 'Reports') {
            continue;
        }
        global $beanFiles;
        if (empty($beanFiles)) {
            include 'include/modules.php';
        }
        //we need singular name here;
        $bean_name = get_singular_bean_name($bean_name);
        require_once $beanFiles[$bean_name];
        $module = new $bean_name();
        $mod_strings = return_module_language($current_language, $module_name);
        $currentModule = $module_name;
        ?>

var rel_defs = new Object();
var link_defs_<?php 
        echo $module_name;
        ?>
 = new Object();
<?php 
        $linked_fields = $module->get_linked_fields();
        foreach ($linked_fields as $linked_field) {
            $module->load_relationship($linked_field['name']);
            $field = $linked_field['name'];
            if (empty($module->{$field}) || isset($linked_field['reportable']) && $linked_field['reportable'] == false || empty($linked_field['relationship'])) {
                continue;
            }
            if (empty($relationships[$linked_field['relationship']])) {
                $relationships[$linked_field['relationship']] = $module->{$field}->relationship;
            }
            $vname = '';
            // To figure out the label, we will start with the least specific and move in from there
            if (!empty($linked_field['vname'])) {
                $vname = $linked_field['vname'];
            }
            // In order to get the correct label, we have to track down and see if there is a name field and use that for the label.
            foreach ($module->field_defs as $idx => $fieldDef) {
                if (!isset($fieldDef['link'])) {
                    continue;
                }
                if ($fieldDef['link'] != $linked_field['name']) {
                    continue;
                }
                if ($fieldDef['type'] == 'relate' && $fieldDef['rname'] == 'name' && !empty($fieldDef['vname'])) {
                    // This is the name field for the link field
                    $vname = $fieldDef['vname'];
                    break;
                }
            }
            if (!empty($vname)) {
                $linked_field['label'] = translate($vname);
                // Try the label from this side of the module
                if ($linked_field['label'] == $vname) {
                    $linked_field['label'] = translate($vname, $module->module_dir);
                }
                // How about from the other side
                if ($linked_field['label'] == $vname) {
                    $linked_field['label'] = translate($vname, $module->{$field}->getRelatedModuleName());
                }
            } else {
                $linked_field['label'] = $linked_field['name'];
            }
            $linked_field['label'] = preg_replace('/:$/', '', $linked_field['label']);
            $linked_field['label'] = addslashes($linked_field['label']);
            echo "link_defs_{$module_name}[ '{$linked_field['name']}' ] = " . json_encode(array('name' => $linked_field['name'], 'relationship_name' => $linked_field['relationship'], 'bean_is_lhs' => $module->{$field}->getSide() == REL_LHS, 'link_type' => $module->{$field}->getType(), 'label' => $linked_field['label'], 'module' => $module->{$field}->getRelatedModuleName())) . ";\n";
        }
        ?>
var field_defs_<?php 
        echo $module_name;
        ?>
 = new Object();
<?php 
        if (is_array($module->field_defs)) {
            $module->ACLFilterFieldList($module->field_defs, array("owner_override" => true));
            ksort($module->field_defs);
            if (isset($module->field_defs['team_set_id'])) {
                $module->field_defs['team_set_id']['type'] = 'team_set_id';
            }
            foreach ($module->field_defs as $field_def) {
                if (isset($field_def['reportable']) && $field_def['reportable'] == false) {
                    continue;
                }
                //Allowed fields array with non-db-source
                $allowed_fields_array = array('full_name', 'default_primary_team');
                if (isset($field_def['source']) && ($field_def['source'] == 'non-db' && empty($field_def['ext2'])) && $field_def['name'] != 'full_name') {
                    continue;
                }
                if ($field_def['type'] == 'relate' && !empty($field_def['custom_type'])) {
                    $field_def['type'] = $field_def['custom_type'];
                }
                if ($field_def['type'] == 'relate' && empty($field_def['ext2']) || $field_def['type'] == 'assigned_user_name' || $field_def['type'] == 'foreign_key') {
                    continue;
                }
                if ($field_def['type'] == 'encrypt') {
                    continue;
                }
                ?>
field_defs_<?php 
                echo $module_name;
                ?>
[ "<?php 
                echo $field_def['name'];
                ?>
"] = <?php 
                $js_defs_array = array();
                foreach ($field_def as $field_name => $field_value) {
                    if (empty($field_name) || empty($field_value) || $field_name == 'comment' || $field_name == "formula" || $field_name == "dependency" || $field_name == "visibility_grid" || is_array($field_value)) {
                        continue;
                    }
                    if ($field_name != "options" || $field_name != "name") {
                        if ($field_name == "vname") {
                            $field_value = translate($field_value);
                            if (substr($field_value, -1) == ':') {
                                $field_value = substr($field_value, 0, -1);
                            }
                        }
                        if ($field_name != 'default' && $field_name != 'default_value') {
                            array_push($js_defs_array, "\"{$field_name}\":" . json_encode($field_value));
                        }
                    }
                }
                if ($field_def['name'] == 'team_set_id' && $module_name != 'Teams') {
                    array_push($js_defs_array, "invisible:true");
                }
                echo "{" . implode(",", $js_defs_array) . "};";
                if (isset($field_def['options'])) {
                    ?>
var option_arr_<?php 
                    echo $module_name;
                    ?>
 = new Array();

<?php 
                    $options_array = array();
                    $trans_options = translate($field_def['options']);
                    if (!is_array($trans_options)) {
                        $trans_options = array();
                    }
                    foreach ($trans_options as $option_value => $option_text) {
                        $option_text = translate($option_text);
                        // BEGIN HALF-FIX
                        if (is_array($option_text)) {
                            $option_text = 'Array';
                        }
                        $option_text = html_entity_decode($option_text, ENT_QUOTES);
                        $option_text = addslashes($option_text);
                        $option_value = html_entity_decode($option_value, ENT_QUOTES);
                        $option_value = addslashes($option_value);
                        ?>
option_arr_<?php 
                        echo $module_name;
                        ?>
[option_arr_<?php 
                        echo $module_name;
                        ?>
.length] = { "value":"<?php 
                        echo $option_value;
                        ?>
", "text":"<?php 
                        echo $option_text;
                        ?>
"};
<?php 
                        // END HALF-FIX
                    }
                    ?>

field_defs_<?php 
                    echo $module_name;
                    ?>
[ "<?php 
                    echo $field_def['name'];
                    ?>
"].options=option_arr_<?php 
                    echo $module_name;
                    ?>
;

<?php 
                } else {
                    if (isset($field_def['type']) && ($field_def['type'] == 'enum' || $field_def['type'] == 'timeperiod') && isset($field_def['function'])) {
                        ?>
					var option_arr_<?php 
                        echo $module_name;
                        ?>
 = new Array();

<?php 
                        $options_array = getFunctionValue(!empty($field_def['function_bean']) ? $field_def['function_bean'] : null, $field_def['function']);
                        foreach ($options_array as $option_value => $option_text) {
                            $option_text = html_entity_decode($option_text, ENT_QUOTES);
                            $option_text = addslashes($option_text);
                            $option_value = html_entity_decode($option_value, ENT_QUOTES);
                            $option_value = addslashes($option_value);
                            ?>
option_arr_<?php 
                            echo $module_name;
                            ?>
[option_arr_<?php 
                            echo $module_name;
                            ?>
.length] = { "value":"<?php 
                            echo $option_value;
                            ?>
", "text":"<?php 
                            echo $option_text;
                            ?>
"};
<?php 
                        }
                        ?>
field_defs_<?php 
                        echo $module_name;
                        ?>
[ "<?php 
                        echo $field_def['name'];
                        ?>
"].options=option_arr_<?php 
                        echo $module_name;
                        ?>
;
<?php 
                    } else {
                        if (isset($field_def['type']) && $field_def['type'] == 'parent_type' && isset($field_def['group']) && isset($module->field_defs[$field_def['group']]) && isset($module->field_defs[$field_def['group']]['options'])) {
                            ?>
	    	var option_arr_<?php 
                            echo $module_name;
                            ?>
 = new Array();
	    	<?php 
                            $options_array = array();
                            $trans_options = translate($module->field_defs[$field_def['group']]['options']);
                            if (!is_array($trans_options)) {
                                $trans_options = array();
                            }
                            foreach ($trans_options as $option_value => $option_text) {
                                $option_text = translate($option_text);
                                if (is_array($option_text)) {
                                    $option_text = 'Array';
                                }
                                $option_text = html_entity_decode($option_text, ENT_QUOTES);
                                $option_text = addslashes($option_text);
                                $option_value = html_entity_decode($option_value, ENT_QUOTES);
                                $option_value = addslashes($option_value);
                                ?>
option_arr_<?php 
                                echo $module_name;
                                ?>
[option_arr_<?php 
                                echo $module_name;
                                ?>
.length] = { "value":"<?php 
                                echo $option_value;
                                ?>
", "text":"<?php 
                                echo $option_text;
                                ?>
"};
				<?php 
                            }
                            ?>

field_defs_<?php 
                            echo $module_name;
                            ?>
[ "<?php 
                            echo $field_def['name'];
                            ?>
"].options=option_arr_<?php 
                            echo $module_name;
                            ?>
;
           <?php 
                        } elseif (isset($field_def['type']) && $field_def['type'] == 'currency_id') {
                            require_once 'include/generic/SugarWidgets/SugarWidgetFieldcurrency_id.php';
                            $tmpList = SugarWidgetFieldcurrency_id::getCurrenciesList();
                            $currencyList = array();
                            foreach ($tmpList as $bean) {
                                $currencyList[] = array('value' => $bean->id, 'text' => $bean->symbol . ' ' . $bean->iso4217);
                            }
                            $json = getJSONobj();
                            echo "var option_arr_{$module_name} = " . $json->encode($currencyList) . ";\n";
                            echo "field_defs_{$module_name}[\"{$field_def['name']}\"].options = option_arr_{$module_name};\n";
                        }
                    }
                }
            }
            //End foreach field
        }
        //var default_table_columns_<php echo $module_name; > = ["<php echo implode("\",\"",$module->default_table_columns); >"];
        ?>
var default_table_columns_<?php 
        echo $module_name;
        ?>
 = ["<?php 
        echo implode("\",\"", array());
        ?>
"];




module_defs['<?php 
        echo $module_name;
        ?>
'] = new Object();
module_defs['<?php 
        echo $module_name;
        ?>
'].link_defs = link_defs_<?php 
        echo $module_name;
        ?>
;
module_defs['<?php 
        echo $module_name;
        ?>
'].field_defs = field_defs_<?php 
        echo $module_name;
        ?>
;
module_defs['<?php 
        echo $module_name;
        ?>
'].default_table_columns = default_table_columns_<?php 
        echo $module_name;
        ?>
;
module_defs['<?php 
        echo $module_name;
        ?>
'].summary_field_defs = new Object();
module_defs['<?php 
        echo $module_name;
        ?>
'].group_by_field_defs = new Object();
module_defs['<?php 
        echo $module_name;
        ?>
'].default_summary_columns = default_summary_columns;
module_defs['<?php 
        echo $module_name;
        ?>
'].label = "<?php 
        echo addslashes(isset($app_list_strings['moduleList'][$module_name]) ? $app_list_strings['moduleList'][$module_name] : $module_name);
        ?>
";
<?php 
    }
    global $beanList;
    foreach ($relationships as $relationship_name => $relationship) {
        $rel_defs_array = array();
        if (empty($beanList[$relationship->lhs_module]) || empty($beanList[$relationship->rhs_module])) {
            continue;
        }
        $lhs_bean_name = $beanList[$relationship->lhs_module];
        $rhs_bean_name = $beanList[$relationship->rhs_module];
        array_push($rel_defs_array, "\"lhs_bean_name\":\"" . $lhs_bean_name . "\"");
        array_push($rel_defs_array, "\"rhs_bean_name\":\"" . $rhs_bean_name . "\"");
        foreach ($relationship->def as $rel_field => $value) {
            if (!is_array($value) && !is_object($value)) {
                array_push($rel_defs_array, '"' . $rel_field . '":"' . $value . '"');
            }
        }
        $rel_defs = "{" . implode(',', $rel_defs_array) . "}";
        print "rel_defs['" . $relationship_name . "'] = {$rel_defs};\n";
    }
    $mod_strings = return_module_language($current_language, 'Reports');
    $currentModule = 'Reports';
    $sum = translate('LBL_SUM');
    $avg = translate('LBL_AVG');
    $max = translate('LBL_MAX');
    $min = translate('LBL_MIN');
    $day = translate('LBL_DAY');
    $month = translate('LBL_MONTH');
    $year = translate('LBL_YEAR');
    $quarter = translate('LBL_QUARTER');
    ?>
var summary_types = {sum:'<?php 
    echo $sum;
    ?>
',avg:'<?php 
    echo $avg;
    ?>
',max:'<?php 
    echo $max;
    ?>
',min:'<?php 
    echo $min;
    ?>
'};
    var date_summary_types = {
        day:'<?php 
    echo $day;
    ?>
',
        month:'<?php 
    echo $month;
    ?>
',
        year:'<?php 
    echo $year;
    ?>
',
        quarter:'<?php 
    echo $quarter;
    ?>
'
    };

// create summary_defs_field and group_by_field_defs for every module

for(module_name in module_defs)
{
	module_defs[module_name].summary_field_defs = new Object();
	// default summary column

	//alert(module_defs[module_name].field_defs.length);
	var got_probability = 0;
	var got_first_name = 0;
	var got_last_name = 0;
	var got_amount = 0;

	module_defs[module_name].summary_field_defs['count'] = { name:'count', vname: '<?php 
    echo $GLOBALS['app_strings']['LBL_REPORT_NEWREPORT_COLUMNS_TAB_COUNT'];
    ?>
',"group_function":"count",summary_type:'group' };

	for(field_name in module_defs[module_name].field_defs)
	{
		var field_def =  module_defs[module_name].field_defs[field_name];
		// allow those of type 'int' for summary info
		var field_type = field_def.type;
        var field_source = (typeof field_def.source == 'undefined') ? '' : field_def.source;

		if(typeof(field_def.custom_type) != 'undefined')
		{
			field_type = field_def.custom_type;
		}

        // do not allow group bys of text fields or fields not from the db
        if(field_type != 'text' && (field_source != 'non-db' || typeof(field_def.ext2) != 'undefined') && field_def.name != 'full_name') {
		      module_defs[module_name].group_by_field_defs[ field_def.name] = field_def;
        }


		if(field_type == 'int' || field_type == 'float' || field_type=='currency' || field_type=='decimal' || field_type == 'long')
		{
			// create a new "column" for each summary type
			for(stype in summary_types)
			{

				module_defs[module_name].summary_field_defs[ field_def.name+':'+stype] = { name: field_def.name+':'+stype, field_def_name: field_def.name, vname: summary_types[stype]+': '+ field_def.vname,group_function:stype,summary_type:'group', field_type:field_type};
			}

		}
		else if(field_type == 'date' || field_type == 'datetime' || field_type == 'datetimecombo')
		{

			// create a new "column" for each datetimecombo summary type
			for(stype in date_summary_types)
			{

				module_defs[module_name].group_by_field_defs[field_def.name+':'+stype] = { name: field_def.name+':'+stype, field_def_name: field_def.name, vname: date_summary_types[stype]+': '+ field_def.vname,column_function:stype,summary_type:'column',field_type:field_type };
			}

		}

		if(field_def.name == 'amount')
		{
			got_amount = 1;
		}

		if(field_def.name == 'probability')
		{
			got_probability = 1;
		}

	}


	if(got_probability == 1 && got_amount == 1)
	{
		module_defs[module_name].summary_field_defs['weighted_amount'] = { name: 'weighted_amount', vname: '<?php 
    echo translate('LBL_WEIGHTED_AVG_AMOUNT');
    ?>
', group_function: 'weighted_amount' };
		module_defs[module_name].summary_field_defs['weighted_sum'] = { name: 'weighted_sum', vname: '<?php 
    echo translate('LBL_WEIGHTED_SUM_AMOUNT');
    ?>
', group_function: 'weighted_sum' };
	}
}

var filter_defs = new Object();
var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'equals',value:'<?php 
    echo $mod_strings['LBL_EQUALS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_equals_str',value:'<?php 
    echo $mod_strings['LBL_DOES_NOT_EQUAL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['encrypt'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'equals',value:'<?php 
    echo $mod_strings['LBL_EQUALS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_equals_str',value:'<?php 
    echo $mod_strings['LBL_DOES_NOT_EQUAL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'contains',value:'<?php 
    echo $mod_strings['LBL_CONTAINS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'does_not_contain',value:'<?php 
    echo $mod_strings['LBL_DOES_NOT_CONTAIN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'starts_with',value:'<?php 
    echo $mod_strings['LBL_STARTS_WITH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'ends_with',value:'<?php 
    echo $mod_strings['LBL_ENDS_WITH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['varchar'] = qualifiers;
filter_defs['char'] = qualifiers;
filter_defs['text'] = qualifiers;
filter_defs['email'] = qualifiers;
filter_defs['yim'] = qualifiers;
filter_defs['time'] = qualifiers;
filter_defs['phone'] = qualifiers;
filter_defs['url'] = qualifiers;


var qualifiers_name = new Array();
var is_def = {name:'is',value:'<?php 
    echo $mod_strings['LBL_IS'];
    ?>
'};
var is_not_def = {name:'is_not',value:"<?php 
    echo $mod_strings['LBL_IS_NOT'];
    ?>
"};
var one_of_def = {name:'one_of',value:'<?php 
    echo $mod_strings['LBL_ONE_OF'];
    ?>
'};
var not_one_of_def = {name:'not_one_of',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_ONE_OF'];
    ?>
'};
qualifiers_name = qualifiers_name.concat(qualifiers);
qualifiers_name.unshift(is_not_def);
qualifiers_name.unshift(is_def);
filter_defs['name'] = qualifiers_name;
filter_defs['fullname'] = qualifiers_name;


var qualifiers_name = new Array();
//qualifiers_name = qualifiers_name.concat(qualifiers);
var is_not_empty_def = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
var is_empty_def = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
var reports_to_def = {name:'reports_to',value:'<?php 
    echo $mod_strings['LBL_REPORTS_TO'];
    ?>
'};
qualifiers_name.unshift(reports_to_def);
qualifiers_name.unshift(is_not_empty_def);
qualifiers_name.unshift(is_empty_def);
qualifiers_name.unshift(not_one_of_def);
qualifiers_name.unshift(one_of_def);
qualifiers_name.unshift(is_not_def);
qualifiers_name.unshift(is_def);
filter_defs['username'] = qualifiers_name;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'on',value:'<?php 
    echo $mod_strings['LBL_ON'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'before',value:'<?php 
    echo $mod_strings['LBL_BEFORE'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'after',value:'<?php 
    echo $mod_strings['LBL_AFTER'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'between_dates',value:'<?php 
    echo $mod_strings['LBL_IS_BETWEEN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_equals_str',value:'<?php 
    echo $mod_strings['LBL_NOT_ON'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};



qualifiers[qualifiers.length] = {name:'tp_yesterday',value:'<?php 
    echo $mod_strings['LBL_YESTERDAY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_today',value:'<?php 
    echo $mod_strings['LBL_TODAY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_tomorrow',value:'<?php 
    echo $mod_strings['LBL_TOMORROW'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_n_days',value:'<?php 
    echo $mod_strings['LBL_LAST_N_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_n_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_N_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_7_days',value:'<?php 
    echo $mod_strings['LBL_LAST_7_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_7_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_7_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_month',value:'<?php 
    echo $mod_strings['LBL_LAST_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_this_month',value:'<?php 
    echo $mod_strings['LBL_THIS_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_month',value:'<?php 
    echo $mod_strings['LBL_NEXT_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_30_days',value:'<?php 
    echo $mod_strings['LBL_LAST_30_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_30_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_30_DAYS'];
    ?>
'};

    qualifiers[qualifiers.length] = {name:'tp_last_quarter',value:'<?php 
    echo $mod_strings['LBL_LAST_QUARTER'];
    ?>
'};
    qualifiers[qualifiers.length] = {name:'tp_this_quarter',value:'<?php 
    echo $mod_strings['LBL_THIS_QUARTER'];
    ?>
'};
    qualifiers[qualifiers.length] = {name:'tp_next_quarter',value:'<?php 
    echo $mod_strings['LBL_NEXT_QUARTER'];
    ?>
'};

qualifiers[qualifiers.length] = {name:'tp_last_year',value:'<?php 
    echo $mod_strings['LBL_LAST_YEAR'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_this_year',value:'<?php 
    echo $mod_strings['LBL_THIS_YEAR'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_year',value:'<?php 
    echo $mod_strings['LBL_NEXT_YEAR'];
    ?>
'};

filter_defs['date'] = qualifiers;
filter_defs['datetime'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'on',value:'<?php 
    echo $mod_strings['LBL_ON'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'before',value:'<?php 
    echo $mod_strings['LBL_BEFORE'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'after',value:'<?php 
    echo $mod_strings['LBL_AFTER'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'between_datetimes',value:'<?php 
    echo $mod_strings['LBL_IS_BETWEEN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_equals_str',value:'<?php 
    echo $mod_strings['LBL_NOT_ON'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_yesterday',value:'<?php 
    echo $mod_strings['LBL_YESTERDAY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_today',value:'<?php 
    echo $mod_strings['LBL_TODAY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_tomorrow',value:'<?php 
    echo $mod_strings['LBL_TOMORROW'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_n_days',value:'<?php 
    echo $mod_strings['LBL_LAST_N_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_n_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_N_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_7_days',value:'<?php 
    echo $mod_strings['LBL_LAST_7_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_7_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_7_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_month',value:'<?php 
    echo $mod_strings['LBL_LAST_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_this_month',value:'<?php 
    echo $mod_strings['LBL_THIS_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_month',value:'<?php 
    echo $mod_strings['LBL_NEXT_MONTH'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_last_30_days',value:'<?php 
    echo $mod_strings['LBL_LAST_30_DAYS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_30_days',value:'<?php 
    echo $mod_strings['LBL_NEXT_30_DAYS'];
    ?>
'};

    qualifiers[qualifiers.length] = {name:'tp_last_quarter',value:'<?php 
    echo $mod_strings['LBL_LAST_QUARTER'];
    ?>
'};
    qualifiers[qualifiers.length] = {name:'tp_this_quarter',value:'<?php 
    echo $mod_strings['LBL_THIS_QUARTER'];
    ?>
'};
    qualifiers[qualifiers.length] = {name:'tp_next_quarter',value:'<?php 
    echo $mod_strings['LBL_NEXT_QUARTER'];
    ?>
'};

qualifiers[qualifiers.length] = {name:'tp_last_year',value:'<?php 
    echo $mod_strings['LBL_LAST_YEAR'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_this_year',value:'<?php 
    echo $mod_strings['LBL_THIS_YEAR'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'tp_next_year',value:'<?php 
    echo $mod_strings['LBL_NEXT_YEAR'];
    ?>
'};

filter_defs['datetimecombo'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'equals',value:'<?php 
    echo $mod_strings['LBL_EQUALS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_equals',value:'<?php 
    echo $mod_strings['LBL_DOES_NOT_EQUAL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'less',value:'<?php 
    echo $mod_strings['LBL_LESS_THAN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'less_equal',value:'<?php 
    echo $mod_strings['LBL_LESS_THAN_EQUAL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'greater_equal',value:'<?php 
    echo $mod_strings['LBL_GREATER_THAN_EQUAL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'greater',value:'<?php 
    echo $mod_strings['LBL_GREATER_THAN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'between',value:'<?php 
    echo $mod_strings['LBL_IS_BETWEEN'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['int'] = qualifiers;
filter_defs['long'] = qualifiers;
filter_defs['float'] = qualifiers;
filter_defs['decimal'] = qualifiers;
filter_defs['currency'] = qualifiers;
filter_defs['num'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'is',value:'<?php 
    echo $mod_strings['LBL_IS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'is_not',value:"<?php 
    echo $mod_strings['LBL_IS_NOT'];
    ?>
"};
qualifiers[qualifiers.length] = {name:'one_of',value:'<?php 
    echo $mod_strings['LBL_ONE_OF'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_one_of',value:"<?php 
    echo $mod_strings['LBL_IS_NOT_ONE_OF'];
    ?>
"};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['enum'] = qualifiers;
filter_defs['radioenum'] = qualifiers;
filter_defs['parent_type'] = qualifiers;
filter_defs['timeperiod'] = qualifiers;
filter_defs['currency_id'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'is',value:'<?php 
    echo $mod_strings['LBL_IS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'is_not',value:"<?php 
    echo $mod_strings['LBL_IS_NOT'];
    ?>
"};
qualifiers[qualifiers.length] = {name:'one_of',value:'<?php 
    echo $mod_strings['LBL_ONE_OF'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_one_of',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_ONE_OF'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['multienum'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'is',value:'<?php 
    echo $mod_strings['LBL_IS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'is_not',value:"<?php 
    echo $mod_strings['LBL_IS_NOT'];
    ?>
"};
qualifiers[qualifiers.length] = {name:'one_of',value:'<?php 
    echo $mod_strings['LBL_ONE_OF'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['assigned_user_name'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'is',value:'<?php 
    echo $mod_strings['LBL_IS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'is_not',value:"<?php 
    echo $mod_strings['LBL_IS_NOT'];
    ?>
"};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['relate'] = qualifiers;
filter_defs['id'] = qualifiers;

var qualifiers =  new Array();
qualifiers[qualifiers.length] = {name:'equals',value:'<?php 
    echo $mod_strings['LBL_EQUALS'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'};
filter_defs['bool'] = qualifiers;

var date_group_defs =  new Array();
date_group_defs[date_group_defs.length] = {name:'day', value:'<?php 
    echo $mod_strings['LBL_BY_DAY'];
    ?>
'};
date_group_defs[date_group_defs.length] = {name:'month', value:'<?php 
    echo $mod_strings['LBL_BY_MONTH'];
    ?>
'};
date_group_defs[date_group_defs.length] = {name:'year', value:'<?php 
    echo $mod_strings['LBL_BY_YEAR'];
    ?>
'};
date_group_defs[date_group_defs.length] = {name:'quarter', value:'<?php 
    echo $mod_strings['LBL_BY_QUARTER'];
    ?>
'};

var qualifiers = new Array();
qualifiers[qualifiers.length] = {name:'any',value:'<?php 
    echo $mod_strings['LBL_ANY'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'all',value:'<?php 
    echo $mod_strings['LBL_ALL'];
    ?>
'};
qualifiers[qualifiers.length] = {name:'exact',value:'<?php 
    echo $mod_strings['LBL_EXACT'];
    ?>
'};
filter_defs['team_set_id'] = qualifiers;

    filter_defs['file'] = [
        {name:'empty',value:'<?php 
    echo $mod_strings['LBL_IS_EMPTY'];
    ?>
'},
        {name:'not_empty',value:'<?php 
    echo $mod_strings['LBL_IS_NOT_EMPTY'];
    ?>
'}
    ];

function in_array(n, h){
    var i = 0;
    while (i < h.length) {
        if (n == h[i]) return true;
        i++;
    }
    return false;
}

for(i in module_defs) {
    if(!in_array(i, ACLAllowedModules)) {
        delete module_defs[i];
    }
}
<?php 
}
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $beanFiles, $beanList, $app_list_strings;
     if (empty($beanFiles)) {
         include 'include/modules.php';
     }
     $ACLAllowedModules = getACLAllowedModules();
     $module_array = array();
     $module = BeanFactory::getBean($_REQUEST['report_module']);
     $bean_name = $module->object_name;
     $linked_fields = $module->get_linked_fields();
     foreach ($linked_fields as $linked_field) {
         $module->load_relationship($linked_field['name']);
         $field = $linked_field['name'];
         if (empty($module->{$field}) || isset($linked_field['reportable']) && $linked_field['reportable'] == false) {
             continue;
         }
         $relationship = $module->{$field}->_relationship;
         if ($this->isRelationshipReportable($relationship) === false) {
             continue;
         }
         $bean_is_lhs = $module->{$field}->_get_bean_position();
         if ($bean_is_lhs == true && isset($beanList[$relationship->rhs_module])) {
             $link_bean = $beanList[$relationship->rhs_module];
             $link_module = $relationship->rhs_module;
         } else {
             if (isset($beanList[$relationship->lhs_module])) {
                 $link_bean = $beanList[$relationship->lhs_module];
                 $link_module = $relationship->lhs_module;
             }
         }
         if (!isset($ACLAllowedModules[$link_module])) {
             continue;
         }
         $custom_label = 'LBL_' . strtoupper($relationship->relationship_name . '_FROM_' . $link_module) . '_TITLE';
         $custom_subpanel_label = 'LBL_' . strtoupper($link_module) . '_SUBPANEL_TITLE';
         //bug 47834
         $lang = $GLOBALS['current_language'];
         foreach (SugarAutoLoader::existing("custom/modules/" . $_REQUEST['report_module'] . "/Ext/Language/" . $lang . ".lang.ext.php") as $file) {
             require $file;
         }
         //end 47834
         // Bug 37308 - Check if the label was changed in studio
         //bug 47834 -  added check to see if the new label name is set in custom $lang.lang.ext.php file
         if (translate($custom_label, $_REQUEST['report_module']) != $custom_label && isset($mod_strings[$custom_label])) {
             $linked_field['label'] = translate($custom_label, $_REQUEST['report_module']);
         } elseif (translate($custom_subpanel_label, $_REQUEST['report_module']) != $custom_subpanel_label && $link_module != $_REQUEST['report_module'] && isset($mod_strings[$custom_subpanel_label])) {
             $linked_field['label'] = translate($custom_subpanel_label, $_REQUEST['report_module']);
         } elseif (!empty($linked_field['vname'])) {
             $linked_field['label'] = translate($linked_field['vname'], $_REQUEST['report_module']);
         } else {
             $linked_field['label'] = $linked_field['name'];
         }
         $linked_field['label'] = preg_replace('/:$/', '', $linked_field['label']);
         $linked_field['label'] = addslashes($linked_field['label']);
         if (isset($app_list_strings['moduleList'][$linked_field['label']])) {
             $linked_field['label'] = $app_list_strings['moduleList'][$linked_field['label']];
         }
         $module_array[] = $this->_populateNodeItem($bean_name, $link_module, $linked_field);
     }
     // Sort alphabetically
     function compare_text($a, $b)
     {
         return strnatcmp($a['text'], $b['text']);
     }
     usort($module_array, 'compare_text');
     $json = getJSONobj();
     echo $json->encode($module_array);
 }
Beispiel #3
0
    // when we click the 'My Favorate Reports', it should not populate the StoredQuery
    $storeQuery->loadQuery($currentModule);
    $storeQuery->populateRequest();
} else {
    $storeQuery->saveFromRequest($currentModule);
}
// setup for search form
$thisMod = 'Reports';
$searchForm = new SearchFormReports($thisMod, $savedReportsSeed);
$searchForm->tabs = array(array('title' => $app_strings['LNK_BASIC_SEARCH'], 'link' => $thisMod . '|basic_search', 'key' => $thisMod . '|basic_search'), array('title' => $app_strings['LNK_ADVANCED_SEARCH'], 'link' => $thisMod . '|advanced_search', 'key' => $thisMod . '|advanced_search'));
$searchForm->populateFromRequest();
$searchForm->searchFields['module'] = $searchForm->searchFields['report_module'];
unset($searchForm->searchFields['report_module']);
$where_clauses = $searchForm->generateSearchWhere();
include 'include/modules.php';
$ACLAllowedModules = getACLAllowedModules();
$ACLUnAllowedModules = getACLDisAllowedModules();
$ACLAllowedModulesKeys = array_keys($ACLAllowedModules);
$listViewDefsNewArray = array();
$listViewDefsNewArray = sugarArrayMerge($listViewDefsNewArray, $listViewDefs);
unset($listViewDefsNewArray['Reports']['IS_EDIT']);
unset($listViewDefsNewArray['Reports']['LAST_RUN_DATE']);
foreach ($ACLUnAllowedModules as $module => $class_name) {
    array_push($where_clauses, "saved_reports.module != '{$module}'");
}
$reportModules = array();
foreach ($ACLAllowedModules as $key => $module) {
    $reportModules[$key] = isset($app_list_strings['moduleList'][$key]) ? $app_list_strings['moduleList'][$key] : $key;
}
asort($reportModules);
if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
function template_reports_report(&$reporter, &$args)
{
    global $current_user;
    global $current_language;
    global $mod_strings, $app_strings;
    global $sugar_config, $sugar_version;
    $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
    $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);
    $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'] : "");
    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);
    $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)));
    require_once 'include/tabs.php';
    $tabs = array();
    array_push($tabs, array('title' => $mod_strings['LBL_1_REPORT_ON'], 'link' => 'module_join_tab', 'key' => 'module_join_tab'));
    array_push($tabs, array('title' => $mod_strings['LBL_2_FILTER'], 'link' => 'filters_tab', 'key' => 'filters_tab'));
    //array_push($tabs,array('title'=>$mod_strings['LBL_3_GROUP'],'link'=>'group_by_tab','key'=>'group_by_tab'));
    //array_push($tabs,array('title'=>$mod_strings['LBL_3_CHOOSE'],'link'=>'columns_tab','key'=>'columns_tab'));
    if ($args['reporter']->report_type == 'tabular') {
        array_push($tabs, array('title' => $mod_strings['LBL_3_GROUP'], 'hidden' => true, 'link' => 'group_by_tab', 'key' => 'group_by_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_3_CHOOSE'], 'link' => 'columns_tab', 'key' => 'columns_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_5_CHART_OPTIONS'], 'hidden' => true, 'link' => 'chart_options_tab', 'key' => 'chart_options_tab'));
    } else {
        array_push($tabs, array('title' => $mod_strings['LBL_3_GROUP'], 'link' => 'group_by_tab', 'key' => 'group_by_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_4_CHOOSE'], 'link' => 'columns_tab', 'key' => 'columns_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_5_CHART_OPTIONS'], 'link' => 'chart_options_tab', 'key' => 'chart_options_tab'));
    }
    $current_key = 'module_join_tab';
    $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showReportTab');
    $smarty->assign('tab_panel_display', $tab_panel->display());
    template_reports_tables($smarty, $args);
    if ($reporter->report_type == 'summary') {
        $summary_display = '';
        if ($reporter->show_columns) {
            $column_display = '';
        } else {
            $column_display = 'none';
        }
        // else
    } else {
        $summary_display = 'none';
        $column_display = '';
    }
    // else
    $summary_join_selector = '&nbsp;<div style="padding-bottom:2px">' . $mod_strings['LBL_MODULE'] . ': <select onChange="viewJoinChanged(this);" id="view_join_summary" name="view_join_summary"></select></div>';
    $chooser_args_summary = array('id' => 'summary_table', 'title' => $mod_strings['LBL_CHOOSE_SUMMARIES'] . ':', 'left_name' => 'display_summary', 'right_name' => 'hidden_summary', 'left_label' => $mod_strings['LBL_DISPLAY_SUMMARIES'], 'right_label' => $summary_join_selector, 'display' => $summary_display, 'onmoveleft' => 'reload_columns(\'join\')', 'onmoveright' => 'reload_columns(\'join\')');
    $join_selector = '&nbsp;<div style="padding-bottom:2px">' . $mod_strings['LBL_MODULE'] . ': <select onChange="viewJoinChanged(this);" id="view_join" name="view_join"></select></div>';
    $chooser_args = array('id' => 'columns_table', 'title' => $mod_strings['LBL_CHOOSE_COLUMNS'] . ':', 'left_name' => 'display_columns', 'right_name' => 'hidden_columns', 'left_label' => $mod_strings['LBL_DISPLAY_COLUMNS'], 'right_label' => $join_selector, 'display' => $column_display, 'topleftcontent' => $join_selector, 'onmoveleft' => 'reload_columns(\'join\')', 'onmoveright' => 'reload_columns(\'join\')');
    $smarty->assign('template_grups_choosers1', template_groups_chooser($chooser_args_summary));
    if ($summary_display == 'none') {
        $smarty->assign('summary_display_style', "display:none");
    }
    // if
    if ($reporter->show_columns) {
        $smarty->assign('show_columns_reports', true);
    }
    // if
    $smarty->assign('column_display', $column_display);
    $smarty->assign('template_grups_choosers2', template_groups_chooser($chooser_args));
    template_reports_filters($smarty, $args);
    $smarty->assign('reporter_report_type', $args['reporter']->report_type);
    template_reports_group_by($smarty, $args);
    template_reports_chart_options($smarty, $args);
    $smarty->assign('md5_current_user_id', md5($current_user->id));
    $smarty->assign('args_image_path', $args['IMAGE_PATH']);
    template_reports_request_vars_js($smarty, $reporter, $args);
    $smarty->assign('cache_path', sugar_cached(''));
    // 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/_template_reports_report.tpl");
    ob_start();
    ?>
<script language="javascript">
if(typeof YAHOO != 'undefined') YAHOO.util.Event.addListener(window, 'load', load_page);
</script>
<?php 
    reportResults($reporter, $args);
    /*
    $do_chart = false;
    
    $dbStart = microtime();
    
    if ($reporter->report_type == 'summary' && ! empty($reporter->report_def['summary_columns'])) {
    if ($reporter->show_columns &&
    	!empty($reporter->report_def['display_columns']) &&
            !empty($reporter->report_def['group_defs'])) {
    
    	template_summary_combo_view($reporter,$args);
    	$do_chart = true;
    
        } else if($reporter->show_columns &&
              !empty($reporter->report_def['display_columns']) &&
              	   empty($reporter->report_def['group_defs'])) {
    	template_detail_and_total_list_view($reporter,$args);
    } else if (!empty($reporter->report_def['group_defs'])) {
    	template_summary_list_view($reporter,$args);
    	$do_chart = true;
    } else {
    	template_total_view($reporter,$args);
    } // else
    } else if (!empty($reporter->report_def['display_columns'])) {
    template_list_view($reporter,$args);
    } // else if
    
    if ($reporter->report_def['chart_type']== 'none') {
    $do_chart = false;
    }
    echo "time = " . microtime_diff($dbStart, microtime())."s ";
    ?>
    </div>
    <?php
    $contents = ob_get_contents();
    ob_end_clean();
    
    if ($do_chart) {
       		template_chart($reporter);
    } // if
    
    print $contents;
    */
}