Esempio n. 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");
  }
Esempio n. 2
0
  @RequestMapping(value = "/timesheet", method = RequestMethod.POST)
  public ModelAndView sendTimeSheet(
      @ModelAttribute("timeSheetForm") TimeSheetForm tsForm, BindingResult result) {
    logger.info(
        "Processing form validation for employee {} ({}).",
        tsForm.getEmployeeId(),
        tsForm.getCalDate());
    tsFormValidator.validate(tsForm, result);
    if (result.hasErrors()) {
      logger.info(
          "TimeSheetForm for employee {} has errors. Form not validated.", tsForm.getEmployeeId());
      ModelAndView mavWithErrors = new ModelAndView("timesheet");
      mavWithErrors.addObject("timeSheetForm", tsForm);
      mavWithErrors.addObject("errors", result.getAllErrors());
      mavWithErrors.addObject("selectedProjectsJson", getSelectedProjectsJson(tsForm));
      mavWithErrors.addObject("selectedProjectRolesJson", getSelectedProjectRolesJson(tsForm));
      mavWithErrors.addObject("selectedProjectTasksJson", getSelectedProjectTasksJson(tsForm));
      mavWithErrors.addObject("selectedWorkplaceJson", getSelectedWorkplaceJson(tsForm));
      mavWithErrors.addObject("selectedActCategoriesJson", getSelectedActCategoriesJson(tsForm));
      mavWithErrors.addObject(
          "selectedLongVacationIllnessJson", getSelectedLongVacationIllnessJson(tsForm));
      mavWithErrors.addObject("selectedCalDateJson", getSelectedCalDateJson(tsForm));
      mavWithErrors.addObject("getDateByDefault", getDateByDefault(tsForm.getEmployeeId()));
      mavWithErrors.addObject("getFirstWorkDate", getEmployeeFirstWorkDay(tsForm.getEmployeeId()));
      mavWithErrors.addAllObjects(getListsToMAV());

      return mavWithErrors;
    }
    TimeSheet timeSheet = timeSheetService.storeTimeSheet(tsForm);
    overtimeCauseService.store(timeSheet, tsForm);
    sendMailService.performMailing(tsForm);

    ModelAndView mav = new ModelAndView("selected");
    mav.addObject("timeSheetForm", tsForm);
    logger.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");

    return mav;
  }
Esempio n. 3
0
  // Пользователь списывает занятость за продолжительные отпуск или болезнь.
  @RequestMapping(value = "/timesheetLong", method = RequestMethod.POST)
  public ModelAndView sendTimeSheetLong(
      @ModelAttribute("timeSheetForm") TimeSheetForm tsForm, BindingResult result) {
    logger.info(
        "Processing form validation for employee {} ({}) (long).",
        tsForm.getEmployeeId(),
        tsForm.getCalDate());
    tsFormValidator.validate(tsForm, result);
    if (result.hasErrors()) {
      logger.info(
          "TimeSheetForm for employee {} has errors. Form not validated (long).",
          tsForm.getEmployeeId());
      ModelAndView mavWithErrors = new ModelAndView("timesheet");
      mavWithErrors.addObject("timeSheetForm", tsForm);
      mavWithErrors.addObject("errors", result.getAllErrors());
      mavWithErrors.addObject("selectedProjectRolesJson", "[{row:'0', role:''}]");
      mavWithErrors.addObject("selectedProjectTasksJson", "[{row:'0', task:''}]");
      mavWithErrors.addObject("selectedProjectsJson", "[{row:'0', project:''}]");
      mavWithErrors.addObject("selectedActCategoriesJson", "[{row:'0', actCat:''}]");
      mavWithErrors.addObject("selectedWorkplace", "[{row:'0', workplace:''}]");
      mavWithErrors.addObject("selectedCalDateJson", "''");
      mavWithErrors.addObject(
          "selectedLongVacationIllnessJson", getSelectedLongVacationIllnessJson(tsForm));
      mavWithErrors.addAllObjects(getListsToMAV());

      return mavWithErrors;
    }
    timeSheetService.storeTimeSheetLong(tsForm);
    sendMailService.performMailing(tsForm);

    ModelAndView mav = new ModelAndView("selected");
    mav.addObject("timeSheetForm", tsForm);
    logger.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");

    return mav;
  }
Esempio n. 4
0
 /**
  * Возвращает планы предыдущего дня и на следующего дня
  *
  * @param date (2012-11-25)
  * @param employeeId (573)
  * @return Json String
  */
 @RequestMapping(value = "/timesheet/plans", headers = "Accept=application/json;Charset=UTF-8")
 @ResponseBody
 public String getPlans(
     @RequestParam("date") String date, @RequestParam("employeeId") Integer employeeId) {
   return timeSheetService.getPlansJson(date, employeeId);
 }
Esempio n. 5
0
 /*
  * <APLANATS-412>
  * Возвращает дату начала работы сотрудника
  */
 private String getEmployeeFirstWorkDay(Integer id) {
   return dateToJsonString(timeSheetService.getEmployeeFirstWorkDay(id));
 }
Esempio n. 6
0
 /*  <APLANATS-474>
  * Возвращает дату (dd.mm.yyyy) для того чтобы установить ее на форме по умолчанию
  */
 private String getDateByDefault(Integer id) {
   return dateToJsonString(timeSheetService.getLastWorkdayWithoutTimesheet(id));
 }