1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   |  
 
    /**
     * Résultat instantané des tâches recherché.
     *
     * @Route("/ifind", name="ifind")
     */
     public function ifindAction(){
 
        $request = $this->getRequest();
 
        $em = $this->getDoctrine()->getEntityManager();
        if($request->isXmlHttpRequest()){
            $expression ='';
            $expression = $request->get('mc');
            if($expression != ''){
                $taches = $em->getRepository('TacheBundle:Tache')->isearch($expression);
                $entreprises = $em->getRepository('EntrepriseBundle:Entreprise')->isearch($expression);
                //$dossiers = $em->getRepository('DossierBundle:Dossier')->isearch($expression);
                //$sites = $em->getRepository('NetBundle:site')->isearch($expression);
                //$sources = $em->getRepository('NetBundle:Source')->isearch($expression);
                //$soumissions = $em->getRepository('NetBundle:Soumission')->isearch($expression);
                //$data_taches = array();
                //$data_entreprises = array();
                $i = 0;
 
                if($taches){
                    echo "Tâches </br>";
                    foreach ($taches as $tache) {
                    $data_taches[$i]['id'] = $tache->getId();
                    $data_taches[$i]['nom'] = $tache->getNom();
                    $data_taches[$i]['priorite'] = $tache->getPriorite();
                    $data_taches[$i]['entreprise'] = $tache->getEntreprise();
                    $data_taches[$i]['personne'] = $tache->getPersonne();
                    $data_taches[$i]['commentaire'] = $tache->getCommentaire();                    
                    echo "<br/>";
/*Au lieu de faire des echos, j'aimerais inclure un bout de code qui affiche le résultat grace à la boucle, dans PHP Native, j'aurais fait include('MON_BOUT_DE_CODE')*/
                    echo $data_taches[$i]['nom'];
                    echo $data_taches[$i]['priorite'];
                    //echo $data_taches[$i]['date'];
                    //echo $data_taches[$i]['heure_debut'];
                    //echo $data_taches[$i]['heure_fin'];
                    echo $data_taches[$i]['entreprise'];
                    echo $data_taches[$i]['personne'];
                    echo $data_taches[$i]['commentaire'];
                    $i++;
                    }
                }
 
 
                return new Response();    
            }
        }
        return new Response("Erreur : pas de requête Ajax");       
    } | 
Partager