Author: mor
Date: Wed Mar 18 16:10:44 2009 New Revision: 755627 URL: http://svn.apache.org/viewvc?rev=755627&view=rev Log: Functionality to add bulk products to purchase order through order detail page. Patch applied from OFBIZ-2221 (https://issues.apache.org/jira/browse/OFBIZ-2221) with slight modification to 1) Label 2) Used view-size in form instead of screen definition. Thanks to Akash Jain, Pranay Pandey (review and test). i18n note: This commit has new label. Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml ofbiz/trunk/applications/order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml ofbiz/trunk/applications/order/webapp/ordermgr/order/appendorderitem.ftl ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml Wed Mar 18 16:10:44 2009 @@ -3713,6 +3713,9 @@ <value xml:lang="th">à¹à¸¡à¹à¸à¸£à¸²à¸à¸à¸à¸¶à¸à¸à¹à¸²à¹à¸à¸£à¹à¸¡à¸à¸±à¸à¸à¸à¸à¸à¸§à¸±à¸</value> <value xml:lang="zh">ä¸æ¯ä¸ä¸ªææçä¿é礼å</value> </property> + <property key="shoppingCartEvents.problem_parsing_item_desiredDeliveryDate_string"> + <value xml:lang="en">Problem in parsing item desired delivery date string</value> + </property> <property key="shoppingCartHelper.no_items_found_to_add"> <value xml:lang="en">No items found to add</value> <value xml:lang="es">No hay Ãtems encontrados para agregar</value> Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Wed Mar 18 16:10:44 2009 @@ -326,7 +326,7 @@ </service> <service name="appendOrderItem" engine="java" auth="true" location="org.ofbiz.order.order.OrderServices" invoke="addItemToApprovedOrder"> - <description>Append an itemto an existing order</description> + <description>Append an item to an existing order</description> <attribute name="orderId" type="String" mode="INOUT" optional="false"/> <attribute name="shipGroupSeqId" type="String" mode="IN" optional="false"/> <attribute name="productId" type="String" mode="IN" optional="false"/> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Wed Mar 18 16:10:44 2009 @@ -26,6 +26,8 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import javolution.util.FastMap; +import java.sql.Timestamp; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -1744,5 +1746,109 @@ request.setAttribute("totalPrice", org.ofbiz.base.util.UtilFormatOut.formatCurrency(configWrapper.getTotalPrice(), currencyUomId, UtilHttp.getLocale(request))); return "success"; - } -} + } + + public static String bulkAddProductsInApprovedOrder(HttpServletRequest request, HttpServletResponse response) { + GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + Locale locale = UtilHttp.getLocale(request); + String productId = null; + String productCategoryId = null; + String quantityStr = null; + String itemDesiredDeliveryDateStr = null; + BigDecimal quantity = BigDecimal.ZERO; + String itemType = null; + String itemDescription = ""; + String orderId = null; + String shipGroupSeqId = null; + + Map paramMap = UtilHttp.getParameterMap(request); + String itemGroupNumber = request.getParameter("itemGroupNumber"); + int rowCount = UtilHttp.getMultiFormRowCount(paramMap); + if (rowCount < 1) { + Debug.logWarning("No rows to process, as rowCount = " + rowCount, module); + } else { + for (int i = 0; i < rowCount; i++) { + String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i; + if (paramMap.containsKey("productId" + thisSuffix)) { + productId = (String) paramMap.remove("productId" + thisSuffix); + } + if (paramMap.containsKey("quantity" + thisSuffix)) { + quantityStr = (String) paramMap.remove("quantity" + thisSuffix); + } + if ((quantityStr == null) || (quantityStr.equals(""))) { + quantityStr = "0"; + } + try { + quantity = new BigDecimal(quantityStr); + } catch (Exception e) { + Debug.logWarning(e, "Problems parsing quantity string: " + quantityStr, module); + quantity = BigDecimal.ZERO; + } + String selectedAmountStr = "0.00"; + if (paramMap.containsKey("amount" + thisSuffix)) { + selectedAmountStr = (String) paramMap.remove("amount" + thisSuffix); + } + BigDecimal amount = null; + if (selectedAmountStr != null && selectedAmountStr.length() > 0) { + try { + amount = new BigDecimal(selectedAmountStr); + } catch (Exception e) { + Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module); + amount = null; + } + } + if (paramMap.containsKey("itemDesiredDeliveryDate" + thisSuffix)) { + itemDesiredDeliveryDateStr = (String) paramMap.remove("itemDesiredDeliveryDate" + thisSuffix); + } + Timestamp itemDesiredDeliveryDate = null; + if (UtilValidate.isNotEmpty(itemDesiredDeliveryDateStr)) { + try { + itemDesiredDeliveryDate = Timestamp.valueOf(itemDesiredDeliveryDateStr); + } catch (Exception e) { + Debug.logWarning(e,"Problems parsing Reservation start string: " + itemDesiredDeliveryDateStr, module); + itemDesiredDeliveryDate = null; + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"shoppingCartEvents.problem_parsing_item_desiredDeliveryDate_string", locale)); + } + } + if (paramMap.containsKey("itemType" + thisSuffix)) { + itemType = (String) paramMap.remove("itemType" + thisSuffix); + } + if (paramMap.containsKey("itemDescription" + thisSuffix)) { + itemDescription = (String) paramMap.remove("itemDescription" + thisSuffix); + } + if (paramMap.containsKey("orderId" + thisSuffix)) { + orderId = (String) paramMap.remove("orderId" + thisSuffix); + } + if (paramMap.containsKey("shipGroupSeqId" + thisSuffix)) { + shipGroupSeqId = (String) paramMap.remove("shipGroupSeqId" + thisSuffix); + } + if (quantity.compareTo(BigDecimal.ZERO) > 0) { + Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + productCategoryId + + ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, module); + HttpSession session = request.getSession(); + GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); + Map appendOrderItemMap = FastMap.newInstance(); + appendOrderItemMap.put("productId", productId); + appendOrderItemMap.put("quantity", quantity); + appendOrderItemMap.put("orderId", orderId); + appendOrderItemMap.put("userLogin", userLogin); + appendOrderItemMap.put("amount", amount); + appendOrderItemMap.put("itemDesiredDeliveryDate", itemDesiredDeliveryDate); + appendOrderItemMap.put("shipGroupSeqId", shipGroupSeqId); + try { + Map result = dispatcher.runSync("appendOrderItem", appendOrderItemMap); + request.setAttribute("shoppingCart", (ShoppingCart) result.get("shoppingCart")); + ShoppingCartEvents.destroyCart(request, response); + } catch (GenericServiceException e) { + Debug.logError(e, "Failed to execute service appendOrderItem", module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + } + } + } + request.setAttribute("orderId", orderId); + return "success"; + } +} \ No newline at end of file Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy Wed Mar 18 16:10:44 2009 @@ -25,6 +25,19 @@ import org.ofbiz.order.shoppingcart.ShoppingCartEvents; productId = request.getParameter("productId") ?: ""; +supplier = null; +supplierPartyId = null; + +orderId = request.getParameter("orderId"); +if (orderId) { + orderItemShipGroup = EntityUtil.getFirst(delegator.findList("OrderItemShipGroup", null, null, ["orderId" , "orderId"], null, false)); + orderHeader = delegator.findOne("OrderHeader", [orderId : orderId], false); + EntityCondition cond = EntityCondition.makeCondition([EntityCondition.makeCondition("orderId", orderId), + EntityCondition.makeCondition("roleTypeId", "BILL_FROM_VENDOR")], EntityOperator.AND); + supplier = EntityUtil.getFirst(delegator.findList("OrderHeaderAndRoles", cond, null, null, null, false)); + context.shipGroupSeqId = orderItemShipGroup.shipGroupSeqId ; + context.orderHeader = orderHeader; +} ShoppingCart shoppingCart = ShoppingCartEvents.getCartObject(request); @@ -33,8 +46,13 @@ // make sure the look up is case insensitive conditionList.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue("productId")), EntityOperator.LIKE, productId.toUpperCase() + "%")); +if (!supplier) { + supplierPartyId = shoppingCart.getOrderPartyId(); +} else { + supplierPartyId = supplier.getString("partyId"); +} +conditionList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, supplierPartyId)); -conditionList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, shoppingCart.getOrderPartyId())); conditionList.add(EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, shoppingCart.getCurrency())); conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Wed Mar 18 16:10:44 2009 @@ -557,6 +557,14 @@ <response name="success" type="request" value="orderentry"/> <response name="error" type="request" value="orderentry"/> </request-map> + + <request-map uri="bulkAddProductsInApprovedOrder"> + <security https="true" auth="true"/> + <event type="java" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="bulkAddProductsInApprovedOrder"/> + <response name="success" type="request-redirect" value="orderview"><redirect-parameter name="orderId"/></response> + <response name="error" type="request" value="orderview"/> + </request-map> + <request-map uri="category"> <security https="true" auth="true"/> <response name="success" type="view" value="category"/> @@ -1457,6 +1465,7 @@ <request-map uri="LookupCustomerName"><security auth="true" https="true"/><response name="success" type="view" value="LookupCustomerName"/></request-map> <request-map uri="LookupProduct"><security https="true" auth="true"/><response name="success" type="view" value="LookupProduct"/></request-map> <request-map uri="LookupSupplierProduct"><security https="true" auth="true"/><response name="success" type="view" value="LookupSupplierProduct"/></request-map> + <request-map uri="LookupBulkAddSupplierProductsInApprovedOrder"><security https="true" auth="true"/><response name="success" type="view" value="LookupBulkAddSupplierProductsInApprovedOrder"/></request-map> <request-map uri="LookupProductAndPrice"><security https="true" auth="true"/><response name="success" type="view" value="LookupProductAndPrice"/></request-map> <request-map uri="LookupProductFeature"><security auth="true" https="true"/><response name="success" type="view" value="LookupProductFeature"/></request-map> <request-map uri="LookupUserLoginAndPartyDetails"><security https="true" auth="true"/><response name="success" type="view" value="LookupUserLoginAndPartyDetails"/></request-map> @@ -1488,7 +1497,6 @@ </request-map> <request-map uri="LookupContent"><security auth="true" https="true"/><response name="success" type="view" value="LookupContent"/></request-map> - <!-- These are just examples of reports developed using JasperReport and not really useful reports. In order to run them you'll have to follow the notes in the @@ -1517,7 +1525,6 @@ <!-- end of request mappings --> <!-- View Mappings --> - <view-map name="LookupProductCategory" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupProductCategory"/> <view-map name="main" type="screen" page="component://order/widget/ordermgr/OrderViewScreens.xml#OrderHeaderListView"/> @@ -1639,6 +1646,7 @@ <view-map name="LookupCustomerName" type="screen" page="component://party/widget/partymgr/LookupScreens.xml#LookupCustomerName"/> <view-map name="LookupProduct" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupProduct"/> <view-map name="LookupSupplierProduct" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupSupplierProduct"/> + <view-map name="LookupBulkAddSupplierProductsInApprovedOrder" type="screen" page="component://order/widget/ordermgr/OrderEntryOrderScreens.xml#LookupBulkAddSupplierProductsInApprovedOrder"/> <view-map name="LookupProductAndPrice" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupProductAndPrice"/> <view-map name="LookupProductFeature" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupProductFeature"/> <view-map name="LookupUserLoginAndPartyDetails" type="screen" page="component://party/widget/partymgr/LookupScreens.xml#LookupUserLoginAndPartyDetails"/> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl Wed Mar 18 16:10:44 2009 @@ -18,17 +18,23 @@ --> <div class="screenlet-title-bar"> - <div class="boxhead-right"> - <a href="<@ofbizUrl>orderentry</@ofbizUrl>" class="lightbuttontext">${uiLabelMap.OrderOrderItems}</a> - </div> - <div class="boxhead-left"> - ${uiLabelMap.CommonCreate} - <#if shoppingCart.getOrderType() == "PURCHASE_ORDER"> - ${uiLabelMap.OrderPurchaseOrder} - <#else> - ${uiLabelMap.OrderSalesOrder} - </#if> - </div> + <#if orderHeader?has_content> + <div class="boxhead-left"> + ${uiLabelMap.PageTitleLookupBulkAddProduct} + </div> + <#else> + <div class="boxhead-right"> + <a href="<@ofbizUrl>orderentry</@ofbizUrl>" class="lightbuttontext">${uiLabelMap.OrderOrderItems}</a> + </div> + <div class="boxhead-left"> + ${uiLabelMap.CommonCreate} + <#if shoppingCart.getOrderType() == "PURCHASE_ORDER"> + ${uiLabelMap.OrderPurchaseOrder} + <#else> + ${uiLabelMap.OrderSalesOrder} + </#if> + </div> + </#if> <div class="boxhead-fill"> </div> </div> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml Wed Mar 18 16:10:44 2009 @@ -117,4 +117,27 @@ </field> <field name="addButton" widget-style="smallSubmit"><submit button-type="button"/></field> </form> + <form name="LookupBulkAddSupplierProductsInApprovedOrder" type="multi" use-row-submit="true" list-name="productList" title="" target="bulkAddProductsInApprovedOrder" + odd-row-style="alternate-row" default-table-style="basic-table hover-bar" paginate-target="LookupBulkAddSupplierProductsInApprovedOrder" view-size="10"> + <actions> + <set field="orderId" from-field="parameters.orderId"/> + </actions> + <field name="orderId"><hidden/></field> + <field name="shipGroupSeqId"><hidden/></field> + <field name="productId" widget-style="buttontext"> + <hyperlink description="${productId}" target="/catalog/control/EditProductInventoryItems?productId=${productId}" target-type="inter-app"/> + </field> + <field name="supplierProductId"><display/></field> + <field name="supplierProductName"><display/></field> + <field name="lastPrice"><display/></field> + <field name="quantity" title="${uiLabelMap.OrderQuantity}"> + <text size="5" maxlength="10"/> + </field> + <field name="itemDesiredDeliveryDate" title="${uiLabelMap.OrderDesiredDeliveryDate}"> + <date-time/> + </field> + <field name="submitButton" title="${uiLabelMap.OrderAddToOrder}" widget-style="smallSubmit"> + <submit/> + </field> + </form> </forms> \ No newline at end of file Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/appendorderitem.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/appendorderitem.ftl?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/appendorderitem.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/appendorderitem.ftl Wed Mar 18 16:10:44 2009 @@ -17,6 +17,12 @@ under the License. --> +<script language="JavaScript" type="text/javascript"> + function quicklookup(element) { + window.location='<@ofbizUrl>LookupBulkAddSupplierProductsInApprovedOrder</@ofbizUrl>?orderId='+element.value; + } +</script> + <#if orderHeader?has_content> <div class="screenlet"> <div class="screenlet-title-bar"> @@ -26,7 +32,8 @@ <br class="clear"/> </div> <div class="screenlet-body"> - <form method="post" action="<@ofbizUrl>appendItemToOrder?${paramString}</@ofbizUrl>" name="appendItemForm"> + <form method="post" action="<@ofbizUrl>appendItemToOrder</@ofbizUrl>" name="appendItemForm"> + <input type="hidden" size="25" name="orderId" value="${orderId?if_exists}"/> <#if catalogCol?size == 1> <input type="hidden" name="prodCatalogId" value="${catalogCol.first}"/> </#if> @@ -49,6 +56,9 @@ <tr> <td class="label">${uiLabelMap.ProductProductId}</td> <td><input type="text" size="25" name="productId" value="${requestParameters.productId?if_exists}"/> + <#if "PURCHASE_ORDER" == orderHeader.orderTypeId> + <a href="javascript:quicklookup(document.appendItemForm.orderId)" class="buttontext">${uiLabelMap.OrderQuickLookup}</a> + </#if> <a href="javascript:call_fieldlookup2(document.appendItemForm.productId,'LookupProduct');"> <img src="<@ofbizContentUrl>/images/fieldlookup.gif</@ofbizContentUrl>" width="15" height="14" border="0" alt="Click here For Field Lookup"/> </a> Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml?rev=755627&r1=755626&r2=755627&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml Wed Mar 18 16:10:44 2009 @@ -279,4 +279,30 @@ </widgets> </section> </screen> + <screen name="LookupBulkAddSupplierProductsInApprovedOrder"> + <section> + <actions> + <set field="titleProperty" value="PageTitleLookupBulkAddSupplierProduct"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/cart/LookupBulkAddSupplierProducts.groovy"/> + </actions> + <widgets> + <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}"> + <decorator-section name="body"> + <section> + <widgets> + <container style="screenlet"> + <platform-specific> + <html><html-template location="component://order/webapp/ordermgr/entry/OrderEntryCatalogTabBar.ftl"/></html> + </platform-specific> + <container style="screenlet-body"> + <include-form location="component://order/webapp/ordermgr/order/OrderForms.xml" name="LookupBulkAddSupplierProductsInApprovedOrder"></include-form> + </container> + </container> + </widgets> + </section> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> </screens> |
Free forum by Nabble | Edit this page |