public function getActionableTimesheets($employeeList) { $timesheetList = null; $accessFlowStateMachinService = new AccessFlowStateMachineService(); $action = array(PluginWorkflowStateMachine::TIMESHEET_ACTION_APPROVE, PluginWorkflowStateMachine::TIMESHEET_ACTION_REJECT); $actionableStatesList = $accessFlowStateMachinService->getActionableStates(PluginWorkflowStateMachine::FLOW_TIME_TIMESHEET, AdminUserRoleDecorator::ADMIN_USER, $action); $empNumbers = array(); foreach ($employeeList as $employee) { $empNumbers[] = $employee['empNumber']; } if ($actionableStatesList != null) { $timesheetList = $this->getTimesheetService()->getTimesheetListByEmployeeIdAndState($empNumbers, $actionableStatesList, self::NUM_PENDING_TIMESHEETS); } return $timesheetList; }
public function getAllowedCandidateHistoryList($candidateId) { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $allowedCandidateHistoryIdList = $accessFlowStateMachineService->getAllowedCandidateHistoryList(AdminUserRoleDecorator::ADMIN_USER, null, $candidateId); $existingIdList = $this->user->getAllowedCandidateHistoryList($candidateId); if (is_null($allowedCandidateHistoryIdList)) { return $existingIdList; } else { $allowedCandidateHistoryIdList = array_unique(array_merge($allowedCandidateHistoryIdList, $existingIdList)); return $allowedCandidateHistoryIdList; } }
/** * Get allowed Workflow action items for User * * @param string $workflow Workflow Name * @param string $state Workflow state * @return array Array of workflow items with action name as array index */ public function getAllowedActions($workflow, $state, $rolesToExclude = array(), $rolesToInclude = array(), $entities = array()) { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $allActions = array(); $filteredRoles = $this->filterRoles($this->userRoles, $rolesToExclude, $rolesToInclude, $entities); foreach ($filteredRoles as $role) { $workFlowItems = $accessFlowStateMachineService->getAllowedWorkflowItems($workflow, $state, $role->getName()); if (count($workFlowItems) > 0) { $allActions = $this->getUniqueActionsBasedOnPriority($allActions, $workFlowItems); } } return $allActions; }
public function getAllowedCandidateHistoryList($candidateId) { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $allowedCandidateHistoryIdList = $accessFlowStateMachineService->getAllowedCandidateHistoryList(InterviewerUserRoleDecorator::INTERVIEWER, $this->getEmployeeNumber(), $candidateId); $existingIdList = $this->user->getAllowedCandidateHistoryList($candidateId); if (is_null($allowedCandidateHistoryIdList)) { return $existingIdList; } else { $allowedCandidateHistoryIdList = array_unique(array_merge($allowedCandidateHistoryIdList, $existingIdList)); return $allowedCandidateHistoryIdList; } }
/** * Given an array of actions, returns the states for which those actions can be applied * by the current logged in user * * @param string $workflow Workflow * @param array $actions Array of Action names * @param array $rolesToExclude * @param array $rolesToInclude * @param array $entities * * @return array Array of states */ public function getActionableStates($workflow, $actions, $rolesToExclude = array(), $rolesToInclude = array(), $entities = array()) { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $actionableStates = array(); $filteredRoles = $this->filterRoles($this->userRoles, $rolesToExclude, $rolesToInclude, $entities); foreach ($filteredRoles as $role) { $roleName = $this->fixUserRoleNameForWorkflowStateMachine($role->getName(), $workflow); $states = $accessFlowStateMachineService->getActionableStates($workflow, $roleName, $actions); if (!empty($states)) { $actionableStates = array_unique(array_merge($actionableStates, $states)); } } return $actionableStates; }
public function getActionableAttendanceStates($actions) { $accessFlowStateMachinService = new AccessFlowStateMachineService(); $actionableAttendanceStatesForSupervisorUser = $accessFlowStateMachinService->getActionableStates(PluginWorkflowStateMachine::FLOW_ATTENDANCE, SupervisorUserRoleDecorator::SUPERVISOR_USER, $actions); $actionableAttendanceStates = $this->user->getActionableAttendanceStates($actions); if (is_null($actionableAttendanceStatesForSupervisorUser)) { return $actionableAttendanceStates; } $actionableAttendanceStatesList = array_unique(array_merge($actionableAttendanceStatesForSupervisorUser, $actionableAttendanceStates)); return $actionableAttendanceStatesList; }
public function createTimesheets($startDate, $employeeId) { $datesInTheCurrenTimesheetPeriod = $this->getTimesheetPeriodService()->getDefinedTimesheetPeriod($startDate); $timesheetStartingDate = $datesInTheCurrenTimesheetPeriod[0]; $endDate = end($datesInTheCurrenTimesheetPeriod); $timesheet = $this->getTimesheetByStartDateAndEmployeeId($timesheetStartingDate, $employeeId); if ($timesheet == null) { if ($this->checkForOverlappingTimesheets($timesheetStartingDate, $endDate, $employeeId) == 0) { $statusValuesArray['state'] = 1; } else { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $tempNextState = $accessFlowStateMachineService->getNextState(WorkflowStateMachine::FLOW_TIME_TIMESHEET, Timesheet::STATE_INITIAL, "SYSTEM", WorkflowStateMachine::TIMESHEET_ACTION_CREATE); $timesheet = new Timesheet(); $timesheet->setState($tempNextState); $timesheet->setStartDate($timesheetStartingDate); $timesheet->setEndDate($endDate); $timesheet->setEmployeeId($employeeId); $timesheet = $this->saveTimesheet($timesheet); $statusValuesArray['state'] = 2; $statusValuesArray['startDate'] = $timesheetStartingDate; } } else { $statusValuesArray['state'] = 3; } return $statusValuesArray; }
public function getAllowedProjectList() { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $allowedProjectIdList = $accessFlowStateMachineService->getAllowedProjectList(ProjectAdminUserRoleDecorator::PROJECT_ADMIN_USER, $this->getEmployeeNumber()); $existingIdList = $this->user->getAllowedProjectList(); if (is_null($allowedProjectIdList)) { return $existingIdList; } else { $allowedProjectIdList = array_unique(array_merge($allowedProjectIdList, $existingIdList)); return $allowedProjectIdList; } }
/** * Get allowed Actions for User * * @param type $workflow * @param type $state * @return actionsArray */ public function getAllowedActions($workflow, $state) { $accessFlowStateMachineService = new AccessFlowStateMachineService(); $allAction = array(); foreach ($this->userRoles as $role) { $userAction = $accessFlowStateMachineService->getAllowedActions($workflow, $state, $role); if (count($userAction) > 0) { $allAction = array_unique(array_merge($allAction, $userAction)); } } return $allAction; }