/**
  *
  * @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);
             }
         }
     }
 }
 /**
  *
  * @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)
 {
     /* 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);
                     }
                 }
             }
         }
     }
 }
 /**
  * @param <type> $query
  * @depends testNativeQueryResultCaching
  */
 public function testResultCacheDependsOnParameters($query)
 {
     $cache = $query->getResultCacheDriver();
     $cacheCount = count($cache->getIds());
     $query->setParameter(1, 50);
     $query->getResult();
     $this->assertEquals($cacheCount + 1, count($cache->getIds()));
 }