예제 #1
0
  /**
   * Удаляет отчет по id. В случае если текущий авторизованный пользователь является руководителем
   * сотрудника, добавившего отчет.
   *
   * @param id
   * @return OK или Error
   */
  @RequestMapping(value = "/timesheetDel/{id}", method = RequestMethod.POST)
  public String delTimeSheet(@PathVariable("id") Integer id, HttpServletRequest httpRequest) {
    TimeSheetUser securityUser = securityService.getSecurityPrincipal();
    if (securityUser == null) {
      throw new SecurityException("Не найден пользователь в контексте безопасности.");
    }

    TimeSheet timeSheet = timeSheetService.find(id);

    logger.info(
        "Удаляется отчет " + timeSheet + ". Инициатор: " + securityUser.getEmployee().getName());
    timeSheetService.delete(timeSheet);

    sendMailService.performTimeSheetDeletedMailing(timeSheet);

    return "redirect:" + httpRequest.getHeader("Referer");
  }
예제 #2
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;
  }