select t1.id,t3.name as project,t1.name as execution,t2.type,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_PROJECT as t3 on t3.id=t1.project
where t1.deleted='0' and t1.type in ('sprint','stage') and t2.deleted='0' and if($project='',1,t3.id=$project) and if($status='',1,t1.status=$status) and if($beginDate='',1,t1.begin>=$beginDate) and if($endDate='',1,t1.end<=$endDate)