Search in sources :

Example 11 with ClientViewService

use of com.axelor.apps.portal.service.ClientViewService 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 12 with ClientViewService

use of com.axelor.apps.portal.service.ClientViewService 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 13 with ClientViewService

use of com.axelor.apps.portal.service.ClientViewService 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 14 with ClientViewService

use of com.axelor.apps.portal.service.ClientViewService 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)

Example 15 with ClientViewService

use of com.axelor.apps.portal.service.ClientViewService in project axelor-open-suite by axelor.

the class ClientViewController method showClientMyCustomerTickets.

/* TICKETS OnClick */
public void showClientMyCustomerTickets(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.getTicketsOfUser(clientUser).get(0);
            if (filter != null) {
                response.setView(ActionView.define(I18n.get("Customer tickets")).model(Ticket.class.getName()).add("grid", "ticket-grid").add("form", "ticket-form").param("search-filters", "ticket-filters").domain(filter.getQuery()).map());
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ClientViewService(com.axelor.apps.portal.service.ClientViewService) Ticket(com.axelor.apps.helpdesk.db.Ticket) User(com.axelor.auth.db.User) Filter(com.axelor.rpc.filter.Filter)

Aggregations

ClientViewService (com.axelor.apps.portal.service.ClientViewService)20 User (com.axelor.auth.db.User)20 Filter (com.axelor.rpc.filter.Filter)19 Invoice (com.axelor.apps.account.db.Invoice)4 Ticket (com.axelor.apps.helpdesk.db.Ticket)4 StockMove (com.axelor.apps.stock.db.StockMove)4 ProjectTask (com.axelor.apps.project.db.ProjectTask)3 SaleOrder (com.axelor.apps.sale.db.SaleOrder)3 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)2 Project (com.axelor.apps.project.db.Project)1 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)1