/** * @Route("/operatore_campagne_attive", name="operatore_campagne_attive") */ public function operatore_campagne_attiveAction(Request $request) { //codice mailup QUI ! $username = '******'; $password = '******'; $client = new MailUpClient($username, $password); $recipients = $client->getGroupRecipients(26); foreach ($recipients->Items as $key => $value) { //controllo se i report scaricati esistono nel database $exist = false; $existingReports = $this->getDoctrine()->getRepository('AppBundle:Contatti')->findAll(); $name = NULL; $campaign = NULL; foreach ($value->Fields as $key => $field) { if ($field->Description == 'name') { $name = $field->Value; } if ($field->Description == 'Campagne') { $campaign = $field->Value; } } foreach ($existingReports as $n => $existingReport) { if ($existingReport->getEmailContatto() == $value->Email && $existingReport->getCampagnaContatto() == $campaign) { $exist = true; } } if (!$exist) { $counter = NULL; $operator = $this->getDoctrine()->getRepository('AppBundle:Utenti')->find(3); $newReport = new Contatti(); $newReport->setCampagnaContatto($campaign)->setNomeContatto($name)->setNumeroTelefonoContatto($value->MobileNumber)->setEmailContatto($value->Email)->setOperatoreContatto($operator); $em = $this->getDoctrine()->getManager(); $em->persist($newReport); $em->flush(); $em->clear(); //var_dump ($newReport);die; } } $listaCampagne = $this->getDoctrine()->getRepository('AppBundle:Contatti')->findAll(); if (!$listaCampagne) { throw $this->createNotFoundException('ops! non trovo campagne di mailup qui'); } return $this->render('AppBundle::operatore_campagne_attive.html.twig', ['listaCampagne' => $listaCampagne]); }
/** * @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)); }