Search in sources :

Example 1 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class ExpenseController method validateExpense.

public void validateExpense(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Expenses to Validate")).model(Expense.class.getName()).add("grid", "expense-validate-grid").add("form", "expense-form").param("search-filters", "expense-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)

Example 2 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class ExpenseController method showSubordinateExpenses.

public void showSubordinateExpenses(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Company activeCompany = user.getActiveCompany();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Expenses to be Validated by your subordinates")).model(Expense.class.getName()).add("grid", "expense-grid").add("form", "expense-form").param("search-filters", "expense-filters");
    String domain = "self.user.employee.managerUser.employee.managerUser = :_user AND self.company = :_activeCompany AND self.statusSelect = 2";
    long nbExpenses = Query.of(Expense.class).filter(domain).bind("_user", user).bind("_activeCompany", activeCompany).count();
    if (nbExpenses == 0) {
        response.setNotify(I18n.get("No expense 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)

Example 3 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class ProjectPlanningTimeController method showPlanning.

public void showPlanning(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    Collection<Map<String, Object>> users = (Collection<Map<String, Object>>) context.get("userSet");
    Map<String, Object> project = (Map<String, Object>) context.get("_project");
    String userIds = "";
    if (users != null) {
        for (Map<String, Object> user : users) {
            if (userIds.isEmpty()) {
                userIds = user.get("id").toString();
            } else {
                userIds += "," + user.get("id").toString();
            }
        }
    }
    String projectId = "";
    if (project != null && project.get("id") != null) {
        projectId = project.get("id").toString();
    }
    ActionViewBuilder builder = ActionView.define(I18n.get("Project Planning time")).model(ProjectPlanningTime.class.getName());
    String url = "project/planning";
    if (!userIds.isEmpty() && !projectId.isEmpty()) {
        url += "?userIds=" + userIds + "&projectIds=" + projectId;
    } else if (!userIds.isEmpty()) {
        url += "?userIds=" + userIds;
    } else if (!projectId.isEmpty()) {
        url += "?projectIds=" + projectId;
    }
    builder.add("html", url);
    response.setView(builder.map());
    response.setCanClose(true);
}
Also used : Context(com.axelor.rpc.Context) Collection(java.util.Collection) ProjectPlanningTime(com.axelor.apps.project.db.ProjectPlanningTime) Map(java.util.Map) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 4 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder 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());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) HRMenuValidateService(com.axelor.apps.hr.service.HRMenuValidateService) Timesheet(com.axelor.apps.hr.db.Timesheet) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 5 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class TimesheetController method allTimesheet.

public void allTimesheet(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Timesheets")).model(Timesheet.class.getName()).add("grid", "all-timesheet-grid").add("form", "timesheet-form").param("search-filters", "timesheet-filters");
    if (employee == null || !employee.getHrManager()) {
        if (employee == null || employee.getManagerUser() == null) {
            actionView.domain("self.user = :_user OR self.user.employee.managerUser = :_user").context("_user", user);
        } else {
            actionView.domain("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)

Aggregations

ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)54 AxelorException (com.axelor.exception.AxelorException)18 User (com.axelor.auth.db.User)17 List (java.util.List)15 Employee (com.axelor.apps.hr.db.Employee)14 Map (java.util.Map)14 ArrayList (java.util.ArrayList)13 Company (com.axelor.apps.base.db.Company)10 Partner (com.axelor.apps.base.db.Partner)9 Wizard (com.axelor.apps.base.db.Wizard)9 Invoice (com.axelor.apps.account.db.Invoice)8 Currency (com.axelor.apps.base.db.Currency)7 PriceList (com.axelor.apps.base.db.PriceList)7 LinkedHashMap (java.util.LinkedHashMap)6 SaleOrder (com.axelor.apps.sale.db.SaleOrder)5 StockMove (com.axelor.apps.stock.db.StockMove)5 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)5 HRMenuValidateService (com.axelor.apps.hr.service.HRMenuValidateService)4 StockMoveMultiInvoiceService (com.axelor.apps.supplychain.service.StockMoveMultiInvoiceService)4 MetaJsonModel (com.axelor.meta.db.MetaJsonModel)4