select t1.id,t4.name as project,t1.name as execution,if(t3.account is not null, t3.account,t2.assignedTo) as assignedTo,t2.id as taskID, t1.status as projectstatus from TABLE_EXECUTION as t1
 left join TABLE_TASK as t2 on t1.id=t2.execution
 left join TABLE_TEAM as t3 on t3.type='task' && t3.root=t2.id 
left join TABLE_PROJECT as t4 on t1.project=t4.id
where t1.deleted='0' and t1.type in ('sprint','stage') and t2.deleted='0' and if($project='',1,t4.id=$project) and if($status='',1,t1.status=$status) and if($beginDate='',1,t1.begin>=$beginDate) and if($endDate='',1,t1.end<=$endDate)