Search in sources :

Example 31 with User

use of com.axelor.auth.db.User in project axelor-open-suite by axelor.

the class EmployeeController method showAnnualReport.

public void showAnnualReport(ActionRequest request, ActionResponse response) throws JSONException, NumberFormatException, AxelorException {
    String employeeId = request.getContext().get("_id").toString();
    String year = request.getContext().get("year").toString();
    int yearId = new JSONObject(year).getInt("id");
    String yearName = new JSONObject(year).getString("name");
    User user = AuthUtils.getUser();
    String name = I18n.get("Annual expenses report") + " :  " + user.getFullName() + " (" + yearName + ")";
    String fileLink = ReportFactory.createReport(IReport.EMPLOYEE_ANNUAL_REPORT, name).addParam("EmployeeId", Long.valueOf(employeeId)).addParam("Timezone", getTimezone(Beans.get(EmployeeRepository.class).find(Long.valueOf(employeeId)).getUser())).addParam("YearId", Long.valueOf(yearId)).addParam("Locale", ReportSettings.getPrintingLocale(null)).toAttach(Beans.get(EmployeeRepository.class).find(Long.valueOf(employeeId))).generate().getFileLink();
    response.setView(ActionView.define(name).add("html", fileLink).map());
    response.setCanClose(true);
}
Also used : EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) User(com.axelor.auth.db.User) JSONObject(wslite.json.JSONObject)

Example 32 with User

use of com.axelor.auth.db.User in project axelor-open-suite by axelor.

the class EmployeeController method printEmployeePhonebook.

public void printEmployeePhonebook(ActionRequest request, ActionResponse response) throws AxelorException {
    User user = AuthUtils.getUser();
    String name = I18n.get("Employee PhoneBook");
    String fileLink = ReportFactory.createReport(IReport.EMPLOYEE_PHONEBOOK, name + "-${date}").addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("UserId", user.getId()).addParam("Timezone", getTimezone(user)).generate().getFileLink();
    LOG.debug("Printing " + name);
    response.setView(ActionView.define(name).add("html", fileLink).map());
}
Also used : User(com.axelor.auth.db.User)

Example 33 with User

use of com.axelor.auth.db.User in project axelor-open-suite by axelor.

the class TimesheetController method historicTimesheetLine.

public void historicTimesheetLine(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("See timesheet lines")).model(TimesheetLine.class.getName()).add("grid", "timesheet-line-grid").add("form", "timesheet-line-form");
    actionView.domain("self.timesheet.company = :_activeCompany AND (self.timesheet.statusSelect = 3 OR self.timesheet.statusSelect = 4)").context("_activeCompany", user.getActiveCompany());
    if (employee == null || !employee.getHrManager()) {
        actionView.domain(actionView.get().getDomain() + " AND self.timesheet.user.employee.managerUser = :_user").context("_user", user);
    }
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 34 with User

use of com.axelor.auth.db.User in project axelor-open-suite by axelor.

the class TimesheetReportController method fillTimesheetReportReminderUsers.

public void fillTimesheetReportReminderUsers(ActionRequest request, ActionResponse response) {
    TimesheetReport timesheetReport = request.getContext().asType(TimesheetReport.class);
    Set<User> reminderUserSet = Beans.get(TimesheetReportService.class).getUserToBeReminded(timesheetReport);
    if (!ObjectUtils.isEmpty(reminderUserSet)) {
        response.setValue("reminderUserSet", reminderUserSet);
    } else {
        response.setValue("reminderUserSet", null);
        response.setNotify(I18n.get(ITranslation.TS_REPORT_FILL_NO_USER));
    }
}
Also used : User(com.axelor.auth.db.User) TimesheetReport(com.axelor.apps.hr.db.TimesheetReport) TimesheetReportService(com.axelor.apps.hr.service.timesheet.TimesheetReportService)

Example 35 with User

use of com.axelor.auth.db.User in project axelor-open-suite by axelor.

the class ExtraHoursController method validateExtraHours.

public void validateExtraHours(ActionRequest request, ActionResponse response) throws AxelorException {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Extra hours to Validate")).model(ExtraHours.class.getName()).add("grid", "extra-hours-validate-grid").add("form", "extra-hours-form").param("search-filters", "extra-hours-filters");
    Beans.get(HRMenuValidateService.class).createValidateDomain(user, employee, actionView);
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) HRMenuValidateService(com.axelor.apps.hr.service.HRMenuValidateService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Aggregations

User (com.axelor.auth.db.User)157 AxelorException (com.axelor.exception.AxelorException)35 Employee (com.axelor.apps.hr.db.Employee)28 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)25 Transactional (com.google.inject.persist.Transactional)24 LocalDate (java.time.LocalDate)23 Filter (com.axelor.rpc.filter.Filter)22 BigDecimal (java.math.BigDecimal)22 ClientViewService (com.axelor.apps.portal.service.ClientViewService)20 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)17 List (java.util.List)17 Map (java.util.Map)16 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)12 LocalDateTime (java.time.LocalDateTime)12 Company (com.axelor.apps.base.db.Company)11 Partner (com.axelor.apps.base.db.Partner)11 Beans (com.axelor.inject.Beans)11 Inject (com.google.inject.Inject)11 Product (com.axelor.apps.base.db.Product)9