use of com.axelor.apps.hr.service.leave.LeaveService in project axelor-open-suite by axelor.
the class LeaveController method cancel.
public void cancel(ActionRequest request, ActionResponse response) {
try {
LeaveRequest leave = request.getContext().asType(LeaveRequest.class);
leave = Beans.get(LeaveRequestRepository.class).find(leave.getId());
LeaveService leaveService = Beans.get(LeaveService.class);
leaveService.cancel(leave);
Message message = leaveService.sendCancellationEmail(leave);
if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
} finally {
response.setReload(true);
}
}
use of com.axelor.apps.hr.service.leave.LeaveService in project axelor-open-suite by axelor.
the class LeaveController method validate.
/**
* Validates leave request and sends an email to the applicant.
*
* @param request
* @param response
* @throws AxelorException
*/
public void validate(ActionRequest request, ActionResponse response) {
try {
LeaveService leaveService = Beans.get(LeaveService.class);
LeaveRequest leaveRequest = request.getContext().asType(LeaveRequest.class);
leaveRequest = Beans.get(LeaveRequestRepository.class).find(leaveRequest.getId());
leaveService.validate(leaveRequest);
Message message = leaveService.sendValidationEmail(leaveRequest);
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(leaveRequest.getCompany(), leaveRequest.getToDateT().toLocalDate(), leaveRequest.getFromDateT().toLocalDate());
} catch (Exception e) {
TraceBackService.trace(response, e);
} finally {
response.setReload(true);
}
}
Aggregations