Ejemplo n.º 1
0
 /**
  * Display work action
  *
  * @param int	$action_id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showWorkAction($action_id)
 {
     $action = $this->actionService->getAction($action_id);
     //check if the user is owner of action
     if ($action->getUserId() != $this->userService->getCurrentUser()->getUserId() || $action->getWorkId() == 0) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     $now = time();
     $time = $action->getEndTime() - $now;
     $work = $this->workService->getWork($action->getWorkId());
     $location = $this->locationService->getLocation($action->getLocationId());
     $building = $this->buildingService->findBuilding($location->getId(), $work->getBuildingTypeId());
     //User must finished the work
     if ($action->getStatus() == 2) {
         $s_hidden_fields = build_hidden_fields(array('action_id' => $action->getId()));
         $this->template->assign_vars(array('IS_CONFIRM_FINISH' => TRUE, 'U_FINISH' => $action->getStatus() == 2 ? $this->helper->route('consim_core_work_end') : FALSE, 'S_HIDDEN_FIELDS' => $s_hidden_fields));
         add_form_key('working_end');
     }
     //Work finished
     $result = null;
     if ($action->getStatus() == 1) {
         $result = $action->getResult();
         $this->template->assign_vars(array('IS_WORK_FINISHED' => TRUE, 'WORK_RESULT_ALL' => $result['conditions']['all'], 'WORK_RESULT_1' => isset($result['conditions'][0]) ? $result['conditions'][0] : 0, 'WORK_RESULT_2' => isset($result['conditions'][1]) ? $result['conditions'][1] : 0, 'WORK_RESULT_3' => isset($result['conditions'][2]) ? $result['conditions'][2] : 0, 'WORK_EXPERIENCE' => $result['experience']));
     }
     $this->workService->allWorkOutputsToTemplate($work->getId(), $result);
     // Set output vars for display in the template
     $this->template->assign_vars(array('SHOW_WORKING' => TRUE, 'IS_WORKING' => $action->getStatus() == 0 ? TRUE : FALSE, 'WORK_NAME' => $work->getName(), 'WORK_CONDITION_1_TYPE' => $work->getCondition1Name(), 'WORK_CONDITION_1_TRIALS' => $work->getCondition1Trials(), 'WORK_CONDITION_1_VALUE' => $work->getCondition1Value(), 'WORK_CONDITION_2_TYPE' => $work->getCondition2Name(), 'WORK_CONDITION_2_TRIALS' => $work->getCondition2Trials(), 'WORK_CONDITION_2_VALUE' => $work->getCondition2Value(), 'WORK_CONDITION_3_TYPE' => $work->getCondition3Name(), 'WORK_CONDITION_3_TRIALS' => $work->getCondition3Trials(), 'WORK_CONDITION_3_VALUE' => $work->getCondition3Value(), 'WORK_CONDITION_ALL' => $work->getCondition1Trials() + $work->getCondition2Trials() + $work->getCondition3Trials(), 'WORK_EXPERIENCE_POINTS' => implode("/", $work->getExperiencePoints()), 'WORK_BUILDING_NAME' => $building->getName() != '' ? '"' . $building->getName() . '"' : '', 'WORK_BUILDING_TYPE' => $building->getTypeName(), 'WORK_LOCATION_NAME' => $location->getName(), 'WORK_TIME' => $action->getStatus() == 0 ? date("i:s", $time) : FALSE));
     // Send all data to the template file
     return $this->helper->render('consim_working.html', $this->user->lang('CONSIM'));
 }