Author: bibryam
Date: Sun Nov 9 02:28:23 2008 New Revision: 712478 URL: http://svn.apache.org/viewvc?rev=712478&view=rev Log: Fixed various bugs related to product amounts. Allow product amount modification during cart update. This commit contains new labels. Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java ofbiz/trunk/framework/images/webapp/images/maincss.css Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.xml?rev=712478&r1=712477&r2=712478&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderUiLabels.xml Sun Nov 9 02:28:23 2008 @@ -9500,6 +9500,9 @@ <value xml:lang="fr">Configurer l'article avant de l'ajouter au panier</value> <value xml:lang="th">สรà¹à¸²à¸à¸ªà¸´à¸à¸à¹à¸²à¸à¹à¸à¸à¸à¸µà¹à¸à¸°à¹à¸à¸´à¹à¸¡à¸¥à¸à¸à¸£à¸°à¸à¸£à¹à¸²</value> </property> + <property key="cart.addToCart.enterAmountBeforeAddingToCart"> + <value xml:lang="en">Enter Amount Before Adding to Cart</value> + </property> <property key="cart.addToCart.enterBookingInforamtionBeforeAddingToCart"> <value xml:lang="de">Reservationsinformationen erfassen vor dem Hinzufügen zum Warenkorb</value> <value xml:lang="en">Enter Booking Information Before Adding to Cart</value> @@ -9563,6 +9566,9 @@ <value xml:lang="zh_CN">没ææå®çå议被å å ¥</value> <value xml:lang="zh">没ææå®è¦æ·»å è¿æ¥çååã</value> </property> + <property key="cart.amount_not_positive_number"> + <value xml:lang="en">Amount must be a positive number</value> + </property> <property key="cart.category_not_specified_to_add_from"> <value xml:lang="de">Keine Kategorie angegeben, aus der hinzugefügt werden kann.</value> <value xml:lang="en">No category specified to add from.</value> 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=712478&r1=712477&r2=712478&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 Sun Nov 9 02:28:23 2008 @@ -411,7 +411,14 @@ amount = null; } } - + + // check for required amount + if ((ProductWorker.isAmountRequired(delegator, productId)) && (amount == null || amount.doubleValue() == 0.0)) { + request.setAttribute("product_id", productId); + request.setAttribute("_EVENT_MESSAGE_",UtilProperties.getMessage(resource,"cart.addToCart.enterAmountBeforeAddingToCart",locale)); + return "product"; + } + // get the ship before date (handles both yyyy-mm-dd input and full timestamp) shipBeforeDateStr = (String) paramMap.remove("shipBeforeDate"); if (shipBeforeDateStr != null && shipBeforeDateStr.length() > 0) { Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=712478&r1=712477&r2=712478&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Sun Nov 9 02:28:23 2008 @@ -137,7 +137,9 @@ // amount sanity check if (amount != null && amount.doubleValue() < 0) { - amount = null; + String errMsg = UtilProperties.getMessage(resource, "cart.amount_not_positive_number", this.cart.getLocale()); + result = ServiceUtil.returnError(errMsg); + return result; } // check desiredDeliveryDate syntax and remove if empty @@ -708,14 +710,28 @@ quantString += " 00:00:00.000"; item.setShipAfterDate(Timestamp.valueOf(quantString)); } + } else if (parameterName.startsWith("amount")) { + if (item != null && quantString.length() > 0) { + double amount = nf.parse(quantString).doubleValue(); + if (amount <= 0 ) { + String errMsg = UtilProperties.getMessage(resource, "cart.amount_not_positive_number", this.cart.getLocale()); + errorMsgs.add(errMsg); + result = ServiceUtil.returnError(errorMsgs); + return result; + } + item.setSelectedAmount(amount); + } } else if (parameterName.startsWith("itemType")) { if (item != null && quantString.length() > 0) { item.setItemType(quantString); - } + } } else { quantity = nf.parse(quantString).doubleValue(); if (quantity < 0) { - throw new CartItemModifyException("Quantity must be a positive number."); + String errMsg = UtilProperties.getMessage(resource, "cart.quantity_not_positive_number", this.cart.getLocale()); + errorMsgs.add(errMsg); + result = ServiceUtil.returnError(errorMsgs); + return result; } } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl?rev=712478&r1=712477&r2=712478&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl Sun Nov 9 02:28:23 2008 @@ -104,7 +104,7 @@ <#list cartLine.getAttribute("surveyResponses") as surveyResponseId> <a href="/content/control/ViewSurveyResponses?surveyResponseId=${surveyResponseId}&externalLoginKey=${externalLoginKey}" class="buttontext" style="font-size: xx-small;">${surveyResponseId}</a> </#list> - </#if> + </#if> </div> </td></tr> <#if cartLine.getRequirementId()?has_content> @@ -235,14 +235,22 @@ <#else> <input size="6" type="text" name="update_${cartLineIndex}" value="${cartLine.getQuantity()?string.number}"/> </#if> - </div> + <#if (cartLine.getSelectedAmount() > 0) > + <br/><b>${uiLabelMap.OrderAmount}:</b><br/><input size="6" type="text" name="amount_${cartLineIndex}" value="${cartLine.getSelectedAmount()?string.number}"/> + </#if> + </div> </td> <td nowrap align="right"> <div> <#if cartLine.getIsPromo() || (shoppingCart.getOrderType() == "SALES_ORDER" && !security.hasEntityPermission("ORDERMGR", "_SALES_PRICEMOD", session))> <@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=currencyUomId/> <#else> - <input size="6" type="text" name="price_${cartLineIndex}" value="${cartLine.getBasePrice()}"/> + <#if (cartLine.getSelectedAmount() > 0) > + <#assign price = cartLine.getBasePrice() / cartLine.getSelectedAmount()> + <#else> + <#assign price = cartLine.getBasePrice()> + </#if> + <input size="6" type="text" name="price_${cartLineIndex}" value="${price}"/> </#if> </div> </td> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=712478&r1=712477&r2=712478&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Sun Nov 9 02:28:23 2008 @@ -836,6 +836,19 @@ return false; } + + public static boolean isAmountRequired(GenericDelegator delegator, String productI) { + try { + GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productI)); + if (product != null) { + return "Y".equals(product.getString("requireAmount")); + } + } catch (GenericEntityException e) { + Debug.logWarning(e.getMessage(), module); + } + + return false; + } public static String getProductTypeId(GenericDelegator delegator, String productI) { try { Modified: ofbiz/trunk/framework/images/webapp/images/maincss.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/maincss.css?rev=712478&r1=712477&r2=712478&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/maincss.css (original) +++ ofbiz/trunk/framework/images/webapp/images/maincss.css Sun Nov 9 02:28:23 2008 @@ -813,7 +813,6 @@ } .hidden { -height: 0; visibility: hidden; } |
Free forum by Nabble | Edit this page |