public function getSimpleSujects(Eiprojet $ei_project, EiDelivery $ei_delivery = null, $state_id = null, $guard_id = null)
 {
     //Requete plus simple car moins de besoin en terme d'objets liés au sujet
     $q = Doctrine_Query::create()->from('EiSubject s')->leftJoin('s.subjectAssignments as')->where('s.project_id=? And s.project_ref=? ', array($ei_project->getProjectId(), $ei_project->getRefId()));
     //Si l'utilisateur est spécifié alors on rajoute le critère
     if ($guard_id != null) {
         $q = $q->andWhere('as.guard_id=' . $guard_id);
     }
     //Si la livraison est spécifiée
     if ($ei_delivery != null) {
         $q = $q->andWhere('s.delivery_id=' . $ei_delivery->getId());
     }
     //Si le statut est spécifié
     if ($state_id != null) {
         $q = $q->andWhere('s.subject_state_id=' . $state_id);
     }
     return $q->execute();
 }
 public function getActiveProfilesForVersion(Eiprojet $ei_project, KalFunction $kal_function, $vn_id, $notice_id, $notice_ref, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     return $conn->fetchAll(" select pr.*,np1.version_notice_id from  \n            (select * from ei_profil p where p.project_id=" . $ei_project->getProjectId() . " and p.project_ref=" . $ei_project->getRefId() . ") as pr\n            left join \n            (select np.profile_id , np.profile_ref , vn.version_notice_id ,vn.name from ei_notice_profil np  \n            inner join (select * from ei_version_notice where version_notice_id=" . $vn_id . " and notice_id=" . $notice_id . " and notice_ref=" . $notice_ref . " group by version_notice_id,notice_id,notice_ref ) vn  on vn.version_notice_id=np.version_notice_id and vn.notice_id=np.notice_id and vn.notice_ref=np.notice_ref \n            inner join ei_notice n on n.notice_id=vn.notice_id and n.notice_ref=vn.notice_ref and n.function_id=" . $kal_function->getFunctionId() . " and n.function_ref=" . $kal_function->getFunctionRef() . "  \n            ) as np1\n\n            on pr.profile_id=np1.profile_id and pr.profile_ref=np1.profile_ref");
 }