svn commit: r608088 - in /ofbiz/trunk/applications: ecommerce/webapp/ecommerce/WEB-INF/ order/config/ order/src/org/ofbiz/order/shoppingcart/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ order/webapp/ordermgr/entr...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r608088 - in /ofbiz/trunk/applications: ecommerce/webapp/ecommerce/WEB-INF/ order/config/ order/src/org/ofbiz/order/shoppingcart/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ order/webapp/ordermgr/entr...

bibryam
Author: bibryam
Date: Wed Jan  2 03:40:22 2008
New Revision: 608088

URL: http://svn.apache.org/viewvc?rev=608088&view=rev
Log:
Commit my patch from (OFBIZ-1424) ShoppingCart.addToCart event for different kind of products

Modified:
    ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/config/OrderUiLabels.properties
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java

Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Wed Jan  2 03:40:22 2008
@@ -234,6 +234,7 @@
         <event type="java" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="addToCart"/>
         <response name="success" type="view" value="showcart"/>
         <response name="survey" type="view" value="survey"/>
+        <response name="product" type="view" value="product"/>
         <response name="viewcart" type="request-redirect" value="showcart"/>
         <response name="error" type="view" value="showcart"/>
     </request-map>

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?rev=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.properties Wed Jan  2 03:40:22 2008
@@ -919,6 +919,9 @@
 PageTitleReturnList=Return List
 PageTitleViewRequest=View Request
 calendar_click_here_for_calendar=Click here For Calendar
+cart.addToCart.chooseVariationBeforeAddingToCart=Choose Variation Before Adding to Cart
+cart.addToCart.configureProductBeforeAddingToCart=Configure Product Before Adding to Cart
+cart.addToCart.enterBookingInforamtionBeforeAddingToCart=Enter Booking Information Before Adding to Cart
 cart.addToCart.noProductInfoPassed=No product information passed, not adding anything to cart.
 cart.addToCart.productConfigurationIsNotValid=Configuration Is Not Valid
 cart.add_category_defaults=Added ${totalQuantity} items to the cart.

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=608088&r1=608087&r2=608088&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 Jan  2 03:40:22 2008
@@ -133,7 +133,6 @@
         Double reservLength = null;
         String reservPersonsStr = null;
         Double reservPersons = null;
-        String shipBeforeStr = null;
         String shipBeforeDateStr = null;
         String shipAfterDateStr = null;
         java.sql.Timestamp shipBeforeDate = null;
@@ -217,11 +216,19 @@
             ProductConfigWorker.fillProductConfigWrapper(configWrapper, request);
             if (!configWrapper.isCompleted()) {
                 // The configuration is not valid
-                request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.productConfigurationIsNotValid", locale));
-                return "error";
+                request.setAttribute("product_id", productId);
+                request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.configureProductBeforeAddingToCart", locale));
+                return "product";
             }
         }
-
+        
+        //Check for virtual products
+        if (ProductWorker.isVirtual(delegator, productId)) {
+            request.setAttribute("product_id", productId);
+            request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.chooseVariationBeforeAddingToCart", locale));
+            return "product";
+        }
+        
         // get the override price
         if (paramMap.containsKey("PRICE")) {
             priceStr = (String) paramMap.remove("PRICE");
@@ -233,22 +240,24 @@
         }
 
         // get the renting data
-        if (paramMap.containsKey("reservStart")) {
-            reservStartStr = (String) paramMap.remove("reservStart");
-            if (reservStartStr.length() == 10) // only date provided, no time string?
-                    reservStartStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
-            if (reservStartStr.length() >0) {
-                try {
-                    reservStart = java.sql.Timestamp.valueOf(reservStartStr);
-                } catch (Exception e) {
-                    Debug.logWarning(e,"Problems parsing Reservation start string: "
-                                + reservStartStr, module);
-                    reservStart = null;
-                    request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource,"cart.addToCart.rental.startDate", locale));
-                    return "error";
+        if ("ASSET_USAGE".equals(ProductWorker.getProductTypeId(delegator, productId))) {
+            if (paramMap.containsKey("reservStart")) {
+                reservStartStr = (String) paramMap.remove("reservStart");
+                if (reservStartStr.length() == 10) // only date provided, no time string?
+                        reservStartStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
+                if (reservStartStr.length() >0) {
+                    try {
+                        reservStart = java.sql.Timestamp.valueOf(reservStartStr);
+                    } catch (Exception e) {
+                        Debug.logWarning(e,"Problems parsing Reservation start string: "
+                                    + reservStartStr, module);
+                        reservStart = null;
+                        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource,"cart.addToCart.rental.startDate", locale));
+                        return "error";
+                    }
                 }
+                else reservStart = null;
             }
-            else reservStart = null;
 
             if (paramMap.containsKey("reservEnd")) {
                 reservEndStr = (String) paramMap.remove("reservEnd");
@@ -267,12 +276,10 @@
                 else reservEnd = null;
             }
 
-            if (reservStart != null && reservEnd != null) {
+            if (reservStart != null && reservEnd != null) {
              reservLength = new Double(UtilDateTime.getInterval(reservStart,reservEnd)/86400000);
             }
 
-
-
             if (reservStart != null && paramMap.containsKey("reservLength")) {
                 reservLengthStr = (String) paramMap.remove("reservLength");
                 // parse the reservation Length
@@ -299,6 +306,14 @@
                     return "error";
                 }
             }
+            
+            //check for valid rental parameters
+            if (UtilValidate.isEmpty(reservStart) && UtilValidate.isEmpty(reservLength) && UtilValidate.isEmpty(reservPersons)) {
+                request.setAttribute("product_id", productId);
+                request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.enterBookingInforamtionBeforeAddingToCart", locale));
+                return "product";
+            }
+            
         }
 
         // get the quantity

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh?rev=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh Wed Jan  2 03:40:22 2008
@@ -35,6 +35,7 @@
 
 detailScreen = "productdetail";
 productId = requestParams.get("product_id");
+if (UtilValidate.isEmpty(productId)) productId = request.getAttribute("product_id");
 
 /*
  * NOTE JLR 20070221 this should be done using the same method than in add to cart. I will do it like that and remove all this after.

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=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Wed Jan  2 03:40:22 2008
@@ -417,13 +417,14 @@
         <event type="java" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="addToCart"/>
         <response name="success" type="request" value="orderentry"/>
         <response name="survey" type="view" value="survey"/>
+        <response name="product" type="view" value="product"/>
         <response name="error" type="request" value="orderentry"/>
     </request-map>
     <request-map uri="additemsurvey">
         <security https="true" auth="true"/>
         <event type="service" invoke="createSurveyResponse"/>
         <response name="success" type="request" value="additem"/>
-        <response name="error" type="view" value="main"/>
+        <response name="error" type="view" value="orderentry"/>
     </request-map>
     <request-map uri="addRequirementsToCart">
         <security https="true" auth="true"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl?rev=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl Wed Jan  2 03:40:22 2008
@@ -328,8 +328,8 @@
       <#if sessionAttributes.userLogin?has_content && sessionAttributes.userLogin.userLoginId != "anonymous">
         <hr class="sepbar"/>
         <form name="addToShoppingList" method="post" action="<@ofbizUrl>addItemToShoppingList<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#if></@ofbizUrl>">
-          <input type="hidden" name="productId" value="${requestParameters.product_id}">
-          <input type="hidden" name="product_id" value="${requestParameters.product_id}">
+          <input type="hidden" name="productId" value="${product.productId}">
+          <input type="hidden" name="product_id" value="${product.productId}">
           <select name="shoppingListId" class="selectBox">
             <#if shoppingLists?has_content>
               <#list shoppingLists as shoppingList>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl?rev=608088&r1=608087&r2=608088&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/productdetail.ftl Wed Jan  2 03:40:22 2008
@@ -471,8 +471,8 @@
       <#if sessionAttributes.userLogin?has_content && sessionAttributes.userLogin.userLoginId != "anonymous">
         <hr class="sepbar"/>
         <form name="addToShoppingList" method="post" action="<@ofbizUrl>addItemToShoppingList<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#if></@ofbizUrl>">
-          <input type="hidden" name="productId" value="${requestParameters.product_id}"/>
-          <input type="hidden" name="product_id" value="${requestParameters.product_id}"/>
+          <input type="hidden" name="productId" value="${product.productId}"/>
+          <input type="hidden" name="product_id" value="${product.productId}"/>
           <input type="hidden" name="productStoreId" value="${productStoreId}"/>
           <input type="hidden" name="reservStart" value= ""/>
           <select name="shoppingListId" class="selectBox">

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=608088&r1=608087&r2=608088&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 Wed Jan  2 03:40:22 2008
@@ -704,6 +704,32 @@
         return isPhysical;
     }
 
+    public static boolean isVirtual(GenericDelegator delegator, String productI) {
+        try {
+            GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productI));
+            if (product != null) {
+                return "Y".equals(product.getString("isVirtual"));
+            }
+        } catch (GenericEntityException e) {
+            Debug.logWarning(e.getMessage(), module);
+        }
+
+        return false;
+    }
+
+    public static String getProductTypeId(GenericDelegator delegator, String productI) {
+        try {
+            GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productI));
+            if (product != null) {
+                return product.getString("productTypeId");
+            }
+        } catch (GenericEntityException e) {
+            Debug.logWarning(e.getMessage(), module);
+        }
+
+        return null;
+    }
+    
     public static String findProductId(GenericDelegator delegator, String idToFind, String goodIdentificationTypeId) throws GenericEntityException {
         // first lookup and see if this is the Product PK
         GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", idToFind));