public function newAction(Request $request)
    {
        $visit = new Visit();
        $form = $this->createForm('CoreExtraBundle\Form\VisitType', $visit);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($visit);
            $em->flush($visit);

            //if come from popup
            if ($request->isXMLHttpRequest()) {         
                return new JsonResponse(array(
                            'id' => $visit->getId(), 
                        ));
            }
            
            /*********************/
            /********Custom ******/
            /*********************/
            //truncate table email token
//            $connection = $em->getConnection();
//            $statement = $connection->prepare("TRUNCATE TABLE email_token");
//            $statement->execute();
            $email = $visit->getActor()->getEmail();
            $emailToken = new EmailToken();
            $emailToken->setEmail($email);
            $token = sha1(uniqid());
            $emailToken->setToken($token);
            $em->persist($emailToken);
            $visit->setEmailToken($emailToken);
            $em->flush();
            $template   = $this->get('twig')->loadTemplate('CoreExtraBundle:Email:email.template.html.twig');
            $body  = $template->renderBlock('body', array(
                'user_name' => $visit->getActor()->getFullName(),
                'place_name' => 'Place name'
            ));
            $body = preg_replace('/(#TOKEN#)/', $token, $body);  
            
            $this->get('core.mailer')->sendFeedback(array($email), $body, 'Place Name');
            $this->get('session')->getFlashBag()->add('success', 'visit.sent');

            $this->get('session')->getFlashBag()->add('success', 'visit.created');
            
            return $this->redirectToRoute('visit_show', array('id' => $visit->getId()));
        }

        return array(
            'visit' => $visit,
            'form' => $form->createView(),
        );
    }