function display() { $output = array(); $fields = unencodeMultienum($this->bean->report_vars); foreach ($fields as $field) { if (strpos($field, '.')) { list($module_name, $field_name) = explode('.', $field, 2); if (!isset($output[$module_name])) { $output[$module_name] = array(); } $output[$module_name][$field_name] = Reports_Utils::translateField($field, '', false); } else { $output[$field] = Reports_Utils::translateField($field, $this->bean->report_module); } $html = '<ul>'; //krsort($output); foreach ($output as $key => $field) { if (is_array($field)) { $html .= "<li><b>{$key}</b></li><ul>"; foreach ($field as $rel_key => $rel_field) { $html .= "<li>{$rel_field} <input type='text' size=25 value='[{$key}.{$rel_key}]'></li>"; } $html .= '</ul>'; } else { $html .= "<li>{$field} <input type='text' size=25 value='[{$key}]'></li>"; } } $html .= '</ul>'; } $this->ss->assign('REPORT_VARS_TREE', $html); $this->ss->assign('DOWNLOAD_TEMPLATE_LINK', $this->bean->getStoredFileName()); parent::display(); }
public static function obtenerDatosBean($plantilla_id, $registro) { $data = array(); $plantilla_bean = BeanFactory::getBean('opalo_plantillas', $plantilla_id); $modulo = $plantilla_bean->pariente; $relaciones = unencodeMultienum($plantilla_bean->relaciones); ///CARGA LOS VALORES DEL MODULO if ($bean = BeanFactory::getBean($modulo, $registro)) { foreach ($bean->field_name_map as $id => $garb) { if (!is_array($bean->{$id}) && !is_object($bean->{$id})) { $data[$id] = $bean->{$id}; } } //echo "<pre>", print_r($relaciones),"</pre>"; die(); foreach ($relaciones as $rel) { if ($rel == '') { continue; } $bean->load_relationship($rel); $tmp = $bean->{$rel}; foreach ($tmp->getBeans() as $relBean) { foreach ($relBean->field_name_map as $id => $garb) { if (!is_array($relBean->{$id}) && !is_object($relBean->{$id})) { $data[$rel . "::" . $id] = $relBean->{$id}; } //$data[$id] = $bean->$id; } } } } return $data; }
/** * Smarty modifier to convert multienum separated value to Array * * Type: function<br> * Name: multienum_to_array<br> * Purpose: Utility to transform multienum String to Array format * @author Collin Lee <clee at sugarcrm dot com> * @param string The multienum field's value(s) as a String * @param default The multienum field's default value * @return Array */ function smarty_function_multienum_to_array($params, &$smarty) { $ret = ""; if (empty($params['string'])) { if (empty($params['default'])) { $ret = array(); } else { if (is_array($params['default'])) { $ret = $params['default']; } else { $ret = unencodeMultienum($params['default']); } } } else { if (is_array($params['string'])) { $ret = $params['string']; } else { $ret = unencodeMultienum($params['string']); } } if (!empty($params['assign'])) { $smarty->assign($params['assign'], $ret); return ""; } return $ret; }
function get_xtpl_detail() { $name = $this->name; $value = ''; if (isset($this->bean->{$name})) { $value = $this->bean->{$name}; } else { if (empty($this->bean->id)) { $value = $this->default_value; } } $returnXTPL = array(); if (empty($value)) { return $returnXTPL; } global $app_list_strings; $values = unencodeMultienum($value); $translatedValues = array(); foreach ($values as $val) { $translated = translate($this->options, '', $val); if (is_string($translated)) { $translatedValues[] = $translated; } } $returnXTPL[strtoupper($this->name)] = implode(', ', $translatedValues); return $returnXTPL; }
function get_body(&$ss, $vardef) { $multi = false; $radio = false; if (isset($vardef['type']) && $vardef['type'] == 'multienum') { $multi = true; } $selected_options = ""; if ($multi && !empty($vardef['default'])) { $selected_options = unencodeMultienum($vardef['default']); } else { if (isset($vardef['default'])) { $selected_options = $vardef['default']; } } $edit_mod_strings = return_module_language($GLOBALS['current_language'], 'EditCustomFields'); if (!empty($_REQUEST['type']) && $_REQUEST['type'] == 'radioenum') { $edit_mod_strings['LBL_DROP_DOWN_LIST'] = $edit_mod_strings['LBL_RADIO_FIELDS']; $radio = true; } $my_list_strings = enum_get_lists(); // should not display read only options $excludedOptions = array('Elastic_boost_options'); foreach ($excludedOptions as $options) { if (isset($my_list_strings[$options])) { unset($my_list_strings[$options]); } } $dropdowns = array_keys($my_list_strings); if (!empty($vardef['options']) && !empty($my_list_strings[$vardef['options']])) { $default_dropdowns = $my_list_strings[$vardef['options']]; } else { //since we do not have a default value then we should assign the first one. $key = $dropdowns[0]; $default_dropdowns = $my_list_strings[$key]; } $selected_dropdown = ''; if (!empty($vardef['options'])) { $selected_dropdown = $vardef['options']; } $show = true; if (!empty($_REQUEST['refresh_dropdown'])) { $show = false; } $ss->assign('dropdowns', $dropdowns); $ss->assign('default_dropdowns', $default_dropdowns); $ss->assign('selected_dropdown', $selected_dropdown); $ss->assign('show', $show); $ss->assign('selected_options', $selected_options); $ss->assign('multi', isset($multi) ? $multi : false); $ss->assign('radio', isset($radio) ? $radio : false); $ss->assign('dropdown_name', !empty($vardef['options']) ? $vardef['options'] : ''); require_once 'include/JSON.php'; $json = new JSON(JSON_LOOSE_TYPE); $ss->assign('app_list_strings', "''"); return $ss->fetch('modules/DynamicFields/templates/Fields/Forms/enum.tpl'); }
/** * @param string $record_id ID of Report * @return Reports_Merge */ public function buildReport($record_id) { if (empty($this->id)) { return; } global $beanList; $focus = new Reports_Merge_Utils(); $filename = $this->getStoredFileName(); $officeDocx = $focus->getDocxObject(); $officeDocx->setTemplate($filename); $seed = new $beanList[$this->report_module](); $seed->retrieve($record_id); $field_values = Reports_Utils::define_fields_value($seed, unencodeMultienum($this->report_vars)); unset($seed); $officeDocx->assign($field_values); $officeDocx->createDocument(); return $officeDocx; }
function display() { global $app_list_strings; $this->ev->process(); $modules = Reports_Utils::available_modules(); foreach ($modules as $key => &$val) { if (isset($app_list_strings['moduleList'][$key])) { $val = $app_list_strings['moduleList'][$key]; } } $this->ss->assign('AVAILABLE_MODULES', get_select_options_with_id($modules, $this->bean->report_module)); $options_fields = ''; $fields = unencodeMultienum($this->bean->report_vars); foreach ($fields as $field) { if (empty($field)) { continue; } $options_fields .= '<option value="' . $field . '">' . Reports_Utils::translateField($field, $this->bean->report_module) . '</option>'; } $this->ss->assign('REPORT_FIELDS', $options_fields); echo $this->ev->display($this->showTitle); }
/** * Merge determined bean data into an determined text template, this could be * an email template, expression template, or another type of text with * bean variables in it. * * @global type $beanList * @param type $bean * @param type $template * @param type $component_array * @param type $evaluate * @return type */ public function mergeTemplate($bean, $template, $component_array, $evaluate = false) { global $beanList; $replace_array = array(); $replace_type_array = array(); foreach ($component_array as $module_name => $module_array) { //base module if ($module_name == $bean->module_dir) { foreach ($module_array as $field => $field_array) { if ($field_array['value_type'] == 'href_link') { //Create href link to target record $replacement_value = $this->get_href_link($bean); } if ($field_array['value_type'] == 'future') { if ($evaluate) { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, false, array()); } else { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, false, array()); } } if ($field_array['value_type'] == 'past') { $replacement_value = bpminbox_check_special_fields($field_array['name'], $bean, true, array()); } $replace_type_array[$field_array['original']] = get_bean_field_type($field_array['name'], $bean); $replace_array[$field_array['original']] = implode(', ', unencodeMultienum($replacement_value)); } } else { //Confirm this is an actual module in the beanlist if (isset($beanList[$module_name]) || isset($bean->field_defs[$module_name])) { ///Build the relationship information using the Relationship handler $rel_handler = $bean->call_relationship_handler("module_dir", true); if (isset($bean->field_defs[$module_name])) { $rel_handler->rel1_relationship_name = $bean->field_defs[$module_name]['relationship']; $rel_module = get_rel_module_name($bean->module_dir, $rel_handler->rel1_relationship_name, $bean->db); $rel_handler->rel1_module = $rel_module; $rel_handler->rel1_bean = get_module_info($rel_module); } else { $rel_handler->process_by_rel_bean($module_name); } foreach ($bean->field_defs as $field => $attribute_array) { if (!empty($attribute_array['relationship']) && $attribute_array['relationship'] == $rel_handler->rel1_relationship_name) { $rel_handler->base_vardef_field = $field; break; } } //obtain the rel_module object $rel_list = $rel_handler->build_related_list("base"); if (!empty($rel_list[0])) { $rel_object = $rel_list[0]; $rel_module_present = true; } else { $rel_module_present = false; } foreach ($module_array as $field => $field_array) { if ($rel_module_present == true) { if ($field_array['value_type'] == 'href_link') { //Create href link to target record $replacement_value = $this->get_href_link($rel_object); } else { //use future always for rel because fetched should always be the same $replacement_value = bpminbox_check_special_fields($field_array['name'], $rel_object, false, array()); } } else { $replacement_value = "Invalid Value"; } $replace_array[$field_array['original']] = implode(', ', unencodeMultienum($replacement_value)); } } } } foreach ($replace_array as $name => $replacement_value) { if ($evaluate) { $replacement_value = str_replace("\n", ' ', $replacement_value); $type = $replace_type_array[$name]['type']; $dbtype = $replace_type_array[$name]['db_type']; //TODO evaluate more types even Ids perhaps $this->logger->info("Field : {$name} , type: '{$type}', DBtype: '{$dbtype}'"); if (($dbtype == 'double' || $dbtype == 'int') && $type != 'currency') { $replacement_value = trim($replacement_value); } elseif ($type == 'currency') { //TODO hardcoded . , should use system currency format $replacement_value = str_replace(",", '', $replacement_value); $replacement_value = str_replace(".", ',', $replacement_value); $replacement_value = floatval($replacement_value); } else { //here $replacement_value must be datatime, time, string datatype values $replacement_value = "'" . $replacement_value . "'"; } } else { $replacement_value = nl2br($replacement_value); } $template = str_replace($name, $replacement_value, $template); } return $template; }
$lead1_options = get_select_options_with_id($app_list_strings[$field1_options], unencodeMultienum($lead->{$field1_name})); } else { $lead1_options = get_select_options_with_id($app_list_strings[$field1_options], ''); } if ($field1_required) { $Web_To_Lead_Form_html .= "<td width='15%' style='text-align: left; font-size: 12px; font-weight: normal;'><span sugar='slot'>{$field1_label}</span sugar='slot'><span class='required' style='color: rgb(255, 0, 0);'>{$web_required_symbol}</span></td>"; } else { $Web_To_Lead_Form_html .= "<td width='15%' style='text-align: left; font-size: 12px; font-weight: normal;'><span sugar='slot'>{$field1_label}</span sugar='slot'></td>"; } if (isset($lead->field_defs[$colsSecondField]['isMultiSelect']) && $lead->field_defs[$colsSecondField]['isMultiSelect'] == 1) { $Web_To_Lead_Form_html .= "<td width='35%' style='font-size: 12px; font-weight: normal;'><span sugar='slot'><select id='{$field1_name}' name='{$field1_name}[]' multiple='true' tabindex='1'>{$lead1_options}</select></span sugar='slot'></td>"; } elseif (ifRadioButton($lead->field_defs[$colsSecondField]['name'])) { $Web_To_Lead_Form_html .= "<td width='35%' style='font-size: 12px; font-weight: normal;'><span sugar='slot'>"; foreach ($app_list_strings[$field1_options] as $field_option_key => $field_option) { if ($field_option != null) { if (!empty($lead->{$field1_name}) && in_array($field_option_key, unencodeMultienum($lead->{$field1_name}))) { $Web_To_Lead_Form_html .= "<input id='{$colsSecondField}" . "_{$field_option_key}' checked name='{$colsSecondField}' value='{$field_option_key}' type='radio'>"; } else { $Web_To_Lead_Form_html .= "<input id='{$colsSecondField}" . "_{$field_option_key}' name='{$colsSecondField}' value='{$field_option_key}' type='radio'>"; } $Web_To_Lead_Form_html .= "<span ='document.getElementById('" . $lead->field_defs[$colsSecondField] . "_{$field_option_key}').checked =true style='cursor:default'; onmousedown='return false;'>{$field_option}</span><br>"; } } $Web_To_Lead_Form_html .= "</span sugar='slot'></td>"; } else { $Web_To_Lead_Form_html .= "<td width='35%' style='font-size: 12px; font-weight: normal;'><span sugar='slot'><select id={$field1_name} name={$field1_name} tabindex='1'>{$lead1_options}</select></span sugar='slot'></td>"; } } if ($field1_type == 'bool') { if ($field1_required) { $Web_To_Lead_Form_html .= "<td width='15%' style='text-align: left; font-size: 12px; font-weight: normal;'><span sugar='slot'>{$field1_label}</span sugar='slot'><span class='required' style='color: rgb(255, 0, 0);'>{$web_required_symbol}</span></td>";
/** * Use the condition statements and processed table to build query to retrieve beans to be actioned */ function get_flow_beans() { global $beanList, $app_list_strings, $sugar_config; if ($beanList[$this->flow_module]) { $module = new $beanList[$this->flow_module](); $where = ''; $sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '" . $this->id . "' AND deleted = 0 ORDER BY condition_order ASC"; $result = $this->db->query($sql); while ($row = $this->db->fetchByAssoc($result)) { $condition = new AOW_Condition(); $condition->retrieve($row['id']); if (isset($app_list_strings['aow_sql_operator_list'][$condition->operator])) { $where_set = false; if ($where != '') { $where .= ' AND '; } $data = $module->field_defs[$condition->field]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->field = $data['id_name']; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $field = $module->table_name . '_cstm.' . $condition->field; } else { $field = $module->table_name . '.' . $condition->field; } switch ($condition->value_type) { case 'Field': $data = $module->field_defs[$condition->value]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->value = $data['id_name']; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $module->table_name . '_cstm.' . $condition->value; } else { $value = $module->table_name . '.' . $condition->value; } break; case 'Date': $params = unserialize(base64_decode($condition->value)); if ($params[0] == 'now') { if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = 'GetDate()'; } else { $value = 'NOW()'; } } else { $data = $module->field_defs[$params[0]]; if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $module->table_name . '_cstm.' . $params[0]; } else { $value = $module->table_name . '.' . $params[0]; } } if ($params[1] != 'now') { switch ($params[3]) { case 'business_hours': //business hours not implemented for query, default to hours $params[3] = 'hours'; default: if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aow_date_operator'][$params[1]] . " {$params['2']}, {$value})"; } else { $value = "DATE_ADD({$value}, INTERVAL " . $app_list_strings['aow_date_operator'][$params[1]] . " {$params['2']} " . $params[3] . ")"; } break; } } break; case 'Multi': $sep = ' AND '; if ($condition->operator == 'Equal_To') { $sep = ' OR '; } $multi_values = unencodeMultienum($condition->value); if (!empty($multi_values)) { $value = '('; foreach ($multi_values as $multi_value) { if ($value != '(') { $value .= $sep; } $value .= $field . ' ' . $app_list_strings['aow_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; } $value .= ')'; } $where .= $value; $where_set = true; break; case 'Value': default: $value = "'" . $condition->value . "'"; break; } if (!$where_set) { $where .= $field . ' ' . $app_list_strings['aow_sql_operator_list'][$condition->operator] . ' ' . $value; } } } if (!$this->multiple_runs) { if ($where != '') { $where .= ' AND '; } $where .= "NOT EXISTS (SELECT * FROM aow_processed WHERE aow_processed.aow_workflow_id='" . $this->id . "' AND aow_processed.parent_id=" . $module->table_name . ".id AND aow_processed.status = 'Complete' AND aow_processed.deleted = 0)"; } $query = $module->create_new_list_query('', $where, array(), array(), 0, '', false, $this); return $module->process_full_list_query($query); } return null; }
function get_body(&$ss, $vardef) { $multi = false; $radio = false; if (isset($vardef['type']) && $vardef['type'] == 'multienum') { $multi = true; } $selected_options = ""; if ($multi && !empty($vardef['default'])) { $selected_options = unencodeMultienum($vardef['default']); } else { if (isset($vardef['default'])) { $selected_options = $vardef['default']; } } $edit_mod_strings = return_module_language($GLOBALS['current_language'], 'EditCustomFields'); if (!empty($_REQUEST['type']) && $_REQUEST['type'] == 'radioenum') { $edit_mod_strings['LBL_DROP_DOWN_LIST'] = $edit_mod_strings['LBL_RADIO_FIELDS']; $radio = true; } $package_strings = array(); if (!empty($_REQUEST['view_package'])) { $view_package = $_REQUEST['view_package']; if ($view_package != 'studio') { require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($view_package, $_REQUEST['view_module']); $lang = $GLOBALS['current_language']; //require_once($package->getPackageDir()."/include/language/$lang.lang.php"); $module->mblanguage->generateAppStrings(false); $package_strings = $module->mblanguage->appListStrings[$lang . '.lang.php']; } } global $app_list_strings; $my_list_strings = $app_list_strings; $my_list_strings = array_merge($my_list_strings, $package_strings); foreach ($my_list_strings as $key => $value) { if (!is_array($value)) { unset($my_list_strings[$key]); } } $dropdowns = array_keys($my_list_strings); sort($dropdowns); $default_dropdowns = array(); if (!empty($vardef['options']) && !empty($my_list_strings[$vardef['options']])) { $default_dropdowns = $my_list_strings[$vardef['options']]; } else { //since we do not have a default value then we should assign the first one. $key = $dropdowns[0]; $default_dropdowns = $my_list_strings[$key]; } $selected_dropdown = ''; if (!empty($vardef['options'])) { $selected_dropdown = $vardef['options']; } $show = true; if (!empty($_REQUEST['refresh_dropdown'])) { $show = false; } $ss->assign('dropdowns', $dropdowns); $ss->assign('default_dropdowns', $default_dropdowns); $ss->assign('selected_dropdown', $selected_dropdown); $ss->assign('show', $show); $ss->assign('selected_options', $selected_options); $ss->assign('multi', isset($multi) ? $multi : false); $ss->assign('radio', isset($radio) ? $radio : false); $ss->assign('dropdown_name', !empty($vardef['options']) ? $vardef['options'] : ''); require_once 'include/JSON.php'; $json = new JSON(JSON_LOOSE_TYPE); $ss->assign('app_list_strings', "''"); return $ss->fetch('custom/modules/DynamicFields/templates/Fields/Forms/dynamicenum.tpl'); }
function parse_template_bean($string, $key, &$focus) { global $app_strings; $repl_arr = array(); foreach ($focus->field_defs as $field_def) { if ($field_def['type'] == 'currency') { $repl_arr[$key . "_" . $field_def['name']] = currency_format_number($focus->{$field_def}['name'], $params = array('currency_symbol' => false)); } else { if ($field_def['type'] == 'enum' && isset($field_def['options'])) { $repl_arr[$key . "_" . $field_def['name']] = translate($field_def['options'], $focus->module_dir, $focus->{$field_def}['name']); } else { if ($field_def['type'] == 'multienum' && isset($field_def['options'])) { $repl_arr[$key . "_" . $field_def['name']] = implode(', ', unencodeMultienum($focus->{$field_def}['name'])); } else { $repl_arr[$key . "_" . $field_def['name']] = $focus->{$field_def}['name']; } } } } // end foreach() krsort($repl_arr); reset($repl_arr); foreach ($repl_arr as $name => $value) { if (strpos($name, 'product_discount') > 0) { if ($value != '' && $value != '0.00') { if ($repl_arr['aos_products_quotes_discount'] == 'Percentage') { $sep = get_number_seperators(); $value = rtrim(rtrim(format_number($value), '0'), $sep[1]); //.$app_strings['LBL_PERCENTAGE_SYMBOL']; } else { $value = currency_format_number($value, $params = array('currency_symbol' => false)); } } else { $value = ''; } } if ($name === 'aos_products_product_image') { $value = '<img src="' . $value . '"width="50" height="50"/>'; } if ($name === 'aos_products_quotes_product_qty') { $sep = get_number_seperators(); $value = rtrim(rtrim(format_number($value), '0'), $sep[1]); } if ($name === 'aos_products_quotes_vat' || strpos($name, 'pct') > 0 || strpos($name, 'percent') > 0 || strpos($name, 'percentage') > 0) { $sep = get_number_seperators(); $value = rtrim(rtrim(format_number($value), '0'), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL']; } if (strpos($name, 'date') > 0 || strpos($name, 'expiration') > 0) { if ($value != '') { $dt = explode(' ', $value); $value = $dt[0]; } } if ($value != '' && is_string($value)) { $string = str_replace("\${$name}", $value, $string); } else { if (strpos($name, 'address') > 0) { $string = str_replace("\${$name}<br />", '', $string); $string = str_replace("\${$name} <br />", '', $string); $string = str_replace("\${$name}", '', $string); } else { $string = str_replace("\${$name}", ' ', $string); } } } return $string; }
/** * @Deprecated */ public function get_audit_list() { global $focus, $genericAssocFieldsArray, $moduleAssocFieldsArray, $current_user, $timedate, $app_strings; $audit_list = array(); if (!empty($_REQUEST['record'])) { $result = $focus->retrieve($_REQUEST['record']); if ($result == null || !$focus->ACLAccess('', $focus->isOwner($current_user->id))) { sugar_die($app_strings['ERROR_NO_RECORD']); } } if ($focus->is_AuditEnabled()) { $order = ' order by ' . $focus->get_audit_table_name() . '.date_created desc'; //order by contacts_audit.date_created desc $query = "SELECT " . $focus->get_audit_table_name() . ".*, users.user_name FROM " . $focus->get_audit_table_name() . ", users WHERE " . $focus->get_audit_table_name() . ".created_by = users.id AND " . $focus->get_audit_table_name() . ".parent_id = '{$focus->id}'" . $order; $result = $focus->db->query($query); // We have some data. require 'metadata/audit_templateMetaData.php'; $fieldDefs = $dictionary['audit']['fields']; while (($row = $focus->db->fetchByAssoc($result)) != null) { if (!ACLField::hasAccess($row['field_name'], $focus->module_dir, $GLOBALS['current_user']->id, $focus->isOwner($GLOBALS['current_user']->id))) { continue; } //If the team_set_id field has a log entry, we retrieve the list of teams to display if ($row['field_name'] == 'team_set_id') { $row['field_name'] = 'team_name'; require_once 'modules/Teams/TeamSetManager.php'; $row['before_value_string'] = TeamSetManager::getCommaDelimitedTeams($row['before_value_string']); $row['after_value_string'] = TeamSetManager::getCommaDelimitedTeams($row['after_value_string']); } $temp_list = array(); foreach ($fieldDefs as $field) { if (array_key_exists($field['name'], $row)) { if (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && (array_key_exists($row['field_name'], $genericAssocFieldsArray) || !empty($moduleAssocFieldsArray[$focus->object_name]) && array_key_exists($row['field_name'], $moduleAssocFieldsArray[$focus->object_name]))) { $temp_list[$field['name']] = Audit::getAssociatedFieldName($row['field_name'], $row[$field['name']]); } else { $temp_list[$field['name']] = $row[$field['name']]; } if ($field['name'] == 'date_created') { $date_created = ''; if (!empty($temp_list[$field['name']])) { $date_created = $timedate->to_display_date_time($temp_list[$field['name']]); $date_created = !empty($date_created) ? $date_created : $temp_list[$field['name']]; } $temp_list[$field['name']] = $date_created; } if (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && ($row['data_type'] == "enum" || $row['data_type'] == "multienum")) { global $app_list_strings; $enum_keys = unencodeMultienum($temp_list[$field['name']]); $enum_values = array(); foreach ($enum_keys as $enum_key) { if (isset($focus->field_defs[$row['field_name']]['options'])) { $domain = $focus->field_defs[$row['field_name']]['options']; if (isset($app_list_strings[$domain][$enum_key])) { $enum_values[] = $app_list_strings[$domain][$enum_key]; } } } if (!empty($enum_values)) { $temp_list[$field['name']] = implode(', ', $enum_values); } if ($temp_list['data_type'] === 'date') { $temp_list[$field['name']] = $timedate->to_display_date($temp_list[$field['name']], false); } } elseif (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && $row['data_type'] == "datetimecombo") { if (!empty($temp_list[$field['name']]) && $temp_list[$field['name']] != 'NULL') { $temp_list[$field['name']] = $timedate->to_display_date_time($temp_list[$field['name']]); } else { $temp_list[$field['name']] = ''; } } elseif ($field['name'] == 'field_name') { global $mod_strings; if (isset($focus->field_defs[$row['field_name']]['vname'])) { $label = $focus->field_defs[$row['field_name']]['vname']; $temp_list[$field['name']] = translate($label, $focus->module_dir); } } } } $temp_list['created_by'] = $row['user_name']; $audit_list[] = $temp_list; } } return $audit_list; }
function decodeMultienumField($field) { return implode(', ', unencodeMultienum($field)); }
function get_field_output(&$temp_module, $selector_array, $meta_array, $actions = false) { global $current_language; global $app_list_strings; global $app_strings; global $mod_strings; $enum_multi = $meta_array['enum_multi']; $temp_module_strings = return_module_language($current_language, $temp_module->module_dir); $all_fields_array = $temp_module->getFieldDefinitions(); $target_field_array = $all_fields_array[$selector_array['field']]; if (!empty($target_field_array['vname'])) { $target_vname = $target_field_array['vname']; } else { $target_vname = ""; } $label_name = get_label($target_vname, $temp_module_strings); $field_type = get_field_type($target_field_array); $field_name = $target_field_array['name']; //////Determine if this is called from an existing record or new and if it is enum multi if ($selector_array['target_field'] == $field_name) { if (($selector_array['operator'] == "in" || $selector_array['operator'] == "not_in") && $selector_array['target_field'] == $field_name || isset($target_field_array['isMultiSelect']) && $target_field_array['isMultiSelect'] == true) { $selected_value = unencodeMultienum($selector_array['value']); $selected_operator = $selector_array['operator']; $selected_time = $selector_array['time']; } else { $selected_value = $selector_array['value']; $selected_operator = $selector_array['operator']; $selected_time = $selector_array['time']; } //Handle Advanced Actions Type if ($actions == true) { $selected_ext1 = $selector_array['ext1']; $selected_ext2 = $selector_array['ext2']; $selected_ext3 = $selector_array['ext3']; } } else { $selected_value = ""; $selected_operator = ""; $selected_time = ""; //Handle Advanced Actions Type if ($actions == true) { $selected_ext1 = ""; $selected_ext2 = ""; $selected_ext3 = ""; } } /////////////////////////////////////////////////////////// //Get output array and return it ////////////////////////////////////////////////////////// $output_array = array(); if ($actions == true) { $output_array['ext1']['display'] = ""; $output_array['ext2']['display'] = ""; $output_array['ext3']['display'] = ""; } if (!empty($field_type)) { /* One off check to see if this is duration_hours or duration_minutes These two fields really should be enum, but they are chars. This is a problem, since the UI for calls is really enum in 15 minute increments */ $sorted_fields = array(); if ($selector_array['target_field'] == "duration_minutes") { $target_field_array['options'] = "duration_intervals"; $field_type = "enum"; //if the module is calls, then populate sorted_fields array with minute values if (get_class($temp_module) == 'Call' && isset($temp_module->minutes_values)) { $target_field_array['function'] = ''; $sorted_fields = $temp_module->minutes_values; } //end if target_field is duration_minutes or duration_hours } //Checking reminder time in meetings and calls if ($selector_array['target_field'] == "reminder_time") { $target_field_array['options'] = "reminder_time_options"; $field_type = "enum"; //end if target_field is reminder_time } // currency_id field should be enum if ($field_type == 'currency_id') { $target_field_array['function'] = 'getCurrencyDropDownList'; $field_type = "enum"; } if ($field_type == "enum" || $field_type == "multienum" || $field_type == "radioenum") { $output_array['real_type'] = $field_type; //check for multi_select and that this is the same dropdown as previous; //Set the value select if (!empty($target_field_array['function'])) { $function = $target_field_array['function']; if (is_array($function) && isset($function['name'])) { $function = $target_field_array['function']['name']; } else { $function = $target_field_array['function']; } if (!empty($target_field_array['function']['returns']) && $target_field_array['function']['returns'] == 'html') { if (!empty($target_field_array['function']['include'])) { require_once $target_field_array['function']['include']; } } if (isset($target_field_array['function_bean'])) { $funcBean = BeanFactory::getBean($target_field_array['function_bean']); if (method_exists($funcBean, $function)) { $function = array($funcBean, $function); } } $sorted_fields = call_user_func($function); } else { //get list of strings if sorted fields has not already been populated if (count($sorted_fields) == 0) { $sorted_fields = $app_list_strings[$target_field_array['options']]; } } if (isset($sorted_fields)) { asort($sorted_fields); } $column_select = get_select_options_with_id($sorted_fields, $selected_value); //if(!empty($target_field_array['isMultiSelect']) && $target_field_array['isMultiSelect'] == true){ // $selected_operator = "in"; // $enum_multi = true; //} $isMultiSelect = false; $value_select = "<select id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "_field_value' tabindex='2'>" . $column_select . "</select>"; if ($enum_multi === true) { $value_select .= " <select id='" . $meta_array['parent_type'] . "__field_value_multi' tabindex='1' name='" . $meta_array['parent_type'] . "__field_value_multi[]' multiple size='5'>" . $column_select . "</select>"; } else { if (!empty($target_field_array['isMultiSelect']) && $target_field_array['isMultiSelect'] == true) { //$value_select = "<select id='".$meta_array['parent_type']."__field_value' name='".$meta_array['parent_type']."_field_value[]' tabindex='2' multiple size='5'>".$column_select."</select>"; $value_select = " <select id='" . $meta_array['parent_type'] . "__field_value_multi' tabindex='1' name='" . $meta_array['parent_type'] . "__field_value_multi[]' multiple size='5'>" . $column_select . "</select>"; $isMultiSelect = true; } } $output_array['value_select']['display'] = $value_select; //Set the Operator variables if ($enum_multi === true) { $operator_select_javascript = "onchange=\"toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals');\""; $javascript_start = "toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals'); \n"; } else { $operator_select_javascript = ""; $javascript_start = ""; } if ($enum_multi === true) { $operator = get_select_options_with_id($app_list_strings['mselect_type_dom'], $selected_operator); } else { if ($isMultiSelect) { $operator = get_select_options_with_id($app_list_strings['mselect_multi_type_dom'], $selected_operator); } else { $operator = get_select_options_with_id($app_list_strings['cselect_type_dom'], $selected_operator); } } $output_array['operator']['display'] = $operator; $output_array['operator']['jscript'] = $operator_select_javascript; $output_array['operator']['jscriptstart'] = $javascript_start; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; if ($actions == true) { $ext1_select = get_select_options_with_id($app_list_strings['wflow_adv_enum_type_dom'], $selected_ext1); $ext1_select = "<select id='" . $meta_array['parent_type'] . "__ext1' id='" . $meta_array['parent_type'] . "__ext1' tabindex='2'>" . $ext1_select . "</select>"; $output_array['adv_value']['display'] = $ext1_select; $value_select = " <input id='" . $meta_array['parent_type'] . "__adv_value' name='" . $meta_array['parent_type'] . "__adv_value' tabindex='1' size='2' maxlength='2' type='text' value='" . $selected_value . "'> step(s)"; $adv_select = $value_select; $output_array['adv_value']['display'] .= $adv_select; $output_array['adv_type']['display'] = "enum_step"; //exception handler for some advanced options not valid if this is a new record if (!empty($meta_array['action_type'])) { if ($meta_array['action_type'] == "new" || $meta_array['action_type'] == "new_rel") { $output_array['set_type']['disabled'] = "Disabled"; } } } //end type enum } if ($field_type == "char" || $field_type == "varchar" || $field_type == "encrypt" || $field_type == "name" || $field_type == "phone" || $field_type == "email" || $field_type == "url") { $output_array['real_type'] = $field_type; if (!empty($target_field_array['len'])) { $max_length = $target_field_array['len']; } else { $max_length = "50"; } $value_select = "<input id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "__field_value' tabindex='1' size='25' maxlength='" . $max_length . "' type='text' value='" . $selected_value . "'>"; $output_array['value_select']['display'] = $value_select; $operator = get_select_options_with_id($app_list_strings['cselect_type_dom'], $selected_operator); $output_array['operator']['display'] = $operator; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; $output_array['operator']['jscript'] = ""; $output_array['operator']['jscriptstart'] = ""; $output_array['set_type']['disabled'] = "Disabled"; if ($actions == true) { $output_array['adv_type']['display'] = ""; $output_array['adv_value']['display'] = ""; } //end if type char, varchar, or float } if ($field_type == "text") { $output_array['real_type'] = $field_type; $value_select = "<textarea id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "__field_value' tabindex='1' cols=\"40\" rows=\"3\">" . $selected_value . "</textarea>"; //$value_select = "<input id='".$meta_array['parent_type']."__field_value' name='".$meta_array['parent_type']."__field_value' tabindex='1' size='25' maxlength='".$max_length."' type='text' value='".$selected_value."'>"; $output_array['value_select']['display'] = $value_select; $operator = get_select_options_with_id($app_list_strings['cselect_type_dom'], $selected_operator); $output_array['operator']['display'] = $operator; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; $output_array['operator']['jscript'] = ""; $output_array['operator']['jscriptstart'] = ""; $output_array['set_type']['disabled'] = "Disabled"; if ($actions == true) { $output_array['adv_type']['display'] = ""; $output_array['adv_value']['display'] = ""; } //end field_type == text } if ($field_type == "datetimecombo" || $field_type == "datetime" || $field_type == "date" || $field_type == "time") { //coming here via actions or triggers? if ($actions == true) { $column_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_value); $value_select = "<select id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "_field_value' tabindex='2'>" . $column_select . "</select>"; //current date or existing //check if this is action new or new_rel and if so, remove the Existing Value optino //since it is not applicable $temp_dom = $app_list_strings['wflow_action_datetime_type_dom']; if ($meta_array['action_type'] == "new" || $meta_array['action_type'] == "new_rel") { unset($temp_dom['Existing Value']); } $ext1_select = get_select_options_with_id($temp_dom, $selected_ext1); $ext1_select = " from <select id='" . $meta_array['parent_type'] . "__ext1' id='" . $meta_array['parent_type'] . "__ext1' tabindex='2'>" . $ext1_select . "</select>"; $value_select .= $ext1_select; $output_array['value_select']['display'] = $value_select; $output_array['set_type']['disabled'] = "Disabled"; $output_array['adv_type']['display'] = "datetime"; $output_array['adv_value']['display'] = ""; $output_array['real_type'] = $field_type; } else { $operator = get_select_options_with_id($app_list_strings['dtselect_type_dom'], $selected_operator); $output_array['operator']['display'] = $operator; $operator_select_javascript = "onchange=\"toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__time_past', '" . $meta_array['parent_type'] . "__time_future', 'More Than');\""; $javascript_start = "toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__time_past', '" . $meta_array['parent_type'] . "__time_future', 'More Than'); \n"; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = "<select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select> "; $output_array['time_select']['display'] .= "<span id='" . $meta_array['parent_type'] . "__time_past'>" . $mod_strings['LBL_TIME_PAST'] . "</span>"; $output_array['time_select']['display'] .= "<span id='" . $meta_array['parent_type'] . "__time_future'>" . $mod_strings['LBL_TIME_FUTURE'] . "</span>"; $output_array['operator']['jscript'] = $operator_select_javascript; $output_array['operator']['jscriptstart'] = $javascript_start; $output_array['set_type']['disabled'] = "Disabled"; $output_array['value_select']['display'] = ""; $output_array['real_type'] = $field_type; } //end if type datetime } if ($field_type == "assigned_user_name" || $field_name == 'assigned_user_id') { //Real type is just a surface variable used by javascript to determine dual type actions //in the javascript $output_array['real_type'] = "enum"; //check for multi_select and that this is the same dropdown as previous; //Set the value select $user_array = get_user_array(TRUE, "Active", "", true, null, ' AND is_group=0 '); //$column_select = get_select_options_with_id($app_list_strings[$target_field_array['options']], $selected_value); $column_select = get_select_options_with_id($user_array, $selected_value); $value_select = "<select id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "_field_value' tabindex='2'>" . $column_select . "</select>"; if ($enum_multi === true) { $value_select .= " <select id='" . $meta_array['parent_type'] . "__field_value_multi' tabindex='1' name='" . $meta_array['parent_type'] . "__field_value_multi[]' multiple size='5'>" . $column_select . "</select>"; } $output_array['value_select']['display'] = $value_select; //Set the Operator variables if ($enum_multi === true) { $operator_select_javascript = "onchange=\"toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals');\""; $javascript_start = "toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals'); \n"; } else { $operator_select_javascript = ""; $javascript_start = ""; } if ($enum_multi === true) { $operator = get_select_options_with_id($app_list_strings['mselect_type_dom'], $selected_operator); } else { $operator = get_select_options_with_id($app_list_strings['cselect_type_dom'], $selected_operator); } $output_array['operator']['display'] = $operator; $output_array['operator']['jscript'] = $operator_select_javascript; $output_array['operator']['jscriptstart'] = $javascript_start; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; ///If we are coming here for actions if ($actions == true) { ////This below is an exception handler flow statement //if this is time based, then don't include the logged in user, since it doesn't really apply if (!empty($meta_array['workflow_type']) && $meta_array['workflow_type'] == "Time") { $adv_user_array = $app_list_strings['wflow_adv_user_type_dom']; unset($adv_user_array['current_user']); //end if this is a time based object } else { $adv_user_array = $app_list_strings['wflow_adv_user_type_dom']; } $adv_select = get_select_options_with_id($adv_user_array, $selected_value); $adv_select = "<select id='" . $meta_array['parent_type'] . "__adv_value' id='" . $meta_array['parent_type'] . "__adv_value' tabindex='2'>" . $adv_select . "</select>"; $output_array['adv_value']['display'] = $adv_select; $ext1_select = get_select_options_with_id($app_list_strings['wflow_relate_type_dom'], $selected_ext1); $ext1_select = " <select id='" . $meta_array['parent_type'] . "__ext1' id='" . $meta_array['parent_type'] . "__ext1' tabindex='2'>" . $ext1_select . "</select>"; $output_array['adv_value']['display'] .= $ext1_select; $output_array['adv_type']['display'] = "exist_user"; } //end if type assigned_user_id } if ($field_type == "team_list") { //Real type is just a surface variable used by javascript to determine dual type actions //in the javascript $output_array['real_type'] = "enum"; //check for multi_select and that this is the same dropdown as previous; //Set the value select $column_select = get_select_options_with_id(get_team_array(), $selected_value); $value_select = "<select id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "_field_value' tabindex='2'>" . $column_select . "</select>"; if ($enum_multi === true) { $value_select .= " <select id='" . $meta_array['parent_type'] . "__field_value_multi' tabindex='1' name='" . $meta_array['parent_type'] . "__field_value_multi[]' multiple size='5'>" . $column_select . "</select>"; } $output_array['value_select']['display'] = $value_select; //Set the Operator variables if ($enum_multi === true) { $operator_select_javascript = "onchange=\"toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals');\""; $javascript_start = "toggleFieldDisplay('" . $meta_array['parent_type'] . "__operator', '" . $meta_array['parent_type'] . "__field_value', '" . $meta_array['parent_type'] . "__field_value_multi', 'Equals'); \n"; } else { $operator_select_javascript = ""; $javascript_start = ""; } if ($enum_multi === true) { $operator = get_select_options_with_id($app_list_strings['mselect_type_dom'], $selected_operator); } else { $operator = get_select_options_with_id($app_list_strings['cselect_type_dom'], $selected_operator); } $output_array['operator']['display'] = $operator; $output_array['operator']['jscript'] = $operator_select_javascript; $output_array['operator']['jscriptstart'] = $javascript_start; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; //if we are coming here to get actions if ($actions == true) { //exception handler. if the workflow type is time, then don't allow logged in user's team to be picked if (!empty($meta_array['workflow_type']) && $meta_array['workflow_type'] == "Time") { $adv_team_array = $app_list_strings['wflow_adv_team_type_dom']; unset($adv_team_array['current_team']); //end if this is a time based object } else { $adv_team_array = $app_list_strings['wflow_adv_team_type_dom']; } $adv_select = get_select_options_with_id($adv_team_array, $selected_value); $adv_select = "<select id='" . $meta_array['parent_type'] . "__adv_value' id='" . $meta_array['parent_type'] . "__adv_value' tabindex='2'>" . $adv_select . "</select>"; $output_array['adv_value']['display'] = $adv_select; $output_array['adv_type']['display'] = "exist_team"; } //end if type team_list } if ($field_type == "bool") { //Real type is just a surface variable used by javascript to determine dual type actions //in the javascript $output_array['real_type'] = $field_type; $column_select = get_select_options_with_id($app_list_strings['bselect_type_dom'], $selected_value); $value_select = "<select id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "__field_value' tabindex='2'>" . $column_select . "</select>"; $output_array['value_select']['display'] = $value_select; $operator = get_select_options_with_id($app_list_strings['bopselect_type_dom'], $selected_operator); $output_array['operator']['display'] = $operator; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; $output_array['operator']['jscript'] = ""; $output_array['operator']['jscriptstart'] = ""; $output_array['set_type']['disabled'] = "Disabled"; if ($actions == true) { $output_array['adv_type']['display'] = ""; $output_array['adv_value']['display'] = ""; } //end if type datetime } if ($field_type == "float" || $field_type == "int" || $field_type == "num" || $field_type == "decimal" || $field_type == "double" || $field_type == "currency") { //Real type is just a surface variable used by javascript to determine dual type actions //in the javascript $output_array['real_type'] = $field_type; if ($field_type == "int") { $length = 11; } else { $length = 25; } $value_select = "<input id='" . $meta_array['parent_type'] . "__field_value' name='" . $meta_array['parent_type'] . "__field_value' tabindex='1' size='" . $length . "' maxlength='" . $length . "' type='text' value='" . $selected_value . "'>"; $output_array['value_select']['display'] = $value_select; $operator = get_select_options_with_id($app_list_strings['dselect_type_dom'], $selected_operator); $output_array['operator']['display'] = $operator; $time_select = get_select_options_with_id($app_list_strings['tselect_type_dom'], $selected_time); $output_array['time_select']['display'] = $mod_strings['LBL_TIME_INT'] . " <select id='time_int' name='time_int' tabindex='2'>" . $time_select . "</select>"; $output_array['operator']['jscript'] = ""; $output_array['operator']['jscriptstart'] = ""; ///If we are coming here for actions if ($actions == true) { $ext1_select = get_select_options_with_id($app_list_strings['query_calc_oper_dom'], $selected_ext1); $ext1_select = "existing value <select id='" . $meta_array['parent_type'] . "__ext1' id='" . $meta_array['parent_type'] . "__ext1' tabindex='2'>" . $ext1_select . "</select>"; $output_array['adv_value']['display'] = $ext1_select; $value_select = " <input id='" . $meta_array['parent_type'] . "__adv_value' name='" . $meta_array['parent_type'] . "__adv_value' tabindex='1' size='5' maxlength='5' type='text' value='" . $selected_value . "'>"; $adv_select = $value_select; $output_array['adv_value']['display'] .= $adv_select; $output_array['adv_type']['display'] = "value_calc"; //exception handler for some advanced options not valid if this is a new record if (!empty($meta_array['action_type'])) { if ($meta_array['action_type'] == "new" || $meta_array['action_type'] == "new_rel") { $output_array['set_type']['disabled'] = "Disabled"; } } //end if actions is true } //end if type float } //end if type is set } $output_array['type'] = $field_type; $output_array['name'] = $label_name; return $output_array; //end function get_output_array }
public function getDocumentForBean(SugarBean $bean) { if ($bean->module_name == 'DocumentRevisions') { $document = $this->getDocumentForRevision($bean); } else { $document = array("error" => false, "document" => new Zend_Search_Lucene_Document()); } if ($document["error"]) { return $document; } $document["document"]->addField(Zend_Search_Lucene_Field::UnIndexed("aod_id", $bean->module_name . " " . $bean->id)); $document["document"]->addField(Zend_Search_Lucene_Field::UnIndexed("record_id", $bean->id)); $document["document"]->addField(Zend_Search_Lucene_Field::UnIndexed("record_module", $bean->module_name)); foreach ($GLOBALS['dictionary'][$bean->getObjectName()]['fields'] as $key => $field) { switch ($field['type']) { case "enum": $document["document"]->addField(Zend_Search_Lucene_Field::Keyword($key, strtolower($bean->{$key}))); break; case "multienum": $vals = unencodeMultienum($bean->{$field}); $document["document"]->addField(Zend_Search_Lucene_Field::unStored($key, strtolower(implode(" ", $vals)))); break; case "name": case "phone": case "html": case "text": case "url": case "varchar": if (property_exists($bean, $key)) { $val = strtolower($bean->{$key}); } else { $val = ''; } $field = Zend_Search_Lucene_Field::unStored($key, $val); if ($key == "name") { $field->boost = 1.5; } $document["document"]->addField($field); break; case "address": case "bool": case "currency": case "date": case "datetimecombo": case "decimal": case "float": case "iframe": case "int": case "radioenum": case "relate": default: break; } } return $document; }
/** * Format a multienum field * * @param string $rawField The multienum field to be formatted * @param array $vardef The field vardef * @return string the formatted multienum field */ public function formatField($rawField, $vardef) { global $app_list_strings; if (!empty($vardef['options'])) { $option_array_name = $vardef['options']; $selectedKeys = unencodeMultienum($rawField); $values = array(); foreach ($selectedKeys as $selected) { if (!empty($app_list_strings[$option_array_name][$selected])) { $values[] = $app_list_strings[$option_array_name][$selected]; } else { $values[] = $selected; } } return implode(", ", $values); } else { return decodeMultienumField($rawField); } }
/** * Enter description here... * * @param String $session -- Session ID returned by a previous call to login. * @param unknown_type $file_name * @param unknown_type $fields * @return unknown */ function get_mailmerge_document2($session, $file_name, $fields) { global $beanList, $beanFiles, $app_list_strings, $app_strings; $error = new SoapError(); if (!validate_authenticated($session)) { $GLOBALS['log']->error('invalid_login'); $error->set_error('invalid_login'); return array('result' => '', 'error' => $error->get_soap_array()); } if (!preg_match('/^sugardata[\\.\\d\\s]+\\.php$/', $file_name)) { $GLOBALS['log']->error($app_strings['ERR_NO_SUCH_FILE'] . " ({$file_name})"); $error->set_error('no_records'); return array('result' => '', 'error' => $error->get_soap_array()); } $html = ''; $file_name = sugar_cached('MergedDocuments/') . pathinfo($file_name, PATHINFO_BASENAME); $master_fields = array(); $related_fields = array(); if (file_exists($file_name)) { include $file_name; $class1 = $merge_array['master_module']; $beanL = $beanList[$class1]; $bean1 = $beanFiles[$beanL]; require_once $bean1; $seed1 = new $beanL(); if (!empty($merge_array['related_module'])) { $class2 = $merge_array['related_module']; $beanR = $beanList[$class2]; $bean2 = $beanFiles[$beanR]; require_once $bean2; $seed2 = new $beanR(); } //parse fields //$token1 = strtolower($class1); if ($class1 == 'Prospects') { $class1 = 'CampaignProspects'; } foreach ($fields as $field) { $pos = strpos(strtolower($field), strtolower($class1)); $pos2 = strpos(strtolower($field), strtolower($class2)); if ($pos !== false) { $fieldName = str_replace(strtolower($class1) . '_', '', strtolower($field)); array_push($master_fields, $fieldName); } else { if ($pos2 !== false) { $fieldName = str_replace(strtolower($class2) . '_', '', strtolower($field)); array_push($related_fields, $fieldName); } } } $html = '<html ' . get_language_header() . '><body><table border = 1><tr>'; foreach ($master_fields as $master_field) { $html .= '<td>' . $class1 . '_' . $master_field . '</td>'; } foreach ($related_fields as $related_field) { $html .= '<td>' . $class2 . '_' . $related_field . '</td>'; } $html .= '</tr>'; $ids = $merge_array['ids']; $resultIds = array(); $is_prospect_merge = $seed1->object_name == 'Prospect'; if ($is_prospect_merge) { $pSeed = $seed1; } foreach ($ids as $key => $value) { if ($is_prospect_merge) { $seed1 = $pSeed->retrieveTarget($key); } else { $seed1->retrieve($key); } $resultIds[] = array('name' => $seed1->module_name, 'value' => $key); $html .= '<tr>'; foreach ($master_fields as $master_field) { if (isset($seed1->{$master_field})) { if ($seed1->field_name_map[$master_field]['type'] == 'enum') { //pull in the translated dom $html .= '<td>' . $app_list_strings[$seed1->field_name_map[$master_field]['options']][$seed1->{$master_field}] . '</td>'; } else { if ($seed1->field_name_map[$master_field]['type'] == 'multienum') { if (isset($app_list_strings[$seed1->field_name_map[$master_field]['options']])) { $items = unencodeMultienum($seed1->{$master_field}); $output = array(); foreach ($items as $item) { if (!empty($app_list_strings[$seed1->field_name_map[$master_field]['options']][$item])) { array_push($output, $app_list_strings[$seed1->field_name_map[$master_field]['options']][$item]); } } // foreach $encoded_output = encodeMultienumValue($output); $html .= "<td>{$encoded_output}</td>"; } } else { $html .= '<td>' . $seed1->{$master_field} . '</td>'; } } } else { $html .= '<td></td>'; } } if (isset($value) && !empty($value)) { $resultIds[] = array('name' => $seed2->module_name, 'value' => $value); $seed2->retrieve($value); foreach ($related_fields as $related_field) { if (isset($seed2->{$related_field})) { if ($seed2->field_name_map[$related_field]['type'] == 'enum') { //pull in the translated dom $html .= '<td>' . $app_list_strings[$seed2->field_name_map[$related_field]['options']][$seed2->{$related_field}] . '</td>'; } else { $html .= '<td>' . $seed2->{$related_field} . '</td>'; } } else { $html .= '<td></td>'; } } } $html .= '</tr>'; } $html .= "</table></body></html>"; } $result = base64_encode($html); return array('html' => $result, 'name_value_list' => $resultIds, 'error' => $error); }
} $json_data = array('field_name' => $tempName, 'field_type' => $field_check); //add an array of fields/values to the json array //for setting all the values for merge if ($field_check == 'relate' or $field_check == 'link') { $temp_array = array(); $tempId = $field_array['id_name']; $json_data['popup_fields'] = array($tempName => $mergeBeanArray[$id]->{$tempName}, $tempId => $mergeBeanArray[$id]->{$tempId}); } else { if ($field_check == 'teamset') { $json_data['field_value'] = TeamSetManager::getCommaDelimitedTeams($mergeBeanArray[$id]->team_set_id, $mergeBeanArray[$id]->team_id, true); $json_data['field_value2'] = TeamSetManager::getTeamsFromSet($mergeBeanArray[$id]->team_set_id); $json_data['field_value3'] = $mergeBeanArray[$id]->team_set_id; } else { if ($field_check == 'multienum') { $json_data['field_value'] = unencodeMultienum($mergeBeanArray[$id]->{$tempName}); } else { $json_data['field_value'] = $mergeBeanArray[$id]->{$tempName}; } } } $encoded_json_data = $json->encode($json_data); $xtpl->assign('ENCODED_JSON_DATA', $encoded_json_data); $xtpl->parse($field_name); } $xtpl->parse("main." . $section_name); $field_count++; } } $header_cols = array(); foreach ($merge_ids_array as $id) {
private static function getFieldEnumRadioGroupHTML($appListStringsFieldOptions, $lead, $fieldName, $colsField, $fieldRequired) { $_required = $fieldRequired ? ' required' : ''; $html = ''; foreach ($appListStringsFieldOptions as $field_option_key => $field_option) { if ($field_option != null) { if (!empty($lead->{$fieldName}) && in_array($field_option_key, unencodeMultienum($lead->{$fieldName}))) { $_checked = ' checked'; } else { $_checked = ''; } $html .= "<input id=\"{$colsField}_{$field_option_key}\" name=\"{$colsField}\" value=\"{$field_option_key}\" type=\"radio\"{$_checked}{$_required}>"; // todo ??? --> $html .= "<span ='document.getElementById('" . $lead->field_defs[$colsField] . "_{$field_option_key}').checked =true style='cursor:default'; onmousedown='return false;'>{$field_option}</span><br>"; } } return $html; }
function check_valid_bean(SugarBean &$bean) { global $app_list_strings, $timedate; require_once 'modules/AOW_Processed/AOW_Processed.php'; $processed = new AOW_Processed(); if (!$this->multiple_runs) { $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id)); if ($processed->status == 'Complete') { //has already run so return false return false; } } if (!isset($bean->date_entered)) { $bean->date_entered = $bean->fetched_row['date_entered']; } if ($this->flow_run_on) { // database time correction with the user's time-zoneqq $beanDateEnteredTimestamp = strtotime($timedate->asUser(new DateTime($timedate->fromDb($bean->date_entered)))); $beanDateModifiedTimestamp = strtotime($timedate->asUser(new DateTime($timedate->fromDb($bean->date_modified)))); $thisDateEnteredTimestamp = strtotime($this->date_entered); switch ($this->flow_run_on) { case 'New_Records': // it is an invalid bean if the user modify it now because the affection need on new records only! if (!empty($bean->fetched_row) || $beanDateEnteredTimestamp < $thisDateEnteredTimestamp) { return false; } break; case 'Modified_Records': // it isn't a valid bean if the user create it now because the affection need on already exists records only! if (empty($bean->fetched_row) || $beanDateModifiedTimestamp < $thisDateEnteredTimestamp && $beanDateModifiedTimestamp != $beanDateEnteredTimestamp) { return false; } break; } } $sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '" . $this->id . "' AND deleted = 0 ORDER BY condition_order ASC"; $result = $this->db->query($sql); $query_array = array(); while ($row = $this->db->fetchByAssoc($result)) { $condition = new AOW_Condition(); $condition->retrieve($row['id']); $path = unserialize(base64_decode($condition->module_path)); $condition_bean = $bean; if (isset($path[0]) && $path[0] != $bean->module_dir) { $query_array = $this->build_query_where($condition, $condition_bean, $query_array); continue; } $field = $condition->field; $value = $condition->value; $dateFields = array('date', 'datetime', 'datetimecombo'); if (isset($app_list_strings['aow_sql_operator_list'][$condition->operator])) { $data = $condition_bean->field_defs[$field]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $field = $data['id_name']; $condition->field = $data['id_name']; } $field = $condition_bean->{$field}; if (in_array($data['type'], $dateFields)) { $field = strtotime($field); } switch ($condition->value_type) { case 'Field': $data = $condition_bean->field_defs[$value]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $value = $data['id_name']; } $value = $condition_bean->{$value}; if (in_array($data['type'], $dateFields)) { $value = strtotime($value); } break; case 'Any_Change': $value = $condition_bean->fetched_row[$condition->field]; if (in_array($data['type'], $dateFields)) { $value = strtotime($value); } switch ($condition->operator) { case 'Not_Equal_To': $condition->operator = 'Equal_To'; break; case 'Equal_To': default: $condition->operator = 'Not_Equal_To'; break; } break; case 'Date': $params = unserialize(base64_decode($value)); $dateType = 'datetime'; if ($params[0] == 'now') { $value = date('Y-m-d H:i:s'); } else { if ($params[0] == 'today') { $dateType = 'date'; $value = date('Y-m-d'); $field = strtotime(date('Y-m-d', $field)); } else { $value = $condition_bean->{$params}[0]; } } if ($params[1] != 'now') { switch ($params[3]) { case 'business_hours': if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) { require_once 'modules/AOBH_BusinessHours/AOBH_BusinessHours.php'; $businessHours = new AOBH_BusinessHours(); $amount = $params[2]; if ($params[1] != "plus") { $amount = 0 - $amount; } $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($value)); $value = strtotime($timedate->asDbType($value, $dateType)); break; } //No business hours module found - fall through. $params[3] = 'hours'; default: $value = strtotime($value . ' ' . $app_list_strings['aow_date_operator'][$params[1]] . " {$params['2']} " . $params[3]); if ($dateType == 'date') { $value = strtotime(date('Y-m-d', $value)); } break; } } else { $value = strtotime($value); } break; case 'Multi': $value = unencodeMultienum($value); if ($data['type'] == 'multienum') { $field = unencodeMultienum($field); } switch ($condition->operator) { case 'Not_Equal_To': $condition->operator = 'Not_One_of'; break; case 'Equal_To': default: $condition->operator = 'One_of'; break; } break; case 'SecurityGroup': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { $sg_module = $condition_bean->module_dir; if (isset($data['module']) && $data['module'] != '') { $sg_module = $data['module']; } $value = $this->check_in_group($field, $sg_module, $value); $field = true; break; } case 'Value': default: if (in_array($data['type'], $dateFields) && trim($value) != '') { $value = strtotime($value); } break; } if (!$this->compare_condition($field, $value, $condition->operator)) { return false; } } } if (isset($query_array['where'])) { $query = 'SELECT ' . $bean->table_name . '.id AS id FROM ' . $bean->table_name . ' '; if (isset($query_array['join'])) { foreach ($query_array['join'] as $join) { $query .= $join; } } $query_where = ''; $query_array['where'][] = $bean->table_name . '.id = ' . "'" . $bean->id . "'"; foreach ($query_array['where'] as $where) { $query_where .= ($query_where == '' ? 'WHERE ' : ' AND ') . $where; } $query .= ' ' . $query_where; $rel_check = $bean->db->getOne($query); if ($rel_check == '') { return false; } } return true; }
/** * Make array from bean * * @param array $module_instance -- Instance of module * @param boolean $recursive -- If TRUE parse related one-to-many fields * @return array -- key : field Name * value : field Value */ public static function parseBeanFields($module_instance, $recursive = FALSE) { global $app_list_strings; $module_instance->ACLFilterFields(); $fields_module = array(); foreach ($module_instance->toArray() as $name => $value) { if (isset($module_instance->field_defs[$name]['type']) && ($module_instance->field_defs[$name]['type'] == 'enum' || $module_instance->field_defs[$name]['type'] == 'radio' || $module_instance->field_defs[$name]['type'] == 'radioenum') && isset($module_instance->field_defs[$name]['options']) && isset($app_list_strings[$module_instance->field_defs[$name]['options']]) && isset($app_list_strings[$module_instance->field_defs[$name]['options']][$value])) { $fields_module[$name] = $app_list_strings[$module_instance->field_defs[$name]['options']][$value]; $fields_module[$name] = str_replace(array(''', '''), "'", $fields_module[$name]); } elseif (isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] == 'multienum' && isset($module_instance->field_defs[$name]['options']) && isset($app_list_strings[$module_instance->field_defs[$name]['options']])) { $multienums = unencodeMultienum($value); $multienums_value = array(); foreach ($multienums as $multienum) { if (isset($app_list_strings[$module_instance->field_defs[$name]['options']][$multienum])) { $multienums_value[] = $app_list_strings[$module_instance->field_defs[$name]['options']][$multienum]; } else { $multienums_value[] = $multienum; } } $fields_module[$name] = implode(', ', $multienums_value); $fields_module[$name] = str_replace(array(''', '''), "'", $fields_module[$name]); } elseif ($recursive && isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] == 'link' && $module_instance->load_relationship($name) && self::hasOneRelationship($module_instance, $name) && count($module_instance->{$name}->get()) == 1) { $related_module = $module_instance->{$name}->getRelatedModuleName(); $related_instance = BeanFactory::getBean($related_module); $related_instance_id = $module_instance->{$name}->get(); if ($related_instance->retrieve($related_instance_id[0]) === null) { $GLOBALS['log']->fatal(__FILE__ . ' Failed loading module ' . $related_module . ' with id ' . $related_instance_id[0]); } $fields_module[$name] = self::parseBeanFields($related_instance, FALSE); } elseif (isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] == 'currency' && isset($module_instance->currency_id)) { global $locale; $format_number_array = array('currency_symbol' => true, 'currency_id' => !empty($module_instance->field_defs[$name]['currency_id']) ? $module_instance->field_defs[$name]['currency_id'] : $module_instance->currency_id, 'type' => 'sugarpdf', 'charset_convert' => true); $fields_module[$name] = format_number_sugarpdf($module_instance->{$name}, $locale->getPrecision(), $locale->getPrecision(), $format_number_array); } elseif (isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] == 'decimal') { global $locale; $format_number_array = array('convert' => false); if (!isset($module_instance->{$name})) { $module_instance->{$name} = 0; } $fields_module[$name] = format_number_sugarpdf($module_instance->{$name}, $locale->getPrecision(), $locale->getPrecision(), $format_number_array); } elseif (isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] == 'image') { $fields_module[$name] = $GLOBALS['sugar_config']['upload_dir'] . "/" . $value; } elseif (is_string($value)) { $value = nl2br(stripslashes($value)); if (isset($module_instance->field_defs[$name]['type']) && $module_instance->field_defs[$name]['type'] === 'html') { $value = htmlspecialchars_decode($value, ENT_QUOTES); } $fields_module[$name] = $value; } } return $fields_module; }
break; } $json_data = array('field_name' => $field_array['name'], 'field_type' => $field_check); //add an array of fields/values to the json array //for setting all the values for merge if ($field_check == 'relate' or $field_check == 'link') { $temp_array = array(); $json_data['popup_fields'] = array($field_array['name'] => $mergeBeanArray[$id]->{$field_array}['name'], $field_array['id_name'] => $mergeBeanArray[$id]->{$field_array}['id_name']); } else { if ($field_check == 'teamset') { $json_data['field_value'] = TeamSetManager::getCommaDelimitedTeams($mergeBeanArray[$id]->team_set_id, $mergeBeanArray[$id]->team_id, true); $json_data['field_value2'] = TeamSetManager::getTeamsFromSet($mergeBeanArray[$id]->team_set_id); $json_data['field_value3'] = $mergeBeanArray[$id]->team_set_id; } else { if ($field_check == 'multienum') { $json_data['field_value'] = unencodeMultienum($mergeBeanArray[$id]->{$field_array}['name']); } else { $json_data['field_value'] = $mergeBeanArray[$id]->{$field_array}['name']; } } } $encoded_json_data = $json->encode($json_data); $xtpl->assign('ENCODED_JSON_DATA', $encoded_json_data); $xtpl->parse($field_name); } $xtpl->parse("main." . $section_name); $field_count++; } } $header_cols = array(); foreach ($merge_ids_array as $id) {
function get_display_array(&$target_bean) { global $app_strings; $this->target_bean = $target_bean; $this->display_array = array(); //Grab label for lhs_field $this->display_array['lhs_field'] = translate_label_from_bean($target_bean, $this->lhs_field); //Grab label for operator $this->display_array['operator'] = $this->get_display_operator($this->operator); //check for enum multi if ($this->operator == "in" || $this->operator == "not_in") { //foreach loop on the in values $selected_array = unencodeMultienum($this->rhs_value); $multi_text = ""; $selected_count = count($selected_array); $the_counter = 1; foreach ($selected_array as $key => $value) { if ($multi_text != "") { if ($the_counter != $selected_count) { $multi_text .= ", "; } else { if ($selected_count > 2) { $multi_text .= ", {$app_strings['LBL_LOWER_OR']} "; } else { $multi_text .= " {$app_strings['LBL_LOWER_OR']} "; } } //end if multi is not blank } $multi_text .= $this->get_display_rhs_value($value); ++$the_counter; } $this->display_array['rhs_value'] = $multi_text; //end if enum multi } else { //Grab lable for rhs_value $this->display_array['rhs_value'] = $this->get_display_rhs_value($this->rhs_value); //end if not enum multi value } //if blank value then set to "NONE" //if($this->display_array['rhs_value']==""){ // $this->display_array['rhs_value'] = "none"; //} return $this->display_array; //end function get_display_array }
function build_report_query_where($query = array()) { global $beanList, $app_list_strings, $sugar_config; if ($beanList[$this->report_module]) { $module = new $beanList[$this->report_module](); $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '" . $this->id . "' AND deleted = 0 ORDER BY condition_order ASC"; $result = $this->db->query($sql); while ($row = $this->db->fetchByAssoc($result)) { $condition = new AOR_Condition(); $condition->retrieve($row['id']); $path = unserialize(base64_decode($condition->module_path)); $condition_module = $module; $table_alias = $condition_module->table_name; if (!empty($path[0]) && $path[0] != $module->module_dir) { foreach ($path as $rel) { if (empty($rel)) { continue; } $rel = strtolower($rel); $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)](); $oldAlias = $table_alias; $table_alias = $table_alias . ":" . $rel; $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module); $condition_module = $new_condition_module; } } if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { $where_set = false; $data = $condition_module->field_defs[$condition->field]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->field = $data['id_name']; $data_new = $condition_module->field_defs[$condition->field]; if (!empty($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { $data_new['type'] = 'link'; $data_new['relationship'] = $data['link']; } $data = $data_new; } if ($data['type'] == 'link' && $data['source'] == 'non-db') { $relModule = getRelatedModule($condition_module->module_dir, $data['relationship']); $new_field_module = new $beanList[$relModule](); $query = $this->build_report_query_join($data['relationship'], $table_alias . ':' . strtolower($relModule), $oldAlias, $condition_module, 'relationship', $query, $new_field_module); $field_module = $new_field_module; $table_alias = $table_alias . ':' . $data['relationship']; $condition->field = 'id'; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field; $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query); } else { $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field; } if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) { $condParam = $this->user_parameters[$condition->id]; $condition->value = $condParam['value']; $condition->operator = $condParam['operator']; $condition->value_type = $condParam['type']; } switch ($condition->value_type) { case 'Field': $data = $condition_module->field_defs[$condition->value]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->value = $data['id_name']; $data_new = $condition_module->field_defs[$condition->value]; if ($data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { $data_new['type'] = 'link'; $data_new['relationship'] = $data['link']; } $data = $data_new; } if ($data['type'] == 'link' && $data['source'] == 'non-db') { $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $data['relationship'])](); $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); $field_module = $new_field_module; $table_alias = $data['relationship']; $field->field = 'id'; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $condition_module->table_name . '_cstm.' . $condition->value; $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); } else { $value = $condition_module->table_name . '.' . $condition->value; } break; case 'Date': $params = unserialize(base64_decode($condition->value)); if ($params[0] == 'now') { if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = 'GetDate()'; } else { $value = 'NOW()'; } } else { $data = $condition_module->field_defs[$params[0]]; if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $condition_module->table_name . '_cstm.' . $params[0]; $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); } else { $value = $condition_module->table_name . '.' . $params[0]; } } if ($params[1] != 'now') { switch ($params[3]) { case 'business_hours': //business hours not implemented for query, default to hours $params[3] = 'hours'; default: if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aor_date_operator'][$params[1]] . " {$params['2']}, {$value})"; } else { $value = "DATE_ADD({$value}, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " {$params['2']} " . $params[3] . ")"; } break; } } break; case 'Multi': $sep = ' AND '; if ($condition->operator == 'Equal_To') { $sep = ' OR '; } $multi_values = unencodeMultienum($condition->value); if (!empty($multi_values)) { $value = '('; foreach ($multi_values as $multi_value) { if ($value != '(') { $value .= $sep; } $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; } $value .= ')'; } $query['where'][] = $value; $where_set = true; break; case 'Value': default: $value = "'" . $this->db->quote($condition->value) . "'"; break; } if (!$where_set) { $query['where'][] = $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; } } } $query['where'][] = $module->table_name . ".deleted = 0 " . $this->build_report_access_query($module, $module->table_name); } return $query; }
function convertCustomFieldsForm(&$form, &$tempBean, &$prefix) { global $mod_strings, $app_list_strings, $app_strings, $lbl_required_symbol; foreach ($this->field_defs as $field => $value) { if (!empty($value['source']) && $value['source'] == 'custom_fields') { if (!empty($tempBean->field_defs[$field]) and isset($tempBean->field_defs[$field])) { $form .= "<tr><td nowrap colspan='4' class='dataLabel'>" . $mod_strings[$tempBean->field_defs[$field]['vname']] . ":"; if (!empty($tempBean->custom_fields->avail_fields[$field]['required']) and ($tempBean->custom_fields->avail_fields[$field]['required'] == 1 or $tempBean->custom_fields->avail_fields[$field]['required'] == '1' or $tempBean->custom_fields->avail_fields[$field]['required'] == 'true' or $tempBean->custom_fields->avail_fields[$field]['required'] == true)) { $form .= " <span class='required'>" . $lbl_required_symbol . "</span>"; } $form .= "</td></tr>"; $form .= "<tr><td nowrap colspan='4' class='dataField' nowrap>"; if (isset($value['isMultiSelect']) && $value['isMultiSelect'] == 1) { $this->{$field} = unencodeMultienum($this->{$field}); $multiple = "multiple"; $array = '[]'; } else { $multiple = null; $array = null; } if (!empty($value['options']) and isset($value['options'])) { $form .= "<select " . $multiple . " name='" . $prefix . $field . $array . "'>"; $form .= get_select_options_with_id($app_list_strings[$value['options']], $this->{$field}); $form .= "</select"; } elseif ($value['type'] == 'bool') { if ($this->{$field} == 1 or $this->{$field} == '1') { $checked = 'checked'; } else { $checked = ''; } $form .= "<input type='checkbox' name='" . $prefix . $field . "' id='" . $prefix . $field . "' value='1' " . $checked . "/>"; } elseif ($value['type'] == 'text') { $form .= "<textarea name='" . $prefix . $field . "' rows='6' cols='50'>" . $this->{$field} . "</textarea>"; } elseif ($value['type'] == 'date') { $form .= "<input name='" . $prefix . $field . "' id='jscal_field" . $field . "' type='text' size='11' maxlength='10' value='" . $this->{$field} . "'> " . SugarThemeRegistry::current()->getImage("jscalendar", "id='jscal_trigger" . $field . "' align='absmiddle'", null, null, ".gif", $mod_strings['LBL_ENTERDATE']) . "' <span class='dateFormat'>yyyy-mm-dd</span><script type='text/javascript'>Calendar.setup ({inputField : 'jscal_field" . $field . "', ifFormat : '%Y-%m-%d', showsTime : false, button : 'jscal_trigger" . $field . "', singleClick : true, step : 1, weekNumbers:false}); addToValidate('ConvertLead', '" . $field . "', 'date', false,'" . $mod_strings[$tempBean->field_defs[$field]['vname']] . "' );</script>"; } else { $form .= "<input name='" . $prefix . $field . "' type='text' value='" . $this->{$field} . "'>"; if ($this->custom_fields->avail_fields[$field]['type'] == 'int') { $form .= "<script>addToValidate('ConvertLead', '" . $prefix . $field . "', 'int', false,'" . $prefix . ":" . $mod_strings[$tempBean->field_defs[$field]['vname']] . "' );</script>"; } elseif ($this->custom_fields->avail_fields[$field]['type'] == 'float') { $form .= "<script>addToValidate('ConvertLead', '" . $prefix . $field . "', 'float', false,'" . $prefix . ":" . $mod_strings[$tempBean->field_defs[$field]['vname']] . "' );</script>"; } } if (!empty($tempBean->custom_fields->avail_fields[$field]['required']) and ($tempBean->custom_fields->avail_fields[$field]['required'] == 1 or $tempBean->custom_fields->avail_fields[$field]['required'] == '1' or $tempBean->custom_fields->avail_fields[$field]['required'] == 'true' or $tempBean->custom_fields->avail_fields[$field]['required'] == true)) { $form .= "<script>addToValidate('ConvertLead', '" . $prefix . $field . "', 'relate', true,'" . $prefix . ":" . $mod_strings[$tempBean->field_defs[$field]['vname']] . "' );</script>"; } $form .= "</td></tr>"; } } } return true; }
public function displayListPlain($layout_def) { if (!empty($layout_def['column_key'])) { $field_def = $this->reporter->all_fields[$layout_def['column_key']]; } else { if (!empty($layout_def['fields'])) { $field_def = $layout_def['fields']; } } if (!empty($layout_def['table_key']) && (empty($field_def['fields']) || empty($field_def['fields'][0]) || empty($field_def['fields'][1]))) { $value = $this->_get_list_value($layout_def); } else { if (!empty($layout_def['name']) && !empty($layout_def['fields'])) { $key = strtoupper($layout_def['name']); $value = $layout_def['fields'][$key]; } } $cell = ''; if (isset($field_def['options'])) { $cell = translate($field_def['options'], $field_def['module'], $value); } else { if (isset($field_def['type']) && $field_def['type'] == 'enum' && isset($field_def['function'])) { global $beanFiles; if (empty($beanFiles)) { include 'include/modules.php'; } $bean_name = get_singular_bean_name($field_def['module']); require_once $beanFiles[$bean_name]; $list = $field_def['function'](); $cell = $list[$value]; } } if (is_array($cell)) { //#22632 $value = unencodeMultienum($value); $cell = array(); foreach ($value as $val) { $returnVal = translate($field_def['options'], $field_def['module'], $val); if (!is_array($returnVal)) { array_push($cell, translate($field_def['options'], $field_def['module'], $val)); } } $cell = implode(", ", $cell); } return $cell; }
function check_valid_bean(SugarBean &$bean) { global $app_list_strings, $timedate; require_once 'modules/AOW_Processed/AOW_Processed.php'; $processed = new AOW_Processed(); if (!$this->multiple_runs) { $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id)); if ($processed->status == 'Complete') { //has already run so return false return false; } } if (!isset($bean->date_entered)) { $bean->date_entered = $bean->fetched_row['date_entered']; } if ($this->flow_run_on) { switch ($this->flow_run_on) { case 'New_Records': if (strtotime($bean->date_entered) < strtotime($this->date_entered)) { return false; } break; case 'Modified_Records': if (strtotime($bean->date_modified) < strtotime($this->date_entered) && strtotime($bean->date_modified) != strtotime($bean->date_entered)) { return false; } break; } } $sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '" . $this->id . "' AND deleted = 0 ORDER BY condition_order ASC"; $result = $this->db->query($sql); while ($row = $this->db->fetchByAssoc($result)) { $condition = new AOW_Condition(); $condition->retrieve($row['id']); $field = $condition->field; $value = $condition->value; $path = unserialize(base64_decode($condition->module_path)); $condition_bean = $bean; //TODO Add related module implementation, until return false if (isset($path[0]) && $path[0] != $bean->module_dir) { return false; } $dateFields = array('date', 'datetime', 'datetimecombo'); if (isset($app_list_strings['aow_sql_operator_list'][$condition->operator])) { $data = $condition_bean->field_defs[$field]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $field = $data['id_name']; $condition->field = $data['id_name']; } $field = $condition_bean->{$field}; if (in_array($data['type'], $dateFields)) { $field = strtotime($field); } switch ($condition->value_type) { case 'Field': $data = $condition_bean->field_defs[$value]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $value = $data['id_name']; } $value = $condition_bean->{$value}; if (in_array($data['type'], $dateFields)) { $value = strtotime($value); } break; case 'Any_Change': $value = $condition_bean->fetched_row[$condition->field]; if (in_array($data['type'], $dateFields)) { $value = strtotime($value); } switch ($condition->operator) { case 'Not_Equal_To': $condition->operator = 'Equal_To'; break; case 'Equal_To': default: $condition->operator = 'Not_Equal_To'; break; } break; case 'Date': $params = unserialize(base64_decode($value)); if ($params[0] == 'now') { $value = date('Y-m-d H:i:s'); } else { $value = $condition_bean->{$params}[0]; } if ($params[1] != 'now') { switch ($params[3]) { case 'business_hours': if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) { require_once 'modules/AOBH_BusinessHours/AOBH_BusinessHours.php'; $businessHours = new AOBH_BusinessHours(); $amount = $params[2]; if ($params[1] != "plus") { $amount = 0 - $amount; } $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($value)); $value = strtotime($timedate->asDb($value)); break; } //No business hours module found - fall through. $params[3] = 'hours'; default: $value = strtotime($value, $app_list_strings['aow_date_operator'][$params[1]] . " {$params['2']} " . $params[3]); break; } } else { $value = strtotime($value); } break; case 'Multi': $value = unencodeMultienum($value); if ($data['type'] == 'multienum') { $field = unencodeMultienum($field); } switch ($condition->operator) { case 'Not_Equal_To': $condition->operator = 'Not_Contains'; break; case 'Equal_To': default: $condition->operator = 'Contains'; break; } break; case 'SecurityGroup': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { $sg_module = $condition_bean->module_dir; if (isset($data['module']) && $data['module'] != '') { $sg_module = $data['module']; } $value = $this->check_in_group($field, $sg_module, $value); $field = true; break; } case 'Value': default: if (in_array($data['type'], $dateFields) && trim($value) != '') { $value = strtotime($value); } break; } if (!$this->compare_condition($field, $value, $condition->operator)) { return false; } } } return true; }
/** * Add replacement(s) to the collection based on field definition * * @param array $data * @param array $field_def * @param array $replacement * @return array */ protected static function add_replacement($data, $field_def, $replacement) { foreach ($replacement as $key => $value) { // @see defect #48641 if ('multienum' == $field_def['type']) { $value = implode(', ', unencodeMultienum($value)); } $data[$key] = $value; } return $data; }
/** * @param array $query * @return array */ function build_report_query_where($query = array()) { global $beanList, $app_list_strings, $sugar_config; $closure = false; if (!empty($query['where'])) { $query['where'][] = '('; $closure = true; } if ($beanList[$this->report_module]) { $module = new $beanList[$this->report_module](); $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '" . $this->id . "' AND deleted = 0 ORDER BY condition_order ASC"; $result = $this->db->query($sql); $tiltLogicOp = true; while ($row = $this->db->fetchByAssoc($result)) { $condition = new AOR_Condition(); $condition->retrieve($row['id']); $path = unserialize(base64_decode($condition->module_path)); $condition_module = $module; $table_alias = $condition_module->table_name; $oldAlias = $table_alias; if (!empty($path[0]) && $path[0] != $module->module_dir) { foreach ($path as $rel) { if (empty($rel)) { continue; } // Bug: Prevents relationships from loading. //$rel = strtolower($rel); $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)](); $oldAlias = $table_alias; $table_alias = $table_alias . ":" . $rel; $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module); $condition_module = $new_condition_module; } } if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { $where_set = false; $data = $condition_module->field_defs[$condition->field]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->field = $data['id_name']; $data_new = $condition_module->field_defs[$condition->field]; if (!empty($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { $data_new['type'] = 'link'; $data_new['relationship'] = $data['link']; } $data = $data_new; } if ($data['type'] == 'link' && $data['source'] == 'non-db') { $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])](); $table_alias = $data['relationship']; $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); $condition_module = $new_field_module; // Debugging: security groups conditions - It's a hack to just get the query working if ($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { // $table_alias = 'opportunities:assigned_user_link:SecurityGroups' ; $table_alias = $oldAlias . ':' . $rel; } $condition->field = 'id'; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field; $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query); } else { $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field; } if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) { $condParam = $this->user_parameters[$condition->id]; $condition->value = $condParam['value']; $condition->operator = $condParam['operator']; $condition->value_type = $condParam['type']; } switch ($condition->value_type) { case 'Field': $data = $condition_module->field_defs[$condition->value]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $condition->value = $data['id_name']; $data_new = $condition_module->field_defs[$condition->value]; if ($data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { $data_new['type'] = 'link'; $data_new['relationship'] = $data['link']; } $data = $data_new; } if ($data['type'] == 'link' && $data['source'] == 'non-db') { $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])](); $table_alias = $data['relationship']; $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); $condition_module = $new_field_module; $condition->field = 'id'; } if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $condition_module->table_name . '_cstm.' . $condition->value; $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); } else { $value = ($table_alias ? "`{$table_alias}`" : $condition_module->table_name) . '.' . $condition->value; } break; case 'Date': $params = unserialize(base64_decode($condition->value)); // Fix for issue #1272 - AOR_Report module cannot update Date type parameter. if ($params == false) { $params = $condition->value; } if ($params[0] == 'now') { if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = 'GetDate()'; } else { $value = 'NOW()'; } } else { if ($params[0] == 'today') { if ($sugar_config['dbconfig']['db_type'] == 'mssql') { //$field = $value = 'CAST(GETDATE() AS DATE)'; } else { $field = 'DATE(' . $field . ')'; $value = 'Curdate()'; } } else { $data = $condition_module->field_defs[$params[0]]; if (isset($data['source']) && $data['source'] == 'custom_fields') { $value = $condition_module->table_name . '_cstm.' . $params[0]; $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); } else { $value = $condition_module->table_name . '.' . $params[0]; } } } if ($params[1] != 'now') { switch ($params[3]) { case 'business_hours': //business hours not implemented for query, default to hours $params[3] = 'hours'; default: if ($sugar_config['dbconfig']['db_type'] == 'mssql') { $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aor_date_operator'][$params[1]] . " {$params['2']}, {$value})"; } else { $value = "DATE_ADD({$value}, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " {$params['2']} " . $params[3] . ")"; } break; } } break; case 'Multi': $sep = ' AND '; if ($condition->operator == 'Equal_To') { $sep = ' OR '; } $multi_values = unencodeMultienum($condition->value); if (!empty($multi_values)) { $value = '('; foreach ($multi_values as $multi_value) { if ($value != '(') { $value .= $sep; } $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; } $value .= ')'; } $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . $value; $where_set = true; break; case "Period": if (array_key_exists($condition->value, $app_list_strings['date_time_period_list'])) { $params = $condition->value; } else { $params = base64_decode($condition->value); } $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; break; case "CurrentUserID": global $current_user; $value = '"' . $current_user->id . '"'; break; case 'Value': default: $value = "'" . $this->db->quote($condition->value) . "'"; break; } //handle like conditions switch ($condition->operator) { case 'Contains': $value = "CONCAT('%', " . $value . " ,'%')"; break; case 'Starts_With': $value = "CONCAT(" . $value . " ,'%')"; break; case 'Ends_With': $value = "CONCAT('%', " . $value . ")"; break; } if ($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') { $value = "{$value} OR {$field} IS NULL"; } if (!$where_set) { if ($condition->value_type == "Period") { if (array_key_exists($condition->value, $app_list_strings['date_time_period_list'])) { $params = $condition->value; } else { $params = base64_decode($condition->value); } $date = getPeriodEndDate($params)->format('Y-m-d H:i:s'); $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; $query['where'][] = $tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND '); $tiltLogicOp = false; switch ($app_list_strings['aor_sql_operator_list'][$condition->operator]) { case "=": $query['where'][] = $field . ' BETWEEN ' . $value . ' AND ' . '"' . $date . '"'; break; case "!=": $query['where'][] = $field . ' NOT BETWEEN ' . $value . ' AND ' . '"' . $date . '"'; break; case ">": case "<": case ">=": case "<=": $query['where'][] = $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; break; } } else { if (!$where_set) { $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; } } } $tiltLogicOp = false; } else { if ($condition->parenthesis) { if ($condition->parenthesis == 'START') { $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; $tiltLogicOp = true; } else { $query['where'][] = ')'; $tiltLogicOp = false; } } else { $GLOBALS['log']->debug('illegal condition'); } } } if (isset($query['where']) && $query['where']) { array_unshift($query['where'], '('); $query['where'][] = ') AND '; } $query['where'][] = $module->table_name . ".deleted = 0 " . $this->build_report_access_query($module, $module->table_name); } if ($closure) { $query['where'][] = ')'; } return $query; }