Search in sources :

Example 86 with User

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

the class TimesheetController method allTimesheetLine.

public void allTimesheetLine(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");
    Beans.get(TimesheetService.class).createDomainAllTimesheetLine(user, employee, actionView);
    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) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 87 with User

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

the class TimesheetController method validateTimesheetLine.

public void validateTimesheetLine(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").context("todayDate", Beans.get(AppBaseService.class).getTodayDate(user.getActiveCompany()));
    Beans.get(TimesheetService.class).createValidateDomainTimesheetLine(user, employee, actionView);
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 88 with User

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

the class ExpenseController method historicExpense.

public void historicExpense(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Historic colleague Expenses")).model(Expense.class.getName()).add("grid", "expense-grid").add("form", "expense-form").param("search-filters", "expense-filters");
    actionView.domain("self.company = :_activeCompany AND (self.statusSelect = 3 OR self.statusSelect = 4)").context("_activeCompany", user.getActiveCompany());
    if (employee == null || !employee.getHrManager()) {
        actionView.domain(actionView.get().getDomain() + " AND self.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) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 89 with User

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

the class ExpenseController method editExpense.

public void editExpense(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Company activeCompany = user.getActiveCompany();
    List<Expense> expenseList = Beans.get(ExpenseRepository.class).all().filter("self.user = ?1 AND self.company = ?2 AND self.statusSelect = 1 AND (self.multipleUsers is false OR self.multipleUsers is null)", user, activeCompany).fetch();
    if (expenseList.isEmpty()) {
        response.setView(ActionView.define(I18n.get("Expense")).model(Expense.class.getName()).add("form", "expense-form").context("_payCompany", Beans.get(UserHrService.class).getPayCompany(user)).map());
    } else if (expenseList.size() == 1) {
        response.setView(ActionView.define(I18n.get("Expense")).model(Expense.class.getName()).add("form", "expense-form").param("forceEdit", "true").context("_showRecord", String.valueOf(expenseList.get(0).getId())).map());
    } else {
        response.setView(ActionView.define(I18n.get("Expense")).model(Wizard.class.getName()).add("form", "popup-expense-form").param("forceEdit", "true").param("popup", "true").param("show-toolbar", "false").param("show-confirm", "false").param("forceEdit", "true").param("popup-save", "false").map());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) User(com.axelor.auth.db.User) Expense(com.axelor.apps.hr.db.Expense) ExpenseRepository(com.axelor.apps.hr.db.repo.ExpenseRepository) Wizard(com.axelor.apps.base.db.Wizard)

Example 90 with User

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

the class ExtraHoursController method showSubordinateExtraHours.

public void showSubordinateExtraHours(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Company activeCompany = user.getActiveCompany();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Extra hours to be Validated by your subordinates")).model(ExtraHours.class.getName()).add("grid", "extra-hours-grid").add("form", "extra-hours-form").param("search-filters", "extra-hours-filters");
    String domain = "self.user.employee.managerUser.employee.managerUser = :_user AND self.company = :_activeCompany AND self.statusSelect = 2";
    long nbExtraHours = Query.of(ExtraHours.class).filter(domain).bind("_user", user).bind("_activeCompany", activeCompany).count();
    if (nbExtraHours == 0) {
        response.setNotify(I18n.get("No extra hours to be validated by your subordinates"));
    } else {
        response.setView(actionView.domain(domain).context("_user", user).context("_activeCompany", activeCompany).map());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) User(com.axelor.auth.db.User) 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