Example #1
2
 /**
  * Get resulting state when given action is performed on the given timesheet
  * 
  * @param Timesheet $timesheet
  * @param int $action Action
  * @param bool $self true if operating on own timesheet
  * @return string
  */
 protected function getResultingState($timesheet, $action, $self)
 {
     $resultingState = $timesheet->getState();
     $excludeRoles = array();
     $includeRoles = array();
     $entities = array('Employee' => $timesheet->getEmployeeId());
     if ($self) {
         $includeRoles[] = 'ESS';
     }
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $allowedActions = $userRoleManager->getAllowedActions(PluginWorkflowStateMachine::FLOW_TIME_TIMESHEET, $timesheet->getState(), $excludeRoles, $includeRoles, $entities);
     if (isset($allowedActions[$action])) {
         $resultingState = $allowedActions[$action]->getResultingState();
     }
     return $resultingState;
 }