You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/11/22 10:28:56 UTC

svn commit: r1544446 - in /ofbiz/branches/release13.07: ./ applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java applications/order/webapp/ordermgr/entry/shipsettings.ftl

Author: jleroux
Date: Fri Nov 22 09:28:55 2013
New Revision: 1544446

URL: http://svn.apache.org/r1544446
Log:
"Applied fix from trunk for revision: 1544444  " 
------------------------------------------------------------------------
r1544444 | jleroux | 2013-11-22 10:27:34 +0100 (ven. 22 nov. 2013) | 19 lignes

A slightly modified patch from Christian Carlow for "Incorrect selected ship destination displayed on purchase order entry form" https://issues.apache.org/jira/browse/OFBIZ-5397

Selected ship group destinations are displayed incorrectly on the purchase order entry Shipping page.  The first ship group destination is selected without checking if any of the other destinations were selected.  Part of the problem is that the facilityId of the destination chosen is not specified in the parameters passed to CheckOutEvents finalizeOrderEntry function.

To reproduce:
1.  Create an order to DemoSupplier
2.  Add any supplier product to the order and click Finalize Order
3.  Click Continue until you reach the Shipping page
4.  Choose the second shipping destination and click Continue
5.  Click the Shipping link to go back to the previous shipping page
6.  Notice that the second destination is not selected

The second destination is actually assigned because it appears on the confirmation page but no code exists to check the correct radio option.  The facilityId will have to be passed in somehow to allow such logic to be correctly implemented.

Using the @ symbol probably isn't the best one to use for separating fields. I wanted to provide the facility destination contactMechIds in a drop down list rather than as a list of radio options and when the @ symbol is used, it is encoded as @ which prevents matching of the key. This means that I don't get an accurate description in the drop down list of the selected record. Replacing the @ symbol with something else such as _ fixes the issue but might cause problems if some facilities or contactMechIds contain an _.

jleroux:I simply used the token _@_ as separator to prevent wrong splits in case @ or _ would have been used in facilities or contactMechIds (though it's not possible OOTB from UI, those Ids are generated)
This solution works well with radio buttons. There are a lof of information to show in each ship group address and I believe in such case it's easier to read as it's currently done (multiple lines for each address) than using a drop-down.

------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
    ofbiz/branches/release13.07/applications/order/webapp/ordermgr/entry/shipsettings.ftl

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1544444

Modified: ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1544446&r1=1544445&r2=1544446&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original)
+++ ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Fri Nov 22 09:28:55 2013
@@ -795,11 +795,17 @@ public class CheckOutEvents {
                 // set the shipping method
                 if (mode.equals("ship")) {
                     shippingContactMechId = request.getParameter(shipGroupIndex + "_shipping_contact_mech_id");
+                    String facilityId = request.getParameter(shipGroupIndex + "_shipGroupFacilityId");
                     if (shippingContactMechId == null) {
                         shippingContactMechId = (String) request.getAttribute("contactMechId"); // FIXME
+                    } else if(cart.getOrderType().equals("PURCHASE_ORDER")){
+                        String[] shipInfo = shippingContactMechId.split("_@_");
+                        if(shipInfo.length > 1){
+                            shippingContactMechId = shipInfo[0];
+                            facilityId = shipInfo[1];   
+                        }
                     }
                     String supplierPartyId = request.getParameter(shipGroupIndex + "_supplierPartyId");
-                    String facilityId = request.getParameter(shipGroupIndex + "_shipGroupFacilityId");
                     if (UtilValidate.isNotEmpty(facilityId)) {
                         cart.setShipGroupFacilityId(shipGroupIndex, facilityId);
                     }

Modified: ofbiz/branches/release13.07/applications/order/webapp/ordermgr/entry/shipsettings.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/order/webapp/ordermgr/entry/shipsettings.ftl?rev=1544446&r1=1544445&r2=1544446&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/order/webapp/ordermgr/entry/shipsettings.ftl (original)
+++ ofbiz/branches/release13.07/applications/order/webapp/ordermgr/entry/shipsettings.ftl Fri Nov 22 09:28:55 2013
@@ -43,6 +43,7 @@ under the License.
                   </td>
                 </tr>
                 <#assign i = 0>
+                <#assign shipGroup = cart.getShipInfo(shipGroupIndex)>
                 <#list facilityMaps as facilityMap>
                 <#assign facility = facilityMap.facility>
                 <#assign facilityContactMechList = facilityMap.facilityContactMechList>
@@ -61,7 +62,13 @@ under the License.
                   <#assign shippingAddress = shippingContactMech.postalAddress>
                   <tr>
                     <td valign="top" nowrap="nowrap">
-                      <input type="radio" name="${shipGroupIndex?default("0")}_shipping_contact_mech_id" value="${shippingAddress.contactMechId}" <#if i == 0>checked</#if> />
+                      <#assign checked='' />
+                      <#if shipGroup?has_content && (shipGroup.getFacilityId()?has_content && shipGroup.getFacilityId() == facility.facilityId) && (shipGroup.getContactMechId()?has_content && shipGroup.getContactMechId() == shippingAddress.contactMechId) >
+                          <#assign checked='checked' />
+                      <#elseif i == 0>
+                          <#assign checked='checked' />
+                      </#if>
+                      <input type="radio" name="${shipGroupIndex?default("0")}_shipping_contact_mech_id" value="${shippingAddress.contactMechId}_@_${facility.facilityId}" ${checked} />
                     </td>
                     <td nowrap="nowrap">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                     <td valign="top" width="100%" nowrap="nowrap">