Search in sources :

Example 6 with ExtraHours

use of com.axelor.apps.hr.db.ExtraHours in project axelor-open-suite by axelor.

the class ExtraHoursController method valid.

/**
 * validating request and sending mail to applicant
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void valid(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        ExtraHours extraHours = request.getContext().asType(ExtraHours.class);
        extraHours = Beans.get(ExtraHoursRepository.class).find(extraHours.getId());
        Beans.get(ExtraHoursService.class).validate(extraHours);
        Message message = Beans.get(ExtraHoursService.class).sendValidationEmail(extraHours);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
        Beans.get(PeriodService.class).checkPeriod(extraHours.getCompany(), extraHours.getValidationDate());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : ExtraHours(com.axelor.apps.hr.db.ExtraHours) Message(com.axelor.apps.message.db.Message) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) PeriodService(com.axelor.apps.base.service.PeriodService) ExtraHoursService(com.axelor.apps.hr.service.extra.hours.ExtraHoursService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

ExtraHours (com.axelor.apps.hr.db.ExtraHours)6 ExtraHoursService (com.axelor.apps.hr.service.extra.hours.ExtraHoursService)5 AxelorException (com.axelor.exception.AxelorException)5 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)4 Message (com.axelor.apps.message.db.Message)4 PeriodService (com.axelor.apps.base.service.PeriodService)1 ExtraHoursRepository (com.axelor.apps.hr.db.repo.ExtraHoursRepository)1 Map (java.util.Map)1