예제 #1
0
  @RequestMapping(value = "/timesheet", method = RequestMethod.GET)
  public ModelAndView showMainForm(
      @RequestParam(value = "date", required = false) String date,
      @RequestParam(value = "id", required = false) Integer id) {
    logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    logger.info("Showing Time Sheet main page!");
    ModelAndView mav = new ModelAndView();
    mav.setViewName("timesheet");

    TimeSheetForm tsForm = new TimeSheetForm();

    TimeSheetUser securityUser = securityService.getSecurityPrincipal();

    if (id != null) {
      tsForm.setDivisionId(employeeService.find(id).getDivision().getId());
      tsForm.setEmployeeId(id);
    } else if (securityUser != null) {
      tsForm.setDivisionId(securityUser.getEmployee().getDivision().getId());
      tsForm.setEmployeeId(securityUser.getEmployee().getId());
    }

    if (date != null) {
      tsForm.setCalDate(date);
      mav.addObject(
          "selectedCalDateJson", getSelectedCalDateJson(tsForm)); // выставляем дату для DateTextBox
    } else {
      mav.addObject("selectedCalDateJson", "''");
    }
    mav.addObject("timeSheetForm", tsForm); // command object
    mav.addObject("selectedProjectRolesJson", "[{row:'0', role:''}]");
    mav.addObject("selectedProjectTasksJson", "[{row:'0', task:''}]");
    mav.addObject("selectedProjectsJson", "[{row:'0', project:''}]");
    mav.addObject("selectedWorkplaceJson", "[{row:'0', workplace:''}]");
    mav.addObject("selectedActCategoriesJson", "[{row:'0', actCat:''}]");
    mav.addObject("selectedLongVacationIllnessJson", getSelectedLongVacationIllnessJson(tsForm));
    mav.addObject("getDateByDefault", getDateByDefault(tsForm.getEmployeeId()));
    mav.addObject("getFirstWorkDate", getEmployeeFirstWorkDay(tsForm.getEmployeeId()));

    mav.addAllObjects(getListsToMAV());
    return mav;
  }
예제 #2
0
  /*
   * Возвращает HashMap со значениями для заполнения списков сотрудников,
   * проектов, пресейлов, проектных задач, типов и категорий активности на
   * форме приложения.
   */
  private Map<String, Object> getListsToMAV() {
    Map<String, Object> result = new HashMap<String, Object>();

    List<DictionaryItem> typesOfActivity = dictionaryItemService.getTypesOfActivity();
    result.put("actTypeList", typesOfActivity);

    String typesOfActivityJson = getDictionaryItemsInJson(typesOfActivity);
    result.put("actTypeJson", typesOfActivityJson);

    String workplacesJson = getDictionaryItemsInJson(dictionaryItemService.getWorkplaces());
    result.put("workplaceJson", workplacesJson);

    result.put(
        "overtimeCauseJson", getDictionaryItemsInJson(dictionaryItemService.getOvertimeCauses()));
    result.put(
        "unfinishedDayCauseJson",
        getDictionaryItemsInJson(dictionaryItemService.getUnfinishedDayCauses()));
    result.put("overtimeThreshold", propertyProvider.getOvertimeThreshold());

    List<Division> divisions = divisionService.getDivisions();
    result.put("divisionList", divisions);

    result.put(
        "employeeListJson",
        employeeHelper.getEmployeeListJson(divisions, employeeService.isShowAll(request)));

    List<DictionaryItem> categoryOfActivity = dictionaryItemService.getCategoryOfActivity();
    result.put("actCategoryList", categoryOfActivity);

    String actCategoryListJson = getDictionaryItemsInJson(categoryOfActivity);
    result.put("actCategoryListJson", actCategoryListJson);

    result.put("availableActCategoriesJson", getAvailableActCategoriesJson());

    result.put("projectListJson", projectService.getProjectListJson(divisions));
    result.put("projectTaskListJson", getProjectTaskListJson(projectService.getProjectsWithCq()));

    List<ProjectRole> projectRoleList = projectRoleService.getProjectRoles();

    for (int i = 0; i < projectRoleList.size(); i++) {
      if (projectRoleList
          .get(i)
          .getCode()
          .equals("ND")) { // Убираем из списка роль "Не определена" APLANATS-270
        projectRoleList.remove(i);
        break;
      }
    }

    result.put("projectRoleList", projectRoleList);
    StringBuilder projectRoleListJson = new StringBuilder();
    projectRoleListJson.append("[");
    for (ProjectRole item : projectRoleList) {
      projectRoleListJson.append("{id:'");
      projectRoleListJson.append(item.getId().toString());
      projectRoleListJson.append("', value:'");
      projectRoleListJson.append(item.getName());
      projectRoleListJson.append("'},");
    }
    result.put(
        "projectRoleListJson",
        projectRoleListJson.toString().substring(0, (projectRoleListJson.toString().length() - 1))
            + "]");

    return result;
  }