/**
  *
  */
 public function configure()
 {
     $this->candidateVacancyId = $this->getOption('candidateVacancyId');
     $this->selectedAction = $this->getOption('selectedAction');
     $this->id = $this->getOption('id');
     if ($this->candidateVacancyId > 0 && $this->selectedAction != "") {
         $stateMachine = new WorkflowStateMachine();
         $this->actionName = $stateMachine->getRecruitmentActionName($this->selectedAction);
         $this->selectedCandidateVacancy = $this->getCandidateService()->getCandidateVacancyById($this->candidateVacancyId);
     }
     if ($this->id > 0) {
         $candidateHistory = $this->getCandidateService()->getCandidateHistoryById($this->id);
         $this->selectedCandidateVacancy = $this->getCandidateService()->getCandidateVacancyByCandidateIdAndVacancyId($candidateHistory->getCandidateId(), $candidateHistory->getVacancyId());
         $this->performedActionName = $candidateHistory->getActionName();
         $date = explode(" ", $candidateHistory->getPerformedDate());
         $this->performedDate = set_datepicker_date_format($date[0]);
         $this->performedBy = $candidateHistory->getPerformerName();
         $this->vacancyId = $candidateHistory->getVacancyId();
         $this->selectedAction = $candidateHistory->getAction();
     }
     $this->candidateId = $this->selectedCandidateVacancy->getCandidateId();
     $this->vacancyId = $this->selectedCandidateVacancy->getVacancyId();
     $this->candidateName = $this->selectedCandidateVacancy->getCandidateName();
     $this->vacancyName = $this->selectedCandidateVacancy->getVacancyName();
     $this->hiringManagerName = $this->selectedCandidateVacancy->getHiringManager();
     $this->currentStatus = ucwords(strtolower($this->selectedCandidateVacancy->getStatus()));
     $this->setWidget('notes', new sfWidgetFormTextArea());
     $this->setValidator('notes', new sfValidatorString(array('required' => false, 'max_length' => 2147483647)));
     $this->widgetSchema->setNameFormat('candidateVacancyStatus[%s]');
     if ($this->id > 0) {
         $this->setDefault('notes', $candidateHistory->getNote());
         $this->widgetSchema['notes']->setAttribute('disabled', 'disable');
         $this->actionName = 'View Action History';
     }
 }
Ejemplo n.º 2
0
 private function extractResultsToArray($candidateVacancyList)
 {
     $stateMachine = new WorkflowStateMachine();
     $i = 0;
     foreach ($candidateVacancyList as $candidateVacancy) {
         $list[$i]['vacancyName'] = $candidateVacancy->getJobVacancy()->getName();
         $list[$i]['candidateName'] = $candidateVacancy->getJobCandidate()->getFullName();
         $list[$i]['hiringManager'] = $candidateVacancy->getJobVacancy()->getEmployee()->getFullName();
         $list[$i]['dateOfApplication'] = $candidateVacancy->getJobCandidate()->getDateOfApplication();
         $list[$i]['status'] = $stateMachine->getRecruitmentApplicationStateNames($candidateVacancy->getStatus());
         $i++;
     }
     return $list;
 }
 public function saveWorkflowStateMachineRecord(WorkflowStateMachine $workflowStateMachine)
 {
     try {
         if ($workflowStateMachine->getId() == '') {
             $idGenService = new IDGeneratorService();
             $idGenService->setEntity($workflowStateMachine);
             $workflowStateMachine->setId($idGenService->getNextID());
         }
         $workflowStateMachine->save();
         return $workflowStateMachine;
     } catch (Exception $ex) {
         throw new DaoException($ex->getMessage());
     }
 }
Ejemplo n.º 4
0
 public function testListenOneWorkflow()
 {
     $workFlow = new WorkflowStateMachine();
     $workFlow->setAction('apply');
     $workFlow->setRolesToNotify('ESS,Supervisor,ABC');
     $workFlow->setRole('ess');
     $eventData = array('workFlow' => $workFlow);
     $emailType = 'leave.apply';
     $recipientRoles = array('ESS', 'Supervisor', 'ABC');
     $mockService = $this->getMock('EmailService', array('sendEmailNotifications'));
     $mockService->expects($this->once())->method('sendEmailNotifications')->with($emailType, $recipientRoles, $eventData, 'ess');
     $this->mailer->setEmailService($mockService);
     $sfEvent = new sfEvent($this, 'test', $eventData);
     $this->mailer->listen($sfEvent);
 }
 public function testSaveWorkflowStateMachineRecord()
 {
     $workflowStateMachineRecord = new WorkflowStateMachine();
     $workflowStateMachineRecord->setAction(PluginWorkflowStateMachine::ATTENDANCE_ACTION_EDIT_PUNCH_TIME);
     $workflowStateMachineRecord->setState(PluginAttendanceRecord::STATE_CREATED);
     $workflowStateMachineRecord->setResultingState(PluginAttendanceRecord::STATE_CREATED);
     $workflowStateMachineRecord->setWorkflow(PluginWorkflowStateMachine::FLOW_ATTENDANCE);
     $workflowStateMachineRecord->setRole("ESS USER");
     $this->accessFlowStateMachineDao->saveWorkflowStateMachineRecord($workflowStateMachineRecord);
     $this->assertNotNull($workflowStateMachineRecord->getId());
     $this->assertEquals($workflowStateMachineRecord->getAction(), PluginWorkflowStateMachine::ATTENDANCE_ACTION_EDIT_PUNCH_TIME);
     $this->assertEquals($workflowStateMachineRecord->getState(), PluginAttendanceRecord::STATE_CREATED);
 }
Ejemplo n.º 6
0
 /**
  *
  * @param <type> $state
  * @return <type>
  */
 public function getNextActionsForCandidateVacancy($state, $userObj)
 {
     $stateMachine = new WorkflowStateMachine();
     $list = array("" => __('Select Action'));
     $allowedActions = $userObj->getAllowedActions(PluginWorkflowStateMachine::FLOW_RECRUITMENT, $state);
     if (empty($allowedActions)) {
         $list[""] = __('No Actions');
     } else {
         foreach ($allowedActions as $action) {
             $list[$action] = $stateMachine->getRecruitmentActionName($action);
         }
     }
     return $list;
 }
 public function testGetLeaveActions()
 {
     $loggedInEmpNumber = 4;
     $leave = new Leave();
     $leave->setStatus(Leave::LEAVE_STATUS_LEAVE_PENDING_APPROVAL);
     $leave->setEmpNumber(5);
     $approveAction = new WorkflowStateMachine();
     $approveAction->fromArray(array('id' => 2, 'workflow' => 'leave', 'state' => 'PENDING APPROVAL', 'role' => 'ADMIN', 'action' => 'APPROVE', 'resulting_state' => 'SCHEDULED', 'roles_to_notify' => '', 'priority' => 0));
     $cancelAction = new WorkflowStateMachine();
     $cancelAction->fromArray(array('id' => 3, 'workflow' => 'leave', 'state' => 'PENDING APPROVAL', 'role' => 'ADMIN', 'action' => 'CANCEL', 'resulting_state' => 'CANCELLED', 'roles_to_notify' => '', 'priority' => 0));
     $rejectAction = new WorkflowStateMachine();
     $rejectAction->fromArray(array('id' => 5, 'workflow' => 'leave', 'state' => 'PENDING APPROVAL', 'role' => 'ADMIN', 'action' => 'REJECT', 'resulting_state' => 'REJECTED', 'roles_to_notify' => '', 'priority' => 0));
     $actions = array($approveAction, $cancelAction, $rejectAction);
     $userManager = $this->getMock('BasicUserRoleManager', array('getAllowedActions'));
     $userManager->expects($this->any())->method('getAllowedActions')->with(WorkflowStateMachine::FLOW_LEAVE, $leave->getTextLeaveStatus(), array(), array())->will($this->returnValue($actions));
     $this->leaveRequestService->setUserRoleManager($userManager);
     $result = $this->leaveRequestService->getLeaveActions($leave, $loggedInEmpNumber);
     $this->verifyLeaveActions($actions, $result);
 }
 public function getActionName()
 {
     $stateMachine = new WorkflowStateMachine();
     return $stateMachine->getRecruitmentActionName($this->getAction());
 }
 public function saveConfigurartion($flow, $state, $role, $action, $resultingState)
 {
     $workflowStateMachineRecord = new WorkflowStateMachine();
     $workflowStateMachineRecord->setWorkflow($flow);
     $workflowStateMachineRecord->setState($state);
     $workflowStateMachineRecord->setRole($role);
     $workflowStateMachineRecord->setAction($action);
     $workflowStateMachineRecord->setResultingState($resultingState);
     $this->getAccessFlowStateMachineService()->saveWorkflowStateMachineRecord($workflowStateMachineRecord);
 }
 public function testGetRolesToNotifyAsArray()
 {
     $workFlow = new WorkflowStateMachine();
     $workFlow->setRolesToNotify(NULL);
     $result = $workFlow->getRolesToNotifyAsArray();
     $this->assertEquals(0, count($result));
     $workFlow->setRolesToNotify('');
     $result = $workFlow->getRolesToNotifyAsArray();
     $this->assertEquals(0, count($result));
     $workFlow->setRolesToNotify('ESS');
     $result = $workFlow->getRolesToNotifyAsArray();
     $this->assertEquals(array('ESS'), $result);
     $workFlow->setRolesToNotify('Ess,Supervisor,Subscriber');
     $result = $workFlow->getRolesToNotifyAsArray();
     $this->assertEquals(array('Ess', 'Supervisor', 'Subscriber'), $result);
     $workFlow->setRolesToNotify(',,,');
     $result = $workFlow->getRolesToNotifyAsArray();
     $this->assertEquals(0, count($result));
 }
 public function testGetWorkflowItemsByStateActionAndRole()
 {
     $item = new WorkflowStateMachine();
     $item->fromArray(array('id' => 9, 'workflow' => Time, 'state' => 'APPROVED', 'role' => 'SUPERVISOR', 'action' => 'VIEW TIMESHEET', 'resulting_state' => 'APPROVED'));
     $accessFlowStateMachineDaoMock = $this->getMock('AccessFlowStateMachineDao', array('getWorkflowItemByStateActionAndRole'));
     $accessFlowStateMachineDaoMock->expects($this->once())->method('getWorkflowItemByStateActionAndRole')->with('Time', 'NOT SUBMITTED', 'SAVE', 'XYZ')->will($this->returnValue($item));
     $this->accessFlowStateMachineService->setAccessFlowStateMachineDao($accessFlowStateMachineDaoMock);
     $result = $this->accessFlowStateMachineService->getWorkflowItemByStateActionAndRole('Time', 'NOT SUBMITTED', 'SAVE', 'XYZ');
     $this->assertEquals($item, $result);
 }