Author: apatel
Date: Sat Jul 14 04:19:11 2007 New Revision: 556264 URL: http://svn.apache.org/viewvc?view=rev&rev=556264 Log: Improved Shipment notification email set up. Modified: ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties ofbiz/trunk/applications/ecommerce/templates/email/ShipmentNotificationEmail.ftl ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh ofbiz/trunk/applications/ecommerce/widget/EmailOrderScreens.xml ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml ofbiz/trunk/applications/product/servicedef/secas_shipment.xml ofbiz/trunk/applications/product/servicedef/services_shipment.xml ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Modified: ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties (original) +++ ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties Sat Jul 14 04:19:11 2007 @@ -268,7 +268,7 @@ PageTitleSearchResults=Search Results PageTitleSearchSites=Search Sites PageTitleSentMessages=Sent Messages -PageTitleOrderShipmentCompleteNotice=Shipment Complete Notice +PageTitleShipmentCompleteNotice=Shipment Complete Notice PageTitleShippingInformation=Shipping Information PageTitleShippingOptions=Shipping Options PageTitleShoppingCart=Shopping Cart @@ -454,4 +454,4 @@ ProductUsuallyShipsIn=Usually ships in ProductYouSearchedFor=you searched for RequestHistory=Request History -QuoteHistory=Quote History \ No newline at end of file +QuoteHistory=Quote History Modified: ofbiz/trunk/applications/ecommerce/templates/email/ShipmentNotificationEmail.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/templates/email/ShipmentNotificationEmail.ftl?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/ecommerce/templates/email/ShipmentNotificationEmail.ftl (original) +++ ofbiz/trunk/applications/ecommerce/templates/email/ShipmentNotificationEmail.ftl Sat Jul 14 04:19:11 2007 @@ -17,48 +17,31 @@ under the License. --> - -<table cellpadding="0" cellspacing="0" width="80%" border="0" class="boxoutside"> - <tr> - <td colspan="3" class="tableheadtext"> - This email is to inform you that your shipment has been completed. - </td> - </tr> - <tr><td colspan="3"> </td></tr> - <#if orderItemShipGroups?has_content> - <tr> - <td colspan="3"> - <h3>${uiLabelMap.OrderShippingInformation}</h3> - </td> - </tr> - <#assign groupIdx = 0> - <#list orderItemShipGroups as shipGroup> - <#-- tracking number --> - <#if trackingNumber?has_content || orderShipmentInfoSummaryList?has_content> - <tr> - <td align="right" valign="top" width="15%" nowrap> - <div class="tabletext"> <b>${uiLabelMap.OrderTrackingNumber}</b></div> - </td> - <td width="5"> </td> - <td align="left" valign="top" width="80%"> - <#-- TODO: add links to UPS/FEDEX/etc based on carrier partyId --> - <#if shipGroup.trackingNumber?has_content> - <div class="tabletext">${shipGroup.trackingNumber}</div> - </#if> - <#if orderShipmentInfoSummaryList?has_content> - <#list orderShipmentInfoSummaryList as orderShipmentInfoSummary> - <div class="tabletext"> - <#if (orderShipmentInfoSummaryList?size > 1)>${orderShipmentInfoSummary.shipmentPackageSeqId}: </#if> - Code: ${orderShipmentInfoSummary.trackingCode?default("[Not Yet Known]")} - <#if orderShipmentInfoSummary.boxNumber?has_content>${uiLabelMap.OrderBoxNubmer}${orderShipmentInfoSummary.boxNumber}</#if> - <#if orderShipmentInfoSummary.carrierPartyId?has_content>(${uiLabelMap.ProductCarrier}: ${orderShipmentInfoSummary.carrierPartyId})</#if> - </div> - </#list> - </#if> - </td> +<#if baseEcommerceSecureUrl?exists><#assign urlPrefix = baseEcommerceSecureUrl/></#if> +<div class="screenlet"> + <div class="screenlet-header"> + <div class="boxhead"> ${uiLabelMap.ShippedItems}</div> + </div> + <div class="screenlet-body"> + <table width="100%" border="0" cellpadding="0"> + <tr align="left" valign="bottom"> + <td width="35%" align="left"><span class="tableheadtext"><b>${uiLabelMap.EcommerceProduct}</b></span></td> + <td width="10%" align="right"><span class="tableheadtext"><b>${uiLabelMap.OrderQuantity}</b></span></td> </tr> - </#if> - <#assign groupIdx = groupIdx + 1> - </#list> - </#if> -</table> \ No newline at end of file + <tr><td colspan="10"><hr class="sepbar"/></td></tr> + <#list shipmentPackages as shipmentPackage> + <#assign shipmentPackageContents = shipmentPackage.getRelated("ShipmentPackageContent")> + <#list shipmentPackageContents as shipmentPackageContent> + <#assign shipmentItem = shipmentPackageContent.getRelatedOne("ShipmentItem")> + <#assign productId = shipmentItem.productId> + <#assign product = shipmentItem.getRelatedOne("Product")> + <tr> + <td colspan="1" valign="top"> ${productId?if_exists} - ${product.internalName?if_exists}</td> + <td align="right" valign="top"> ${shipmentItem.quantity?if_exists}</td> + </tr> + </#list> + <tr><td colspan="10"><hr class="sepbar"/></td></tr> + </#list> + </table> + </div> +</div> Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh Sat Jul 14 04:19:11 2007 @@ -17,28 +17,14 @@ * under the License. */ -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.util.*; -import org.ofbiz.order.order.OrderReadHelper; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.entity.GenericDelegator; +shipmentId = parameters.get("shipmentId"); +if (shipmentId != null) { + shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); + shipmentPackages = delegator.findByAnd("ShipmentPackage", UtilMisc.toMap("shipmentId", shipmentId)); -orderId = parameters.get("orderId"); - -if(orderId != null) { - orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); - orderReadHelper = new OrderReadHelper(orderHeader); - orderItemShipGroups = orderReadHelper.getOrderItemShipGroups(); - context.put("orderItemShipGroups", orderItemShipGroups); - - osisCond = new EntityFieldMap(UtilMisc.toMap("orderId", orderId), EntityOperator.AND); - osisOrder = UtilMisc.toList("shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId"); - osisFields = UtilMisc.toList("shipmentId", "shipmentRouteSegmentId", "carrierPartyId", "shipmentMethodTypeId"); - osisFields.add("shipmentPackageSeqId"); - osisFields.add("trackingCode"); - osisFields.add("boxNumber"); - osisFindOptions = new EntityFindOptions(); osisFindOptions.setDistinct(true); - orderShipmentInfoSummaryList = delegator.findByCondition("OrderShipmentInfoSummary", osisCond, null, osisFields, osisOrder, osisFindOptions); - context.put("orderShipmentInfoSummaryList",orderShipmentInfoSummaryList); + context.put("shipment", shipment); + context.put("shipmentPackages", shipmentPackages); } Modified: ofbiz/trunk/applications/ecommerce/widget/EmailOrderScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/widget/EmailOrderScreens.xml?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/ecommerce/widget/EmailOrderScreens.xml (original) +++ ofbiz/trunk/applications/ecommerce/widget/EmailOrderScreens.xml Sat Jul 14 04:19:11 2007 @@ -149,7 +149,7 @@ <screen name="ShipmentCompleteNotice"> <section> <actions> - <set field="title" value="${uiLabelMap.PageTitleOrderShipmentCompleteNotice}"/> + <set field="title" value="${uiLabelMap.PageTitleShipmentCompleteNotice}"/> <set field="baseEcommerceSecureUrl" value="${baseSecureUrl}/ecommerce/control/"/> <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipmentstatus.bsh"/> </actions> Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Sat Jul 14 04:19:11 2007 @@ -760,9 +760,4 @@ <attribute name="orderListSize" type="Integer" mode="OUT" optional="false"/> </service> - <service name="sendShipCompleteNotification" engine="java" require-new-transaction="true" max-retry="3" - location="org.ofbiz.order.order.OrderServices" invoke="sendShipCompleteNotification"> - <description>Send a Shipment complete notification</description> - <implements service="orderNotificationInterface"/> - </service> </services> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sat Jul 14 04:19:11 2007 @@ -2081,9 +2081,6 @@ return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_PAYRETRY"); } - public static Map sendShipCompleteNotification(DispatchContext ctx, Map context) { - return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_SHIP_COMPLT"); - } protected static Map sendOrderNotificationScreen(DispatchContext dctx, Map context, String emailType) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml Sat Jul 14 04:19:11 2007 @@ -229,7 +229,7 @@ <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/> <now-timestamp-to-env env-name="lookedUpValue.lastModifiedDate"/> <set from-field="userLogin.userLoginId" field="lookedUpValue.lastModifiedByUserLogin"/> - + <field-to-result field-name="lookedUpValue.shipmentId" result-name="shipmentId"/> <store-value value-name="lookedUpValue"/> </simple-method> <simple-method method-name="deleteShipment" short-description="Delete Shipment"> @@ -1323,7 +1323,6 @@ <!-- update the shipment status to shipped --> <set from-field="shipment.shipmentId" field="packedContext.shipmentId"/> <set value="SHIPMENT_SHIPPED" field="packedContext.statusId"/> - <set field="packedContext.orderId" from-field="orderHeader.orderId"/> <call-service service-name="updateShipment" in-map-name="packedContext"/> </then> <else> <!-- PURCHASE_ORDER --> @@ -1827,6 +1826,7 @@ <remove-value value-name="lookedUpValue"/> </simple-method> --> + Modified: ofbiz/trunk/applications/product/servicedef/secas_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/secas_shipment.xml?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/product/servicedef/secas_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/secas_shipment.xml Sat Jul 14 04:19:11 2007 @@ -31,7 +31,7 @@ <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> <condition field-name="statusId" operator="equals" value="SHIPMENT_SHIPPED"/> <condition field-name="shipmentTypeId" operator="equals" value="SALES_SHIPMENT"/> - <action service="sendShipCompleteNotification" mode="async" persist="true"/> + <action service="sendShipmentCompleteNotification" mode="async" persist="true"/> </eca> <!-- if new statusId of a PURCHASE_SHIPMENT is PURCH_SHIP_RECEIVED, create invoice --> Modified: ofbiz/trunk/applications/product/servicedef/services_shipment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services_shipment.xml Sat Jul 14 04:19:11 2007 @@ -123,7 +123,7 @@ <service name="updateShipment" default-entity-name="Shipment" engine="simple" location="org/ofbiz/shipment/shipment/ShipmentServices.xml" invoke="updateShipment" auth="true"> <description>Update Shipment</description> - <auto-attributes include="pk" mode="IN" optional="false"/> + <auto-attributes include="pk" mode="INOUT" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"> <exclude field-name="shipmentTypeId"/> <exclude field-name="createdDate"/> @@ -136,7 +136,6 @@ <attribute name="oldPrimaryOrderId" type="String" mode="OUT" optional="true"/> <attribute name="oldOriginFacilityId" type="String" mode="OUT" optional="true"/> <attribute name="oldDestinationFacilityId" type="String" mode="OUT" optional="true"/> - <attribute name="orderId" type="String" mode="IN" optional="true"/> </service> <service name="deleteShipment" default-entity-name="Shipment" engine="simple" location="org/ofbiz/shipment/shipment/ShipmentServices.xml" invoke="deleteShipment" auth="true"> @@ -689,4 +688,14 @@ <attribute name="originFacilityId" type="String" mode="IN" optional="true"/> <attribute name="quantityNotReserved" type="Double" mode="IN" optional="false"/> </service> + + <service name="sendShipmentCompleteNotification" engine="java" require-new-transaction="true" max-retry="3" + location="org.ofbiz.shipment.shipment.ShipmentServices" invoke="sendShipmentCompleteNotification" auth="true"> + <description>Send a notification on Shipment Complete</description> + <attribute name="shipmentId" type="String" mode="IN" optional="false"/> + <attribute name="sendTo" type="String" mode="IN" optional="true"/> + <attribute name="screenUri" type="String" mode="IN" optional="true"/> + <attribute name="comments" type="String" mode="IN" optional="true"/> + <attribute name="body" type="String" mode="OUT" optional="true"/> + </service> </services> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?view=diff&rev=556264&r1=556263&r2=556264 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Sat Jul 14 04:19:11 2007 @@ -24,6 +24,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.*; +import org.ofbiz.base.util.collections.ResourceBundleMapWrapper; import org.ofbiz.common.geo.GeoWorker; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; @@ -35,6 +36,7 @@ import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; +import org.ofbiz.party.party.PartyWorker; /** * ShipmentServices @@ -44,6 +46,7 @@ public static final String module = ShipmentServices.class.getName(); public static final String resource = "ProductUiLabels"; + public static final String resource_error = "OrderErrorUiLabels"; public static final int decimals = UtilNumber.getBigDecimalScale("order.decimals"); public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding"); public static final BigDecimal ZERO = (new BigDecimal("0")).setScale(decimals, rounding); @@ -1055,4 +1058,98 @@ result.put("packageValue", packageTotalValue); return result; } + + public static Map sendShipmentCompleteNotification(DispatchContext dctx, Map context) { + LocalDispatcher dispatcher = dctx.getDispatcher(); + GenericDelegator delegator = dctx.getDelegator(); + GenericValue userLogin = (GenericValue) context.get("userLogin"); + String shipmentId = (String) context.get("shipmentId"); + String sendTo = (String) context.get("sendTo"); + String screenUri = (String) context.get("screenUri"); + + // prepare the shipment information + Map sendMap = FastMap.newInstance(); + GenericValue shipment = null ; + GenericValue orderHeader = null; + try { + shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); + orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", shipment.getString("primaryOrderId"))); + } catch (GenericEntityException e) { + Debug.logError(e, "Problem getting info from database", module); + } + GenericValue productStoreEmail = null; + try { + productStoreEmail = delegator.findByPrimaryKey("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT")); + } catch (GenericEntityException e) { + Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId =" + orderHeader.get("productStoreId") + " and emailType = PRDS_ODR_SHIP_COMPLT", module); + } + if (productStoreEmail == null) { + return ServiceUtil.returnFailure("No valid email setting for store with productStoreId =" + orderHeader.get("productStoreId") + " and emailType = PRDS_ODR_SHIP_COMPLT"); + } + // the override screenUri + if (UtilValidate.isEmpty(screenUri)) { + if (productStoreEmail != null) { + String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation"); + sendMap.put("bodyScreenUri", bodyScreenLocation); + } else { + sendMap.put("bodyScreenUri", "component://ecommerce/widget/EmailOrderScreens.xml#ShipmentCompleteNotice"); + } + } else { + sendMap.put("bodyScreenUri", screenUri); + } + + String partyId = shipment.getString("partyIdTo"); + + // get the email address + String emailString = null; + GenericValue email = PartyWorker.findPartyLatestContactMech(partyId, "EMAIL_ADDRESS", delegator); + if (UtilValidate.isNotEmpty(email)) { + emailString = email.getString("infoString"); + } + if (UtilValidate.isEmpty(emailString)) { + return ServiceUtil.returnError("No sendTo email address found"); + } + + Locale locale = PartyWorker.findPartyLastLocale(partyId, delegator); + if (locale == null) { + locale = Locale.getDefault(); + } + ResourceBundleMapWrapper uiLabelMap = (ResourceBundleMapWrapper) UtilProperties.getResourceBundleMap("EcommerceUiLabels", locale); + uiLabelMap.addBottomResourceBundle("OrderUiLabels"); + uiLabelMap.addBottomResourceBundle("CommonUiLabels"); + + Map bodyParameters = UtilMisc.toMap("partyId", partyId, "shipmentId", shipmentId, "orderId", shipment.getString("primaryOrderId"), "userLogin", userLogin, "uiLabelMap", uiLabelMap, "locale", locale); + sendMap.put("bodyParameters", bodyParameters); + sendMap.put("userLogin",userLogin); + + if (productStoreEmail != null) { + sendMap.put("subject", productStoreEmail.getString("subject")); + sendMap.put("contentType", productStoreEmail.get("contentType")); + sendMap.put("sendFrom", productStoreEmail.get("fromAddress")); + sendMap.put("sendCc", productStoreEmail.get("ccAddress")); + sendMap.put("sendBcc", productStoreEmail.get("bccAddress")); + } else { + sendMap.put("subject", "Shipment Complete Notification"); + sendMap.put("contentType", "text/html"); + } + if ((sendTo != null) && UtilValidate.isEmail(sendTo)) { + sendMap.put("sendTo", sendTo); + } else { + sendMap.put("sendTo", emailString); + } + // send the notification + Map sendResp = null; + try { + sendResp = dispatcher.runSync("sendMailFromScreen", sendMap); + } catch (Exception e) { + Debug.logError(e, "Problem sending mail", module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemSendingEmail", locale)); + } + // check for errors + if (sendResp != null && ServiceUtil.isError(sendResp)) { + sendResp.put("emailType", "PRDS_ODR_SHIP_COMPLT"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemSendingEmail", locale), null, null, sendResp); + } + return sendResp; + } } |
Free forum by Nabble | Edit this page |