Exemplo n.º 1
0
 /**
  * Register the project details.
  * 
  * @param \Symfony\Component\HttpFoundation\Request $resquest
  * 
  * returns array
  */
 public function getProjectDataAction(Request $request)
 {
     $screenName = 'projects';
     $errorValue = 0;
     $flag = 0;
     $userService = $this->get('UserService');
     $em = $this->getDoctrine()->getManager();
     $session = $request->getSession();
     if ($request->isMethod('GET')) {
         $id = $request->query->get('projectId');
         if (!empty($id)) {
             $projects = $em->getRepository('VlreleasesUserBundle:Projects')->findOneBy(array("pid" => $id));
         }
     } else {
         if ($request->isMethod('POST')) {
             $data = $request->request->all();
             $projectNameId = $data['addProjectform']['projectName'];
             $pId = $request->request->get('updateprojectId');
             if ($pId) {
                 $projects = $em->getRepository('VlreleasesUserBundle:Projects')->findOneBy(array("pid" => $pId));
             } else {
                 $projects = new Projects();
                 $project_entity = $em->getRepository('VlreleasesUserBundle:Project')->findOneBy(array("id" => $projectNameId));
                 $projects->setProjectName($project_entity);
                 $client_entity = $em->getRepository('VlreleasesUserBundle:Client')->findOneBy(array("id" => $data['addProjectform']['client']));
                 $projects->setClient($client_entity);
                 $phase_entity = $em->getRepository('VlreleasesUserBundle:Phase')->findOneBy(array("id" => $data['addProjectform']['phase']));
                 $projects->setPhase($phase_entity);
                 $date = new \DateTime($data['addProjectform']['startDate']);
                 $projects->setStartDate($date);
                 $projects->setBugTool($data['addProjectform']['bugTool']);
                 $projects->setDescription($data['addProjectform']['description']);
                 $projects->setBillingStatus($data['addProjectform']['billingStatus']);
                 $projects->setSvnPath($data['addProjectform']['svnpath']);
                 $projects->setLifeCycleStatus($data['addProjectform']['lifeCycleStatus']);
                 $platform_entity = $em->getRepository('VlreleasesUserBundle:Platforms')->findOneBy(array("id" => $data['addProjectform']['platforms']));
                 $projects->setPlatforms($platform_entity);
             }
         }
     }
     $addProjectForm = $this->createForm(new AddProjectForm(), $projects);
     if ($request->isMethod('POST')) {
         $addProjectForm->handleRequest($request);
         //@fix-me:Think of a better solution.
         //Setting the status since it is gettig reset above to zero.
         $projects->setStatus(1);
         $userService->register1($projects);
         $flag = 1;
         $addProjectForm = $this->getEmptyForm();
     }
     $userData['userName'] = $session->get('userName');
     $userData['userType'] = $session->get('userType');
     $userData['userRole'] = $session->get('userRole');
     $user = $this->getUserService()->findOneById($session->get('userId'));
     if ($user->getPersonalProfile() == '') {
         $userData['photo'] = 'default.jpg';
     } else {
         if ($user->getPersonalProfile()->getPhoto()) {
             $userData['photo'] = $user->getPersonalProfile()->getPhoto();
         } else {
             $userData['photo'] = 'default.jpg';
         }
     }
     $roleId = $session->get('userRole');
     $userRolesPermissions = $userService->findUserPermissions($roleId);
     $action_entity = $em->getRepository('VlreleasesUserBundle:Actions')->findOneBy(array("screenName" => $screenName));
     $userData['rolePermission'] = $em->getRepository('VlreleasesUserBundle:RolesPermissions')->findOneBy(array("role" => $roleId, 'actions' => $action_entity->getId()));
     $projectsService = $this->get('ProjectsService');
     $projects = $userService->getAllProjects();
     return $this->render('VlreleasesUserBundle:User:projectsList.html.twig', array('userData' => $userData, 'projects' => $projects, 'flag' => $flag, 'addProjectForm' => $addProjectForm->createView()));
 }
 /**
  * {@inheritDoc}
  */
 public function setClient(\Vlreleases\UserBundle\Entity\Client $client = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setClient', array($client));
     return parent::setClient($client);
 }