Esempio 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'));
 }
Esempio n. 2
0
 /**
  * Display a building in a location
  *
  * @param int $location_id
  * @param int $building_id
  * @return \Symfony\Component\HttpFoundation\Response
  * @access public
  */
 public function showLocationBuildingAction($location_id, $building_id)
 {
     //must be an integer
     $location_id = (int) $location_id;
     $building_id = (int) $building_id;
     if ($location_id === 0 || $building_id === 0) {
         redirect($this->helper->route('consim_core_location', array('location_id' => $location_id)));
     }
     $location = $this->locationService->getLocation($location_id);
     $building = $this->buildingService->getBuilding($building_id);
     //add location to navbar
     $this->add_navlinks($location->getName(), $this->helper->route('consim_core_location', array('location_id' => $location->getId())));
     //Show all Works
     $this->workService->allWorksToTemplate($building->getTypeId());
     add_form_key('working');
     // Set output vars for display in the template
     $this->template->assign_vars(array('BUILDING_NAME' => $building->getName() != '' ? '"' . $building->getName() . '"' : '', 'BUILDING_DESCRIPTION' => $building->getDescription() != '' ? '' . $building->getDescription() . '' : '', 'BUILDING_TYP' => $building->getTypeName(), 'LOCATION' => $location->getName(), 'BACK_TO_LOCATION' => $this->helper->route('consim_core_location', array('location_id' => $location_id)), 'S_WORK_ACTION' => $this->helper->route('consim_core_work_start')));
     // Send all data to the template file
     return $this->helper->render('consim_building.html', $this->user->lang('CONSIM'));
 }