Ejemplo n.º 1
0
 /**
  * This method returns the dropdown options of a given field
  * @param array $api
  * @param array $args
  * @return array
  */
 public function getEnumValues($api, $args)
 {
     $this->requireArgs($args, array('module', 'field'));
     $bean = BeanFactory::newBean($args['module']);
     if (!isset($bean->field_defs[$args['field']])) {
         throw new SugarApiExceptionNotFound('field not found');
     }
     $vardef = $bean->field_defs[$args['field']];
     $value = null;
     $cache_age = 0;
     if (isset($vardef['function'])) {
         if (isset($vardef['function']['returns']) && $vardef['function']['returns'] == 'html') {
             throw new SugarApiExceptionError('html dropdowns are not supported');
         }
         $value = getFunctionValue(isset($vardef['function_bean']) ? $vardef['function_bean'] : null, $vardef['function']);
         $cache_age = 60;
     } else {
         if (!isset($GLOBALS['app_list_strings'][$vardef['options']])) {
             throw new SugarApiExceptionNotFound('options not found');
         }
         $value = $GLOBALS['app_list_strings'][$vardef['options']];
         $cache_age = 3600;
     }
     // If a particular field has an option list that is expensive to calculate and/or rarely changes,
     // set the cache_setting property on the vardef to the age in seconds you want browsers to wait before refreshing
     if (isset($vardef['cache_setting'])) {
         $cache_age = $vardef['cache_setting'];
     }
     generateEtagHeader(md5(serialize($value)), $cache_age);
     return $value;
 }
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 
}
Ejemplo n.º 3
0
 public function getEmailTemplateValue($inputField, $vardef, $context = null)
 {
     //if function is defined then call the function value and retrieve the input field string
     if (!empty($vardef['function'])) {
         // figure out the bean we should be using
         $bean = isset($vardef['function_bean']) && !empty($vardef['function_bean']) ? $vardef['function_bean'] : null;
         return getFunctionValue($bean, $vardef['function'], $args = array('selectID' => $inputField));
     }
     // call format field to return value
     return $this->formatField($inputField, $vardef);
 }
Ejemplo n.º 4
0
    /**
     * Displays the massupdate form
     */
    function getMassUpdateForm($hideDeleteIfNoFieldsAvailable = false)
    {
        global $app_strings;
        global $current_user;
        if (!$this->sugarbean->ACLAccess('edit', true) && !$this->sugarbean->ACLAccess('massupdate', true)) {
            return '';
        }
        $lang_delete = translate('LBL_DELETE');
        $lang_update = translate('LBL_UPDATE');
        $lang_confirm = translate('NTC_DELETE_CONFIRMATION_MULTIPLE');
        $lang_sync = translate('LBL_SYNC_CONTACT');
        $lang_oc_status = translate('LBL_OC_STATUS');
        $lang_unsync = translate('LBL_UNSYNC');
        $lang_archive = translate('LBL_ARCHIVE');
        $lang_optout_primaryemail = $app_strings['LBL_OPT_OUT_FLAG_PRIMARY'];
        $field_count = 0;
        $html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE'] . "</h3></td></tr></table>";
        $html .= "<div id='mass_update_div'><table cellpadding='0' cellspacing='1' border='0' width='100%' class='edit view' id='mass_update_table'>";
        $even = true;
        if ($this->sugarbean->object_name == 'Contact') {
            $html .= "<tr><td width='15%' scope='row'>{$lang_sync}</td><td width='35%' class='dataField'><select name='Sync'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td>";
            $even = false;
        } else {
            if ($this->sugarbean->object_name == 'Employee') {
                $this->sugarbean->field_defs['employee_status']['type'] = 'enum';
                $this->sugarbean->field_defs['employee_status']['massupdate'] = true;
                $this->sugarbean->field_defs['employee_status']['options'] = 'employee_status_dom';
            } else {
                if ($this->sugarbean->object_name == 'InboundEmail') {
                    $this->sugarbean->field_defs['status']['type'] = 'enum';
                    $this->sugarbean->field_defs['status']['options'] = 'user_status_dom';
                }
            }
        }
        //These fields should never appear on mass update form
        static $banned = array('date_modified' => 1, 'date_entered' => 1, 'created_by' => 1, 'modified_user_id' => 1, 'deleted' => 1, 'modified_by_name' => 1);
        foreach ($this->sugarbean->field_defs as $field) {
            if (!$this->sugarbean->ACLFieldAccess($field['name'], 'edit')) {
                continue;
            }
            if ($this->sugarbean->object_name == 'User' && $field['name'] == 'is_admin') {
                // already have 'User Type'
                continue;
            }
            if (!isset($banned[$field['name']]) && (!isset($field['massupdate']) || !empty($field['massupdate']))) {
                $newhtml = '';
                if ($even) {
                    $newhtml .= "<tr>";
                }
                if (isset($field['vname'])) {
                    $displayname = translate($field['vname']);
                } else {
                    $displayname = '';
                }
                if (isset($field['type']) && $field['type'] == 'relate' && isset($field['id_name']) && $field['id_name'] == 'assigned_user_id') {
                    $field['type'] = 'assigned_user_name';
                }
                if (isset($field['custom_type'])) {
                    $field['type'] = $field['custom_type'];
                }
                if (isset($field['type'])) {
                    switch ($field["type"]) {
                        case "relate":
                            // bug 14691: avoid laying out an empty cell in the <table>
                            $handleRelationship = $this->handleRelationship($displayname, $field);
                            if ($handleRelationship != '') {
                                $even = !$even;
                                $newhtml .= $handleRelationship;
                            }
                            break;
                        case "parent":
                            $even = !$even;
                            $newhtml .= $this->addParent($displayname, $field);
                            break;
                        case "int":
                            if (!empty($field['massupdate']) && empty($field['auto_increment'])) {
                                $even = !$even;
                                $newhtml .= $this->addInputType($displayname, $field);
                            }
                            break;
                        case "contact_id":
                            $even = !$even;
                            $newhtml .= $this->addContactID($displayname, $field["name"]);
                            break;
                        case "assigned_user_name":
                            $even = !$even;
                            $newhtml .= $this->addAssignedUserID($displayname, $field["name"]);
                            break;
                        case "account_id":
                            $even = !$even;
                            $newhtml .= $this->addAccountID($displayname, $field["name"]);
                            break;
                        case "account_name":
                            $even = !$even;
                            $newhtml .= $this->addAccountID($displayname, $field["id_name"]);
                            break;
                        case "bool":
                            $even = !$even;
                            $newhtml .= $this->addBool($displayname, $field["name"]);
                            break;
                        case "enum":
                        case "multienum":
                            if (!empty($field['isMultiSelect'])) {
                                $even = !$even;
                                $newhtml .= $this->addStatusMulti($displayname, $field["name"], translate($field["options"]));
                                break;
                            } else {
                                if (!empty($field['options'])) {
                                    $even = !$even;
                                    $newhtml .= $this->addStatus($displayname, $field["name"], translate($field["options"]));
                                    break;
                                } else {
                                    if (!empty($field['function'])) {
                                        $functionValue = getFunctionValue(isset($field['function_bean']) ? $field['function_bean'] : null, $field['function'], array($this->sugarbean, $field['name'], '', 'MassUpdate'));
                                        $even = !$even;
                                        $newhtml .= $this->addStatus($displayname, $field["name"], $functionValue);
                                        break;
                                    }
                                }
                            }
                            break;
                        case "radioenum":
                            $even = !$even;
                            $newhtml .= $this->addRadioenum($displayname, $field["name"], translate($field["options"]));
                            break;
                        case "datetimecombo":
                            $even = !$even;
                            $newhtml .= $this->addDatetime($displayname, $field["name"]);
                            break;
                        case "datetime":
                        case "date":
                            $even = !$even;
                            $newhtml .= $this->addDate($displayname, $field["name"]);
                            break;
                        case "team_list":
                            $teamhtml = $this->addTeamList(translate('LBL_TEAMS'), $field);
                            break;
                        default:
                            $newhtml .= $this->addDefault($displayname, $field, $even);
                            break;
                            break;
                    }
                }
                if ($even) {
                    $newhtml .= "</tr>";
                }
                $field_count++;
                if (!in_array($newhtml, array('<tr>', '</tr>', '<tr></tr>', '<tr><td></td></tr>'))) {
                    $html .= $newhtml;
                }
            }
        }
        if (isset($teamhtml)) {
            if (!$even) {
                $teamhtml .= "</tr>";
            }
            if (!in_array($teamhtml, array('<tr>', '</tr>', '<tr></tr>', '<tr><td></td></tr>'))) {
                $html .= $teamhtml;
            }
            $field_count++;
        }
        /*---------------------------------------------------------------
          This is being taken off of the Menu as part of MAR-1421 until the support for it exists in the new MassUpdate Api
          BR-823 was created to add the support in the New MassUpdate Api
          ----------------------------------------------------------------*/
        // if ($this->sugarbean->object_name == 'Contact' ||
        //      $this->sugarbean->object_name == 'Account' ||
        //  	$this->sugarbean->object_name == 'Lead' ||
        //  	$this->sugarbean->object_name == 'Prospect') {
        //
        //      $html .= "<tr><td width='15%'  scope='row' class='dataLabel'>$lang_optout_primaryemail</td><td width='35%' class='dataField'><select name='optout_primary'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td></tr>";
        //
        // }
        $html .= "</table>";
        $html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td class='buttons'><input onclick='return sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\")' type='submit' id='update_button' name='Update' value='{$lang_update}' class='button'>&nbsp;<input onclick='javascript:toggleMassUpdateForm();' type='button' id='cancel_button' name='Cancel' value='{$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL']}' class='button'>";
        // TODO: allow ACL access for Delete to be set false always for users
        //		if($this->sugarbean->ACLAccess('Delete', true) && $this->sugarbean->object_name != 'User') {
        //			global $app_list_strings;
        //			$html .=" <input id='delete_button' type='submit' name='Delete' value='{$lang_delete}' onclick='return confirm(\"{$lang_confirm}\") && sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\", 1)' class='button'>";
        //		}
        // only for My Inbox views - to allow CSRs to have an "Archive" emails feature to get the email "out" of their inbox.
        if ($this->sugarbean->object_name == 'Email' && (isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id'])) && (isset($_REQUEST['type']) && !empty($_REQUEST['type']) && $_REQUEST['type'] == 'inbound')) {
            $html .= <<<eoq
\t\t\t<input type='button' name='archive' value="{$lang_archive}" class='button' onClick='setArchived();'>
\t\t\t<input type='hidden' name='ie_assigned_user_id' value="{$current_user->id}">
\t\t\t<input type='hidden' name='ie_type' value="inbound">
eoq;
        }
        if ($this->sugarbean->object_name == 'User' && ($current_user->is_admin || $current_user->isAdminForModule('Users'))) {
            $html .= <<<eoq
            <input type='hidden' name='current_admin_id' value="{$current_user->id}">
eoq;
        }
        $html .= "</td></tr></table></div></div>";
        $html .= <<<EOJS
<script>
function toggleMassUpdateForm(){
    document.getElementById('massupdate_form').style.display = 'none';
}
</script>
EOJS;
        if ($field_count > 0) {
            return $html;
        } else {
            //If no fields are found, render either a form that still permits Mass Update deletes or just display a message that no fields are available
            $html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE'] . "</h3></td></tr></table>";
            if ($this->sugarbean->ACLAccess('Delete', true) && !$hideDeleteIfNoFieldsAvailable) {
                $html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td><input type='submit' name='Delete' value='{$lang_delete}' onclick=\"return confirm('{$lang_confirm}')\" class='button'></td></tr></table></div>";
            } else {
                $html .= $app_strings['LBL_NO_MASS_UPDATE_FIELDS_AVAILABLE'] . "</div>";
            }
            return $html;
        }
    }
Ejemplo n.º 5
0
 function process($checkFormName = false, $formName = '')
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings;
     //the retrieve already did this work;
     //$this->focus->fill_in_relationship_fields();
     //Bug#53261: If quickeditview is loaded after editview.tpl is created,
     //           the th->checkTemplate will return true. So, the following
     //           code prevent avoid rendering popup editview container.
     if (!empty($this->formName)) {
         $formName = $this->formName;
         $checkFormName = true;
     }
     if (!$this->th->checkTemplate($this->module, $this->view, $checkFormName, $formName)) {
         $this->render();
     }
     if (isset($_REQUEST['offset'])) {
         $this->offset = $_REQUEST['offset'] - 1;
     }
     if ($this->showVCRControl) {
         $this->th->ss->assign('PAGINATION', SugarVCR::menu($this->module, $this->offset, $this->focus->is_AuditEnabled(), $this->view == 'EditView'));
     }
     if (isset($_REQUEST['return_module'])) {
         $this->returnModule = $_REQUEST['return_module'];
     }
     if (isset($_REQUEST['return_action'])) {
         $this->returnAction = $_REQUEST['return_action'];
     }
     if (isset($_REQUEST['return_id'])) {
         $this->returnId = $_REQUEST['return_id'];
     }
     if (isset($_REQUEST['return_relationship'])) {
         $this->returnRelationship = $_REQUEST['return_relationship'];
     }
     if (isset($_REQUEST['return_name'])) {
         $this->returnName = $this->getValueFromRequest($_REQUEST, 'return_name');
     }
     // handle Create $module then Cancel
     if (empty($this->returnId)) {
         $this->returnAction = 'index';
     }
     $is_owner = $this->focus->isOwner($GLOBALS['current_user']->id);
     $this->fieldDefs = array();
     if ($this->focus) {
         global $current_user;
         if (!empty($this->focus->job) && $this->focus->job_function == '') {
             $this->focus->job_function = $this->focus->job;
         }
         if (empty($this->focus->team_id)) {
             $this->focus->team_id = $current_user->default_team;
             $this->focus->team_name = $current_user->default_team_name;
         } else {
             if (empty($this->focus->team_name)) {
                 $this->focus->team_name = Team::getTeamName($this->focus->team_id);
             }
         }
         foreach ($this->focus->toArray() as $name => $value) {
             $valueFormatted = false;
             //if ($this->focus->field_defs[$name]['type']=='link')continue;
             $this->fieldDefs[$name] = !empty($this->fieldDefs[$name]) && !empty($this->fieldDefs[$name]['value']) ? array_merge($this->focus->field_defs[$name], $this->fieldDefs[$name]) : $this->focus->field_defs[$name];
             foreach (array("formula", "default", "comments", "help") as $toEscape) {
                 if (!empty($this->fieldDefs[$name][$toEscape])) {
                     $this->fieldDefs[$name][$toEscape] = htmlentities($this->fieldDefs[$name][$toEscape], ENT_QUOTES, 'UTF-8');
                 }
             }
             if (isset($this->fieldDefs[$name]['options']) && isset($app_list_strings[$this->fieldDefs[$name]['options']])) {
                 if (isset($GLOBALS['sugar_config']['enable_autocomplete']) && $GLOBALS['sugar_config']['enable_autocomplete'] == true) {
                     $this->fieldDefs[$name]['autocomplete'] = true;
                     $this->fieldDefs[$name]['autocomplete_options'] = $this->fieldDefs[$name]['options'];
                     // we need the name for autocomplete
                 } else {
                     $this->fieldDefs[$name]['autocomplete'] = false;
                 }
                 // Bug 57472 - $this->fieldDefs[$name]['autocomplete_options' was set too late, it didn't retrieve the list's name, but the list itself (the developper comment show us that developper expected to retrieve list's name and not the options array)
                 $this->fieldDefs[$name]['options'] = $app_list_strings[$this->fieldDefs[$name]['options']];
             }
             if (isset($this->fieldDefs[$name]['options']) && is_array($this->fieldDefs[$name]['options']) && isset($this->fieldDefs[$name]['default_empty']) && !isset($this->fieldDefs[$name]['options'][$this->fieldDefs[$name]['default_empty']])) {
                 $this->fieldDefs[$name]['options'] = array_merge(array($this->fieldDefs[$name]['default_empty'] => $this->fieldDefs[$name]['default_empty']), $this->fieldDefs[$name]['options']);
             }
             if (isset($this->fieldDefs[$name]['function'])) {
                 $functionBean = isset($this->fieldDefs[$name]['function_bean']) ? $this->fieldDefs[$name]['function_bean'] : null;
                 $function = $this->fieldDefs[$name]['function'];
                 $functionArgs = array($this->focus, $name, $value, $this->view);
                 // since we are on the old edit view, we need to revert to the old way to get the currency
                 // drop down and not the new fancy way that REST needs to get it.
                 $setValueFormatted = false;
                 if ($function == 'getCurrencies' && $functionBean == 'Currencies') {
                     $function = array('returns' => 'html', 'name' => 'getCurrencyDropDown');
                     $functionBean = array();
                     $setValueFormatted = true;
                 }
                 $value = getFunctionValue($functionBean, $function, $functionArgs);
                 if ($setValueFormatted || !empty($this->fieldDefs[$name]['function']['returns']) && $this->fieldDefs[$name]['function']['returns'] == 'html') {
                     $valueFormatted = true;
                 } else {
                     $this->fieldDefs[$name]['options'] = $value;
                 }
             }
             if (isset($this->fieldDefs[$name]['type']) && $this->fieldDefs[$name]['type'] == 'function' && isset($this->fieldDefs[$name]['function_name'])) {
                 $value = $this->callFunction($this->fieldDefs[$name]);
                 $valueFormatted = true;
             }
             if (!$valueFormatted) {
                 // $this->focus->format_field($this->focus->field_defs[$name]);
                 $value = isset($this->focus->{$name}) ? $this->focus->{$name} : '';
             }
             if (empty($this->fieldDefs[$name]['value'])) {
                 $this->fieldDefs[$name]['value'] = $value;
             }
             //This code is used for QuickCreates that go to Full Form view.  We want to overwrite the values from the bean
             //with values from the request if they are set and either the bean is brand new (such as a create from a subpanels) or the 'full form' button has been clicked
             if (($this->populateBean && empty($this->focus->id) || isset($_REQUEST['full_form'])) && (!isset($this->fieldDefs[$name]['function']['returns']) || $this->fieldDefs[$name]['function']['returns'] != 'html') && isset($_REQUEST[$name])) {
                 $this->fieldDefs[$name]['value'] = $this->getValueFromRequest($_REQUEST, $name);
             }
             /*
              * Populate any relate fields that are linked by a relationship to the calling module.
              * Clicking the create button on a subpanel for example will populate three values in the $_REQUEST:
              * 1. return_module => the name of the calling module
              * 2. return_id => the id of the record in the calling module that the user was viewing and that should be associated with this new record
              * 3. return_name => the display value of the return_id record - the value to show in any relate field in this EditView
              * Only do if this fieldDef does not already have a value; if it does it will have been explicitly set, and that should overrule this less specific mechanism
              */
             if (isset($this->returnModule) && isset($this->returnName) && empty($this->focus->id) && empty($this->fieldDefs['name']['value'])) {
                 if ($this->focus->field_defs[$name]['type'] == 'relate' && isset($this->focus->field_defs[$name]['module']) && $this->focus->field_defs[$name]['module'] == $this->returnModule) {
                     if (isset($this->fieldDefs[$name]['id_name']) && !empty($this->returnRelationship) && isset($this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship']) && $this->returnRelationship == $this->focus->field_defs[$this->fieldDefs[$name]['id_name']]['relationship'] || !empty($this->fieldDefs[$name]['custom_module']) && !empty($this->focus->module_dir) && $this->focus->module_dir == $this->fieldDefs[$name]['custom_module']) {
                         $this->fieldDefs[$name]['value'] = $this->returnName;
                         // set the hidden id field for this relate field to the correct value i.e., return_id
                         $this->fieldDefs[$this->fieldDefs[$name]['id_name']]['value'] = $this->returnId;
                     }
                 }
             }
         }
         $this->focus->ACLFilterFieldList($this->fieldDefs, array(), array("add_acl" => true));
     }
     if (isset($this->focus->additional_meta_fields)) {
         $this->fieldDefs = array_merge($this->fieldDefs, $this->focus->additional_meta_fields);
     }
     if ($this->isDuplicate) {
         foreach ($this->fieldDefs as $name => $defs) {
             if (!empty($defs['auto_increment'])) {
                 $this->fieldDefs[$name]['value'] = '';
             }
         }
     }
 }