2 if (!defined('sugarEntry') || !sugarEntry)
3 die('Not A Valid Entry Point');
4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
39 /*********************************************************************************
41 * Description: TODO: To be written.
42 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
43 * All Rights Reserved.
44 * Contributor(s): ______________________________________..
45 ********************************************************************************/
49 require_once ('include/JSON.php');
50 $timedate = TimeDate::getInstance();
53 global $app_list_strings;
54 global $current_language;
56 global $currentModule;
58 global $filter_for_valid_editable_attributes;
59 //filter condition for fields in vardefs that can participate in merge.
60 $filter_for_valid_editable_attributes =
62 array('type'=>'datetimecombo','source'=>'db'),
63 array('type'=>'datetime','source'=>'db'),
64 array('type'=>'varchar','source'=>'db'),
65 array('type'=>'enum','source'=>'db'),
66 array('type'=>'multienum','source'=>'db'),
67 array('type'=>'text','source'=>'db'),
68 array('type'=>'date','source'=>'db'),
69 array('type'=>'time','source'=>'db'),
70 array('type'=>'int','source'=>'db'),
71 array('type'=>'long','source'=>'db'),
72 array('type'=>'double','source'=>'db'),
73 array('type'=>'float','source'=>'db'),
74 array('type'=>'short','source'=>'db'),
75 array('dbType'=>'varchar','source'=>'db'),
76 array('dbType'=>'double','source'=>'db'),
77 array('type'=>'relate'),
80 $filter_for_valid_related_attributes = array( array('type'=>'link'),);
81 $filter_for_invalid_related_attributes = array(array('type'=>'link','link_type'=>'one'));
83 //following attributes will be ignored from the merge process.
84 $invalid_attribute_by_name= array('date_entered'=>'date_entered','date_modified'=>'date_modified','modified_user_id'=>'modified_user_id', 'created_by'=>'created_by','deleted'=>'deleted');
86 $merge_ids_array = array ();
87 if (isset($_REQUEST['change_parent']) && $_REQUEST['change_parent']=='1') {
88 $base_id=$_REQUEST['change_parent_id'];
89 foreach ($_REQUEST['merged_ids'] as $id) {
90 if ($id != $base_id) {
91 $merge_ids_array[] = $id;
94 //add the existing parent to merged_id array.
95 $merge_ids_array[] = $_REQUEST['record'];
96 } elseif (isset($_REQUEST['remove']) && $_REQUEST['remove']=='1') {
97 $base_id=$_REQUEST['record'];
98 $removed_id= $_REQUEST['remove_id'];
99 foreach ($_REQUEST['merged_ids'] as $id) {
100 if ($id != $removed_id) {
101 $merge_ids_array[] = $id;
105 $base_id=$_REQUEST['record'];
106 foreach ($_REQUEST['mass'] as $id) {
107 $merge_ids_array[] = $id;
110 $focus = new MergeRecord();
111 $focus->load_merge_bean($_REQUEST['merge_module'], true, $base_id);
113 $params[] = "<a href='index.php?module={$focus->merge_bean->module_dir}&action=index'>{$GLOBALS['app_list_strings']['moduleList'][$focus->merge_bean->module_dir]}</a>";
114 $params[] = $mod_strings['LBL_MODULE_NAME'];
115 $params[] = $focus->merge_bean->name;
116 echo getClassicModuleTitle($focus->merge_bean->module_dir, $params, true);
118 $mergeBeanArray = array ();
120 //render a column for each record to merge
122 $merge_records_names=array();
123 foreach ($merge_ids_array as $id) {
124 require_once ($focus->merge_bean_file_path);
125 $mergeBeanArray[$id] = new $focus->merge_bean_class();
126 $mergeBeanArray[$id]->retrieve($id);
127 $merge_records_names[]=$mergeBeanArray[$id]->get_summary_text();
129 $merged_ids.="<input type='hidden' name='merged_ids[]' value='$id'>";
132 $col_width=floor(80/$records).'%';
133 global $max_data_length;
134 $max_data_length=floor(65/$records);
136 $xtpl = new XTemplate("modules/MergeRecords/Step3.html");
137 $xtpl->assign("MOD", $mod_strings);
138 $xtpl->assign("APP", $app_strings);
140 $xtpl->assign("ID", $focus->merge_bean->id);
141 $xtpl->assign("MERGE_MODULE", $focus->merge_module);
143 $xtpl->assign("MERGED_IDS", $merged_ids);
145 //set return parameters.
146 if (!empty ($_REQUEST['return_module'])) {
147 $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
149 if (!empty ($_REQUEST['return_action'])) {
150 $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
152 if (!empty ($_REQUEST['return_id'])) {
153 $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
156 $temp_field_array = $focus->merge_bean->field_defs;
158 $json = new JSON(JSON_LOOSE_TYPE);
160 foreach ($temp_field_array as $field_array) {
163 if (show_field($field_array)
166 $select_row_curr_field_value = null;
167 $b_values_different = false;
168 $section_name='merge_row_similar';
170 //Prcoess locaton of the field. if values are different show field in first section. else 2nd.
171 $select_row_curr_field_value = $focus->merge_bean->$field_array['name'];
172 foreach ($merge_ids_array as $id) {
173 if (($mergeBeanArray[$id]-> $field_array['name']=='' and $select_row_curr_field_value =='') or $mergeBeanArray[$id]-> $field_array['name'] == $select_row_curr_field_value ) {
174 $section_name='merge_row_similar';
176 $section_name='merge_row_diff';
181 //check for vname in mod strings first, then app, else just display name
182 $col_name = $field_array['name'];
183 if (isset ($focus->merge_bean_strings[$field_array['vname']]) && $focus->merge_bean_strings[$field_array['vname']] != '')
184 $xtpl->assign("FIELD_LABEL", $focus->merge_bean_strings[$field_array['vname']]);
185 elseif (isset ($app_strings[$field_array['vname']]) && $app_strings[$field_array['vname']] != '') $xtpl->assign("FIELD_LABEL", $app_strings[$field_array['vname']]);
187 $xtpl->assign("FIELD_LABEL", $field_array['name']);
188 //if required add signage.
189 if (!empty($focus->merge_bean->required_fields[$col_name]) or $col_name=='team_name') {
190 $xtpl->assign("REQUIRED_SYMBOL","<span class='required'>".$app_strings['LBL_REQUIRED_SYMBOL']."</span>");
192 $xtpl->assign("REQUIRED_SYMBOL","");
195 $xtpl->assign("CELL_WIDTH", "20%");
196 $xtpl->parse("main.".$section_name.".merge_cell_label");
198 if (isset ($field_array['custom_type']) && $field_array['custom_type'] != '')
199 $field_check = $field_array['custom_type'];
201 $field_check = $field_array['type'];
204 if(preg_match('/.*?_address_street$/', $field_array['name'])) {
205 $field_check = 'text';
208 $xtpl->assign("EDIT_FIELD_NAME", $field_array['name']);
209 $xtpl->assign("TAB_INDEX", $field_count);
212 //check to see if the value of the field is from a function
213 $valueFormatted = false;
214 if(!empty($field_array['function'])){
216 //process the function array if it exists
217 $function = $field_array['function'];
218 if(is_array($function) && isset($function['name'])){
219 $function = $field_array['function']['name'];
221 $function = $field_array['function'];
223 if(!empty($field_array['function']['include']) && file_exists($field_array['function']['include']))
225 require_once($field_array['function']['include']);
228 //if field is enum or multi enum, lets make sure we are returning options as html, as this is what
229 //merge step3 expects
230 if($field_check == 'multienum' || $field_check == 'enum'){
231 if(!empty($field_array['function']['returns']) && $field_array['function']['returns'] == 'html'){
233 //use valueformatted to hold the returned options
234 $valueFormatted = call_user_func($function, $focus->merge_bean, $field_array['name'], $select_row_curr_field_value, 'Import');
237 //if no html was returned, we have an array of options, lets create the html markup
238 $field_array['options'] = call_user_func($function);
240 foreach( $field_array['options'] as $k=>$v){
241 //process and mark the field as selected if needed
242 if($field_check == 'enum' && $select_row_curr_field_value == $k){
243 $valueFormatted .="<option value='$k' selected>$v</option>";
244 }elseif($field_check == 'multienum' && !empty($k) && strpos($select_row_curr_field_value, $k) !== false){
245 $valueFormatted .="<option value='$k' selected>$v</option>";
248 $valueFormatted .="<option value='$k'>$v</option>";
255 $select_row_curr_field_value = call_user_func($function);
259 switch ($field_check) {
265 case ('custom_fields') :
272 $xtpl->assign("EDIT_FIELD_VALUE", $select_row_curr_field_value);
273 $xtpl->assign("CELL_WIDTH", $col_width);
274 $xtpl->parse("main.".$section_name.".merge_cell_edit_text");
277 $xtpl->assign("EDIT_FIELD_VALUE", $select_row_curr_field_value);
278 $xtpl->assign("CELL_WIDTH", $col_width);
279 $xtpl->parse("main.".$section_name.".merge_cell_edit_textarea");
283 //assign value(s) directly if it is derived from a function
284 if(empty($field_array['function'])){
285 $xtpl->assign("SELECT_OPTIONS", get_select_options_with_id($app_list_strings[$field_array['options']], $select_row_curr_field_value));
286 }elseif(is_string($valueFormatted)){
287 //if this field has a function, then assign values directly
288 $xtpl->assign("SELECT_OPTIONS", $valueFormatted);
290 $xtpl->assign("CELL_WIDTH",$col_width);
291 $xtpl->parse("main.".$section_name.".merge_cell_edit_dropdown");
295 //assign value(s) directly if it is derived from a function
296 if(empty($field_array['function'])){
297 $select_row_curr_field_value = unencodeMultienum($select_row_curr_field_value);
298 $xtpl->assign("SELECT_OPTIONS", get_select_options_with_id($app_list_strings[$field_array['options']], $select_row_curr_field_value));
299 }elseif(is_string($valueFormatted)){
300 $xtpl->assign("SELECT_OPTIONS", $valueFormatted);
303 $xtpl->assign("CELL_WIDTH",$col_width);
304 $xtpl->parse("main.".$section_name.".merge_cell_edit_multidropdown");
306 //popup fields need to be fixed.., cant automate with vardefs
308 if(!empty($field_array['link'])) {
309 $exclude[$field_array['link']] = $field_array['link'];
313 if (empty($select_row_curr_field_value)) {
314 $related_name=get_related_name($field_array,$focus->merge_bean->$field_array['id_name']);
315 if ($related_name !== false ) {
316 $select_row_curr_field_value=$related_name;
319 if($field_check == 'link') {//relate type should not enter this.
320 $exclude[$field_array['name']] = $field_array['name'];
322 $xtpl->assign("POPUP_ID_FIELD", $field_array['id_name']);
323 $xtpl->assign("POPUP_NAME_FIELD", $field_array['name']);
324 $xtpl->assign("POPUP_NAME_VALUE", $select_row_curr_field_value);
325 $xtpl->assign("POPUP_ID_VALUE", $focus->merge_bean-> $field_array['id_name']);
326 $xtpl->assign("POPUP_MODULE", $field_array['module']);
327 $xtpl->assign("CELL_WIDTH", $col_width);
328 $xtpl->assign("MERGED_LINKS", implode(',', $exclude));
330 $popup_data = array ('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array ('id' => $field_array['id_name'], 'name' => $field_array['name'],),);
331 $xtpl->assign('ENCODED_POPUP_DATA', $json->encode($popup_data));
333 $xtpl->parse("main.".$section_name.".merge_cell_edit_popup");
336 if (($select_row_curr_field_value == '1' || $select_row_curr_field_value == 'yes' || $select_row_curr_field_value == 'on') && !empty($select_row_curr_field_value))
337 $xtpl->assign("EDIT_FIELD_VALUE", " checked");
339 $xtpl->assign("EDIT_FIELD_VALUE", "");
341 $xtpl->assign("CELL_WIDTH", $col_width);
342 $xtpl->parse("main.".$section_name.".merge_cell_edit_checkbox");
346 $xtpl->assign("CALENDAR_LANG", "en");
347 $xtpl->assign("USER_DATEFORMAT", '('.$timedate->get_user_date_format().')');
348 $xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
349 $xtpl->assign("EDIT_FIELD_VALUE", $select_row_curr_field_value);
350 $xtpl->assign("CELL_WIDTH", $col_width);
351 $xtpl->assign("THEME", $theme);
352 $xtpl->parse("main.".$section_name.".merge_cell_edit_date");
354 case ('datetimecombo') :
355 $xtpl->assign("CALENDAR_LANG", "en");
356 $xtpl->assign("USER_DATEFORMAT", $timedate->get_user_time_format());
357 $xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
358 $xtpl->assign("EDIT_FIELD_VALUE", $select_row_curr_field_value);
359 $xtpl->assign("CELL_WIDTH", $col_width);
360 $xtpl->assign("THEME", $theme);
361 $xtpl->parse("main.".$section_name.".merge_cell_edit_datetime");
367 //render a column for each selected record to merge
368 foreach ($merge_ids_array as $id) {
369 $xtpl->assign("CELL_WIDTH", $col_width);
371 switch ($field_check) {
373 if (($mergeBeanArray[$id]->$field_array['name'] == '1' || $mergeBeanArray[$id]->$field_array['name'] == 'yes' || $mergeBeanArray[$id]->$field_array['name'] == 'on') && !empty($mergeBeanArray[$id]->$field_array['name'])) {
374 $xtpl->assign("FIELD_VALUE", " checked");
376 $xtpl->assign("FIELD_VALUE", "");
378 $field_name="main.".$section_name.".merge_cell_field_value_checkbox";
381 if(!empty($field_array['function']) && !empty($field_array['options']) && !empty($mergeBeanArray[$id]-> $field_array['name'])){
382 //if fieldoptions were set from a function, get the value directly
383 display_field_value($field_array['options'][$mergeBeanArray[$id]-> $field_array['name']]);
385 }else if ($mergeBeanArray[$id]-> $field_array['name'] != '' and isset($field_array['options']) and isset($app_list_strings[$field_array['options']][$mergeBeanArray[$id]-> $field_array['name']])) {
386 display_field_value( $app_list_strings[$field_array['options']][$mergeBeanArray[$id]-> $field_array['name']]);
388 display_field_value($mergeBeanArray[$id]-> $field_array['name']);
390 $field_name="main.".$section_name.".merge_cell_field_value";
393 if(!empty($field_array['function']) && !empty($field_array['options']) && !empty($mergeBeanArray[$id]-> $field_array['name'])){
394 //if fieldoptions were set from a function, get the value directly
395 $displayME = str_replace("^","",$mergeBeanArray[$id]-> $field_array['name']);
396 $meVals = explode(',', $displayME);
397 //iterate through each entry and get the Options value
398 foreach($meVals as $optionIndex){
399 $displayME = str_replace($optionIndex,$field_array['options'][$optionIndex],$displayME);
401 display_field_value($displayME);
403 }else if ($mergeBeanArray[$id]-> $field_array['name'] != '' and isset($field_array['options']) and isset($app_list_strings[$field_array['options']][$mergeBeanArray[$id]-> $field_array['name']])) {
404 display_field_value(str_replace("^","",$app_list_strings[$field_array['options']][$mergeBeanArray[$id]-> $field_array['name']]));
406 display_field_value(str_replace("^","",$mergeBeanArray[$id]-> $field_array['name']));
408 $field_name="main.".$section_name.".merge_cell_field_value";
413 if (empty($mergeBeanArray[$id]-> $field_array['name']) && !empty($mergeBeanArray[$id]-> $field_array['id_name'])) {
414 $related_name=get_related_name($field_array,$mergeBeanArray[$id]-> $field_array['id_name']);
415 if ($related_name !== false) {
416 $mergeBeanArray[$id]-> $field_array['name']=$related_name;
419 display_field_value($mergeBeanArray[$id]-> $field_array['name']);
420 $field_name="main.".$section_name.".merge_cell_field_value";
423 display_field_value($mergeBeanArray[$id]-> $field_array['name']);
424 $field_name="main.".$section_name.".merge_cell_field_value";
428 $json_data = array ('field_name' => $field_array['name'], 'field_type' => $field_check,);
429 //add an array of fields/values to the json array
430 //for setting all the values for merge
431 if ($field_check == 'relate' or $field_check == 'link') {
432 $temp_array = Array ();
433 $json_data['popup_fields'] = Array ($field_array['name'] => $mergeBeanArray[$id]-> $field_array['name'], $field_array['id_name'] => $mergeBeanArray[$id]-> $field_array['id_name'],);
434 } else if($field_check == 'teamset') {
435 $json_data['field_value'] = TeamSetManager::getCommaDelimitedTeams($mergeBeanArray[$id]->team_set_id, $mergeBeanArray[$id]->team_id, true);
436 $json_data['field_value2'] = TeamSetManager::getTeamsFromSet($mergeBeanArray[$id]->team_set_id);
437 $json_data['field_value3'] = $mergeBeanArray[$id]->team_set_id;
438 } else if($field_check == 'multienum') {
439 $json_data['field_value'] = unencodeMultienum($mergeBeanArray[$id]-> $field_array['name']);
441 $json_data['field_value'] = $mergeBeanArray[$id]-> $field_array['name'];
443 $encoded_json_data = $json->encode($json_data);
444 $xtpl->assign('ENCODED_JSON_DATA', $encoded_json_data);
445 $xtpl->parse($field_name);
448 $xtpl->parse("main.".$section_name);
453 $header_cols= array();
454 foreach ($merge_ids_array as $id) {
455 $td="<td width='$col_width' valign='top' class='dataLabel' align='left'><input type='button' class='button' id='$id' onclick=\"change_primary(this,'{$id}');\" value='<<'> {$mod_strings['LBL_CHANGE_PARENT']}";
456 if (count($merge_ids_array) > 1) {
457 $td.=" |<a id='remove_$id' onclick=\"remove_me(this,'{$id}');\" href='#' >{$mod_strings['LBL_REMOVE_FROM_MERGE']}</a>";
463 if ($diff_field_count>0) {
464 $xtpl->assign("DIFF_HEADER","<tr height='20'><td colspan=2><strong>{$mod_strings['LBL_DIFF_COL_VALUES']}</strong></td>".implode(' ',$header_cols)."</tr>");
465 $xtpl->assign("SIMILAR_HEADER","<tr height='20'><td colspan=20><strong>{$mod_strings['LBL_SAME_COL_VALUES']}</strong></td></tr>");
466 $xtpl->assign("GROUP_PARTITION","<tr height=3><td colspan=20' class='listViewHRS1'></td></tr>");
468 $xtpl->assign("SIMILAR_HEADER","<tr height='20'><td colspan=2><strong>{$mod_strings['LBL_SAME_COL_VALUES']}</strong></td>".implode(' ',$header_cols)."</tr>");
470 $merge_verify=$mod_strings['LBL_DELETE_MESSAGE'].'\\n';
471 foreach ($merge_records_names as $name) {
472 $merge_verify.= $name."\\n";
474 $merge_verify.='\\n'.$mod_strings['LBL_PROCEED'];
475 $xtpl->assign("MERGE_VERIFY",$merge_verify);
479 //Jenny - Bug 8386 - The object_name couldn't be found because it was searching for
480 // 'Case' instead of 'aCase'.
481 if ($focus->merge_bean->object_name == 'Case') {
482 $focus->merge_bean->object_name = 'aCase';
485 $mod=array_search($focus->merge_bean->object_name,$beanList);
486 $mod_strings = return_module_language($current_language, $mod);
488 //add javascript for required fields enforcement.
490 $javascript = new javascript();
491 $javascript->setFormName('EditView');
492 $javascript->setSugarBean($focus->merge_bean);
493 $javascript->addAllFields('');
494 if (isset($focus->merge_bean->field_defs['team_name'])) {
495 $javascript->addFieldGeneric('team_name', 'varchar', $app_strings['LBL_TEAM'] ,'true');
497 $xtpl->assign("VALIDATION_JS", $javascript->getScript());
499 $xtpl->parse("main");
503 * function truncates values to max_data_legth and adds the complete value as hover text.
505 function display_field_value($value) {
506 global $xtpl, $max_data_length, $mod_strings;
507 if (strlen($value)-$max_data_length > 3) {
508 $xtpl->assign("FIELD_VALUE", substr($value,0,$max_data_length).'...');
510 $xtpl->assign("FIELD_VALUE", $value);
512 $xtpl->assign("HOVER_TEXT", $mod_strings['LBL_MERGE_VALUE_OVER'] .': ' . $value);
515 * implements the rules that decide which fields will participate in a merge.
517 function show_field($field_def) {
518 global $filter_for_valid_editable_attributes,$invalid_attribute_by_name;
519 //field in invalid attributes list?
520 if (isset($invalid_attribute_by_name[$field_def['name']])) {
523 //field has 'duplicate_merge property set to disabled?'
524 if (isset($field_def['duplicate_merge']) ) {
525 if ($field_def['duplicate_merge']=='disabled' or $field_def['duplicate_merge']==false) {
528 if ($field_def['duplicate_merge']=='enabled' or $field_def['duplicate_merge']==true) {
533 //field has auto_increment set to true do not participate in merge.
534 //we have a unique index on that field.
535 if (isset($field_def['auto_increment']) and $field_def['auto_increment']==true) {
539 //set required attribute values in $field_def
540 if (!isset($field_def['source']) or empty($field_def['source'])) {
541 $field_def['source']='db';
544 if (!isset($field_def['dbType']) or empty($field_def['dbType']) and isset($field_def['type'])) {
545 $field_def['dbType']=$field_def['type'];
548 foreach ($filter_for_valid_editable_attributes as $attribute_set) {
550 foreach ($attribute_set as $attr=>$value) {
551 if (isset($field_def[$attr]) and $field_def[$attr]==$value) {
564 /* if the attribute of type relate and name is empty fetch using the vardef entries.
567 function get_related_name($field_def,$id_value) {
568 if (!empty($field_def['rname']) && !empty($field_def['id_name']) && !empty($field_def['table'])) {
569 if (!empty($id_value)) {
571 //default the column name to rname in vardefs
572 $col_name = $field_def['rname'];
573 //if this module is non db and has a module set, then check to see if this field should be concatenated
574 if (!empty($field_def['module']) && $field_def['source'] == 'non-db'){
575 global $beanList, $beanFiles;
576 //get the bean field defs based on the module param
577 $bean = $beanList[$field_def['module']];
578 require_once ($beanFiles[$bean]);
579 $focus = new $bean();
580 if(!empty( $focus->field_defs[$field_def['rname']])){
581 $related_def = $focus->field_defs[$field_def['rname']];
582 //if field defs has concat field array set, then concatenate values
583 if(isset($related_def['db_concat_fields']) && !empty($related_def['db_concat_fields'])){
584 $col_name = $focus->db->concat($field_def['table'], $related_def['db_concat_fields']);
589 $query = "select ".$col_name." from " .$field_def['table'] ." where id='$id_value'";
591 $result=$GLOBALS['db']->query($query);
592 $row=$GLOBALS['db']->fetchByAssoc($result);
593 if (!empty($row[$field_def['rname']])) {
594 return $row[$field_def['rname']];