src/Repository/Kanban/FicheRepository.php line 79

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Kanban;
  3. use App\Entity\Kanban\Fiche;
  4. use DateInterval;
  5. use Datetime;
  6. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. /**
  9.  * FicheRepository
  10.  *
  11.  * This class was generated by the Doctrine ORM. Add your own custom
  12.  * repository methods below.
  13.  */
  14. class FicheRepository extends ServiceEntityRepository
  15. {
  16.     public function __construct(ManagerRegistry $registry)
  17.     {
  18.         parent::__construct($registryFiche::class);
  19.     }
  20.     public function getTotalAffaireClient($client) {
  21.             
  22.                 
  23.         $query $this->createQueryBuilder('p')
  24.             ->select("COUNT(p.id) as total")
  25.             ->where('p.client = :client AND p.dateSuppression IS NULL AND (p.statutFiche is NULL or p.statutFiche = :gagne or p.statutFiche = :perdu)')
  26.             ->setParameters(['client' => $client'gagne' =>'1''perdu' =>'2'])
  27.             ;
  28.         $res $query->getQuery()->getOneOrNullResult();
  29.         return $res;
  30.     }
  31.     
  32.     
  33.     public function nbAffaireGagnee($parametres = [], $user) {
  34.         
  35.         $where_equipiers "";
  36.        
  37.         if (array_key_exists('equipiers'$parametres) && count($parametres["equipiers"]) > 0) {
  38.             foreach($parametres["equipiers"] as $e) {
  39.                 $where_equipiers .= $e.",";
  40.             }
  41.         }
  42.        
  43.        if($where_equipiers != "") {
  44.            $where_equipiers trim($where_equipiers,',');
  45.            //$where_equipiers = " AND utilisateur_id IN (".$where_equipiers.")";
  46.            $where_equipiers " AND (utilisateur_id IN (".$where_equipiers.") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$where_equipiers.") ) )";
  47.        }
  48.         
  49.         if(!is_object($user->getType()) or ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  50.             //$where_equipiers = " AND utilisateur_id IN (".$user->getId().")";
  51.             $where_equipiers " AND (utilisateur_id IN (".$user->getId().") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$user->getId().") ) )";
  52.         }      
  53.         
  54.         
  55.         $sql 'select count(*) as total 
  56.                     from kanban__fiche kf
  57.                     where 
  58.                     kf.dateSuppression is NULL    
  59.                     and
  60.                     kf.statut_fiche_id = 1
  61.                     '.$where_equipiers.'                
  62.                     ';
  63.                     
  64.             
  65.         
  66.         //echo $sql.'<br/><br/>';
  67.         
  68.         $em $this->getEntityManager();
  69.         $stmt $em->getConnection()->prepare($sql);
  70.         $res =  $stmt->executeQuery()->fetchAllAssociative();
  71.         return $res[0]["total"];
  72.         
  73.     }
  74.     
  75.     public function nbAffairePerdue($parametres = [], $user) {
  76.         
  77.         $where_equipiers "";
  78.        
  79.         if (array_key_exists('equipiers'$parametres) && count($parametres["equipiers"]) > 0) {
  80.             foreach($parametres["equipiers"] as $e) {
  81.                 $where_equipiers .= $e.",";
  82.             }
  83.         }
  84.        
  85.        if($where_equipiers != "") {
  86.            $where_equipiers trim($where_equipiers,',');
  87.            //$where_equipiers = " AND utilisateur_id IN (".$where_equipiers.")";
  88.            $where_equipiers " AND (utilisateur_id IN (".$where_equipiers.") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$where_equipiers.") ) )";
  89.        }
  90.        
  91.            if(!is_object($user->getType()) or ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  92.             //$where_equipiers = " AND utilisateur_id IN (".$user->getId().")";
  93.             $where_equipiers " AND (utilisateur_id IN (".$user->getId().") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$user->getId().") ) )";
  94.         }  
  95.         
  96.         
  97.         $sql 'select count(*) as total 
  98.                     from kanban__fiche kf
  99.                     where 
  100.                     kf.dateSuppression is NULL    
  101.                     and
  102.                     kf.statut_fiche_id = 2    
  103.                     '.$where_equipiers.'            
  104.                     ';
  105.                     
  106.             
  107.         
  108.         //echo $sql.'<br/><br/>';
  109.         
  110.         $em $this->getEntityManager();
  111.         $stmt $em->getConnection()->prepare($sql);
  112.         $res =  $stmt->executeQuery()->fetchAllAssociative();
  113.         return $res[0]["total"];
  114.         
  115.     }
  116.     
  117.     public function nbAffaireEnCours($parametres = [], $user) {
  118.         
  119.         $where_equipiers "";
  120.        
  121.         if (array_key_exists('equipiers'$parametres) && count($parametres["equipiers"]) > 0) {
  122.             foreach($parametres["equipiers"] as $e) {
  123.                 $where_equipiers .= $e.",";
  124.             }
  125.         }
  126.        
  127.        if($where_equipiers != "") {
  128.            $where_equipiers trim($where_equipiers,',');
  129.            //$where_equipiers = " AND utilisateur_id IN (".$where_equipiers.")";
  130.            $where_equipiers " AND (utilisateur_id IN (".$where_equipiers.") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$where_equipiers.") ) )";
  131.        }
  132.         
  133.        if(!is_object($user->getType()) or ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  134.             //$where_equipiers = " AND utilisateur_id IN (".$user->getId().")";
  135.             $where_equipiers " AND (utilisateur_id IN (".$user->getId().") or id IN (select fiche_id FROM kanban__equipe WHERE utilisateur_id IN (".$user->getId().") ) )";
  136.         }  
  137.         
  138.         $sql 'select count(*) as total 
  139.                     from kanban__fiche kf
  140.                     where 
  141.                     kf.dateSuppression is NULL    
  142.                     and
  143.                     kf.statut_fiche_id is null    
  144.                     '.$where_equipiers.'            
  145.                     ';
  146.                     
  147.             
  148.         
  149.         //echo $sql.'<br/><br/>';
  150.         
  151.         $em $this->getEntityManager();
  152.         $stmt $em->getConnection()->prepare($sql);
  153.         $res =  $stmt->executeQuery()->fetchAllAssociative();
  154.         return $res[0]["total"];
  155.         
  156.     }
  157.     
  158.     
  159.     
  160.     
  161.     public function getTotalFiches() {
  162.         $sql 'select count(*) as total 
  163.                     from kanban__fiche kf
  164.                     where 
  165.                     kf.dateSuppression is NULL                    
  166.                     ';
  167.                     
  168.             
  169.         
  170.         //echo $sql.'<br/><br/>';
  171.         
  172.         $em $this->getEntityManager();
  173.         $stmt $em->getConnection()->prepare($sql);
  174.         $res =  $stmt->executeQuery()->fetchAllAssociative();
  175.         return $res[0]["total"];
  176.     }
  177.         
  178.     public function getFichesDate($periode$param = [], $user$chefProjet='') {
  179.         
  180.         //print_r($periode);
  181.         $query $this->createQueryBuilder('p');
  182.         $dateDebut = new Datetime($periode["date"]);
  183.         $dateDebut->setTime(00,00,00);        
  184.         
  185.         //echo "<div>".$dateDebut->format("Y-m-d H:i:s")."</div>";
  186.         
  187.         $dateFin= new Datetime($periode["date"]);
  188.         $dateFin->setTime(00,00,00);
  189.         $dateFin->add(new DateInterval('P1M'));
  190.         
  191.         //echo "<div>".$dateFin->format("Y-m-d H:i:s")."</div>";
  192.         
  193.         $param['parametres'] = $param;
  194.         $parametres = ["dateDebut" =>$dateDebut"dateFin" =>$dateFin];
  195.         $where "";
  196.         $join '';
  197.         
  198.         $query->leftjoin('p.statutFiche''sf');
  199.         $where "(sf.id IS NULL OR sf.id NOT IN (3))";
  200.         $query->leftjoin('p.client''c');
  201.         
  202.         /*if(array_key_exists('etat', $param['parametres']) and in_array($param['parametres']['etat'], array("1",'2','4')) ) {                    
  203.           //$qb->join('x.marque', 'm', \Doctrine\ORM\Query\Expr\Join::LEFT_JOIN);      
  204.           if($where != '') $where .= ' and ';
  205.       $where .= "p.statutFiche = :statutFiche";
  206.           $parametres['statutFiche']=$param['parametres']['etat'];   
  207.         }
  208.         else if(empty($param['parametres']['etat']) || $param['parametres']['etat'] == 'NULL') {                    
  209.         //else if(array_key_exists('etat', $param['parametres']) and ($param['parametres']['etat'] == "NULL")) {                    
  210.           //$qb->join('x.marque', 'm', \Doctrine\ORM\Query\Expr\Join::LEFT_JOIN);      
  211.           if($where != '') $where .= ' and ';
  212.       $where .="p.statutFiche is NULL";
  213.           //$parametres['statutFiche']=$param['parametres']['etat'];   
  214.         }
  215.         else if(array_key_exists('etat', $param['parametres']) and ($param['parametres']['etat'] == "all")) {    
  216.             //$where .= "AND p.statutFiche is NULL";
  217.       
  218.         } else {
  219.             //$where .= " AND p.statutFiche is NULL";
  220.       if($where != '') $where .= ' and ';
  221.             $where .= "(p.statutFiche != :statutFicheSupprime or p.statutFiche is NULL)";
  222.             $parametres['statutFicheSupprime']=3;
  223.         }
  224.         */
  225.         
  226.         if(array_key_exists('regions'$param["parametres"]) && $param["parametres"]["regions"]> 0) {
  227.             
  228.             if($where != ''$where .= ' and ';
  229.             $where .= "p.region = :region";
  230.             $parametres['region']=$param['parametres']['regions'];
  231.         }
  232.         
  233.         if(array_key_exists('sansactivites'$param["parametres"])) {
  234.             // 1 A faire
  235.             // 2 Fait
  236.             
  237.             //$query->Join('p.notes', 'no', 'with', 'no.fiche = p.id AND no.statut != 1');
  238.             
  239.             $qBLu $this->createQueryBuilder('f2')
  240.              ->select("f2.id")
  241.              ->leftJoin('f2.notes''no2')
  242.              ->where('no2.statut = :noteStatut2')
  243.              //->setParameters(array("noteStatut2"=>"1"))
  244.              //->setMaxResults(1);
  245.             ;
  246.             if($where != ''$where .= ' and ';
  247.             
  248.             $where .= 'p.id NOT IN (' $qBLu->getDQL() . ')';
  249.             $parametres['noteStatut2']=1;
  250.         }
  251.         
  252.         
  253.            
  254.         if(array_key_exists('client'$param['parametres']) and ($param['parametres']['client'] != "")) {    
  255.             $query->leftjoin('p.client''c');
  256.           if($where != ''$where .= ' and ';
  257.             $where .= "c.id = :client";
  258.             $parametres['client'] = $param['parametres']['client'];
  259.         }
  260.                 
  261.         if(array_key_exists('contact'$param['parametres']) and ($param['parametres']['contact'] != "")) {    
  262.             $query->leftjoin('p.contact''ct');
  263.             if($where != ''$where .= ' and ';
  264.             $where .= "ct.id = :contact";
  265.             $parametres['contact'] = $param['parametres']['contact'];
  266.         }
  267.         
  268.         if(array_key_exists('u'$param['parametres']) and count($param['parametres']['u'])>0) {                          
  269.           if($where != ''$where .= ' and ';
  270.       $where .= "p.utilisateur IN (:utilisateurs)";          
  271.           foreach($param['parametres']['u'] as $key=>$value) {
  272.               $parametres['utilisateurs'][]=$value
  273.           }                      
  274.         }
  275.                 
  276.                 
  277.         if(is_object($user->getType()) and ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  278.             
  279.             /*
  280.             $where .= " AND p.utilisateur IN (:utilisateurs)";    
  281.             $parametres['utilisateurs'][]=array($user->getId()); 
  282.             */
  283.             if($where != ''$where .= ' and ';
  284.             $where .= "( p.utilisateur IN (:utilisateurs) OR eq.utilisateur = :equipier )";    
  285.             $parametres['utilisateurs'][]= [$user->getId()];
  286.             $parametres['equipier'][]=$user->getId();    
  287.             
  288.         }
  289.         else if(array_key_exists('filtre-utilisateurs'$param['parametres']) and count($param['parametres']['filtre-utilisateurs'])>0) {                          
  290.           if($where != ''$where .= ' and ';
  291.           $where .= "( p.utilisateur IN (:utilisateurs) OR eq.utilisateur IN (:equipier) )";          
  292.           foreach($param['parametres']['filtre-utilisateurs'] as $key=>$value) {
  293.               $parametres['utilisateurs'][]=$value
  294.               $parametres['equipier'][]=$value
  295.               
  296.           }        
  297.                         
  298.         }                
  299.                 
  300.         if(array_key_exists('filtre-apporteurs'$param['parametres']) and count($param['parametres']['filtre-apporteurs'])>0) {                          
  301.           if($where != ''$where .= ' and ';
  302.           $where .= "p.apporteur IN (:apporteurs)";          
  303.             foreach($param['parametres']['filtre-apporteurs'] as $key=>$value) {
  304.                 $parametres['apporteurs'][]=$value
  305.                 
  306.             }        
  307.         }
  308.         if(array_key_exists('filtre-commerciaux'$param['parametres']) and count($param['parametres']['filtre-commerciaux'])>0) {                          
  309.             if($where != ''$where .= ' and ';
  310.       $where .= "p.commercial IN (:commerciaux)";          
  311.             foreach($param['parametres']['filtre-commerciaux'] as $key=>$value) {
  312.                 $parametres['commerciaux'][]=$value
  313.                 
  314.             }        
  315.         }
  316.         if(array_key_exists('filtre-chefsProjet'$param['parametres']) and count($param['parametres']['filtre-chefsProjet'])>0) {                          
  317.             if($where != ''$where .= ' and ';
  318.               $where .= "p.chefProjet IN (:chefsProjet)";          
  319.             foreach($param['parametres']['filtre-chefsProjet'] as $key=>$value) {
  320.                 $parametres['chefsProjet'][]=$value
  321.             }        
  322.             if(!empty($chefProjet)){
  323.                 if($where != ''$where .= ' and ';
  324.                 $where .= "eq.role = :chefProjetArticle";
  325.                 $parametres['chefProjetArticle'] = $chefProjet;
  326.             }
  327.         }
  328.             if(array_key_exists('tunnel'$param['parametres']) and ($param['parametres']['tunnel'] != "")) {    
  329.            
  330.                    
  331.             //$em = $this->getDoctrine()->getManager();
  332.             //$repo_kanban = $em->getRepository('DTCKanbanBundle:Kanban');
  333.             //$repo_colonne = $em->getRepository('DTCKanbanBundle:Colonne');
  334.             
  335.             $sql "SELECT colonne_id FROM kanban__kanban WHERE id = ".$param['parametres']['tunnel'];
  336.             $sql trim($sql);        
  337.         
  338.             $em $this->getEntityManager();
  339.             $stmt $em->getConnection()->prepare($sql);
  340.             $kanban_obj =  $stmt->executeQuery()->fetchAllAssociative();
  341.             
  342.             
  343.             
  344.                         
  345.             //$kanban_obj = $repo_kanban->find($param['parametres']['tunnel']);
  346.             
  347.             if(!is_null($kanban_obj[0]["colonne_id"])) 
  348.             //if(is_object($kanban_obj) && is_object($kanban_obj->getColonne()) ) 
  349.             {
  350.                 $colids = [];
  351.                 //$colids = $repo_colonne->findBy(array("kanban"=>$kanban_obj));    
  352.                 
  353.                 $sql "SELECT id FROM kanban__colonne WHERE kanban_id = ".$param['parametres']['tunnel'];
  354.                 $sql trim($sql);        
  355.                 
  356.                 $em $this->getEntityManager();
  357.                 $stmt $em->getConnection()->prepare($sql);
  358.                 $colids =  $stmt->executeQuery()->fetchAllAssociative();
  359.                 
  360.                 $query->leftjoin('p.colonne''col');
  361.                                 
  362.                             
  363.                 if($where != ''$where .= ' and ';                
  364.                 $where .= 'col.id IN (:colids)';
  365.                 $parametres['colids']=$colids;                                    
  366.             }
  367.             else {
  368.                 if($where != ""$where .= " AND ";
  369.                 $where .= "p.kanban = :kanban";
  370.                 $parametres['kanban']=$param['parametres']['tunnel'];
  371.             }
  372.                    
  373.                    
  374.            
  375.                 
  376.                 
  377.                 
  378.             
  379.         }     
  380.         
  381.         
  382.         /*
  383.         if(array_key_exists('or', $param['parametres']) and ($param['parametres']['or'] != "")) {    
  384.             //echo "AAAAAA(".$param['parametres']['or'].")";
  385.               $query->leftjoin('p.ficheOrigine', 'fo');
  386.               $where .= " AND fo.origine = :origine";
  387.             $parametres['origine'] = $param['parametres']['or'];
  388.         }
  389.            */   
  390.         if(array_key_exists('or'$param['parametres']) and ($param['parametres']['or'] != "")) {    
  391.               $query->leftjoin('p.origineCommande''fo');
  392.         if($where != ''$where .= ' and ';
  393.               $where .= "fo.id = :origine";
  394.             $parametres['origine'] = $param['parametres']['or'];
  395.         } 
  396.         if(array_key_exists('marche'$param['parametres']) and ($param['parametres']['marche'] != "")) {    
  397.             $query->leftjoin('p.marche''mr');
  398.             if($where != ''$where .= ' and ';
  399.       $where .= "mr.id = :marche";
  400.             $parametres['marche'] = $param['parametres']['marche'];
  401.         }
  402.         if(!empty($param['parametres']['apporteur'])) {    
  403.             $query->leftjoin('p.apporteur''ap');
  404.             if($where != ''$where .= ' and ';
  405.       $where .= "ap.id = :apporteur";
  406.             $parametres['apporteur'] = $param['parametres']['apporteur'];
  407.         }
  408.           
  409.         if(array_key_exists('domaine'$param['parametres']) and ($param['parametres']['domaine'] != "")) {    
  410.             $query->leftjoin('p.projetDomaines''pd');
  411.             $query->leftjoin('pd.domaine''do');
  412.             if($where != ''$where .= ' and ';
  413.       $where .= "do.id = :domaine";
  414.             $parametres['domaine'] = $param['parametres']['domaine'];
  415.         }
  416.           
  417.         if(array_key_exists('activite'$param['parametres']) and ($param['parametres']['activite'] != "")) {    
  418.             $query->leftjoin('p.projetActivites''pa');
  419.             $query->leftjoin('pa.activite''paa');
  420.             if($where != ''$where .= ' and ';
  421.       $where .= "paa.id = :activite";
  422.             $parametres['activite'] = $param['parametres']['activite'];
  423.         }
  424.           /*
  425.         if(array_key_exists('partenaire', $param['parametres']) and ($param['parametres']['partenaire'] != "")) {    
  426.             $query->leftjoin('p.commandes', 'cmd');
  427.             $query->leftjoin('cmd.articleCommande', 'accmd');
  428.             $query->leftjoin('cmd.statutCommande', 'scmd');
  429.             $query->leftjoin('cmd.typeDocumentCommercial', 'tcmd');
  430.       if($where != '') $where .= ' and ';
  431.       $where .= "scmd.ordre NOT IN (0) AND tcmd.id IN (1) AND accmd.fournisseur = :partenaire";
  432.             $parametres['partenaire'] = $param['parametres']['partenaire'];
  433.         }
  434.         */
  435.         if($where != ""$where .= " AND ";
  436.         $where .= '(p.archive = 0 OR p.archive IS NULL) and p.date >= :dateDebut and p.date < :dateFin';
  437.           
  438.         $query
  439.             //->join('c.kanban', 'k')
  440.             //->leftjoin('p.statutFiche', 's')
  441.             //->leftjoin('p.equipe', 'eq')
  442.             ->leftjoin('p.projetUtilisateurs''eq')
  443.             ->where($where)
  444.             ->setParameters($parametres)
  445.             ->orderBy('p.date''DESC')
  446.             ->groupBy('p.id')
  447.             ;
  448.         
  449.         
  450.         if(array_key_exists('favoris'$param['parametres']) and ($param['parametres']['favoris'] == "1")) {                    
  451.           $query->join('p.favoris''f');
  452.             
  453.         }    
  454.         else {
  455.             $query->leftjoin('p.favoris''f');
  456.         }    
  457.         
  458.         $query->orderBy('f.date''DESC');    
  459.         
  460.                 
  461.         $res $query->getQuery()->getResult();
  462.         return $res;
  463.         
  464.     }        
  465.         
  466.     public function getFiches($kanban$param = [], $user$chefProjet='') {
  467.         
  468.         
  469.         $query $this->createQueryBuilder('p');
  470.         
  471.         $param['parametres'] = $param;
  472.         $parametres = [];
  473.         //$parametres = array("kanban"=>$kanban->getId());    
  474.         $where "";
  475.         $query->leftjoin('p.statutFiche''sf');
  476.         $where "(sf.id IS NULL OR sf.id NOT IN (3))";//supprime
  477.         
  478.         //print_r($param);        
  479.         
  480.         if(array_key_exists('regions'$param["parametres"]) && $param["parametres"]["regions"]> 0) {
  481.             
  482.             if($where != ''$where .= ' and ';
  483.             $where .= "p.region = :region";
  484.             $parametres['region']=$param['parametres']['regions'];
  485.         }
  486.         
  487.         if(array_key_exists('date_debut'$param['parametres']) and ($param['date_debut'] != "")) {                    
  488.             $dateDebut DateTime::createFromFormat('d/m/Y',$param['date_debut']);
  489.             $dateDebut->setTime(00,00,00);    
  490.       if($where != ''$where .= ' and ';        
  491.             $where .= "p.date >= :dateDebut";            
  492.             $parametres['dateDebut']= $dateDebut->format('Y-m-d H:i:s');
  493.         }    
  494.         
  495.         if(array_key_exists('date_fin'$param['parametres']) and ($param['date_fin'] != "")) {                    
  496.             $dateFin DateTime::createFromFormat('d/m/Y',$param['date_fin']);
  497.             $dateFin->setTime(23,59,59);
  498.       if($where != ''$where .= ' and ';
  499.             $where .= "p.date <= :dateFin";            
  500.             $parametres['dateFin']= $dateFin->format('Y-m-d H:i:s');
  501.         }    
  502.         
  503.         
  504.         if(array_key_exists('sansactivites'$param["parametres"])) {
  505.             // 1 A faire
  506.             // 2 Fait
  507.             
  508.             
  509.             /*$qBLu = $this->createQueryBuilder('f2')
  510.              ->select("f2.id")
  511.              ->leftJoin('f2.notes', 'no2')
  512.              ->where('no2.statut = :noteStatut2')
  513.              //->setParameters(array("noteStatut2"=>"1"))
  514.              //->setMaxResults(1);
  515.             ;
  516.             if($where != '') $where .= ' and ';
  517.             
  518.             $where .= 'p.id NOT IN (' . $qBLu->getDQL() . ')';
  519.             $parametres['noteStatut2']=1;*/
  520.             $query->leftjoin('p.notes''notes');
  521.             if($where != ''$where .= ' and ';
  522.                 $where .= "notes.statut = 1 AND CURRENT_DATE() >= notes.dateFin";
  523.             
  524.         }
  525.         
  526.         
  527.         if(array_key_exists('u'$param['parametres']) and count($param['parametres']['u'])>0) {    
  528.       if($where != ''$where .= ' and ';                      
  529.           $where .= "p.utilisateur IN (:utilisateurs)";          
  530.           foreach($param['parametres']['u'] as $key=>$value) {
  531.               $parametres['utilisateurs'][]=$value
  532.           }                      
  533.         }
  534.          
  535.         if(is_object($user->getType()) and ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  536.             
  537.             /*
  538.             $where .= " AND p.utilisateur IN (:utilisateurs)";    
  539.             $parametres['utilisateurs'][]=array($user->getId()); 
  540.             */
  541.             if($where != ''$where .= ' and ';
  542.             $where .= "( p.utilisateur IN (:utilisateurs) OR (eq.utilisateur = :equipier) )";    
  543.             $parametres['utilisateurs'][]= [$user->getId()];
  544.             $parametres['equipier'][]=$user->getId();    
  545.             
  546.         }
  547.         else if(array_key_exists('filtre-utilisateurs'$param['parametres']) and count($param['parametres']['filtre-utilisateurs'])>0) {                          
  548.           if($where != ''$where .= ' and ';
  549.           $where .= "( p.utilisateur IN (:utilisateurs) OR (eq.utilisateur IN (:equipier)) )";          
  550.             foreach($param['parametres']['filtre-utilisateurs'] as $key=>$value) {
  551.               $parametres['utilisateurs'][]=$value
  552.               $parametres['equipier'][]=$value
  553.               
  554.           }        
  555.                         
  556.         }
  557.         if(array_key_exists('filtre-apporteurs'$param['parametres']) and count($param['parametres']['filtre-apporteurs'])>0) {                          
  558.             if($where != ''$where .= ' and ';
  559.               $where .= "p.apporteur IN (:apporteurs)";          
  560.             foreach($param['parametres']['filtre-apporteurs'] as $key=>$value) {
  561.                 $parametres['apporteurs'][]=$value
  562.                 
  563.             }        
  564.         }
  565.         if(array_key_exists('filtre-commerciaux'$param['parametres']) and count($param['parametres']['filtre-commerciaux'])>0) {                          
  566.             if($where != ''$where .= ' and ';
  567.               $where .= "p.commercial IN (:commerciaux)";          
  568.             foreach($param['parametres']['filtre-commerciaux'] as $key=>$value) {
  569.                 $parametres['commerciaux'][]=$value
  570.                 
  571.             }        
  572.         }
  573.         if(array_key_exists('filtre-chefsProjet'$param['parametres']) and count($param['parametres']['filtre-chefsProjet'])>0) {                          
  574.             if($where != ''$where .= ' and ';// where projetUtilisateurs.utilisateur == filtre and projetUtilisateurs.role.id = 
  575.               $where .= "projetU.utilisateur IN (:chefsProjet)";         
  576.             foreach($param['parametres']['filtre-chefsProjet'] as $key=>$value) {
  577.                 $parametres['chefsProjet'][]=$value
  578.             }
  579.             if(!empty($chefProjet)){
  580.                 if($where != ''$where .= ' and ';
  581.                 $where .= "eq.role = :chefProjetArticle";
  582.                 $parametres['chefProjetArticle'] = $chefProjet;
  583.             }
  584.         }
  585.         
  586.                 
  587.         if(array_key_exists('client'$param['parametres']) and ($param['parametres']['client'] != "")) {    
  588.             $query->leftjoin('p.client''cli');
  589.           if($where != ''$where .= ' and ';
  590.             $where .= "cli.id = :client";
  591.             $parametres['client'] = $param['parametres']['client'];
  592.         }
  593.                 
  594.         if(array_key_exists('contact'$param['parametres']) and ($param['parametres']['contact'] != "")) {    
  595.             $query->leftjoin('p.contact''ct');
  596.             if($where != ''$where .= ' and ';
  597.           $where .= "ct.id = :contact";
  598.             $parametres['contact'] = $param['parametres']['contact'];
  599.         }
  600.                 
  601.         if(array_key_exists('filtre-fiche'$param['parametres']) and ($param['parametres']['filtre-fiche'] != "")) {    
  602.           if($where != ''$where .= ' and ';  
  603.             $where .= "p.id = :fiche";
  604.             $parametres['fiche'] = $param['parametres']['filtre-fiche'];
  605.         }
  606.         
  607.         /*
  608.         if(array_key_exists('or', $param['parametres']) and ($param['parametres']['or'] != "")) {    
  609.             //echo "AAAAAA(".$param['parametres']['or'].")";
  610.               $query->leftjoin('p.ficheOrigine', 'fo');
  611.               $where .= " AND fo.origine = :origine";
  612.             $parametres['origine'] = $param['parametres']['or'];
  613.             
  614.         }    
  615.         */
  616.         if(array_key_exists('or'$param['parametres']) and ($param['parametres']['or'] != "")) {    
  617.             $query->leftjoin('p.origineCommande''fo');
  618.             if($where != ''$where .= ' and ';
  619.       $where .= "fo.id = :origine";
  620.           $parametres['origine'] = $param['parametres']['or'];
  621.           } 
  622.           
  623.         if(array_key_exists('marche'$param['parametres']) and ($param['parametres']['marche'] != "")) {    
  624.             $query->leftjoin('p.marche''mr');
  625.             if($where != ''$where .= ' and ';
  626.       $where .= "mr.id = :marche";
  627.             $parametres['marche'] = $param['parametres']['marche'];
  628.         }
  629.         if(!empty($param['parametres']['apporteur'])) {    
  630.             $query->leftjoin('p.apporteur''ap');
  631.             if($where != ''$where .= ' and ';
  632.       $where .= "ap.id = :apporteur";
  633.             $parametres['apporteur'] = $param['parametres']['apporteur'];
  634.         }
  635.           
  636.         if(array_key_exists('domaine'$param['parametres']) and ($param['parametres']['domaine'] != "")) {    
  637.             $query->leftjoin('p.projetDomaines''pd');
  638.             $query->leftjoin('pd.domaine''do');
  639.             if($where != ''$where .= ' and ';
  640.       $where .= "do.id = :domaine";
  641.             $parametres['domaine'] = $param['parametres']['domaine'];
  642.         }
  643.           
  644.         if(array_key_exists('activite'$param['parametres']) and ($param['parametres']['activite'] != "")) {    
  645.             $query->leftjoin('p.projetActivites''pa');
  646.             $query->leftjoin('pa.activite''paa');
  647.             if($where != ''$where .= ' and ';
  648.       $where .= "paa.id = :activite";
  649.             $parametres['activite'] = $param['parametres']['activite'];
  650.         }
  651.           /*
  652.         if(array_key_exists('filtre-fournisseurs', $param['parametres']) and ($param['parametres']['filtre-fournisseurs'] != "")) {    
  653.             if($where != '') $where .= ' and ';    
  654.             $where .= "scmd.ordre NOT IN (0) AND tcmd.id IN (1) AND accmd.fournisseur IN (:partenaire)";
  655.             
  656.             $parametres['partenaire'] = $param['parametres']['filtre-fournisseurs'];
  657.         }
  658.         if(array_key_exists('consortium', $param['parametres']) and ($param['parametres']['consortium'] != "")) {    
  659.             if($where != '') $where .= ' and ';
  660.             $where .= "accmd.fournisseur IS NOT NULL AND four.consortium = 1";
  661.             
  662.             
  663.         }
  664.           */
  665.         if($where != ""$where .= " AND ";
  666.         $where .= '(k.id = :kanban or kck.id = :kanban or kckck = :kanban) AND (p.archive = 0 OR p.archive IS NULL)';
  667.         //print_r($parametres);
  668.         //echo $where;
  669.         /*
  670.         $query           
  671.             ->join('p.colonne', 'c')
  672.             ->join('c.kanban', 'k')
  673.             ->leftjoin('p.equipe', 'eq')
  674.             //->where('k.id = :kanban '.$where)
  675.             //->setParameters($parametres)
  676.             ->where("1=1 ".$where)
  677.             ->setParameters($parametres)
  678.             ->groupBy('p.id')
  679.             ;
  680.             */
  681.         $parametres['kanban'] = $kanban;
  682.         $query           
  683.             ->join('p.colonne''c')
  684.             ->join('c.kanban''k')
  685.             ->leftJoin('k.colonne''kc')
  686.             ->leftJoin('kc.kanban''kck')
  687.             ->leftJoin('kck.colonne''kckc')
  688.             ->leftJoin('kckc.kanban''kckck')
  689.             //->leftjoin('p.equipe', 'eq')
  690.             ->leftjoin('p.projetUtilisateurs''eq')
  691.             /*
  692.             ->leftjoin('p.commandes', 'cmd')
  693.             ->leftjoin('cmd.articleCommande', 'accmd')
  694.             ->leftjoin('cmd.statutCommande', 'scmd')
  695.             ->leftjoin('cmd.typeDocumentCommercial', 'tcmd')
  696.             */
  697.             //->leftjoin('accmd.fournisseur', 'four')
  698.             //->leftjoin('p.projetUtilisateurs', 'projetU')
  699.             ->where($where)
  700.             //->setParameters($parametres)
  701.             //->where("1=1 ".$where)
  702.             ->setParameters($parametres)
  703.             ->groupBy('p.id')
  704.         ;
  705.    
  706.             
  707.     
  708.     
  709.         if(array_key_exists('favoris'$param['parametres']) and ($param['parametres']['favoris'] == "1")) {                    
  710.           $query->join('p.favoris''f');
  711.             
  712.         }    
  713.         else {
  714.             $query->leftjoin('p.favoris''f');
  715.         }    
  716.         
  717.         //$query->orderBy('f.date', 'DESC');    
  718.         $query->orderBy('p.libelle''ASC');    
  719.   
  720.         //echo $where;    
  721.         $res $query->getQuery()->getResult();
  722.         
  723.         return $res;
  724.     }
  725.     public function getFichesByColonne($colonne$param = [], $user$chefProjet='') {
  726.         
  727.         
  728.         $query $this->createQueryBuilder('p');
  729.         
  730.         $param['parametres'] = $param;
  731.         $parametres = [];
  732.         //$parametres = array("kanban"=>$kanban->getId());    
  733.         $where "";
  734.         $query->leftjoin('p.statutFiche''sf');
  735.         $where "(sf.id IS NULL OR sf.id NOT IN (3))";//supprime
  736.         
  737.         //print_r($param);        
  738.         
  739.         if(array_key_exists('regions'$param["parametres"]) && $param["parametres"]["regions"]> 0) {
  740.             
  741.             if($where != ''$where .= ' and ';
  742.             $where .= "p.region = :region";
  743.             $parametres['region']=$param['parametres']['regions'];
  744.         }
  745.         
  746.         if(array_key_exists('date_debut'$param['parametres']) and ($param['date_debut'] != "")) {                    
  747.             $dateDebut DateTime::createFromFormat('d/m/Y',$param['date_debut']);
  748.             $dateDebut->setTime(00,00,00);    
  749.       if($where != ''$where .= ' and ';        
  750.             $where .= "p.date >= :dateDebut";            
  751.             $parametres['dateDebut']= $dateDebut->format('Y-m-d H:i:s');
  752.         }    
  753.         
  754.         if(array_key_exists('date_fin'$param['parametres']) and ($param['date_fin'] != "")) {                    
  755.             $dateFin DateTime::createFromFormat('d/m/Y',$param['date_fin']);
  756.             $dateFin->setTime(23,59,59);
  757.       if($where != ''$where .= ' and ';
  758.             $where .= "p.date <= :dateFin";            
  759.             $parametres['dateFin']= $dateFin->format('Y-m-d H:i:s');
  760.         }    
  761.         
  762.         
  763.         if(array_key_exists('sansactivites'$param["parametres"])) {
  764.             // 1 A faire
  765.             // 2 Fait
  766.             
  767.             
  768.             /*$qBLu = $this->createQueryBuilder('f2')
  769.              ->select("f2.id")
  770.              ->leftJoin('f2.notes', 'no2')
  771.              ->where('no2.statut = :noteStatut2')
  772.              //->setParameters(array("noteStatut2"=>"1"))
  773.              //->setMaxResults(1);
  774.             ;
  775.             if($where != '') $where .= ' and ';
  776.             
  777.             $where .= 'p.id NOT IN (' . $qBLu->getDQL() . ')';
  778.             $parametres['noteStatut2']=1;*/
  779.             $query->leftjoin('p.notes''notes');
  780.             if($where != ''$where .= ' and ';
  781.                 $where .= "notes.statut = 1 AND CURRENT_DATE() >= notes.dateFin";
  782.             
  783.         }
  784.         
  785.         
  786.         if(array_key_exists('u'$param['parametres']) and count($param['parametres']['u'])>0) {    
  787.       if($where != ''$where .= ' and ';                      
  788.           $where .= "p.utilisateur IN (:utilisateurs)";          
  789.           foreach($param['parametres']['u'] as $key=>$value) {
  790.               $parametres['utilisateurs'][]=$value
  791.           }                      
  792.         }
  793.          
  794.         if(is_object($user->getType()) and ($user->getType()->getId() != "1" and $user->getType()->getId() != "2")) {
  795.             
  796.             /*
  797.             $where .= " AND p.utilisateur IN (:utilisateurs)";    
  798.             $parametres['utilisateurs'][]=array($user->getId()); 
  799.             */
  800.             if($where != ''$where .= ' and ';
  801.             $where .= "( p.utilisateur IN (:utilisateurs) OR (eq.utilisateur = :equipier) )";    
  802.             $parametres['utilisateurs'][]= [$user->getId()];
  803.             $parametres['equipier'][]=$user->getId();    
  804.             
  805.         }
  806.         else if(array_key_exists('filtre-utilisateurs'$param['parametres']) and count($param['parametres']['filtre-utilisateurs'])>0) {                          
  807.           if($where != ''$where .= ' and ';
  808.           $where .= "( p.utilisateur IN (:utilisateurs) OR (eq.utilisateur IN (:equipier)) )";          
  809.             foreach($param['parametres']['filtre-utilisateurs'] as $key=>$value) {
  810.               $parametres['utilisateurs'][]=$value
  811.               $parametres['equipier'][]=$value
  812.               
  813.           }        
  814.                         
  815.         }
  816.         if(array_key_exists('filtre-apporteurs'$param['parametres']) and count($param['parametres']['filtre-apporteurs'])>0) {                          
  817.             if($where != ''$where .= ' and ';
  818.               $where .= "p.apporteur IN (:apporteurs)";          
  819.             foreach($param['parametres']['filtre-apporteurs'] as $key=>$value) {
  820.                 $parametres['apporteurs'][]=$value
  821.                 
  822.             }        
  823.         }
  824.         if(array_key_exists('filtre-commerciaux'$param['parametres']) and count($param['parametres']['filtre-commerciaux'])>0) {                          
  825.             if($where != ''$where .= ' and ';
  826.               $where .= "p.commercial IN (:commerciaux)";          
  827.             foreach($param['parametres']['filtre-commerciaux'] as $key=>$value) {
  828.                 $parametres['commerciaux'][]=$value
  829.                 
  830.             }        
  831.         }
  832.         if(array_key_exists('filtre-chefsProjet'$param['parametres']) and count($param['parametres']['filtre-chefsProjet'])>0) {                          
  833.             if($where != ''$where .= ' and ';// where projetUtilisateurs.utilisateur == filtre and projetUtilisateurs.role.id = 
  834.               $where .= "projetU.utilisateur IN (:chefsProjet)";         
  835.             foreach($param['parametres']['filtre-chefsProjet'] as $key=>$value) {
  836.                 $parametres['chefsProjet'][]=$value
  837.             }
  838.             if(!empty($chefProjet)){
  839.                 if($where != ''$where .= ' and ';
  840.                 $where .= "eq.role = :chefProjetArticle";
  841.                 $parametres['chefProjetArticle'] = $chefProjet;
  842.             }
  843.         }
  844.         
  845.                 
  846.         if(array_key_exists('client'$param['parametres']) and ($param['parametres']['client'] != "")) {    
  847.             $query->leftjoin('p.client''cli');
  848.           if($where != ''$where .= ' and ';
  849.             $where .= "cli.id = :client";
  850.             $parametres['client'] = $param['parametres']['client'];
  851.         }
  852.                 
  853.         if(array_key_exists('contact'$param['parametres']) and ($param['parametres']['contact'] != "")) {    
  854.             $query->leftjoin('p.contact''ct');
  855.             if($where != ''$where .= ' and ';
  856.           $where .= "ct.id = :contact";
  857.             $parametres['contact'] = $param['parametres']['contact'];
  858.         }
  859.                 
  860.         if(array_key_exists('filtre-fiche'$param['parametres']) and ($param['parametres']['filtre-fiche'] != "")) {    
  861.           if($where != ''$where .= ' and ';  
  862.             $where .= "p.id = :fiche";
  863.             $parametres['fiche'] = $param['parametres']['filtre-fiche'];
  864.         }
  865.         
  866.         /*
  867.         if(array_key_exists('or', $param['parametres']) and ($param['parametres']['or'] != "")) {    
  868.             //echo "AAAAAA(".$param['parametres']['or'].")";
  869.               $query->leftjoin('p.ficheOrigine', 'fo');
  870.               $where .= " AND fo.origine = :origine";
  871.             $parametres['origine'] = $param['parametres']['or'];
  872.             
  873.         }    
  874.         */
  875.         if(array_key_exists('or'$param['parametres']) and ($param['parametres']['or'] != "")) {    
  876.             $query->leftjoin('p.origineCommande''fo');
  877.             if($where != ''$where .= ' and ';
  878.       $where .= "fo.id = :origine";
  879.           $parametres['origine'] = $param['parametres']['or'];
  880.           } 
  881.           
  882.         if(array_key_exists('marche'$param['parametres']) and ($param['parametres']['marche'] != "")) {    
  883.             $query->leftjoin('p.marche''mr');
  884.             if($where != ''$where .= ' and ';
  885.       $where .= "mr.id = :marche";
  886.             $parametres['marche'] = $param['parametres']['marche'];
  887.         }
  888.         if(!empty($param['parametres']['apporteur'])) {    
  889.             $query->leftjoin('p.apporteur''ap');
  890.             if($where != ''$where .= ' and ';
  891.       $where .= "ap.id = :apporteur";
  892.             $parametres['apporteur'] = $param['parametres']['apporteur'];
  893.         }
  894.           
  895.         if(array_key_exists('domaine'$param['parametres']) and ($param['parametres']['domaine'] != "")) {    
  896.             $query->leftjoin('p.projetDomaines''pd');
  897.             $query->leftjoin('pd.domaine''do');
  898.             if($where != ''$where .= ' and ';
  899.       $where .= "do.id = :domaine";
  900.             $parametres['domaine'] = $param['parametres']['domaine'];
  901.         }
  902.           
  903.         if(array_key_exists('activite'$param['parametres']) and ($param['parametres']['activite'] != "")) {    
  904.             $query->leftjoin('p.projetActivites''pa');
  905.             $query->leftjoin('pa.activite''paa');
  906.             if($where != ''$where .= ' and ';
  907.       $where .= "paa.id = :activite";
  908.             $parametres['activite'] = $param['parametres']['activite'];
  909.         }
  910.           /*
  911.         if(array_key_exists('filtre-fournisseurs', $param['parametres']) and ($param['parametres']['filtre-fournisseurs'] != "")) {    
  912.             if($where != '') $where .= ' and ';    
  913.             $where .= "scmd.ordre NOT IN (0) AND tcmd.id IN (1) AND accmd.fournisseur IN (:partenaire)";
  914.             
  915.             $parametres['partenaire'] = $param['parametres']['filtre-fournisseurs'];
  916.         }
  917.         if(array_key_exists('consortium', $param['parametres']) and ($param['parametres']['consortium'] != "")) {    
  918.             if($where != '') $where .= ' and ';
  919.             $where .= "accmd.fournisseur IS NOT NULL AND four.consortium = 1";
  920.             
  921.             
  922.         }
  923.           */
  924.         if($where != ""$where .= " AND ";
  925.         //$where .= '(k.id = :kanban or kck.id = :kanban or kckck = :kanban) AND (p.archive = 0 OR p.archive IS NULL)';
  926.         $where .= 'c.id = :colonne AND (p.archive = 0 OR p.archive IS NULL)';
  927.         //print_r($parametres);
  928.         //echo $where;
  929.         /*
  930.         $query           
  931.             ->join('p.colonne', 'c')
  932.             ->join('c.kanban', 'k')
  933.             ->leftjoin('p.equipe', 'eq')
  934.             //->where('k.id = :kanban '.$where)
  935.             //->setParameters($parametres)
  936.             ->where("1=1 ".$where)
  937.             ->setParameters($parametres)
  938.             ->groupBy('p.id')
  939.             ;
  940.             */
  941.         //$parametres['kanban'] = $kanban;
  942.         $parametres['colonne'] = $colonne;
  943.         $query           
  944.             ->join('p.colonne''c')
  945.             ->join('c.kanban''k')
  946.             ->leftJoin('k.colonne''kc')
  947.             ->leftJoin('kc.kanban''kck')
  948.             ->leftJoin('kck.colonne''kckc')
  949.             ->leftJoin('kckc.kanban''kckck')
  950.             //->leftjoin('p.equipe', 'eq')
  951.             ->leftjoin('p.projetUtilisateurs''eq')
  952.             /*
  953.             ->leftjoin('p.commandes', 'cmd')
  954.             ->leftjoin('cmd.articleCommande', 'accmd')
  955.             ->leftjoin('cmd.statutCommande', 'scmd')
  956.             ->leftjoin('cmd.typeDocumentCommercial', 'tcmd')
  957.             */
  958.             //->leftjoin('accmd.fournisseur', 'four')
  959.             //->leftjoin('p.projetUtilisateurs', 'projetU')
  960.             ->where($where)
  961.             //->setParameters($parametres)
  962.             //->where("1=1 ".$where)
  963.             ->setParameters($parametres)
  964.             ->groupBy('p.id')
  965.         ;
  966.    
  967.             
  968.     
  969.     
  970.         if(array_key_exists('favoris'$param['parametres']) and ($param['parametres']['favoris'] == "1")) {                    
  971.           $query->join('p.favoris''f');
  972.             
  973.         }    
  974.         else {
  975.             $query->leftjoin('p.favoris''f');
  976.         }    
  977.         
  978.         //$query->orderBy('f.date', 'DESC');    
  979.         $query->orderBy('p.libelle''ASC');    
  980.   
  981.         //echo $where;    
  982.         $res $query->getQuery()->getResult();
  983.         
  984.         return $res;
  985.     }
  986.         
  987.     public function getRechercheFiche($recherche,$client_id ""$maxResults 500) {
  988.         $cond $recherche "%";
  989.         
  990.         if (strpos($cond"*") !== false) {
  991.             $cond str_replace("*","%",$cond);
  992.         }
  993.         
  994.         
  995.         $parameters = ['cond' => $cond];
  996.         
  997.         $where_supp "";
  998.         
  999.         if($client_id != "") {
  1000.             $where_supp " AND c.id = :client_id";
  1001.             $parameters["client_id"]=$client_id;
  1002.         }
  1003.         
  1004.         
  1005.         
  1006.         $query $this->createQueryBuilder('p')
  1007.               
  1008.               
  1009.               //CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),p.reference),')') as libelle
  1010.               
  1011.             ->select("CONCAT(CONCAT(CONCAT(CONCAT(p.libelle, ' :'), ' ('),p.reference),')') as libelle, CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),c.nom),')') as reference, p.id, c.nom,c.id as clientId")
  1012.             
  1013.             
  1014.             //->select("CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),c.nom),')') as reference,p.libelle, p.id, c.nom,c.id as clientId")
  1015.             
  1016.             ->leftjoin('p.client''c')
  1017.             ->where('(p.libelle LIKE :cond or p.reference LIKE :cond or p.description LIKE :cond) '.$where_supp)
  1018.             ->setParameters($parameters)
  1019.             ->setFirstResult(0)
  1020.             ->setMaxResults($maxResults)
  1021.             ->orderBy('p.reference''ASC');
  1022.     
  1023.         $res $query->getQuery()->getResult();
  1024.         return $res;
  1025.     }
  1026.     
  1027.     
  1028.     public function getRechercheFicheFiltre($recherche,$client_id ""$maxResults 500) {
  1029.         $cond $recherche "%";
  1030.         
  1031.         if (strpos($cond"*") !== false) {
  1032.             $cond str_replace("*","%",$cond);
  1033.         }
  1034.         
  1035.         $parameters = ['cond' => $cond'gagne' =>'1''perdu' =>'2'];
  1036.         
  1037.         $where_supp "";
  1038.         
  1039.         if($client_id != "") {
  1040.             $where_supp " AND c.id = :client_id";
  1041.             $parameters["client_id"]=$client_id;
  1042.         }
  1043.         
  1044.         $query $this->createQueryBuilder('p')
  1045.               
  1046.               //CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),p.reference),')') as libelle
  1047.               
  1048.             //->select("CONCAT(CONCAT(CONCAT(CONCAT(p.libelle, ' :'), ' ('),p.id),')') as libelle, CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.id, ' : '), p.libelle),' ('),c.nom),')') as reference, p.id, c.nom,c.id as clientId")
  1049.             ->select("CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' :'), ' ('),p.libelle),')') as libelle, CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),c.nom),')') as reference, p.id, c.nom,c.id as clientId")
  1050.             
  1051.             
  1052.             //->select("CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(p.reference, ' : '), p.libelle),' ('),c.nom),')') as reference,p.libelle, p.id, c.nom,c.id as clientId")
  1053.             
  1054.             ->leftjoin('p.client''c')
  1055.             ->where('(p.statutFiche is NULL or p.statutFiche = :gagne or p.statutFiche = :perdu) AND (p.libelle LIKE :cond or p.reference LIKE :cond or p.description LIKE :cond or p.id LIKE :cond) '.$where_supp)
  1056.             ->setParameters($parameters)
  1057.             ->setFirstResult(0)
  1058.             ->setMaxResults($maxResults)
  1059.             ->orderBy('p.reference''ASC');
  1060.     
  1061.         $res $query->getQuery()->getResult();
  1062.         return $res;
  1063.     }
  1064.     public function getMontantPondereFiche($fiche)
  1065.     {
  1066.         $budget $fiche->getBudget();
  1067.         if(!empty($fiche->getPropabilite())){
  1068.             return $budget floatval($fiche->getPropabilite()) / 100;
  1069.         } else if ($fiche->getColonne() && !is_null($fiche->getColonne()->getProbabilite()))
  1070.         {
  1071.             $probabilite $fiche->getColonne()->getProbabilite()/100;
  1072.             return $budget $probabilite;
  1073.         } elseif ($fiche->getColonne() && $fiche->getColonne()->getKanban() && $fiche->getColonne()->getKanban()->getColonne() 
  1074.             && !is_null($fiche->getColonne()->getKanban()->getColonne()->getProbabilite())){
  1075.             
  1076.             $probabilite $fiche->getColonne()->getKanban()->getColonne()->getProbabilite()/100;
  1077.             return $budget $probabilite;
  1078.         }
  1079.         
  1080.         return $budget;
  1081.     }
  1082. }