/**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewJobVacancy');
     $usrObj = $this->getUser()->getAttribute('user');
     if (!$usrObj->isAdmin()) {
         $this->redirect('recruitment/viewCandidates');
     }
     $this->vacancyId = $request->getParameter('Id');
     $values = array('vacancyId' => $this->vacancyId);
     $this->setForm(new AddJobVacancyForm(array(), $values));
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
         MessageRegistry::instance()->addMessage($this->message, 'recruitment', 'addJobVacancy', MessageRegistry::PREPEND);
         $this->message = MessageRegistry::instance()->getMessage('recruitment', 'addJobVacancy');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->vacancyId = $this->form->save();
             $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
             $this->redirect('recruitment/addJobVacancy?Id=' . $this->vacancyId);
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewJobVacancy');
     $this->vacancyPermissions = $this->getDataGroupPermissions('recruitment_vacancies');
     $this->vacancyId = $request->getParameter('Id');
     $values = array('vacancyId' => $this->vacancyId, 'vacancyPermissions' => $this->vacancyPermissions);
     $this->setForm(new AddJobVacancyForm(array(), $values));
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
         MessageRegistry::instance()->addMessage($this->message, 'recruitment', 'addJobVacancy', MessageRegistry::PREPEND);
         $this->message = MessageRegistry::instance()->getMessage('recruitment', 'addJobVacancy');
     }
     if ($request->isMethod('post')) {
         if ($this->vacancyPermissions->canCreate() || $this->vacancyPermissions->canUpdate()) {
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $this->vacancyId = $this->form->save();
                 $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
                 $this->redirect('recruitment/addJobVacancy?Id=' . $this->vacancyId);
             } else {
                 Logger::getLogger('recruitment.addJobVacancy')->error($this->form);
                 $this->getUser()->setFlash('warning', __(TopLevelMessages::SAVE_FAILURE), false);
             }
         }
     }
 }
 /**
  * execute function
  * @param <type> $request
  */
 public function execute($request)
 {
     $this->setForm(new LocalizationForm());
     $languages = $this->getRequest()->getLanguages();
     $this->browserLanguage = $languages[0];
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             // For reloading main menu (index.php)
             $_SESSION['load.admin.localization'] = true;
             $formValues = $this->form->getFormValues();
             $defaultLanguage = $formValues['defaultLanguage'];
             $setBrowserLanguage = !empty($formValues['setBrowserLanguage']) ? "Yes" : "No";
             $supprotedLanguages = $this->form->getLanguages();
             if ($setBrowserLanguage == "Yes" && in_array($languages[0], $supprotedLanguages)) {
                 $defaultLanguage = $languages[0];
             }
             $this->getUser()->setCulture($defaultLanguage);
             $this->getConfigService()->setAdminLocalizationDefaultLanguage($formValues['defaultLanguage']);
             $this->getConfigService()->setAdminLocalizationUseBrowserLanguage($setBrowserLanguage);
             $this->getUser()->setDateFormat($formValues['defaultDateFormat']);
             $this->getConfigService()->setAdminLocalizationDefaultDateFormat($formValues['defaultDateFormat']);
             $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
         }
         $this->redirect("admin/localization");
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $isPaging = $request->getParameter('pageNo');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $userId = $request->getParameter('userId');
     $this->setForm(new SearchSystemUserForm());
     $pageNumber = $isPaging;
     if ($userId > 0 && $this->getUser()->hasAttribute('pageNumber')) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $limit = SystemUser::NO_OF_RECORDS_PER_PAGE;
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $limit : ($request->getParameter('pageNo', 1) - 1) * $limit;
     $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $userId > 0) {
         if ($this->getUser()->hasAttribute('searchClues')) {
             $searchClues = $this->getUser()->getAttribute('searchClues');
             $searchClues['offset'] = $offset;
             $searchClues['sortField'] = $sortField;
             $searchClues['sortOrder'] = $sortOrder;
             $this->form->setDefaultDataToWidgets($searchClues);
         }
     } else {
         $this->getUser()->setAttribute('searchClues', $searchClues);
     }
     $userIds = UserRoleManagerFactory::getUserRoleManager()->getAccessibleEntityIds('SystemUser');
     $params = array();
     $this->parmetersForListCompoment = $params;
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     if ($request->isMethod('post')) {
         if (empty($isPaging)) {
             $offset = 0;
             $pageNumber = 1;
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
                 $this->getUser()->setAttribute('searchClues', $searchClues);
             } else {
                 $this->redirect('admin/viewSystemUsers');
             }
         }
     }
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     if (empty($userIds)) {
         $systemUserList = array();
         $systemUserListCount = 0;
     } else {
         $searchClues['user_ids'] = $userIds;
         $systemUserList = $this->getSystemUserService()->searchSystemUsers($searchClues);
         $systemUserListCount = $this->getSystemUserService()->getSearchSystemUsersCount($searchClues);
     }
     $this->_setListComponent($systemUserList, $limit, $pageNumber, $systemUserListCount);
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $this->projectPermissions = $this->getDataGroupPermissions('time_projects');
     $userRoleManager = sfContext::getInstance()->getUserRoleManager();
     $allowedProjectList = $userRoleManager->getAccessibleEntityIds('Project');
     $isPaging = $request->getParameter('pageNo');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $projectId = $request->getParameter('projectId');
     if ($this->projectPermissions->canRead()) {
         $this->setForm(new SearchProjectForm());
         $pageNumber = $isPaging;
         if ($projectId > 0 && $this->getUser()->hasAttribute('pageNumber')) {
             $pageNumber = $this->getUser()->getAttribute('pageNumber');
         }
         $limit = Project::NO_OF_RECORDS_PER_PAGE;
         $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $limit : ($request->getParameter('pageNo', 1) - 1) * $limit;
         $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
         if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $projectId > 0) {
             if ($this->getUser()->hasAttribute('searchClues')) {
                 $searchClues = $this->getUser()->getAttribute('searchClues');
                 $searchClues['offset'] = $offset;
                 $searchClues['sortField'] = $sortField;
                 $searchClues['sortOrder'] = $sortOrder;
                 $this->form->setDefaultDataToWidgets($searchClues);
             }
         } else {
             $this->getUser()->setAttribute('searchClues', $searchClues);
         }
         $projectList = $this->getProjectService()->searchProjects($searchClues, $allowedProjectList);
         $projectListCount = $this->getProjectService()->getSearchProjectListCount($searchClues, $allowedProjectList);
         $this->_setListComponent($projectList, $limit, $pageNumber, $projectListCount, $this->projectPermissions);
         $this->getUser()->setAttribute('pageNumber', $pageNumber);
         $params = array();
         $this->parmetersForListCompoment = $params;
         if ($this->getUser()->hasFlash('templateMessage')) {
             list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
         }
         if ($request->isMethod('post')) {
             $offset = 0;
             $pageNumber = 1;
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
                 $this->getUser()->setAttribute('searchClues', $searchClues);
                 $searchedProjectList = $this->getProjectService()->searchProjects($searchClues, $allowedProjectList);
                 $projectListCount = $this->getProjectService()->getSearchProjectListCount($searchClues, $allowedProjectList);
                 $this->_setListComponent($searchedProjectList, $limit, $pageNumber, $projectListCount, $this->projectPermissions);
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     if (!($usrObj->isAdmin() || $usrObj->isProjectAdmin())) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $allowedProjectList = $usrObj->getAllowedProjectList();
     $isPaging = $request->getParameter('pageNo');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $projectId = $request->getParameter('projectId');
     $this->setForm(new SearchProjectForm());
     $pageNumber = $isPaging;
     if ($projectId > 0 && $this->getUser()->hasAttribute('pageNumber')) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $limit = Project::NO_OF_RECORDS_PER_PAGE;
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $limit : ($request->getParameter('pageNo', 1) - 1) * $limit;
     $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $projectId > 0) {
         if ($this->getUser()->hasAttribute('searchClues')) {
             $searchClues = $this->getUser()->getAttribute('searchClues');
             $searchClues['offset'] = $offset;
             $searchClues['sortField'] = $sortField;
             $searchClues['sortOrder'] = $sortOrder;
             $this->form->setDefaultDataToWidgets($searchClues);
         }
     } else {
         $this->getUser()->setAttribute('searchClues', $searchClues);
     }
     $projectList = $this->getProjectService()->searchProjects($searchClues, $allowedProjectList);
     $projectListCount = $this->getProjectService()->getSearchProjectListCount($searchClues, $allowedProjectList);
     $this->_setListComponent($projectList, $limit, $pageNumber, $projectListCount, $usrObj);
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     $params = array();
     $this->parmetersForListCompoment = $params;
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     if ($request->isMethod('post')) {
         $offset = 0;
         $pageNumber = 1;
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
             $this->getUser()->setAttribute('searchClues', $searchClues);
             $searchedProjectList = $this->getProjectService()->searchProjects($searchClues, $allowedProjectList);
             $projectListCount = $this->getProjectService()->getSearchProjectListCount($searchClues, $allowedProjectList);
             $this->_setListComponent($searchedProjectList, $limit, $pageNumber, $projectListCount, $usrObj);
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $param = null;
     $this->candidateId = null;
     $this->vacancyId = $request->getParameter('id');
     //$this->candidateId = $request->getParameter('candidateId');
     $this->getResponse()->setTitle(__("Vacancy Apply Form"));
     //$param = array('candidateId' => $this->candidateId);
     $this->setForm(new ApplyVacancyForm(array(), $param, true));
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     if (!empty($this->vacancyId)) {
         $vacancy = $this->getVacancyService()->getVacancyById($this->vacancyId);
         if (empty($vacancy)) {
             $this->redirect('recruitmentApply/jobs.html');
         }
         $this->description = $vacancy->getDescription();
         $this->name = $vacancy->getName();
     } else {
         $this->redirect('recruitmentApply/jobs.html');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         $file = $request->getFiles($this->form->getName());
         if ($_FILES['addCandidate']['size']['resume'] > 1024000) {
             $this->templateMessage = array('WARNING', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
         } else {
             if ($_FILES == null) {
                 $this->getUser()->setFlash('templateMessage', array('warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE)));
                 $this->redirect('recruitmentApply/applyVacancy?id=' . $this->vacancyId);
             } else {
                 if ($this->form->isValid()) {
                     $result = $this->form->save();
                     if (isset($result['messageType'])) {
                         $this->messageType = $result['messageType'];
                         $this->message = $result['message'];
                     } else {
                         $this->candidateId = $result['candidateId'];
                         if (!empty($this->candidateId)) {
                             $this->messageType = 'success';
                             $this->message = __('Application Received');
                         }
                         //$this->getUser()->setFlash('templateMessage', array('success', __('Your Application for the Position of ' . $this->name . ' Was Received')));
                         //$this->redirect('recruitmentApply/applyVacancy?id=' . $this->vacancyId . '&candidateId=' . $this->form->candidateId);
                     }
                 }
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $param = null;
     $this->candidateId = null;
     $this->vacancyId = $request->getParameter('id');
     //$this->candidateId = $request->getParameter('candidateId');
     $this->getResponse()->setTitle(__("Vacancy Apply Form"));
     //$param = array('candidateId' => $this->candidateId);
     $this->setForm(new ApplyVacancyForm(array(), $param, true));
     if (!empty($this->vacancyId)) {
         $vacancy = $this->getVacancyService()->getVacancyById($this->vacancyId);
         if (empty($vacancy)) {
             $this->redirect('recruitmentApply/jobs.html');
         }
         $this->description = $vacancy->getDescription();
         $this->name = $vacancy->getName();
     } else {
         $this->redirect('recruitmentApply/jobs.html');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         $file = $request->getFiles($this->form->getName());
         if ($_FILES['addCandidate']['size']['resume'] > 1024000) {
             $this->getUser()->setFlash('applyVacancy.warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
         } else {
             if ($_FILES == null) {
                 $this->getUser()->setFlash('applyVacancy.warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
                 $this->redirect('recruitmentApply/applyVacancy?id=' . $this->vacancyId);
             } else {
                 if ($this->form->isValid()) {
                     $result = $this->form->save();
                     if (isset($result['messageType'])) {
                         $this->getUser()->setFlash('applyVacancy.' . $result['messageType'], $result['message']);
                     } else {
                         $this->candidateId = $result['candidateId'];
                         if (!empty($this->candidateId)) {
                             $this->getUser()->setFlash('applyVacancy.success', __('Application Received'));
                             $this->getUser()->setFlash('applyVacancy.warning', null);
                             // Send a confirmation e-mail to the applicant and notification to the hiring manager.
                             $logger = Logger::getLogger('recruitment.applyvacancy');
                             $logger->info('Application recieved');
                             $eventData = array('vacancy' => $vacancy, 'candidateId' => $this->candidateId);
                             $this->getDispatcher()->notify(new sfEvent($this, RecruitmentEvents::RECRUITMENT_APPLY, $eventData));
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     if (!$usrObj->isAdmin()) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $isPaging = $request->getParameter('pageNo');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $locationId = $request->getParameter('locationId');
     $this->setForm(new SearchLocationForm());
     $pageNumber = $isPaging;
     if ($locationId > 0 && $this->getUser()->hasAttribute('pageNumber')) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $limit = Location::NO_OF_RECORDS_PER_PAGE;
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $limit : ($request->getParameter('pageNo', 1) - 1) * $limit;
     $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $locationId > 0) {
         if ($this->getUser()->hasAttribute('searchClues')) {
             $searchClues = $this->getUser()->getAttribute('searchClues');
             $searchClues['offset'] = $offset;
             $searchClues['sortField'] = $sortField;
             $searchClues['sortOrder'] = $sortOrder;
             $this->form->setDefaultDataToWidgets($searchClues);
         }
     } else {
         $this->getUser()->setAttribute('searchClues', $searchClues);
     }
     $locationList = $this->getLocationService()->searchLocations($searchClues);
     $locationListCount = $this->getLocationService()->getSearchLocationListCount($searchClues);
     $this->_setListComponent($locationList, $limit, $pageNumber, $locationListCount);
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     $params = array();
     $this->parmetersForListCompoment = $params;
     if ($request->isMethod('post')) {
         $offset = 0;
         $pageNumber = 1;
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $searchClues = $this->_setSearchClues($sortField, $sortOrder, $offset, $limit);
             $this->getUser()->setAttribute('searchClues', $searchClues);
             $searchedLocationList = $this->getLocationService()->searchLocations($searchClues);
             $locationListCount = $this->getLocationService()->getSearchLocationListCount($searchClues);
             $this->_setListComponent($searchedLocationList, $limit, $pageNumber, $locationListCount);
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewCandidates');
     $usrObj = $this->getUser()->getAttribute('user');
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $empNumber = $usrObj->getEmployeeNumber();
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $this->historyId = $request->getParameter('historyId');
     $this->interviewId = $request->getParameter('interviewId');
     $candidateVacancyId = $request->getParameter('candidateVacancyId');
     $selectedAction = $request->getParameter('selectedAction');
     $this->editHiringManager = true;
     $param = array();
     if ($candidateVacancyId > 0 && $selectedAction != "") {
         $interviewHistory = $this->getJobInterviewService()->getInterviewScheduledHistoryByInterviewId($this->interviewId);
         $param = array('interviewId' => $this->interviewId, 'candidateVacancyId' => $candidateVacancyId, 'selectedAction' => $selectedAction, 'historyId' => !empty($interviewHistory) ? $interviewHistory->getId() : null);
     }
     if (!empty($this->historyId) && !empty($this->interviewId)) {
         $history = $this->getCandidateService()->getCandidateHistoryById($this->historyId);
         $candidateVacancyId = $this->getCandidateService()->getCandidateVacancyByCandidateIdAndVacancyId($history->getCandidateId(), $history->getVacancyId());
         $selectedAction = $history->getAction();
         $param = array('id' => $this->interviewId, 'candidateVacancyId' => $candidateVacancyId, 'selectedAction' => $selectedAction);
     }
     if (!$this->getCandidateService()->isHiringManager($candidateVacancyId, $empNumber) && $this->getCandidateService()->isInterviewer($candidateVacancyId, $empNumber)) {
         $this->editHiringManager = false;
     }
     //        $lastAction = $this->getCandidateService()->getLastPerformedActionByCandidateVAcancyId($candidateVacancyId);
     $this->setForm(new JobInterviewForm(array(), $param, true));
     if (!in_array($this->form->candidateId, $allowedCandidateList) && !in_array($this->form->vacancyId, $allowedVacancyList)) {
         $this->redirect('recruitment/viewCandidates');
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $result = $this->form->save();
             if (isset($result['messageType'])) {
                 $this->getUser()->setFlash('templateMessage', array($result['messageType'], $result['message']));
             } else {
                 $this->getUser()->setFlash('templateMessage', array('success', __('Successfully Scheduled')));
             }
             $this->redirect('recruitment/changeCandidateVacancyStatus?id=' . $this->form->historyId);
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewCandidates');
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $this->candidatePermissions = $this->getDataGroupPermissions('recruitment_candidates');
     $usrObj = $this->getUser()->getAttribute('user');
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $empNumber = $usrObj->getEmployeeNumber();
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $this->historyId = $request->getParameter('historyId');
     $this->interviewId = $request->getParameter('interviewId');
     $candidateVacancyId = $request->getParameter('candidateVacancyId');
     $selectedAction = $request->getParameter('selectedAction');
     $this->editHiringManager = true;
     $param = array();
     if ($candidateVacancyId > 0 && $selectedAction != "") {
         $candidateVacancy = $this->getCandidateService()->getCandidateVacancyById($candidateVacancyId);
         // check if user can perform action on candidate
         if (!empty($this->interviewId) && $request->isMethod('post')) {
             $allowedStates = $userRoleManager->getActionableStates(WorkflowStateMachine::FLOW_RECRUITMENT, array($selectedAction));
             $actionAllowed = !empty($allowedStates);
         } else {
             $actionAllowed = $userRoleManager->isActionAllowed(WorkflowStateMachine::FLOW_RECRUITMENT, $candidateVacancy->getStatus(), $selectedAction);
         }
         if ($actionAllowed) {
             $this->candidatePermissions = new ResourcePermission(true, true, true, true);
         }
         $interviewHistory = $this->getJobInterviewService()->getInterviewScheduledHistoryByInterviewId($this->interviewId);
         $param = array('interviewId' => $this->interviewId, 'candidateVacancyId' => $candidateVacancyId, 'selectedAction' => $selectedAction, 'historyId' => !empty($interviewHistory) ? $interviewHistory->getId() : null, 'candidatePermissions' => $this->candidatePermissions);
     }
     if (!empty($this->historyId) && !empty($this->interviewId)) {
         $history = $this->getCandidateService()->getCandidateHistoryById($this->historyId);
         $candidateVacancyId = $this->getCandidateService()->getCandidateVacancyByCandidateIdAndVacancyId($history->getCandidateId(), $history->getVacancyId());
         $selectedAction = $history->getAction();
         // check if user can perform this history action
         $allowedStates = $userRoleManager->getActionableStates(WorkflowStateMachine::FLOW_RECRUITMENT, array($selectedAction));
         if (!empty($allowedStates)) {
             $this->candidatePermissions = new ResourcePermission(true, true, true, true);
         }
         $param = array('id' => $this->interviewId, 'candidateVacancyId' => $candidateVacancyId, 'selectedAction' => $selectedAction, 'candidatePermissions' => $this->candidatePermissions);
     }
     if (!$this->getCandidateService()->isHiringManager($candidateVacancyId, $empNumber) && $this->getCandidateService()->isInterviewer($candidateVacancyId, $empNumber)) {
         $this->editHiringManager = false;
     }
     //        $lastAction = $this->getCandidateService()->getLastPerformedActionByCandidateVAcancyId($candidateVacancyId);
     $this->setForm(new JobInterviewForm(array(), $param, true));
     if (!in_array($this->form->candidateId, $allowedCandidateList) && !in_array($this->form->vacancyId, $allowedVacancyList)) {
         $this->redirect('recruitment/viewCandidates');
     }
     if ($request->isMethod('post')) {
         if ($this->candidatePermissions->canUpdate()) {
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $result = $this->form->save();
                 if (isset($result['messageType'])) {
                     $this->getUser()->setFlash('templateMessage', array($result['messageType'], $result['message']));
                 } else {
                     $this->getUser()->setFlash('templateMessage', array('success', __('Successfully Scheduled')));
                 }
                 $this->redirect('recruitment/changeCandidateVacancyStatus?id=' . $this->form->historyId);
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewCandidates');
     $usrObj = $this->getUser()->getAttribute('user');
     if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer())) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete();
     $this->enableEdit = true;
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $id = $request->getParameter('id');
     if (!empty($id)) {
         $history = $this->getCandidateService()->getCandidateHistoryById($id);
         $action = $history->getAction();
         $this->interviewId = $history->getInterviewId();
         if ($action == WorkflowStateMachine::RECRUITMENT_APPLICATION_ACTION_SHEDULE_INTERVIEW || $action == WorkflowStateMachine::RECRUITMENT_APPLICATION_ACTION_SHEDULE_2ND_INTERVIEW) {
             if ($this->getUser()->hasFlash('templateMessage')) {
                 list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
                 $this->getUser()->setFlash($this->messageType, $this->message);
             }
             $this->redirect('recruitment/jobInterview?historyId=' . $id . '&interviewId=' . $this->interviewId);
         }
         $this->performedAction = $action;
         if ($this->getCandidateService()->isInterviewer($this->getCandidateService()->getCandidateVacancyByCandidateIdAndVacancyId($history->getCandidateId(), $history->getVacancyId()), $usrObj->getEmployeeNumber())) {
             $this->enableEdit = false;
             if ($action == WorkflowStateMachine::RECRUITMENT_APPLICATION_ACTION_MARK_INTERVIEW_PASSED || $action == WorkflowStateMachine::RECRUITMENT_APPLICATION_ACTION_MARK_INTERVIEW_FAILED) {
                 $this->enableEdit = true;
             }
         }
     }
     $candidateVacancyId = $request->getParameter('candidateVacancyId');
     $this->selectedAction = $request->getParameter('selectedAction');
     $param = array();
     if ($id > 0) {
         $param = array('id' => $id);
     }
     if ($candidateVacancyId > 0 && $this->selectedAction != "") {
         $candidateVacancy = $this->getCandidateService()->getCandidateVacancyById($candidateVacancyId);
         $nextActionList = $this->getCandidateService()->getNextActionsForCandidateVacancy($candidateVacancy->getStatus(), $usrObj);
         if ($nextActionList[$this->selectedAction] == "" || !in_array($candidateVacancy->getCandidateId(), $allowedCandidateList)) {
             $this->redirect('recruitment/viewCandidates');
         }
         $param = array('candidateVacancyId' => $candidateVacancyId, 'selectedAction' => $this->selectedAction);
         $this->performedAction = $this->selectedAction;
     }
     $this->setForm(new CandidateVacancyStatusForm(array(), $param, true));
     //        if (!in_array($this->form->candidateId, $allowedCandidateList) && !in_array($this->form->vacancyId, $allowedVacancyList)) {
     //            $this->redirect('recruitment/viewCandidates');
     //        }
     //        if (!in_array($this->form->candidateId, $allowedCandidateListToDelete)) {
     //            $this->enableEdit = false;
     //        }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $result = $this->form->performAction();
             if (isset($result['messageType'])) {
                 $this->getUser()->setFlash($result['messageType'], $result['message']);
             } else {
                 $message = __(TopLevelMessages::UPDATE_SUCCESS);
                 $this->getUser()->setFlash('success', $message);
             }
             $this->redirect('recruitment/changeCandidateVacancyStatus?id=' . $this->form->historyId);
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array('recruitment_candidates' => new ResourcePermission(true, false, false, false)));
     $allowedVacancyList = $userRoleManager->getAccessibleEntityIds('Vacancy', null, null, array(), array(), $requiredPermissions);
     $usrObj = $this->getUser()->getAttribute('user');
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete();
     $this->candidaatePermissions = $this->getDataGroupPermissions('recruitment_candidates');
     $isAdmin = $usrObj->isAdmin();
     if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer() || $this->candidaatePermissions->canRead())) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $param = array('allowedCandidateList' => $allowedCandidateList, 'allowedVacancyList' => $allowedVacancyList, 'allowedCandidateListToDelete' => $allowedCandidateListToDelete);
     list($this->messageType, $this->message) = $this->getUser()->getFlash('candidateListMessageItems');
     $candidateId = $request->getParameter('candidateId');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $isPaging = $request->getParameter('pageNo');
     $pageNumber = $isPaging;
     if (!is_null($this->getUser()->getAttribute('pageNumber')) && !($pageNumber >= 1)) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     $searchParam = new CandidateSearchParameters();
     $searchParam->setIsAdmin($isAdmin);
     $searchParam->setEmpNumber($usrObj->getEmployeeNumber());
     $noOfRecords = $searchParam->getLimit();
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     $searchParam->setAdditionalParams($request->getParameter('additionalParams', array()));
     $this->setForm(new viewCandidatesForm(array(), $param, true));
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $candidateId > 0) {
         if ($this->getUser()->hasAttribute('searchParameters')) {
             $searchParam = $this->getUser()->getAttribute('searchParameters');
             $this->form->setDefaultDataToWidgets($searchParam);
         }
         $searchParam->setSortField($sortField);
         $searchParam->setSortOrder($sortOrder);
     } else {
         $this->getUser()->setAttribute('searchParameters', $searchParam);
         $offset = 0;
         $pageNumber = 1;
     }
     $searchParam->setAllowedCandidateList($allowedCandidateList);
     $searchParam->setAllowedVacancyList($allowedVacancyList);
     $searchParam->setOffset($offset);
     $candidates = $this->getCandidateService()->searchCandidates($searchParam);
     if ($this->candidaatePermissions->canRead()) {
         $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber, $this->candidaatePermissions);
     }
     $params = array();
     $this->parmetersForListCompoment = $params;
     if (empty($isPaging)) {
         if ($request->isMethod('post')) {
             $pageNumber = 1;
             $searchParam->setOffset(0);
             $this->getUser()->setAttribute('pageNumber', $pageNumber);
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $srchParams = $this->form->getSearchParamsBindwithFormData($searchParam);
                 $this->getUser()->setAttribute('searchParameters', $srchParams);
                 $candidates = $this->getCandidateService()->searchCandidates($srchParams);
                 $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber, $this->candidaatePermissions);
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     if (!$usrObj->isAdmin()) {
         $this->redirect('recruitment/viewCandidates');
     }
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $isPaging = $request->getParameter('pageNo');
     $vacancyId = $request->getParameter('vacancyId');
     $pageNumber = $isPaging;
     if (!is_null($this->getUser()->getAttribute('vacancyPageNumber')) && !($pageNumber >= 1)) {
         $pageNumber = $this->getUser()->getAttribute('vacancyPageNumber');
     }
     $this->getUser()->setAttribute('vacancyPageNumber', $pageNumber);
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $noOfRecords = JobVacancy::NUMBER_OF_RECORDS_PER_PAGE;
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     $param = array('allowedVacancyList' => $allowedVacancyList);
     $this->setForm(new ViewJobVacancyForm(array(), $param, true));
     $srchParams = array('jobTitle' => "", 'jobVacancy' => "", 'hiringManager' => "", 'status' => "");
     $srchParams['noOfRecords'] = $noOfRecords;
     $srchParams['offset'] = $offset;
     if (!empty($sortField) && !empty($sortOrder) || $vacancyId > 0 || $isPaging > 0) {
         if ($this->getUser()->hasAttribute('searchParameters')) {
             $srchParams = $this->getUser()->getAttribute('searchParameters');
             $this->form->setDefaultDataToWidgets($srchParams);
         }
         $srchParams['orderField'] = $sortField;
         $srchParams['orderBy'] = $sortOrder;
     } else {
         $this->getUser()->setAttribute('searchParameters', $srchParams);
     }
     list($this->messageType, $this->message) = $this->getUser()->getFlash('vacancyDeletionMessageItems');
     $srchParams['offset'] = $offset;
     $vacancyList = $this->getVacancyService()->searchVacancies($srchParams);
     $this->_setListComponent($vacancyList, $noOfRecords, $srchParams, $pageNumber);
     $params = array();
     $this->parmetersForListCompoment = $params;
     if (empty($isPaging)) {
         if ($request->isMethod('post')) {
             $pageNumber = 1;
             $this->getUser()->setAttribute('vacancyPageNumber', $pageNumber);
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $srchParams = $this->form->getSearchParamsBindwithFormData();
                 $srchParams['noOfRecords'] = $noOfRecords;
                 $srchParams['offset'] = 0;
                 $this->getUser()->setAttribute('searchParameters', $srchParams);
                 $vacancyList = $this->getVacancyService()->searchVacancies($srchParams);
                 $this->_setListComponent($vacancyList, $noOfRecords, $srchParams, $pageNumber);
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $userObj = $this->getUser()->getAttribute('user');
     $allowedVacancyList = $userObj->getAllowedVacancyList();
     $allowedCandidateListToDelete = $userObj->getAllowedCandidateListToDelete();
     $this->candidateId = $request->getParameter('id');
     $this->invalidFile = false;
     $reDirect = false;
     $this->edit = true;
     if ($this->candidateId > 0 && !in_array($this->candidateId, $allowedCandidateListToDelete)) {
         $reDirect = true;
         $this->edit = false;
     }
     $param = array('candidateId' => $this->candidateId, 'allowedVacancyList' => $allowedVacancyList, 'empNumber' => $userObj->getEmployeeNumber(), 'isAdmin' => $userObj->isAdmin());
     $this->setForm(new AddCandidateForm(array(), $param, true));
     if ($this->getUser()->hasFlash('templateMessage')) {
         list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
     }
     $this->jobVacancyList = $this->getVacancyService()->getAllVacancies();
     $this->candidateStatus = JobCandidate::ACTIVE;
     if ($this->candidateId > 0) {
         $allowedCandidateList = $userObj->getAllowedCandidateList();
         if (!in_array($this->candidateId, $allowedCandidateList)) {
             $this->redirect('recruitment/viewCandidates');
         }
         $this->actionForm = new ViewCandidateActionForm(array(), $param, true);
         $allowedHistoryList = $userObj->getAllowedCandidateHistoryList($this->candidateId);
         $candidateHistory = $this->getCandidateService()->getCandidateHistoryForCandidateId($this->candidateId, $allowedHistoryList);
         $candidateHistoryService = new CandidateHistoryService();
         $this->_setListComponent($candidateHistoryService->getCandidateHistoryList($candidateHistory));
         $params = array();
         $this->parmetersForListCompoment = $params;
         $this->candidateStatus = $this->getCandidateService()->getCandidateById($this->candidateId)->getStatus();
     } else {
         if (!($userObj->isAdmin() || $userObj->isHiringManager())) {
             $this->redirect('recruitment/viewCandidates');
         }
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         $file = $request->getFiles($this->form->getName());
         if ($_FILES['addCandidate']['size']['resume'] > 1024000 || $_FILES['addCandidate']['error']['resume'] && $_FILES['addCandidate']['name']['resume']) {
             $title = $this->candidateId > 0 ? __('Editing Candidate') : __('Adding Candidate');
             $this->templateMessage = array('WARNING', '' . __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
         } elseif ($_FILES == null) {
             $title = $this->candidateId > 0 ? __('Editing Candidate') : __('Adding Candidate');
             $this->getUser()->setFlash('templateMessage', array('warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE)));
             $this->redirect('recruitment/addCandidate');
         } else {
             $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
             $file = $request->getFiles($this->form->getName());
             if ($this->form->isValid()) {
                 $result = $this->form->save();
                 if (isset($result['messageType'])) {
                     $this->messageType = $result['messageType'];
                     $this->message = $result['message'];
                     $this->invalidFile = true;
                 } else {
                     $this->candidateId = $result['candidateId'];
                     $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS)));
                     $this->redirect('recruitment/addCandidate?id=' . $this->candidateId);
                 }
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $usrObj = $this->getUser()->getAttribute('user');
     $allowedCandidateList = $usrObj->getAllowedCandidateList();
     $allowedVacancyList = $usrObj->getAllowedVacancyList();
     $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete();
     $isAdmin = $usrObj->isAdmin();
     if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer())) {
         $this->redirect('pim/viewPersonalDetails');
     }
     $param = array('allowedCandidateList' => $allowedCandidateList, 'allowedVacancyList' => $allowedVacancyList, 'allowedCandidateListToDelete' => $allowedCandidateListToDelete);
     list($this->messageType, $this->message) = $this->getUser()->getFlash('candidateListMessageItems');
     $candidateId = $request->getParameter('candidateId');
     $sortField = $request->getParameter('sortField');
     $sortOrder = $request->getParameter('sortOrder');
     $isPaging = $request->getParameter('pageNo');
     $pageNumber = $isPaging;
     if (!is_null($this->getUser()->getAttribute('pageNumber')) && !($pageNumber >= 1)) {
         $pageNumber = $this->getUser()->getAttribute('pageNumber');
     }
     $this->getUser()->setAttribute('pageNumber', $pageNumber);
     $searchParam = new CandidateSearchParameters();
     $searchParam->setIsAdmin($isAdmin);
     $searchParam->setEmpNumber($request->getParameter('referralId'));
     $searchParam->setReferralName($request->getParameter('referralName'));
     $noOfRecords = $searchParam->getLimit();
     $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords;
     $searchParam->setAdditionalParams($request->getParameter('additionalParams', array()));
     $this->setForm(new viewCandidatesForm(array(), $param, true));
     if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $candidateId > 0) {
         if ($this->getUser()->hasAttribute('searchParameters')) {
             $searchParam = $this->getUser()->getAttribute('searchParameters');
             $this->form->setDefaultDataToWidgets($searchParam);
         }
         $searchParam->setSortField($sortField);
         $searchParam->setSortOrder($sortOrder);
     } else {
         $this->getUser()->setAttribute('searchParameters', $searchParam);
         $offset = 0;
         $pageNumber = 1;
     }
     $searchParam->setAllowedCandidateList($allowedCandidateList);
     $searchParam->setAllowedVacancyList($allowedVacancyList);
     $searchParam->setOffset($offset);
     $candidates = $this->getCandidateService()->searchCandidates($searchParam);
     $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber);
     $params = array();
     $this->parmetersForListCompoment = $params;
     if (empty($isPaging)) {
         if ($request->isMethod('post')) {
             $pageNumber = 1;
             $searchParam->setOffset(0);
             $this->getUser()->setAttribute('pageNumber', $pageNumber);
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $srchParams = $this->form->getSearchParamsBindwithFormData($searchParam);
                 $this->getUser()->setAttribute('searchParameters', $srchParams);
                 $candidates = $this->getCandidateService()->searchCandidates($srchParams);
                 $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber);
             }
         }
     }
 }
 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     /* For highlighting corresponding menu item */
     $request->setParameter('initialActionName', 'viewCandidates');
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array('recruitment_candidates' => new ResourcePermission(true, false, false, false)));
     $allowedVacancyList = $userRoleManager->getAccessibleEntityIds('Vacancy', null, null, array(), array(), $requiredPermissions);
     $this->candidatePermissions = $this->getDataGroupPermissions('recruitment_candidates');
     $userObj = $this->getUser()->getAttribute('user');
     $allowedCandidateListToDelete = $userObj->getAllowedCandidateListToDelete();
     $this->candidateId = $request->getParameter('id');
     $this->invalidFile = false;
     $reDirect = false;
     $this->edit = true;
     if ($this->candidateId > 0 && !in_array($this->candidateId, $allowedCandidateListToDelete)) {
         $reDirect = true;
         $this->edit = false;
     }
     $param = array('candidateId' => $this->candidateId, 'allowedVacancyList' => $allowedVacancyList, 'empNumber' => $userObj->getEmployeeNumber(), 'isAdmin' => $userObj->isAdmin(), 'candidatePermissions' => $this->candidatePermissions);
     $this->setForm(new AddCandidateForm(array(), $param, true));
     $vacancyProperties = array('name', 'id', 'status');
     $this->jobVacancyList = $this->getVacancyService()->getVacancyPropertyList($vacancyProperties);
     $this->candidateStatus = JobCandidate::ACTIVE;
     if ($this->candidateId > 0) {
         $allowedCandidateList = $userObj->getAllowedCandidateList();
         if (!in_array($this->candidateId, $allowedCandidateList)) {
             $this->redirect('recruitment/viewCandidates');
         }
         $this->actionForm = new ViewCandidateActionForm(array(), $param, true);
         $allowedHistoryList = $userObj->getAllowedCandidateHistoryList($this->candidateId);
         $candidateHistory = $this->getCandidateService()->getCandidateHistoryForCandidateId($this->candidateId, $allowedHistoryList);
         $candidateHistoryService = new CandidateHistoryService();
         if ($this->candidatePermissions->canRead()) {
             $this->_setListComponent($candidateHistoryService->getCandidateHistoryList($candidateHistory));
         }
         $params = array();
         $this->parmetersForListCompoment = $params;
         $this->candidateStatus = $this->getCandidateService()->getCandidateById($this->candidateId)->getStatus();
     } else {
         if (!($userObj->isAdmin() || $userObj->isHiringManager() || $this->candidatePermissions->canRead())) {
             $this->redirect('recruitment/viewCandidates');
         }
     }
     if ($request->isMethod('post')) {
         if ($this->candidatePermissions->canCreate() || $this->candidatePermissions->canUpdate()) {
             $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
             $file = $request->getFiles($this->form->getName());
             if ($_FILES['addCandidate']['size']['resume'] > 1024000 || $_FILES['addCandidate']['error']['resume'] && $_FILES['addCandidate']['name']['resume']) {
                 $title = $this->candidateId > 0 ? __('Editing Candidate') : __('Adding Candidate');
                 $this->getUser()->setFlash('addcandidate.warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
             } elseif ($_FILES == null) {
                 $title = $this->candidateId > 0 ? __('Editing Candidate') : __('Adding Candidate');
                 $this->getUser()->setFlash('addcandidate.warning', __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE));
                 $this->redirect('recruitment/addCandidate');
             } else {
                 $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
                 $file = $request->getFiles($this->form->getName());
                 if ($this->form->isValid()) {
                     $result = $this->form->save();
                     if (isset($result['messageType'])) {
                         $this->getUser()->setFlash('addcandidate.warning', $result['message']);
                         $this->invalidFile = true;
                     } else {
                         $this->candidateId = $result['candidateId'];
                         $this->getUser()->setFlash('addcandidate.success', __(TopLevelMessages::SAVE_SUCCESS));
                         $this->redirect('recruitment/addCandidate?id=' . $this->candidateId);
                     }
                 }
             }
         }
     }
 }