Beispiel #1
0
 public function captureEmailAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $gbl_email_support = $this->container->getParameter('gbl_email_support');
     $gbl_email_administrator = $this->container->getParameter('gbl_email_administrator');
     $reviewDateTime = new DateTime();
     $website_url = $this->container->getParameter('website_url');
     $realtorId = $this->get('request')->request->get('realtorReview');
     $stars = $this->get('request')->request->get('stars');
     $starH = $this->get('request')->request->get('starH');
     $starR = $this->get('request')->request->get('starR');
     $starM = $this->get('request')->request->get('starM');
     $starL = $this->get('request')->request->get('starL');
     $starG = $this->get('request')->request->get('starG');
     $starQ = $this->get('request')->request->get('starQ');
     $headline = $this->get('request')->request->get('headline');
     $writereview = $this->get('request')->request->get('writereview');
     $agent = $this->get('request')->request->get('agent');
     $receiveUpdates = $this->get('request')->request->get('receiveUpdates') == 'on' ? 1 : 0;
     $recommend = $this->get('request')->request->get('recommend');
     $type = 3;
     $status = 1;
     $session = $this->getRequest()->getSession();
     if ($session->get('userId') && $session->get('userId') != '') {
         $reviewerName = $em->createQueryBuilder()->select('user')->from('RARAdminBundle:User', 'user')->where('user.id=:id')->setParameter('id', $session->get('userId'))->getQuery()->getArrayResult();
         $firstname = $reviewerName[0]['first_name'];
         $emailReviewer = $reviewerName[0]['email'];
         $lastname = $reviewerName[0]['last_name'];
         $rating = new Review();
         $rating->setHeadline($headline);
         $rating->setDescription($writereview);
         $rating->setUseAgent($agent);
         $rating->setReceiveUpdates($receiveUpdates);
         $rating->setRecomendAgent($recommend);
         $rating->setRating($stars);
         $rating->setReviewerId($session->get('userId'));
         /*----Start Function -  Check Headline  -----*/
         $rating->setcreationTimestamp($reviewDateTime);
         if ($realtorId) {
             $rating->setRealtorId($realtorId);
         } else {
             $rating->setRealtorId($id);
         }
         $rating->setSender('REVIEWER');
         $rating->setStatus(2);
         $rating->setHonesty($starH);
         $rating->setMarketKnowldege($starL);
         $rating->setSoldPrice($starH);
         $rating->setResponsiveness($starR);
         $rating->setService($starM);
         $rating->setSoldQuickly($starQ);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($rating);
         $em->flush();
         $reviewId = $rating->getId();
         $confirmationLink = "{$website_url}/confirmation/" . $reviewId;
         $messageAdmin = \Swift_Message::newInstance()->setSubject('Review')->setFrom($emailReviewer)->setTo($gbl_email_administrator)->setBody($this->renderView('RARWebBundle:Email:admin.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'confirmationLink' => $confirmationLink, 'writereview' => $writereview, 'stars' => $stars)));
         $this->get('mailer')->send($messageAdmin);
         return $this->render('RARWebBundle:Page:sendReview.html.twig');
     }
     $website_url = $this->container->getParameter('website_url');
     if ($request->getMethod() == 'POST') {
         $fbFirstName = $this->get('request')->request->get('fbFirstName');
         $fbLastName = $this->get('request')->request->get('fbLastName');
         $fbUserFullName = $this->get('request')->request->get('fbUserFullName');
         $fbEmail = $this->get('request')->request->get('fbEmail');
         if ($fbEmail == "") {
             $firstname = $this->get('request')->request->get('firstname');
             $lastname = $this->get('request')->request->get('lastname');
             $email = $this->get('request')->request->get('email');
             $stars = $this->get('request')->request->get('stars');
             $starH = $this->get('request')->request->get('starH');
             $starR = $this->get('request')->request->get('starR');
             $starM = $this->get('request')->request->get('starM');
             $starL = $this->get('request')->request->get('starL');
             $starG = $this->get('request')->request->get('starG');
             $starQ = $this->get('request')->request->get('starQ');
             $headline = $this->get('request')->request->get('headline');
             $writereview = $this->get('request')->request->get('writereview');
             $agent = $this->get('request')->request->get('agent');
             $receiveUpdates = $this->get('request')->request->get('receiveUpdates') == 'on' ? 1 : 0;
             $recommend = $this->get('request')->request->get('recommend');
             $type = 3;
             $status = 2;
             $sysPwd = $this->generateRandomString(8);
             $em = $this->getDoctrine()->getEntityManager();
             $repository = $em->getRepository('RARAdminBundle:User');
             $user = $repository->findOneBy(array('email' => $email));
             $reviewer = new User();
             $reviewer->setFirstName($firstname);
             $reviewer->setLastName($lastname);
             $reviewer->setEmail($email);
             $reviewer->setPassword(md5($sysPwd));
             $reviewer->setType($type);
             $reviewer->setStatus($status);
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($reviewer);
             $em->flush();
             $reviewerId = $reviewer->getId();
             $website_url = $this->container->getParameter('website_url');
             //get website url
             $confirmationLink = $website_url . "/confirmed/registration/" . $reviewerId;
             //registration link
             /*---Start - Swift mailer for registration -----*/
             $message = \Swift_Message::newInstance()->setSubject('Registration')->setFrom('*****@*****.**')->setTo($email)->setBody($this->renderView('RARWebBundle:Email:registration.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $sysPwd, 'confirmationLink' => $confirmationLink)));
             $this->get('mailer')->send($message);
             $reviewDateTime = new DateTime();
             $rating = new Review();
             $rating->setHeadline($headline);
             $rating->setDescription($writereview);
             $rating->setUseAgent($agent);
             $rating->setReceiveUpdates($receiveUpdates);
             $rating->setRecomendAgent($recommend);
             $rating->setRating($stars);
             $rating->setReviewerId($reviewerId);
             $rating->setcreationTimestamp($reviewDateTime);
             if ($realtorId) {
                 $rating->setRealtorId($realtorId);
             } else {
                 $rating->setRealtorId($id);
             }
             $rating->setSender('REVIEWER');
             $rating->setStatus(2);
             $rating->setHonesty($starH);
             $rating->setMarketKnowldege($starL);
             $rating->setSoldPrice($starH);
             $rating->setResponsiveness($starR);
             $rating->setService($starM);
             $rating->setSoldQuickly($starQ);
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($rating);
             $em->flush();
             $confirmationLink = "{$website_url}/confirmation/" . $reviewerId;
             $date = date("Y/m/d.");
             $message = \Swift_Message::newInstance()->setSubject('Review')->setFrom($email)->setTo($gbl_email_administrator)->setBody($this->renderView('RARWebBundle:Email:review.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'confirmationLink' => $confirmationLink, 'writereview' => $writereview, 'stars' => $stars)));
             $this->get('mailer')->send($message);
             return $this->render('RARWebBundle:Page:confirmationLink.html.twig');
         } else {
             $firstname = $fbFirstName;
             $lastname = $fbLastName;
             $email = $fbEmail;
             $fbId = $this->get('request')->request->get('user_form_email');
         }
         $stars = $this->get('request')->request->get('stars');
         $starH = $this->get('request')->request->get('starH');
         $starR = $this->get('request')->request->get('starR');
         $starM = $this->get('request')->request->get('starM');
         $starL = $this->get('request')->request->get('starL');
         $starG = $this->get('request')->request->get('starG');
         $starQ = $this->get('request')->request->get('starQ');
         $headline = $this->get('request')->request->get('headline');
         $writereview = $this->get('request')->request->get('writereview');
         $agent = $this->get('request')->request->get('agent');
         $receiveUpdates = $this->get('request')->request->get('receiveUpdates') == 'on' ? 1 : 0;
         $recommend = $this->get('request')->request->get('recommend');
         $type = 3;
         $status = 1;
         $sysPwd = $this->generateRandomString(8);
         $em = $this->getDoctrine()->getEntityManager();
         $repository = $em->getRepository('RARAdminBundle:User');
         $user = $repository->findOneBy(array('email' => $email));
         $reviewer = new User();
         $reviewer->setFirstName($firstname);
         $reviewer->setLastName($lastname);
         $reviewer->setEmail($email);
         $reviewer->setPassword(md5($sysPwd));
         $reviewer->setType($type);
         $reviewer->setStatus($status);
         $reviewer->setfacebookId($fbId);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($reviewer);
         $em->flush();
         $reviewerId = $reviewer->getId();
         $session = $this->getRequest()->getSession();
         $session->set('userId', $reviewerId);
         $session->set('userEmail', $email);
         $session->set('userName', $firstname);
         $session->set('userType', $type);
         $facebookRepository = $em->getRepository('RARAdminBundle:User');
         $userLogin = $facebookRepository->findOneBy(array('email' => $email, 'facebook_id' => $fbId, 'type' => 3, 'status' => 1));
         /* code for mail send for review to realtor first time end here */
         $reviewDateTime = new DateTime();
         $rating = new Review();
         $rating->setHeadline($headline);
         $rating->setDescription($writereview);
         $rating->setUseAgent($agent);
         $rating->setReceiveUpdates($receiveUpdates);
         $rating->setRecomendAgent($recommend);
         $rating->setRating($stars);
         $rating->setReviewerId($reviewerId);
         $rating->setcreationTimestamp($reviewDateTime);
         $rating->setRealtorId($id);
         $rating->setSender('REVIEWER');
         $rating->setStatus(2);
         $rating->setHonesty($starH);
         $rating->setMarketKnowldege($starL);
         $rating->setSoldPrice($starH);
         $rating->setResponsiveness($starR);
         $rating->setService($starM);
         $rating->setSoldQuickly($starQ);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($rating);
         $em->flush();
         $confirmationLink = "{$website_url}/confirmation/" . $reviewerId;
         $date = date("Y/m/d.");
         $message = \Swift_Message::newInstance()->setSubject('Review')->setFrom($email)->setTo($gbl_email_administrator)->setBody($this->renderView('RARWebBundle:Email:review.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'confirmationLink' => $confirmationLink, 'writereview' => $writereview, 'stars' => $stars)));
         $this->get('mailer')->send($message);
         /* code for mail send for review information end here */
         if ($userLogin) {
             return $this->redirect($this->generateUrl('rar_web_homepage'));
         }
     }
     return $this->render('RARWebBundle:Page:confirmationLink.html.twig');
 }
 public function replyAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     if (!$session->get('userId') || $session->get('userId') == '') {
         return $this->redirect($this->generateUrl('rar_web_login'));
     }
     if ($request->getMethod() == 'POST') {
         $reply = $this->get('request')->request->get('reply');
         $parentId = $this->get('request')->request->get('hidParentId');
         $reviewerId = $this->get('request')->request->get('hidReviewerId');
         $review = new Review();
         $review->setDescription($reply);
         $review->setRealtorId($session->get('userId'));
         $review->setReviewerId($reviewerId);
         $review->setParentId($parentId);
         $review->setStatus(1);
         $review->setSender("REALTOR");
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($review);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('rar_web_feedback', array('name' => $session->get('realtorName'), 'id' => $session->get('userId'))));
 }