/** * @Route("/", name="index") */ public function indexshowAction() { if ($this->container->get('security.context')->isGranted('ROLE_ADMIN')) { return $this->redirectToRoute('admin'); } /* $joinChiamateUtenti = $this->getDoctrine()->getEntityManager()->getRepository('AppBundle:Chiamate'); $matchChiamateUtenti = $joinChiamateUtenti->createQueryBuilder('c') ->add('select', 'c, u') ->add('from', 'AppBundle:Chiamate c') ->innerJoin('AppBundle:Utenti', 'u') ->where('c.utente=u.id') ->getQuery() ->getArrayResult(); /*foreach ($matchChiamateUtenti as $matchChiamateUtente) { foreach ($matchChiamateUtente as $matchChiamateUtente) { if($matchChiamateUtente instanceof DateTime){ $string = $matchChiamateUtente->getTimestamp(); } else { //$inizioChiamata = strtotime($matchChiamateUtente['inizioChiamata']); $obj= $matchChiamateUtente['inizioChiamata']; } //$statusUtente =$matchChiamateUtente['statusUtente']; //echo $statusUtente; } }*/ $username = '******'; $password = '******'; // Create a new mailup client $client = new MailUpClient($username, $password); $elencoUtenti = $client->getListRecipients(3, 'Subscribed'); foreach ($elencoUtenti->Items as $Items) { $nuovoUtente = new Utenti(); $email = $Items->Email; $nuovoUtente->setEmail($email); foreach ($Items->Fields as $Fields) { $description = $Fields->Description; switch ($description) { case 'surname': $surname = $Fields->Value; $nuovoUtente->setSurname($surname); break; case 'name': $name = $Fields->Value; $nuovoUtente->setName($name); break; case 'phone': $phone = $Fields->Value; $nuovoUtente->setPhone($phone); break; case 'Campagne': $campagna = $Fields->Value; $nuovoUtente->setCampagna($campagna); } } $em = $this->getDoctrine()->getManager(); $utenteCheck = $em->getRepository('AppBundle:Utenti')->findOneByEmail($email); if (!$utenteCheck) { $em = $this->getDoctrine()->getManager(); $em->persist($nuovoUtente); $em->flush(); } } $em = $this->getDoctrine()->getEntityManager(); $Chiamate = $em->getRepository('AppBundle:Chiamate')->findAll(); $utenti = $em->getRepository('AppBundle:Utenti')->findAll(); if (!$utenti) { throw $this->createNotFoundException('Unable to find lista Utenti .'); } return $this->render('AppBundle::default/index-user.html.twig', array('utenti' => $utenti, 'chiamate' => $Chiamate)); }