Search in sources :

Example 36 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyAwaitingInvoices.

public void showClientMyAwaitingInvoices(ActionRequest request, ActionResponse response) {
    try {
        ClientViewService clientViewService = Beans.get(ClientViewService.class);
        User clientUser = clientViewService.getClientUser();
        if (clientUser.getPartner() == null) {
            response.setError(I18n.get(ITranslation.CLIENT_PORTAL_NO_PARTNER));
        } else {
            Filter filter = clientViewService.getAwaitingInvoicesOfUser(clientUser).get(0);
            if (filter != null) {
                response.setView(ActionView.define(I18n.get("Awaiting invoices")).model(Invoice.class.getName()).add("grid", "invoice-grid").add("form", "invoice-form").param("search-filters", "customer-invoices-filters").domain(filter.getQuery()).map());
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) User(com.axelor.auth.db.User) Invoice(com.axelor.apps.account.db.Invoice) Filter(com.axelor.rpc.filter.Filter)

Example 37 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyLastOrder.

public void showClientMyLastOrder(ActionRequest request, ActionResponse response) {
    try {
        ClientViewService clientViewService = Beans.get(ClientViewService.class);
        User clientUser = clientViewService.getClientUser();
        if (clientUser.getPartner() == null) {
            response.setError(I18n.get(ITranslation.CLIENT_PORTAL_NO_PARTNER));
        } else {
            Filter filter = clientViewService.getLastOrderOfUser(clientUser).get(0);
            if (filter != null) {
                SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).all().filter(filter.getQuery()).fetchOne();
                if (saleOrder != null) {
                    response.setView(ActionView.define(I18n.get("Last order")).model(SaleOrder.class.getName()).add("form", "sale-order-form").context("_showRecord", saleOrder.getId()).map());
                }
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) User(com.axelor.auth.db.User) Filter(com.axelor.rpc.filter.Filter) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 38 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyOrdersInProgress.

/* SALEORDER OnCLick */
public void showClientMyOrdersInProgress(ActionRequest request, ActionResponse response) {
    try {
        ClientViewService clientViewService = Beans.get(ClientViewService.class);
        User clientUser = clientViewService.getClientUser();
        if (clientUser.getPartner() == null) {
            response.setError(I18n.get(ITranslation.CLIENT_PORTAL_NO_PARTNER));
        } else {
            Filter filter = clientViewService.getOrdersInProgressOfUser(clientUser).get(0);
            if (filter != null) {
                response.setView(ActionView.define(I18n.get("Orders in progress")).model(SaleOrder.class.getName()).add("grid", "sale-order-grid").add("form", "sale-order-form").param("search-filters", "sale-order-filters").domain(filter.getQuery()).map());
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) User(com.axelor.auth.db.User) Filter(com.axelor.rpc.filter.Filter) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 39 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyLastDelivery.

/* STOCKMOVE OnClick */
public void showClientMyLastDelivery(ActionRequest request, ActionResponse response) {
    try {
        ClientViewService clientViewService = Beans.get(ClientViewService.class);
        User clientUser = clientViewService.getClientUser();
        if (clientUser.getPartner() == null) {
            response.setError(I18n.get(ITranslation.CLIENT_PORTAL_NO_PARTNER));
        } else {
            Filter filter = clientViewService.getLastDeliveryOfUser(clientUser).get(0);
            if (filter != null) {
                StockMove stockMove = Beans.get(StockMoveRepository.class).all().filter(filter.getQuery()).fetchOne();
                if (stockMove != null) {
                    response.setView(ActionView.define(I18n.get("Last delivery")).model(StockMove.class.getName()).add("form", "stock-move-form").context("_showRecord", stockMove.getId()).map());
                }
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) User(com.axelor.auth.db.User) StockMove(com.axelor.apps.stock.db.StockMove) Filter(com.axelor.rpc.filter.Filter) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository)

Example 40 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyNextDelivery.

public void showClientMyNextDelivery(ActionRequest request, ActionResponse response) {
    try {
        ClientViewService clientViewService = Beans.get(ClientViewService.class);
        User clientUser = clientViewService.getClientUser();
        if (clientUser.getPartner() == null) {
            response.setError(I18n.get(ITranslation.CLIENT_PORTAL_NO_PARTNER));
        } else {
            Filter filter = clientViewService.getNextDeliveryOfUser(clientUser).get(0);
            if (filter != null) {
                StockMove stockMove = Beans.get(StockMoveRepository.class).all().filter(filter.getQuery()).fetchOne();
                if (stockMove != null) {
                    response.setView(ActionView.define(I18n.get("Next delivery")).model(StockMove.class.getName()).add("form", "stock-move-form").context("_showRecord", stockMove.getId()).map());
                }
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) User(com.axelor.auth.db.User) StockMove(com.axelor.apps.stock.db.StockMove) Filter(com.axelor.rpc.filter.Filter) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository)

Aggregations

Filter (com.axelor.rpc.filter.Filter)47 JPQLFilter (com.axelor.rpc.filter.JPQLFilter)23 ArrayList (java.util.ArrayList)22 User (com.axelor.auth.db.User)21 ClientViewService (com.axelor.apps.portal.service.ClientViewService)19 StockMove (com.axelor.apps.stock.db.StockMove)7 Invoice (com.axelor.apps.account.db.Invoice)5 Ticket (com.axelor.apps.helpdesk.db.Ticket)5 SaleOrder (com.axelor.apps.sale.db.SaleOrder)5 ProjectTask (com.axelor.apps.project.db.ProjectTask)4 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)3 HashMap (java.util.HashMap)3 AdvancedExport (com.axelor.apps.base.db.AdvancedExport)2 AdvancedExportService (com.axelor.apps.base.service.advancedExport.AdvancedExportService)2 Project (com.axelor.apps.project.db.Project)2 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)2 JpaSecurity (com.axelor.db.JpaSecurity)2 Model (com.axelor.db.Model)2 I18n (com.axelor.i18n.I18n)2 Beans (com.axelor.inject.Beans)2