From f552aca3ea458bc1a7ec2871afe68ee97d544a42 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Fri, 22 Nov 2013 09:27:34 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1544444 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/ofbiz/order/shoppingcart/CheckOutEvents.java | 8 +++++++- .../order/webapp/ordermgr/entry/shipsettings.ftl | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java index d56a5be03a..e8370c5b9b 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -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); } diff --git a/applications/order/webapp/ordermgr/entry/shipsettings.ftl b/applications/order/webapp/ordermgr/entry/shipsettings.ftl index ead49a8e56..cf07304f63 100644 --- a/applications/order/webapp/ordermgr/entry/shipsettings.ftl +++ b/applications/order/webapp/ordermgr/entry/shipsettings.ftl @@ -43,6 +43,7 @@ under the License. <#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> - checked /> + <#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' /> + +