Esempio n. 1
0
 public function captureEmailAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $gbl_email_administrator = $this->container->getParameter('gbl_email_administrator');
     //get email of administrator
     $website_url = $this->container->getParameter('website_url');
     //get url of website
     $reviewDateTime = new DateTime();
     $airlineId = $this->get('request')->request->get('airlineReview');
     $airlineName = $this->get('request')->request->get('search');
     $departureCity = $this->get('request')->request->get('departureCity');
     $destinationCity = $this->get('request')->request->get('destinationCity');
     $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');
     $travel = $this->get('request')->request->get('recagent');
     $trip = $this->get('request')->request->get('trip');
     $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('recomend');
     /*----Start - When reviewr is Logged In-----*/
     $session = $this->getRequest()->getSession();
     if ($session->get('userId') && $session->get('userId') != '') {
         /*---Start - fetch detail of reviewer -----*/
         $reviewerName = $em->createQueryBuilder()->select('user')->from('RAAAdminBundle: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'];
         /*---End - fetch detail of reviewer -----*/
         /*---Start - Store a new review in database -----*/
         $file = $_FILES['revImage']['name'];
         $file1 = $_FILES['revImage']['tmp_name'];
         move_uploaded_file($_FILES["revImage"]["tmp_name"], "images/Airline/" . $_FILES["revImage"]["name"]);
         $rating = new Review();
         $rating->setHeadline($headline);
         $rating->setDescription($writereview);
         $rating->setUseAgent($agent);
         $rating->setReceiveUpdates($receiveUpdates);
         $rating->setDepartureCity($departureCity);
         $rating->setDestinationCity($destinationCity);
         $rating->setRecomendAgent($recommend);
         $rating->setRating($stars);
         $rating->setReviewerId($session->get('userId'));
         $rating->setcreationTimestamp($reviewDateTime);
         if ($airlineId) {
             $rating->setAirlineId($airlineId);
         } else {
             $rating->setAirlineId($id);
         }
         $rating->setHonesty($starH);
         $rating->setTravel($travel);
         $rating->setTrip($trip);
         $rating->setSender('REVIEWER');
         $rating->setStatus(2);
         $rating->setHonesty($starH);
         $rating->setMarketKnowldege($starL);
         $rating->setSoldPrice($starH);
         $rating->setResponsiveness($starR);
         $rating->setService($starM);
         $rating->setSoldQuickly($starQ);
         $rating->setReviewerImage($file);
         $em->persist($rating);
         $em->flush();
         /*---End - Store a new review in database -----*/
         $reviewId = $rating->getId();
         //get last inserted id of reviewer
         $confirmationLink = $website_url . "approve/review/" . $reviewId;
         //review link
         /*---Start - swift mailer for approve review -----*/
         $message = \Swift_Message::newInstance()->setSubject('Review')->setFrom($emailReviewer)->setTo($gbl_email_administrator)->setBody($this->renderView('RAAWebBundle:Email:review.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'writereview' => $writereview, 'airlineName' => $airlineName, 'confirmationLink' => $confirmationLink, 'stars' => $stars)));
         $this->get('mailer')->send($message);
         /*---Start - swift mailer for approve review -----*/
         return $this->render('RAAWebBundle:Page:confirmationLink.html.twig');
     }
     /*----End - When reviewer is Logged In-----*/
     $website_url = $this->container->getParameter('website_url');
     if ($request->getMethod() == 'POST') {
         $file = $_FILES['revImage']['name'];
         $file1 = $_FILES['revImage']['tmp_name'];
         move_uploaded_file($_FILES["revImage"]["tmp_name"], "images/Airline/" . $_FILES["revImage"]["name"]);
         $phone = $this->get('request')->request->get('phone');
         $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');
         $fbUserprofpic = $this->get('request')->request->get('fbpimage');
         $fbId = $this->get('request')->request->get('user_form_email');
         /*----Start - When Guest is Register-----*/
         if ($fbEmail == "") {
             $firstname = $this->get('request')->request->get('firstname');
             $lastname = $this->get('request')->request->get('lastname');
             $email = $this->get('request')->request->get('email');
             $phone = $this->get('request')->request->get('phone');
             $airlineId = $this->get('request')->request->get('airlineReview');
             $departureCity = $this->get('request')->request->get('departureCity');
             $destinationCity = $this->get('request')->request->get('destinationCity');
             $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');
             $travel = $this->get('request')->request->get('recagent');
             $trip = $this->get('request')->request->get('trip');
             $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('recomend');
             $type = 3;
             $status = 1;
             $sysPwd = $this->generateRandomString(8);
             $repository = $em->getRepository('RAAAdminBundle:User');
             $user = $repository->findOneBy(array('email' => $email));
             /*---Start - Register new Reviewer -----*/
             $reviewer = new User();
             $reviewer->setFirstName($firstname);
             $reviewer->setLastName($lastname);
             $reviewer->setEmail($email);
             $reviewer->setPassword(md5($sysPwd));
             $reviewer->setPhone($phone);
             $reviewer->setType($type);
             $reviewer->setStatus($status);
             $em->persist($reviewer);
             $em->flush();
             /*---End - Register new Reviewer -----*/
             $reviewerId = $reviewer->getId();
             //last inserted id of reviewer
             $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('RAAWebBundle:Email:registration.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $sysPwd, 'confirmationLink' => $confirmationLink)));
             $this->get('mailer')->send($message);
             /*---End - Swift mailer for registration -----*/
             /*---Start - add new Review -----*/
             $reviewDateTime = new DateTime();
             $rating = new Review();
             $rating->setHeadline($headline);
             $rating->setDescription($writereview);
             $rating->setUseAgent($agent);
             $rating->setReceiveUpdates($receiveUpdates);
             $rating->setRecomendAgent($recommend);
             $rating->setDepartureCity($departureCity);
             $rating->setDestinationCity($destinationCity);
             $rating->setRating($stars);
             $rating->setReviewerId($reviewerId);
             $rating->setcreationTimestamp($reviewDateTime);
             if ($airlineId) {
                 $em = $this->getDoctrine()->getEntityManager();
                 $rating->setAirlineId($airlineId);
             } else {
                 $rating->setAirlineId($id);
             }
             $rating->setSender('REVIEWER');
             $rating->setStatus(2);
             $rating->setHonesty($starH);
             $rating->setTravel($travel);
             $rating->setTrip($trip);
             $rating->setMarketKnowldege($starL);
             $rating->setSoldPrice($starH);
             $rating->setResponsiveness($starR);
             $rating->setService($starM);
             $rating->setSoldQuickly($starQ);
             $rating->setReviewerImage($file);
             $em->persist($rating);
             $em->flush();
             /*---End - add new Review -----*/
             $reviewId = $rating->getId();
             if (!isset($emailReviewer)) {
                 $emailReviewer = $email;
             }
             $confirmationLink = $website_url . "approve/review/" . $reviewId;
             //review link
             /*---Start - swift mailer for approve review -----*/
             $messageAdmin = \Swift_Message::newInstance()->setSubject('Review')->setFrom($emailReviewer)->setTo($gbl_email_administrator)->setBody($this->renderView('RAAWebBundle:Email:review.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'writereview' => $writereview, 'airlineName' => $airlineName, 'confirmationLink' => $confirmationLink, 'stars' => $stars)));
             $this->get('mailer')->send($messageAdmin);
             /*---End - swift mailer for approve review -----*/
             return $this->render('RAAWebBundle:Page:reviewRegistration.html.twig');
             /*----End - When Guest is Register-----*/
             /*----Start - When Guest is Logged with facebook-----*/
         } else {
             $firstname = $fbFirstName;
             $lastname = $fbLastName;
             $email = $fbEmail;
             $fbUserprofpic = $this->get('request')->request->get('fbpimage');
             $fbId = $this->get('request')->request->get('user_form_email');
             $session->set('fbId', $fbId);
             $session->set('fbUserprofpic', $fbUserprofpic);
         }
         $airlineId = $this->get('request')->request->get('airlineReview');
         $departureCity = $this->get('request')->request->get('departureCity');
         $destinationCity = $this->get('request')->request->get('destinationCity');
         $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');
         $travel = $this->get('request')->request->get('recagent');
         $trip = $this->get('request')->request->get('trip');
         $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('recomend');
         $type = 3;
         $status = 1;
         $sysPwd = $this->generateRandomString(8);
         $repository = $em->getRepository('RAAAdminBundle:User');
         $user = $repository->findOneBy(array('email' => $email));
         /*---Start - Add Facebook User -----*/
         $reviewer = new User();
         $reviewer->setFirstName($firstname);
         $reviewer->setLastName($lastname);
         $reviewer->setEmail($email);
         $reviewer->setPassword(md5($sysPwd));
         $reviewer->setPhone($phone);
         $reviewer->setImage($fbUserprofpic);
         $reviewer->setfacebookId($fbId);
         $reviewer->setType($type);
         $reviewer->setStatus($status);
         $em->persist($reviewer);
         $em->flush();
         /*---End - Add Facebook User -----*/
         /*---Start - Login Facebook User -----*/
         $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('RAAAdminBundle:User');
         $userLogin = $facebookRepository->findOneBy(array('email' => $email, 'facebook_id' => $fbId, 'type' => 3, 'status' => 1));
         /*---End - Login Facebook User -----*/
         /*---Start - Add  a new Reviewer -----*/
         $website_url = $this->container->getParameter('website_url');
         $confirmationLink = $website_url . "confirmed/registration/" . $reviewerId;
         $reviewDateTime = new DateTime();
         $rating = new Review();
         $rating->setHeadline($headline);
         $rating->setDescription($writereview);
         $rating->setUseAgent($agent);
         $rating->setReceiveUpdates($receiveUpdates);
         $rating->setRecomendAgent($recommend);
         $rating->setDepartureCity($departureCity);
         $rating->setDestinationCity($destinationCity);
         $rating->setRating($stars);
         $rating->setReviewerId($reviewerId);
         $rating->setcreationTimestamp($reviewDateTime);
         if ($airlineId) {
             $rating->setAirlineId($airlineId);
         } else {
             $rating->setAirlineId($id);
         }
         $rating->setSender('REVIEWER');
         $rating->setStatus(2);
         $rating->setHonesty($starH);
         $rating->setTravel($travel);
         $rating->setTrip($trip);
         $rating->setMarketKnowldege($starL);
         $rating->setSoldPrice($starH);
         $rating->setResponsiveness($starR);
         $rating->setService($starM);
         $rating->setSoldQuickly($starQ);
         $rating->setReviewerImage($file);
         $em->persist($rating);
         $em->flush();
         /*---End - Add  a new Reviewer -----*/
         /*---Start - swift mailer for approve review -----*/
         $reviewId = $rating->getId();
         $confirmationLink = $website_url . "approve/review/" . $reviewId;
         $messageAdmin = \Swift_Message::newInstance()->setSubject('Review')->setFrom($email)->setTo($gbl_email_administrator)->setBody($this->renderView('RAAWebBundle:Email:review.txt.twig', array('firstname' => $firstname, 'lastname' => $lastname, 'writereview' => $writereview, 'airlineName' => $airlineName, 'confirmationLink' => $confirmationLink, 'stars' => $stars)));
         $this->get('mailer')->send($messageAdmin);
         /*---End - swift mailer for approve review -----*/
         if ($userLogin) {
             return $this->redirect($this->generateUrl('raa_web_home'));
         }
     }
     return $this->render('RAAWebBundle:Page:reviewRegistration.html.twig');
 }
Esempio n. 2
0
 public function importRealtorsAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     $loggedInUserId = $session->get('userId');
     $currentTimestamp = new DateTime();
     if ($request->getMethod() == 'POST') {
         //echo $_FILES['file']['type'];die();
         if (!($_FILES['file']['type'] == "text/comma-separated-values") && !($_FILES['file']['type'] == "application/vnd.ms-excel")) {
             $error = 'Wrong file selected';
             return $this->render('RAAAdminBundle:Airline:importAirlines.html.twig', array('error' => $error));
         } else {
             if (is_uploaded_file($_FILES['file']['tmp_name'])) {
                 //readfile($_FILES['file']['tmp_name']);
             }
             $handle = fopen($_FILES['file']['tmp_name'], "r");
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 $firstName = $data[0];
                 $lastName = $data[1];
                 $email = $data[2];
                 $password = $data[3];
                 $phone = $data[4];
                 $address = $data[5];
                 $address2 = $data[6];
                 $city = $data[7];
                 $state = $data[8];
                 $country = $data[9];
                 $pincode = $data[10];
                 $fax = $data[11];
                 $business = $data[12];
                 $overview = $data[13];
                 $twitter = $data[14];
                 $google = $data[15];
                 $linkedin = $data[16];
                 $video = $data[17];
                 $facebook = $data[18];
                 $realtor = new User();
                 $realtor->setFirstName($firstName);
                 $realtor->setLastName($lastName);
                 $realtor->setEmail($email);
                 $realtor->setPassword(md5($password));
                 $realtor->setPhone($phone);
                 $realtor->setAddress($address);
                 $realtor->setAddress2($address2);
                 $realtor->setCity($city);
                 $realtor->setState($state);
                 $realtor->setCountry($country);
                 $realtor->setPinCode($pincode);
                 $realtor->setFax($fax);
                 $realtor->setBusinessName($business);
                 $realtor->setOverview($overview);
                 $realtor->setTwitter($twitter);
                 $realtor->setGoogle($google);
                 $realtor->setLinkedin($linkedin);
                 $realtor->setFacebook($facebook);
                 $realtor->setVideo($video);
                 $realtor->setType(2);
                 $realtor->setPlanId(1);
                 $realtor->setStatus(1);
                 $realtor->setCreatorId($loggedInUserId);
                 $realtor->setModifierId($loggedInUserId);
                 $realtor->setCreationTimestamp($currentTimestamp);
                 $realtor->setModificationTimestamp($currentTimestamp);
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->persist($realtor);
                 $em->flush();
             }
             fclose($handle);
             //print "Import done";
         }
     }
     return $this->render('RAAAdminBundle:Airline:importAirlines.html.twig');
 }