Package com.openbravo.pos.pda.bo

Examples of com.openbravo.pos.pda.bo.RestaurantManager


    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        FloorForm floorForm = (FloorForm) form;
        RestaurantManager manager = new RestaurantManager();
        String floorId = (String) floorForm.getFloorId();
        String place = (String) floorForm.getId();
        String str = (String) floorForm.getMode();
        String[] array = null;

        int mode = 0;
        if (!str.equals("")) {
            mode = Integer.valueOf(str);
        }
        List<TicketLineInfo> linesList = new ArrayList<TicketLineInfo>();
        List products = new ArrayList<ProductInfoExt>();
        TicketInfo ticket;
        switch (mode) {

            //removes products
            case 1:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        if (linesList.get(Integer.valueOf(array[i])).getMultiply() > 1) {
                            linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() - 1);
                        }

                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("product", products.get(0));
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("line", linesList.get(Integer.valueOf(array[0])));
                request.setAttribute("lineNo", array[0]);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(UPDATE);

            case 4:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                int var = Integer.parseInt(array[0]);
                linesList.remove(var);
                if (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                    linesList.remove(var);
                    while (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                        linesList.remove(var);
                        if (linesList.size() == var) {
                            break;
                        }
                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("floorId", floorId);
                request.setAttribute("lines", linesList);
                request.setAttribute("products", products);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(SUCCESS);

            //edits lines
            case 2:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                String[] index = floorForm.getParameters();
                //if null go to default and refresh products. that's why no break
                linesList.get(Integer.valueOf(index[0])).setMultiply(Double.valueOf(index[1]));

                manager.updateLineFromTicket(floorForm.getId(), ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                break;

            //increment product
            case 3:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() + 1);    //strange
                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }
                request.setAttribute("product", products.get(0));
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("line", linesList.get(Integer.valueOf(array[0])));
                request.setAttribute("lineNo", array[0]);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(UPDATE);

            //adds new products or just refresh
            default:
                if (manager.findTicket(place) == null) {
                    manager.initTicket(place);
                } else {
                    linesList = manager.findTicketLines(place);
                }
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }
                break;
        }

        request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
        request.setAttribute("place", place);
        request.setAttribute("placeName", manager.findPlaceNameById(place));
        request.setAttribute("floorId", floorId);
        request.setAttribute("lines", linesList);
        request.setAttribute("products", products);
        request.setAttribute("total", manager.getTotalOfaTicket(place));

        return mapping.findForward(SUCCESS);
    }
View Full Code Here


    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm inputFormPlace = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        List products = new ArrayList<ProductInfoExt>();
        products = manager.findProductsByCategory((String) inputFormPlace.get("categoryId"));
        List rates = new ArrayList<String>();
        rates = manager.findAllTaxRatesByCategory(products);
        request.getSession().setAttribute("products", products);
        request.getSession().setAttribute("rates", rates);
        if (inputFormPlace.get("mode").equals("1")) {
            request.setAttribute("subcategories", manager.findAllSubcategories(inputFormPlace.getString("categoryId")));
            return mapping.findForward(NEXTLEVEL);
        }
        request.setAttribute("subcategories", manager.findAllSubcategories(inputFormPlace.getString("categoryId")));

        return mapping.findForward(SUCCESS);

    }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm inputForm = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        String login = inputForm.getString("login");
        String password = inputForm.getString("password");
        UserInfo user = manager.findUser(login, password);
        if (user != null) {
            HttpSession session = request.getSession();
            session.setAttribute("user", user);
            return mapping.findForward(SUCCESS);
        }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm inputFormPlace = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        //gets floors
        ArrayList<Floor> floors = new ArrayList<Floor>();
        floors = (ArrayList<Floor>) manager.findAllFloors();
        List busyTables = new ArrayList<Floor>();
        //floorId
        String floorId = (String) inputFormPlace.get("floorId");
        try {
            String deletedPlace = (String) inputFormPlace.get("place");
            manager.deleteTicket(deletedPlace);
        } catch (java.lang.IllegalArgumentException ex) {
            //no receipt to delete so just continue and show floors
        }
        List places = new ArrayList<Place>();
        if (floorId.equals("") || floorId.equals("undefined")) {
            places = manager.findAllPlaces(floors.get(0).getId());
            floorId = floors.get(0).getId();
            busyTables = manager.findAllBusyTable(floorId);
        } else {
            places = manager.findAllPlaces(floorId);
            busyTables = manager.findAllBusyTable(floorId);
        }

        request.setAttribute("i", 0);
        request.setAttribute("busy", busyTables);
        request.getSession().setAttribute("places", places);
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm aform = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        List busyTables = new ArrayList<Floor>();
        List places = new ArrayList<Place>();
        String floorId = (String) aform.get("floorId");
        if (((String) aform.get("floorId")).equals("")) {
            places = manager.findAllPlaces(manager.findTheFirstFloor());
            busyTables = manager.findAllBusyTable(floorId);
        } else {
            places = manager.findAllPlaces(floorId);
            busyTables = manager.findAllBusyTable(floorId);
        }

        request.setAttribute("busy", busyTables);
        request.getSession().setAttribute("floorId", floorId);
        request.getSession().setAttribute("places", places);
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        FloorForm floorForm = (FloorForm) form;
        RestaurantManager manager = new RestaurantManager();
        String floorId = (String) floorForm.getFloorId();
        String place = (String) floorForm.getId();
        String str = (String) floorForm.getMode();
        String[] array = null;

        int mode = 0;
        if (!str.equals("")) {
            mode = Integer.valueOf(str);
        }
        List<TicketLineInfo> linesList = new ArrayList<TicketLineInfo>();
        List products = new ArrayList<ProductInfoExt>();
        TicketInfo ticket;
        switch (mode) {

            //removes products
            case 1:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        if (linesList.get(Integer.valueOf(array[i])).getMultiply() > 1) {
                            linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() - 1);
                        }

                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("product", products.get(0));
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("line", linesList.get(Integer.valueOf(array[0])));
                request.setAttribute("lineNo", array[0]);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(UPDATE);

            case 4:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                int var = Integer.parseInt(array[0]);
                linesList.remove(var);
                if (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                    linesList.remove(var);
                    while (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                        linesList.remove(var);
                        if (linesList.size() == var) {
                            break;
                        }
                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("floorId", floorId);
                request.setAttribute("lines", linesList);
                request.setAttribute("products", products);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(SUCCESS);

            //edits lines
            case 2:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                String[] index = floorForm.getParameters();
                //if null go to default and refresh products. that's why no break
                linesList.get(Integer.valueOf(index[0])).setMultiply(Double.valueOf(index[1]));

                manager.updateLineFromTicket(floorForm.getId(), ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                break;

            //increment product
            case 3:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() + 1);    //strange
                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }
                request.setAttribute("product", products.get(0));
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("line", linesList.get(Integer.valueOf(array[0])));
                request.setAttribute("lineNo", array[0]);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(UPDATE);

            //adds new products or just refresh
            default:
                if (manager.findTicket(place) == null) {
                    manager.initTicket(place);
                } else {
                    linesList = manager.findTicketLines(place);
                }
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }
                break;
        }

        request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
        request.setAttribute("place", place);
        request.setAttribute("placeName", manager.findPlaceNameById(place));
        request.setAttribute("floorId", floorId);
        request.setAttribute("lines", linesList);
        request.setAttribute("products", products);
        request.setAttribute("total", manager.getTotalOfaTicket(place));

        return mapping.findForward(SUCCESS);
    }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        AddedProductForm aForm = (AddedProductForm) form;
        RestaurantManager bo = new RestaurantManager();
        String place = aForm.getPlace();
        String productId = aForm.getProductId();

        bo.addLineToTicket(place, productId);
        List auxiliars = new ArrayList<ProductInfo>();
        auxiliars = bo.findAuxiliars(productId);
        request.setAttribute("place", place);
        request.setAttribute("auxiliars", auxiliars);
        request.setAttribute("rates", bo.findAllTaxRatesByCategory(auxiliars));

        return mapping.findForward(SUCCESS);
    }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm inputFormPlace = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        List<CategoryInfo> categories = new ArrayList<CategoryInfo>();
        categories = manager.findAllCategories();
        List products = new ArrayList<ProductInfo>();
        products = manager.findProductsByCategory(categories.get(0).getId());
        List taxRates = new ArrayList<String>();
        taxRates = manager.findAllTaxRatesByCategory(products);
        List subcategories = new ArrayList<CategoryInfo>();
        subcategories = manager.findAllSubcategories(categories.get(0).getId());

        request.setAttribute("products", products);
        request.setAttribute("rates", taxRates);
        request.getSession().setAttribute("place", (String) inputFormPlace.get("place"));
        request.setAttribute("placeName", manager.findPlaceNameById((String) inputFormPlace.get("place")));
        request.setAttribute("categories", categories);
        request.setAttribute("subcategories", subcategories);
        request.getSession().setAttribute("floorId", (String) inputFormPlace.get("floorId"));

        return mapping.findForward(SUCCESS);
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaActionForm inputFormPlace = (DynaActionForm) form;
        RestaurantManager manager = new RestaurantManager();
        List products = new ArrayList<ProductInfoExt>();
        products = manager.findProductsByCategory((String) inputFormPlace.get("categoryId"));
        List rates = new ArrayList<String>();
        rates = manager.findAllTaxRatesByCategory(products);
        request.getSession().setAttribute("products", products);
        request.getSession().setAttribute("rates", rates);
        if (inputFormPlace.get("mode").equals("1")) {
            request.setAttribute("subcategories", manager.findAllSubcategories(inputFormPlace.getString("categoryId")));
            return mapping.findForward(NEXTLEVEL);
        }
        request.setAttribute("subcategories", manager.findAllSubcategories(inputFormPlace.getString("categoryId")));

        return mapping.findForward(SUCCESS);

    }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        FloorForm floorForm = (FloorForm) form;
        RestaurantManager manager = new RestaurantManager();
        String floorId = (String) floorForm.getFloorId();
        String place = (String) floorForm.getId();
        String str = (String) floorForm.getMode();
        String[] array = floorForm.getParameters();
        List<TicketLineInfo> linesList = new ArrayList<TicketLineInfo>();
        List products = new ArrayList<ProductInfoExt>();
        TicketInfo ticket = manager.findTicket(place);
        linesList = ticket.getM_aLines();
        if (array != null) {
            for (int i = 0; i < array.length; i++) {
                linesList.get(Integer.valueOf(array[i]) - 0).setMultiply(linesList.get(Integer.valueOf(array[i]) - 0).getMultiply() + 1);    //strange
            }
        }
        manager.updateLineFromTicket(floorForm.getId(), ticket);
        for (Object line : linesList) {
            TicketLineInfo li = (TicketLineInfo) line;
            products.add(manager.findProductById(li.getProductid()));
        }


        request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
        request.setAttribute("place", place);

        request.setAttribute("placeName", manager.findPlaceNameById(place));
        request.setAttribute("floorId", floorId);
        request.setAttribute("lines", linesList);
        request.setAttribute("products", products);
        request.setAttribute("total", manager.getTotalOfaTicket(place));

        return mapping.findForward(SUCCESS);
    }
View Full Code Here

TOP

Related Classes of com.openbravo.pos.pda.bo.RestaurantManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.