Hi bunglesan
Bellow is the code.
You can copy the code between the andopes change and paste at the appropriate place.
PHP Code:
function create_export_query(&$order_by, &$where)
{
$custom_join = $this->custom_fields->getJOIN();
$query = "SELECT
accounts.*,
users.user_name as assigned_user_name ";
// begin andopes change
$query.= ", GROUP_CONCAT(DISTINCT ea.email_address ORDER BY ea.email_address DESC SEPARATOR ' ') AS email ";
// end andopes change
if($custom_join){
$query .= $custom_join['select'];
}
$query .= "FROM accounts ";
if($custom_join){
$query .= $custom_join['join'];
}
$query .= " LEFT JOIN users
ON accounts.assigned_user_id=users.id ";
// begin andopes change
$query.= " LEFT JOIN email_addr_bean_rel eabr ON accounts.id = eabr.bean_id AND eabr.bean_module = 'Accounts' AND eabr.deleted = 0 INNER JOIN email_addresses ea ON eabr.email_address_id = ea.id AND ea.deleted = 0 ";
// end andopes change
$where_auto = " accounts.deleted=0 ";
if($where != "")
$query .= "where ($where) AND ".$where_auto;
else
$query .= "where ".$where_auto;
// begin andopes change
$query.= "GROUP BY accounts.id";
// end andopes change
if(!empty($order_by)){
//check to see if order by variable already has table name by looking for dot "."
$table_defined_already = strpos($order_by, ".");
if($table_defined_already === false){
//table not defined yet, define accounts to avoid "ambigous column" SQL error
$query .= " ORDER BY $order_by";
}else{
//table already defined, just add it to end of query
$query .= " ORDER BY $order_by";
}
}
return $query;
}
It is working properly.
Cheers
Bookmarks