select t1.id,t3.name as project,t1.name,t2.status,IF(t3.multiple="1",t1.name,"") as execution,t2.id as taskID,  t1.status as projectstatus, (case when t2.deadline < CURDATE() and t2.deadline != '0000-00-00' and t2.status != 'closed' and t2.status != 'done' and t2.status != 'cancel' then 1 else 0 end) as timeout 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)