diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java index 5f6ff4de4b..984c88d024 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -627,6 +627,7 @@ public class CheckOutEvents { Map paramMap = UtilHttp.getParameterMap(request); Boolean offlinePayments; + String shipGroupIndexPar = null; String shippingContactMechId = null; String shippingMethod = null; String shippingInstructions = null; @@ -709,6 +710,16 @@ public class CheckOutEvents { isAnonymousCheckout = true; } + shipGroupIndexPar = request.getParameter("shipGroupIndex"); + int shipGroupIndex = 0; + if (shipGroupIndexPar != null) { + try { + shipGroupIndex = Integer.parseInt(shipGroupIndexPar); + } catch(Exception exc) { + Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage(), module); + } + } + // get the shipping method shippingContactMechId = request.getParameter("shipping_contact_mech_id"); if (shippingContactMechId == null) { @@ -777,7 +788,7 @@ public class CheckOutEvents { checkOutHelper.setCheckOutPayment(selectedPaymentMethods, null, billingAccountId, billingAccountAmt); } - Map callResult = checkOutHelper.finalizeOrderEntry(mode, shippingContactMechId, shippingMethod, shippingInstructions, + Map callResult = checkOutHelper.finalizeOrderEntry(mode, shipGroupIndex, shippingContactMechId, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, methodType, checkOutPaymentId, isSingleUsePayment, doAppendPayment, paramMap, internalCode, shipBeforeDate, shipAfterDate); @@ -818,9 +829,9 @@ public class CheckOutEvents { requireAdditionalParty = requireAdditionalPartyStr == null || requireAdditionalPartyStr.equalsIgnoreCase("true"); } - String shipContactMechId = cart.getShippingContactMechId(); String customerPartyId = cart.getPartyId(); - String shipmentMethodTypeId = cart.getShipmentMethodTypeId(); + String shipContactMechId = cart.getShippingContactMechId(shipGroupIndex); + String shipmentMethodTypeId = cart.getShipmentMethodTypeId(shipGroupIndex); List paymentMethodIds = cart.getPaymentMethodIds(); List paymentMethodTypeIds = cart.getPaymentMethodTypeIds(); diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java index 464d0b55cc..9d1da18bc3 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -1231,18 +1231,19 @@ public class CheckOutHelper { } /** - * Sets the shipping contact mechanism on the cart + * Sets the shipping contact mechanism for a given ship group on the cart * + * @param shipGroupIndex The index of the ship group in the cart * @param shippingContactMechId The identifier of the contact * @return A Map conforming to the OFBiz Service conventions containing * any error messages */ - public Map finalizeOrderEntryShip(String shippingContactMechId) { + public Map finalizeOrderEntryShip(int shipGroupIndex, String shippingContactMechId) { Map result; String errMsg=null; //Verify the field is valid if (UtilValidate.isNotEmpty(shippingContactMechId)) { - this.cart.setShippingContactMechId(shippingContactMechId); + this.cart.setShippingContactMechId(shipGroupIndex, shippingContactMechId); result = ServiceUtil.returnSuccess(); } else { errMsg = UtilProperties.getMessage(resource,"checkhelper.enter_shipping_address", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -1253,8 +1254,9 @@ public class CheckOutHelper { } /** - * Sets the options associated with the order + * Sets the options associated with the order for a given ship group * + * @param shipGroupIndex The index of the ship group in the cart * @param shippingMethod The shipping method indicating the carrier and * shipment type to use * @param shippingInstructions Any additional handling instructions @@ -1265,7 +1267,7 @@ public class CheckOutHelper { * @return A Map conforming to the OFBiz Service conventions containing * any error messages */ - public Map finalizeOrderEntryOptions(String shippingMethod, String shippingInstructions, String maySplit, + public Map finalizeOrderEntryOptions(int shipGroupIndex, String shippingMethod, String shippingInstructions, String maySplit, String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate) { Map result; @@ -1281,19 +1283,19 @@ public class CheckOutHelper { carrierPartyId = shippingMethod.substring(delimiterPos + 1); } - this.cart.setShipmentMethodTypeId(shipmentMethodTypeId); - this.cart.setCarrierPartyId(carrierPartyId); + this.cart.setShipmentMethodTypeId(shipGroupIndex, shipmentMethodTypeId); + this.cart.setCarrierPartyId(shipGroupIndex, carrierPartyId); } else { errMsg = UtilProperties.getMessage(resource,"checkhelper.select_shipping_method", (cart != null ? cart.getLocale() : Locale.getDefault())); result = ServiceUtil.returnError(errMsg); } //Set the remaining order options - this.cart.setShippingInstructions(shippingInstructions); - this.cart.setGiftMessage(giftMessage); - this.cart.setMaySplit(Boolean.valueOf(maySplit)); - this.cart.setIsGift(Boolean.valueOf(isGift)); - this.cart.setInternalCode(internalCode); + this.cart.setShippingInstructions(shipGroupIndex, shippingInstructions); + this.cart.setGiftMessage(shipGroupIndex, giftMessage); + this.cart.setMaySplit(shipGroupIndex, Boolean.valueOf(maySplit)); + this.cart.setIsGift(shipGroupIndex, Boolean.valueOf(isGift)); + this.cart.setInternalCode(internalCode); // FIXME: the internalCode is not a ship group field and should be moved outside of this method // set ship before date if ((shipBeforeDate != null) && (shipBeforeDate.length() > 8)) { @@ -1303,7 +1305,7 @@ public class CheckOutHelper { } try { - this.cart.setShipBeforeDate((Timestamp) ObjectType.simpleTypeConvert(shipBeforeDate, "Timestamp", null, null)); + this.cart.setShipBeforeDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeConvert(shipBeforeDate, "Timestamp", null, null)); } catch (Exception e) { errMsg = "Ship Before Date must be a valid date formed "; result = ServiceUtil.returnError(errMsg); @@ -1318,7 +1320,7 @@ public class CheckOutHelper { } try { - this.cart.setShipAfterDate((Timestamp) ObjectType.simpleTypeConvert(shipAfterDate,"Timestamp", null, null)); + this.cart.setShipAfterDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeConvert(shipAfterDate,"Timestamp", null, null)); } catch (Exception e) { errMsg = "Ship After Date must be a valid date formed "; result = ServiceUtil.returnError(errMsg); @@ -1362,7 +1364,7 @@ public class CheckOutHelper { * @see CheckOutHelper#finalizeOrderEntryPayment(String, Double, boolean, boolean) * @see CheckOutHelper#finalizeOrderEntryShip(String) */ - public Map finalizeOrderEntry(String finalizeMode, String shippingContactMechId, String shippingMethod, + public Map finalizeOrderEntry(String finalizeMode, int shipGroupIndex, String shippingContactMechId, String shippingMethod, String shippingInstructions, String maySplit, String giftMessage, String isGift, String methodType, String checkOutPaymentId, boolean isSingleUsePayment, boolean appendPayment, Map params, String internalCode, String shipBeforeDate, String shipAfterDate) { @@ -1374,13 +1376,13 @@ public class CheckOutHelper { // set the shipping method if (finalizeMode != null && finalizeMode.equals("ship")) { - callResult = this.finalizeOrderEntryShip(shippingContactMechId); + callResult = this.finalizeOrderEntryShip(shipGroupIndex, shippingContactMechId); this.addErrors(errorMessages, errorMaps, callResult); } // set the options if (finalizeMode != null && finalizeMode.equals("options")) { - callResult = this.finalizeOrderEntryOptions(shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate); + callResult = this.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate); this.addErrors(errorMessages, errorMaps, callResult); } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java index 94df439b63..b524abc943 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java @@ -1758,6 +1758,11 @@ public class ShoppingCart implements Serializable { // Ship Group Methods // ---------------------------------------- + public int addShipInfo() { + shipInfo.add(new CartShipInfo()); + return (shipInfo.size() - 1); + } + public List getShipGroups() { return this.shipInfo; } diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh index 2813c141fd..d920a60151 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh +++ b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh @@ -27,6 +27,22 @@ cart = session.getAttribute("shoppingCart"); context.put("cart", cart); productStoreId = ProductStoreWorker.getProductStoreId(request); +String shipGroupIndexPar = request.getParameter("shipGroupIndex"); +String createNewShipGroup = request.getParameter("createNewShipGroup"); +int shipGroupIndex = 0; +if (createNewShipGroup != null && createNewShipGroup.equals("Y")) { + shipGroupIndex = cart.addShipInfo(); +} else { + if (shipGroupIndexPar != null) { + try { + shipGroupIndex = Integer.parseInt(shipGroupIndexPar); + } catch(Exception exc) { + Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage()); + } + } +} +context.put("shipGroupIndex", shipGroupIndex); + // nuke the event messages request.removeAttribute("_EVENT_MESSAGE_"); @@ -40,8 +56,8 @@ if (orderPartyIdId != null) { context.put("carrierShipmentMethodList", delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber"))); context.put("emailList", ContactHelper.getContactMechByType(orderPartyId, "EMAIL_ADDRESS", false)); -if (cart.getShipmentMethodTypeId() != null && cart.getCarrierPartyId() != null) { - context.put("chosenShippingMethod", cart.getShipmentMethodTypeId() + '@' + cart.getCarrierPartyId()); +if (cart.getShipmentMethodTypeId(shipGroupIndex) != null && cart.getCarrierPartyId(shipGroupIndex) != null) { + context.put("chosenShippingMethod", cart.getShipmentMethodTypeId(shipGroupIndex) + '@' + cart.getCarrierPartyId(shipGroupIndex)); } // create the beforeDate for calendar diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh index 5392eb6537..d46e3f6c02 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh +++ b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh @@ -26,6 +26,23 @@ import javolution.util.FastList; delegator = request.getAttribute("delegator"); cart = session.getAttribute("shoppingCart"); + +String shipGroupIndexPar = request.getParameter("shipGroupIndex"); +String createNewShipGroup = request.getParameter("createNewShipGroup"); +int shipGroupIndex = 0; +if (createNewShipGroup != null && createNewShipGroup.equals("Y")) { + shipGroupIndex = cart.addShipInfo(); +} else { + if (shipGroupIndexPar != null) { + try { + shipGroupIndex = Integer.parseInt(shipGroupIndexPar); + } catch(Exception exc) { + Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage()); + } + } +} +context.put("shipGroupIndex", shipGroupIndex); + orderPartyId = cart.getPartyId(); context.put("cart", cart); @@ -42,6 +59,8 @@ if ("SALES_ORDER".equals(cart.getOrderType())) { context.put("orderPerson", orderPerson); context.put("shippingContactMechList", shippingContactMechList); } + String currShipContactMechId = cart.getShippingContactMechId(shipGroupIndex); + context.put("currShipContactMechId", currShipContactMechId); } } else { // Purchase order diff --git a/applications/order/webapp/ordermgr/entry/billsettings.ftl b/applications/order/webapp/ordermgr/entry/billsettings.ftl index eff7c9cd07..455b3c94ae 100644 --- a/applications/order/webapp/ordermgr/entry/billsettings.ftl +++ b/applications/order/webapp/ordermgr/entry/billsettings.ftl @@ -49,7 +49,8 @@ function makeExpDate() { - diff --git a/applications/order/webapp/ordermgr/entry/optionsettings.ftl b/applications/order/webapp/ordermgr/entry/optionsettings.ftl index b7ead06d85..47193caa3d 100644 --- a/applications/order/webapp/ordermgr/entry/optionsettings.ftl +++ b/applications/order/webapp/ordermgr/entry/optionsettings.ftl @@ -19,11 +19,13 @@ under the License.
+ + Create New Ship Group ${uiLabelMap.CommonCreateNew}
+
- + + <#if cart.getOrderType() != "PURCHASE_ORDER"> <#assign shipEstimateWrapper = Static["org.ofbiz.order.shoppingcart.shipping.ShippingEstimateWrapper"].getWrapper(dispatcher, cart, 0)> @@ -37,7 +39,7 @@ under the License. <#if cart.getOrderType() != "PURCHASE_ORDER"> @@ -115,8 +117,8 @@ under the License. <#else>
${uiLabelMap.OrderIsThisGift} - checked name='is_gift' value='true'>${uiLabelMap.CommonYes} - checked name='is_gift' value='false'>${uiLabelMap.CommonNo} + checked name='is_gift' value='true'>${uiLabelMap.CommonYes} + checked name='is_gift' value='false'>${uiLabelMap.CommonNo}
@@ -130,7 +132,7 @@ under the License. diff --git a/applications/order/webapp/ordermgr/entry/shipGroupTabBar.ftl b/applications/order/webapp/ordermgr/entry/shipGroupTabBar.ftl new file mode 100644 index 0000000000..d4669a7444 --- /dev/null +++ b/applications/order/webapp/ordermgr/entry/shipGroupTabBar.ftl @@ -0,0 +1,32 @@ +<#-- + +Copyright 2001-2006 The Apache Software Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +--> + +<#if shipGroupIndex?exists> + +<#assign targetUri = targetShipGroupUri?default("setShipping")> +
+<#list 1..cart.getShipGroupSize() as currIndex> + <#assign currShipGroupIndex = currIndex - 1> + <#if shipGroupIndex == currShipGroupIndex> + <#assign classStyle = "tabButtonSelected"> + <#else> + <#assign classStyle = "tabButton"> + + Ship Group #${currIndex} + +
+ diff --git a/applications/order/webapp/ordermgr/entry/shipsettings.ftl b/applications/order/webapp/ordermgr/entry/shipsettings.ftl index ee5f0058c6..fb7d8b686c 100644 --- a/applications/order/webapp/ordermgr/entry/shipsettings.ftl +++ b/applications/order/webapp/ordermgr/entry/shipsettings.ftl @@ -105,15 +105,29 @@ under the License. - - + + + <#assign i = 0> <#list shippingContactMechList as shippingContactMech> <#assign shippingAddress = shippingContactMech.getRelatedOne("PostalAddress")> + <#if currShipContactMechId?exists> + <#if currShipContactMechId == shippingContactMech.contactMechId> + <#assign checkedValue = "checked"> + <#else> + <#assign checkedValue = ""> + + <#else> + <#if i == 0> + <#assign checkedValue = "checked"> + <#else> + <#assign checkedValue = ""> + +
<#if carrierShipmentMethod.partyId != "_NA_">${carrierShipmentMethod.partyId?if_exists} ${carrierShipmentMethod.description?if_exists} - <#if cart.getShippingContactMechId()?exists> + <#if cart.getShippingContactMechId(shipGroupIndex)?exists> <#assign shippingEst = shipEstimateWrapper.getShippingEstimate(carrierShipmentMethod)?default(-1)> <#if shippingEst?has_content>  -  @@ -73,7 +75,7 @@ under the License.
- checked name='may_split' value='false'> + checked name='may_split' value='false'>
${uiLabelMap.FacilityWaitEntireOrderReady}
@@ -81,7 +83,7 @@ under the License.
- checked type='radio' name='may_split' value='true'> + checked type='radio' name='may_split' value='true'>
${uiLabelMap.FacilityShipAvailable}
@@ -95,7 +97,7 @@ under the License.
- +
- +

- checked> +
diff --git a/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml b/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml index 6337d65f5c..39a1f8bb87 100644 --- a/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml +++ b/applications/order/widget/ordermgr/OrderEntryOrderScreens.xml @@ -87,10 +87,14 @@ under the License.