@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; }
// Пользователь списывает занятость за продолжительные отпуск или болезнь. @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; }