Exemplo n.º 1
0
 public function addCompanyAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     if ($session->get('type') != 1) {
         //if user is login then it will be redirect to login page
         return $this->redirect($this->generateUrl('drp_adminLogin'));
     }
     $em = $this->getDoctrine()->getEntityManager();
     if ($request->getMethod() == 'POST') {
         $name = $request->get('name');
         $description = $request->get('description');
         $email = $request->get('email');
         $address = $request->get('address');
         $tin = $request->get('tin');
         $telephone1 = $request->get('tel1');
         $telephone2 = $request->get('tel2');
         $addBusiness = new Business();
         $addBusiness->setName($name);
         $addBusiness->setDescription($description);
         $addBusiness->setEmail($email);
         $addBusiness->setAddress($address);
         $addBusiness->setTin($tin);
         $addBusiness->setTelephone1($telephone1);
         $addBusiness->setTelephone2($telephone2);
         $em->persist($addBusiness);
         $em->flush();
         return $this->redirect($this->generateUrl('drp_showBusiness'));
     }
     return $this->render('DRPAdminBundle:Pages:addCompany.html.twig');
 }
Exemplo n.º 2
0
 public function registrationAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     if ($request->getMethod() == 'POST') {
         $sourcePath = $file = $_FILES['image']['name'];
         $file1 = $_FILES['image']['tmp_name'];
         move_uploaded_file($_FILES["image"]["tmp_name"], "uploads/user/" . $_FILES["image"]["name"]);
         $firstName = $request->get('firstname');
         $password = $request->get('password');
         $middleName = $request->get('middlename');
         $lastName = $request->get('lastname');
         $email = $request->get('email');
         $userName = $request->get('username');
         $telephone1 = $request->get('tel1');
         $telephone2 = $request->get('tel2');
         $nin = $request->get('nin');
         $tin = $request->get('tin');
         $token = $this->generateRandomString(8);
         $name = $request->get('name');
         $description = $request->get('description');
         $emailCompany = $request->get('emailCompany');
         $address = $request->get('addressCompany');
         $tinCompany = $request->get('tinCompany');
         $telephone1Company = $request->get('tel1Company');
         $telephone2Company = $request->get('tel2Company');
         $planId = $request->get('plan');
         $plans = $em->createQueryBuilder()->select('plan')->from('DRPAdminBundle:Plan', 'plan')->where('plan.id=:id')->setParameter('id', $planId)->getQuery()->getArrayResult();
         //echo"<pre>";print_r($plans[0]['searches']);die;
         $addUser = new User();
         $addUser->setFirstName($firstName);
         $addUser->setMiddleName($middleName);
         $addUser->setLastName($lastName);
         $addUser->setEmail($email);
         $addUser->setUsername($userName);
         $addUser->setTelephone1($telephone1);
         $addUser->setTelephone2($telephone2);
         $addUser->setPassword(md5($password));
         $addUser->setNin($nin);
         $addUser->setTin($tin);
         $addUser->setStatus(1);
         $addUser->setType(4);
         //$addUser->setPicture($sourcePath);
         $addUser->setToken($token);
         //$addUser->setSearchCountTotal($plans[0]['searches']);
         $em->persist($addUser);
         $em->flush();
         $userId = $addUser->getId();
         $userName = $addUser->getFirstName();
         $addBusiness = new Business();
         $addBusiness->setName($name);
         $addBusiness->setDescription($description);
         $addBusiness->setEmail($emailCompany);
         $addBusiness->setAddress($address);
         $addBusiness->setTin($tinCompany);
         $addBusiness->setTelephone1($telephone1Company);
         $addBusiness->setTelephone2($telephone2Company);
         $addBusiness->setUserId($userId);
         $em->persist($addBusiness);
         $em->flush();
         $plan = new UserPlan();
         $plan->setPlanId($planId);
         $plan->setToken($token);
         $plan->setUserId($userId);
         $plan->setStatus(0);
         $plan->setPaymentStatus(0);
         $em->persist($plan);
         $em->flush();
         $date = date("Y/m/d.");
         $headers = "MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
         $headers .= 'From: <*****@*****.**>' . "\r\n";
         $to = $email;
         $subject = "User Registration";
         $txt = 'Hello ' . $firstName . ' ' . $lastName . ',<br><br>Your have created account on ' . $date . '<br><br>Email is: <b>' . $email . '</b>' . 'and your password is' . $password;
         mail($to, $subject, $txt, $headers);
         $ipAddress = $_SERVER['REMOTE_ADDR'];
         $params['event'] = $this->getLogEventTitleAction('REGISTRATION');
         $params['description'] = $this->getLogEventDescriptionAction('REGISTRATION');
         $params['userId'] = $userId;
         $params['ipAddress'] = $ipAddress;
         $params['creatorId'] = $userId;
         $this->setLogAction($params);
         return $this->redirect($this->generateUrl('user_printRegistration'));
     }
     return $this->render('DRPUserBundle:Pages:registrationSuccess.html.twig');
 }