public function getSubjectWithRel(EiProjet $ei_project, $delivery_id = null, $subject_id = null, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $q = "select * from ei_subjects_with_relations_vw where project_id=" . $ei_project->getProjectId() . " and project_ref=" . $ei_project->getRefId();
     if ($delivery_id != null) {
         $q .= " and delivery_id=" . $delivery_id;
     }
     if ($subject_id != null) {
         $q .= " and id=" . $subject_id;
     }
     return EiSubject::parseSubjects($conn->fetchAll($q));
 }
 public function getBugWithImpactOrNot($delivery_id, $hasImpact = true, Doctrine_Connection $conn = null)
 {
     $q = "select distinct(s.id), s.name  ,vwf.delivery_id, ss.name as ss_name, ss.color_code as ss_color_code,st.name as type_name,sp.name as sp_name,g.id as assign_id,g.username as assign_name\n            from ei_subject s\n            left join ei_subject_state ss on ss.id=s.subject_state_id\n            left join ei_subject_type st on st.id=s.subject_type_id\n            left join ei_subject_priority sp on sp.id=s.subject_priority_id\n            left join ei_subject_assignment sa on sa.subject_id=s.id\n            left join sf_guard_user g on g.id=sa.guard_id \n            left join \n            (\n            SELECT  IF(s_id is null,  s2_id , s_id) as subject_id, IF(s_delivery_id is null,  s2_delivery_id , s_delivery_id) as delivery_id from\n              ei_delivery_impacted_functions_vw     \n            WHERE t_type='Function' )  as vwf\n            on s.id= vwf.subject_id\n            where  s.delivery_id=" . $delivery_id;
     if ($hasImpact) {
         $q .= " and vwf.subject_id is not  null";
     } else {
         $q .= " and vwf.subject_id is   null";
     }
     return EiSubject::parseSubjects($conn->fetchAll($q));
 }