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');
 }