Hello,
I'm running Sugar 4.5.1 and I'd like to know if its possible to export the list of contacts that are associated with a Project. When I've tried the export I just get the project details and not the list of contacts which would be really useful,
I think this would be possible by modifying the export query in project.php but am unsure of the SQL statement needed. Has anyone else done this and can they let me know what the create_export_query should be changed to?
function create_export_query(&$order_by, &$where)
{
$custom_join = $this->custom_fields->getJOIN();
$query = "SELECT
project.*,
users.user_name as assigned_user_name ";
if($custom_join){
$query .= $custom_join['select'];
}
$query .= "FROM project ";
if($custom_join){
$query .= $custom_join['join'];
}
$query .= " LEFT JOIN users
ON project.assigned_user_id=users.id ";
$where_auto = " project.deleted=0 ";
if($where != "")
$query .= "where ($where) AND ".$where_auto;
else
$query .= "where ".$where_auto;
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;
Thanks very much,
James


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks