use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method valid.
/**
* Action called when validating a timesheet. Changing status + Sending mail to Applicant
*
* @param request
* @param response
* @throws AxelorException
*/
public void valid(ActionRequest request, ActionResponse response) throws AxelorException {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
TimesheetService timesheetService = Beans.get(TimesheetService.class);
timesheetService.checkEmptyPeriod(timesheet);
computeTimeSpent(request, response);
Message message = timesheetService.validateAndSendValidationEmail(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)));
}
Beans.get(PeriodService.class).checkPeriod(timesheet.getCompany(), timesheet.getToDate(), timesheet.getFromDate());
} 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 editTimesheetSelected.
public void editTimesheetSelected(ActionRequest request, ActionResponse response) {
Map<?, ?> timesheetMap = (Map<?, ?>) request.getContext().get("timesheetSelect");
Timesheet timesheet = Beans.get(TimesheetRepository.class).find(Long.valueOf((Integer) timesheetMap.get("id")));
response.setView(ActionView.define("Timesheet").model(Timesheet.class.getName()).add("form", "timesheet-form").param("forceEdit", "true").domain("self.id = " + timesheetMap.get("id")).context("_showRecord", String.valueOf(timesheet.getId())).map());
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method setShowActivity.
public void setShowActivity(ActionRequest request, ActionResponse response) {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
boolean showActivity = true;
User user = timesheet.getUser();
if (user != null) {
Company company = user.getActiveCompany();
if (company != null && company.getHrConfig() != null) {
showActivity = !company.getHrConfig().getUseUniqueProductForTimesheet();
}
}
response.setValue("$showActivity", showActivity);
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method prefillLines.
public void prefillLines(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
Beans.get(TimesheetService.class).prefillLines(timesheet);
response.setValues(timesheet);
} catch (AxelorException e) {
TraceBackService.trace(response, e);
}
}
Aggregations