use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method validateTimesheet.
public void validateTimesheet(ActionRequest request, ActionResponse response) {
User user = AuthUtils.getUser();
Employee employee = user.getEmployee();
ActionViewBuilder actionView = ActionView.define(I18n.get("Timesheets to Validate")).model(Timesheet.class.getName()).add("grid", "timesheet-validate-grid").add("form", "timesheet-form").param("search-filters", "timesheet-filters").context("todayDate", Beans.get(AppBaseService.class).getTodayDate(user.getActiveCompany()));
Beans.get(HRMenuValidateService.class).createValidateDomain(user, employee, actionView);
response.setView(actionView.map());
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method refuse.
// action called when refusing a timesheet. Changing status + Sending mail to Applicant
public void refuse(ActionRequest request, ActionResponse response) throws AxelorException {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
Message message = Beans.get(TimesheetService.class).refuseAndSendRefusalEmail(timesheet);
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.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetServiceImpl method createTimesheet.
@Override
public Timesheet createTimesheet(User user, LocalDate fromDate, LocalDate toDate) {
Timesheet timesheet = new Timesheet();
timesheet.setUser(user);
Company company = null;
Employee employee = user.getEmployee();
if (employee != null && employee.getMainEmploymentContract() != null) {
company = employee.getMainEmploymentContract().getPayCompany();
} else {
company = user.getActiveCompany();
}
String timeLoggingPreferenceSelect = employee == null ? null : employee.getTimeLoggingPreferenceSelect();
timesheet.setTimeLoggingPreferenceSelect(timeLoggingPreferenceSelect);
timesheet.setCompany(company);
timesheet.setFromDate(fromDate);
timesheet.setStatusSelect(TimesheetRepository.STATUS_DRAFT);
timesheet.setFullName(computeFullName(timesheet));
return timesheet;
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method cancel.
public void cancel(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
Message message = Beans.get(TimesheetService.class).cancelAndSendCancellationEmail(timesheet);
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.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method confirm.
/**
* Action called when confirming a timesheet. Changing status + Sending mail to Manager
*
* @param request
* @param response
*/
public void confirm(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
Message message = Beans.get(TimesheetService.class).confirmAndSendConfirmationEmail(timesheet);
if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
}
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(e);
response.setError(e.getMessage());
}
}
Aggregations