use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method updateTimeLoggingPreference.
/**
* Called from timesheet form, on user change. Call {@link
* TimesheetService#updateTimeLoggingPreference(Timesheet)} to update the timesheet, and update
* the dummy field $periodTotalConvert
*
* @param request
* @param response
*/
public void updateTimeLoggingPreference(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
Beans.get(TimesheetService.class).updateTimeLoggingPreference(timesheet);
response.setAttr("$periodTotalConvert", "hidden", false);
response.setAttr("$periodTotalConvert", "value", Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, timesheet.getPeriodTotal(), false));
response.setAttr("$periodTotalConvert", "title", Beans.get(TimesheetService.class).getPeriodTotalConvertTitle(timesheet));
response.setValue("timeLoggingPreferenceSelect", timesheet.getTimeLoggingPreferenceSelect());
response.setValue("timesheetLineList", timesheet.getTimesheetLineList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method draft.
/**
* Called from timesheet form view, on clicking "return to draft" button. <br>
* Call {@link TimesheetService#draft(Timesheet)}
*
* @param request
* @param response
*/
public void draft(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
Beans.get(TimesheetService.class).draft(timesheet);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method printTimesheet.
public void printTimesheet(ActionRequest request, ActionResponse response) throws AxelorException {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
String name = I18n.get("Timesheet") + " " + timesheet.getFullName().replace("/", "-");
String fileLink = ReportFactory.createReport(IReport.TIMESHEET, name).addParam("TimesheetId", timesheet.getId()).addParam("Timezone", timesheet.getCompany() != null ? timesheet.getCompany().getTimezone() : null).addParam("Locale", ReportSettings.getPrintingLocale(null)).toAttach(timesheet).generate().getFileLink();
logger.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetController method timesheetPeriodTotalController.
public void timesheetPeriodTotalController(ActionRequest request, ActionResponse response) {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
TimesheetService timesheetService = Beans.get(TimesheetService.class);
BigDecimal periodTotal = timesheetService.computePeriodTotal(timesheet);
response.setAttr("periodTotal", "value", periodTotal);
response.setAttr("$periodTotalConvert", "hidden", false);
response.setAttr("$periodTotalConvert", "value", Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, periodTotal, false));
response.setAttr("$periodTotalConvert", "title", timesheetService.getPeriodTotalConvertTitle(timesheet));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.hr.db.Timesheet in project axelor-open-suite by axelor.
the class TimesheetLineController method setDuration.
/**
* Called from timesheet editor Get the timesheet corresponding to timesheetline and call {@link
* TimesheetLineService#computeHoursDuration(Timesheet, BigDecimal, boolean)}
*
* @param request
* @param response
*/
public void setDuration(ActionRequest request, ActionResponse response) {
try {
TimesheetLine timesheetLine = request.getContext().asType(TimesheetLine.class);
Timesheet timesheet;
Context parent = request.getContext().getParent();
if (parent != null && parent.getContextClass().equals(Timesheet.class)) {
timesheet = parent.asType(Timesheet.class);
} else {
timesheet = timesheetLine.getTimesheet();
}
BigDecimal duration = Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, timesheetLine.getHoursDuration(), false);
response.setValue(DURATION_FIELD, duration);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations