Ejemplo n.º 1
0
 function addGeneralAction(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'));
     }
     if ($request->getMethod() == 'POST') {
         $em = $this->getDoctrine()->getEntityManager();
         $sourcePath = $file = $_FILES['images']['name'];
         $file1 = $_FILES['images']['tmp_name'];
         move_uploaded_file($_FILES["images"]["tmp_name"], "uploads/user/" . $_FILES["images"]["name"]);
         $firstName = $request->get('firstname');
         $middleName = $request->get('middlename');
         $lastName = $request->get('lastname');
         $email = $request->get('email');
         $passcode = $request->get('passcode');
         $password = $request->get('password');
         $telephone1 = $request->get('tel1');
         $telephone2 = $request->get('tel2');
         $nin = $request->get('nin');
         $addUser = new User();
         $addUser->setFirstName($firstName);
         $addUser->setMiddleName($middleName);
         $addUser->setLastName($lastName);
         $addUser->setEmail($email);
         $addUser->setPassword(md5($password));
         $addUser->setTelephone1($telephone1);
         $addUser->setTelephone2($telephone2);
         $addUser->setNin($nin);
         $addUser->setStatus(1);
         $addUser->setPicture($sourcePath);
         $addUser->setType(2);
         $addUser->setPasscode($passcode);
         $em->persist($addUser);
         $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 = "Registrar General 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('ADD_REGISTRAR_GENERAL');
         $params['description'] = $this->getLogEventDescriptionAction('ADD_REGISTRAR_GENERAL');
         $params['userId'] = $session->get('userId');
         $params['ipAddress'] = $ipAddress;
         $params['creatorId'] = $session->get('userId');
         $this->setLogAction($params);
         return $this->redirect($this->generateUrl('drp_general'));
     }
     return $this->render('DRPAdminBundle:Pages:addGeneral.html.twig');
 }
Ejemplo 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');
 }