SugarCRM 自定义选择按钮


一、EditView 中需要写的代码
///////////////////////////////////////
///
/// SETUP PARENT POPUP
/// Account Popup
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'Status_c',
'name' => 'Status_c_name',
),
);

$json = new JSON(JSON_LOOSE_TYPE);
$encoded_popup_request_data = $json->encode($popup_request_data);
$xtpl->assign('encoded_popup_request_data', $encoded_popup_request_data);


require_once('include/QuickSearchDefaults.php');
$sqs_objects = array('parent_name' => $qsParent,
'assigned_user_name' => $qsUser,
'team_name' => $qsTeam);
$quicksearch_js = $qsScripts;
$quicksearch_js .= '
<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
//$quicksearch_js .= '
<script type="text/javascript" language="javascript" src="include/javascript/change_region_'.$current_language.'.js"></script>';

$xtpl->assign("PARENT_ID", $focus->Status_c);
$xtpl->assign("PARENT_NAME", $focus->Status_c_name);

if(isset($_REQUEST['Status_c'])) $xtpl->assign("PARENT_ID", $_REQUEST['Status_c']);
if(isset($_REQUEST['Status_c_name'])) $xtpl->assign("PARENT_NAME", urldecode($_REQUEST['Status_c_name']));

require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('EditView');
$javascript->setSugarBean($focus);
$javascript->addAllFields('');
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');

二、ListView 中显示问题
在bw_MessageSend.php 文件中的 create_list_query 方法,此方法是创建查询语句的。
更新思路:将查询语句加一个左连接,用已经存储在数据库中的id与要查询的表相关联即可。
解决方案: create_list_query 方法中的部分代码
$query = "SELECT
users.user_name assigned_user_name,
bw_messagesends.*
";

if($custom_join){ $query .= " ,bw_messagesends_cstm.SendTime_c"; }//在ListView中要显示cstm表中的字段 //更新前为 $custom_join['select']; //此变量为 ' ,bw_messagesends_cstm.* '

$query.=" , accounts.name Status_c";//增加的字段 别名 Status_c 必须与cstm表中的同名

$query .= " FROM bw_messagesends ";
$query .= "LEFT JOIN users ON bw_messagesends.assigned_user_id=users.id ";
if($custom_join){ $query .= $custom_join['join']; }

$query .= " LEFT JOIN accounts ON bw_messagesends_cstm.Status_c=accounts.id "; //左连接

$where_auto = '1=1';
posted @ 2011-02-13 17:44  海乐学习  阅读(552)  评论(0编辑  收藏  举报