First pass in the implementation of the user interface to create, in the order entry checkout process, more than one ship group.

It is now possible to create ship groups and set different addresses and options for them but it is still not possible to assign the products in the cart to them.
I'm going to start the implementation of a new checkout screen that will allow this.


git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@432836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2006-08-19 13:55:15 +00:00
parent 68f5f7926e
commit 2bc7c3ca80
10 changed files with 144 additions and 34 deletions
@@ -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();
@@ -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);
}
@@ -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;
}
@@ -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
@@ -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
@@ -49,7 +49,8 @@ function makeExpDate() {
<input type="hidden" name="finalizeMode" value="payment"/>
<table width="100%" cellpadding="1" cellspacing="0" border="0">
<tr>
<td colspan="2">
<td colspan="2">
<a href="<@ofbizUrl>setShipping?createNewShipGroup=Y</@ofbizUrl>" class="buttontext">Create New Ship Group</a>
<a href="<@ofbizUrl>setBilling?createNew=Y</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonCreateNew}</a>
</td>
</tr>
@@ -19,11 +19,13 @@ under the License.
<table border="0" width='100%' cellspacing='0' cellpadding='0' class='boxoutside'>
<tr>
<td width='100%'>
<br/>
<table width='100%' border='0' cellspacing='0' cellpadding='0' class='boxbottom'>
<tr>
<td>
<form method="post" action="<@ofbizUrl>finalizeOrder</@ofbizUrl>" name="checkoutsetupform">
<input type="hidden" name="finalizeMode" value="options">
<input type="hidden" name="finalizeMode" value="options"/>
<input type="hidden" name="shipGroupIndex" value="${shipGroupIndex?if_exists}"/>
<table width="100%" cellpadding="1" border="0" cellpadding="0" cellspacing="0">
<#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.
<td valign="top">
<div class='tabletext'>
<#if carrierShipmentMethod.partyId != "_NA_">${carrierShipmentMethod.partyId?if_exists}&nbsp;</#if>${carrierShipmentMethod.description?if_exists}
<#if cart.getShippingContactMechId()?exists>
<#if cart.getShippingContactMechId(shipGroupIndex)?exists>
<#assign shippingEst = shipEstimateWrapper.getShippingEstimate(carrierShipmentMethod)?default(-1)>
<#if shippingEst?has_content>
&nbsp;-&nbsp;
@@ -73,7 +75,7 @@ under the License.
</tr>
<tr>
<td valign="top">
<input type='radio' <#if cart.getMaySplit()?default("N") == "N">checked</#if> name='may_split' value='false'>
<input type='radio' <#if cart.getMaySplit(shipGroupIndex)?default("N") == "N">checked</#if> name='may_split' value='false'>
</td>
<td valign="top">
<div class="tabletext">${uiLabelMap.FacilityWaitEntireOrderReady}</div>
@@ -81,7 +83,7 @@ under the License.
</tr>
<tr>
<td valign="top">
<input <#if cart.getMaySplit()?default("N") == "Y">checked</#if> type='radio' name='may_split' value='true'>
<input <#if cart.getMaySplit(shipGroupIndex)?default("N") == "Y">checked</#if> type='radio' name='may_split' value='true'>
</td>
<td valign="top">
<div class="tabletext">${uiLabelMap.FacilityShipAvailable}</div>
@@ -95,7 +97,7 @@ under the License.
</tr>
<tr>
<td colspan="2">
<textarea class='textAreaBox' cols="30" rows="3" name="shipping_instructions">${cart.getShippingInstructions()?if_exists}</textarea>
<textarea class='textAreaBox' cols="30" rows="3" name="shipping_instructions">${cart.getShippingInstructions(shipGroupIndex)?if_exists}</textarea>
</td>
</tr>
<#if cart.getOrderType() != "PURCHASE_ORDER">
@@ -115,8 +117,8 @@ under the License.
<#else>
<div>
<span class="head2"><b>${uiLabelMap.OrderIsThisGift}</b></span>
<input type='radio' <#if cart.getIsGift()?default("Y") == "Y">checked</#if> name='is_gift' value='true'><span class='tabletext'>${uiLabelMap.CommonYes}</span>
<input type='radio' <#if cart.getIsGift()?default("N") == "N">checked</#if> name='is_gift' value='false'><span class='tabletext'>${uiLabelMap.CommonNo}</span>
<input type='radio' <#if cart.getIsGift(shipGroupIndex)?default("Y") == "Y">checked</#if> name='is_gift' value='true'><span class='tabletext'>${uiLabelMap.CommonYes}</span>
<input type='radio' <#if cart.getIsGift(shipGroupIndex)?default("N") == "N">checked</#if> name='is_gift' value='false'><span class='tabletext'>${uiLabelMap.CommonNo}</span>
</div>
</#if>
</td>
@@ -130,7 +132,7 @@ under the License.
</tr>
<tr>
<td colspan="2">
<textarea class='textAreaBox' cols="30" rows="3" name="gift_message">${cart.getGiftMessage()?if_exists}</textarea>
<textarea class='textAreaBox' cols="30" rows="3" name="gift_message">${cart.getGiftMessage(shipGroupIndex)?if_exists}</textarea>
</td>
</tr>
</#if>
@@ -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")>
<div class="tabContainer">
<#list 1..cart.getShipGroupSize() as currIndex>
<#assign currShipGroupIndex = currIndex - 1>
<#if shipGroupIndex == currShipGroupIndex>
<#assign classStyle = "tabButtonSelected">
<#else>
<#assign classStyle = "tabButton">
</#if>
<a href="<@ofbizUrl>${targetUri}?shipGroupIndex=${currShipGroupIndex}</@ofbizUrl>" class="${classStyle}">Ship Group #${currIndex}</a>
</#list>
</div>
</#if>
@@ -105,15 +105,29 @@ under the License.
</td>
</tr>
<form method="post" action="<@ofbizUrl>finalizeOrder</@ofbizUrl>" name="checkoutsetupform">
<input type="hidden" name="finalizeMode" value="ship">
<input type="hidden" name="finalizeMode" value="ship"/>
<input type="hidden" name="shipGroupIndex" value="${shipGroupIndex?if_exists}"/>
<tr><td colspan="3"><hr class='sepbar'></td></tr>
<#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 = "">
</#if>
<#else>
<#if i == 0>
<#assign checkedValue = "checked">
<#else>
<#assign checkedValue = "">
</#if>
</#if>
<tr>
<td align="left" valign="top" width="1%" nowrap>
<input type="radio" name="shipping_contact_mech_id" value="${shippingAddress.contactMechId}" <#if i == 0>checked</#if>>
<input type="radio" name="shipping_contact_mech_id" value="${shippingAddress.contactMechId}" ${checkedValue}>
</td>
<td align="left" valign="top" width="99%" nowrap>
<div class="tabletext">
@@ -87,10 +87,14 @@ under the License.
<set field="stepTitleId" value="OrderOrderEntryShipToSettings"/>
<set field="stepLabelId" value="FacilityShipping"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh"/>
<set field="targetShipGroupUri" value="setShipping"/>
</actions>
<widgets>
<decorator-screen name="CommonOrderCheckoutDecorator">
<decorator-section name="body">
<platform-specific>
<html><html-template location="component://order/webapp/ordermgr/entry/shipGroupTabBar.ftl"/></html>
</platform-specific>
<platform-specific>
<html><html-template location="component://order/webapp/ordermgr/entry/shipsettings.ftl"/></html>
</platform-specific>
@@ -130,10 +134,14 @@ under the License.
<set field="stepTitleId" value="OrderOrderOptionSettings"/>
<set field="stepLabelId" value="CommonOptions"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh"/>
<set field="targetShipGroupUri" value="setOptions"/>
</actions>
<widgets>
<decorator-screen name="CommonOrderCheckoutDecorator">
<decorator-section name="body">
<platform-specific>
<html><html-template location="component://order/webapp/ordermgr/entry/shipGroupTabBar.ftl"/></html>
</platform-specific>
<platform-specific>
<html><html-template location="component://order/webapp/ordermgr/entry/optionsettings.ftl"/></html>
</platform-specific>