Author: mor
Date: Sat Jul 4 10:57:01 2009 New Revision: 791100 URL: http://svn.apache.org/viewvc?rev=791100&view=rev Log: Added an option to cancel selected order items on Order Detail Page. Applied patch from Divesh Dutta, part of OFBIZ-2696 (https://issues.apache.org/jira/browse/OFBIZ-2696) Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.xml?rev=791100&r1=791099&r2=791100&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderUiLabels.xml Sat Jul 4 10:57:01 2009 @@ -1731,6 +1731,9 @@ <value xml:lang="th">à¸à¸±à¸à¸£à¹à¸à¹à¹à¸à¹à¸à¸£à¹à¸¡à¸à¸±à¸</value> <value xml:lang="zh">è´ç©è½¦æç»ä½¿ç¨ä¿éæ åµ</value> </property> + <property key="OrderCancelSelectedItems"> + <value xml:lang="en">Cancel Selected Items</value> + </property> <property key="OrderCartSummary"> <value xml:lang="cs">Obsah koÅ¡Ãku</value> <value xml:lang="de">Ihr Warenkorb enthält</value> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java?rev=791100&r1=791099&r2=791100&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderEvents.java Sat Jul 4 10:57:01 2009 @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -36,6 +37,12 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.LocalDispatcher; +import org.ofbiz.service.ServiceUtil; + +import javolution.util.FastMap; + /** * Order Events */ @@ -89,4 +96,56 @@ return "success"; } + + public static String cancelSelectedOrderItems(HttpServletRequest request, HttpServletResponse response) { + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); + HttpSession session = request.getSession(); + GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); + + Map resultMap = FastMap.newInstance(); + String orderId = request.getParameter("orderId"); + String[] orderItemSeqIds = request.getParameterValues("selectedItem"); + + if (orderItemSeqIds != null) { + for (String orderItemSeqId : orderItemSeqIds) { + try { + GenericValue orderItem = delegator.findOne("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), false); + List<GenericValue> orderItemShipGroupAssocs = orderItem.getRelated("OrderItemShipGroupAssoc"); + for (GenericValue orderItemShipGroupAssoc : orderItemShipGroupAssocs) { + GenericValue orderItemShipGroup = orderItemShipGroupAssoc.getRelatedOne("OrderItemShipGroup"); + String shipGroupSeqId = orderItemShipGroup.getString("shipGroupSeqId"); + + Map contextMap = FastMap.newInstance(); + contextMap.put("orderId", orderId); + contextMap.put("orderItemSeqId", orderItemSeqId); + contextMap.put("shipGroupSeqId", shipGroupSeqId); + contextMap.put("userLogin", userLogin); + try { + resultMap = dispatcher.runSync("cancelOrderItem", contextMap); + + if(ServiceUtil.isError(resultMap)) { + String errorMessage = (String) resultMap.get("errorMessage"); + Debug.logError(errorMessage, module); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + return "error"; + } + + } catch (GenericServiceException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", resultMap.get("errorMessage")); + return "error"; + } + } + } catch (GenericEntityException e ) { + Debug.logError(e, module); + return "error"; + } + } + return "success"; + } else { + request.setAttribute("_ERROR_MESSAGE_", "No order item selected. Please select an order item to cancel"); + return "error"; + } + } } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=791100&r1=791099&r2=791100&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Sat Jul 4 10:57:01 2009 @@ -188,6 +188,12 @@ <response name="success" type="view" value="orderview"/> <response name="error" type="view" value="orderview"/> </request-map> + <request-map uri="cancelSelectedOrderItems"> + <security https="true" auth="true"/> + <event type="java" path="org.ofbiz.order.order.OrderEvents" invoke="cancelSelectedOrderItems"/> + <response name="success" type="view" value="orderview"/> + <response name="error" type="view" value="orderview"/> + </request-map> <request-map uri="createOrderAdjustment"> <security https="true" auth="true"/> <event type="service" invoke="createOrderAdjustment"/> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl?rev=791100&r1=791099&r2=791100&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/editorderitems.ftl Sat Jul 4 10:57:01 2009 @@ -17,6 +17,7 @@ under the License. --> + <#if orderHeader?has_content> <#-- Order Items changes to basic-table style --> @@ -41,6 +42,7 @@ <li class="h3"> ${uiLabelMap.OrderOrderItems}</li> <#if security.hasEntityPermission("ORDERMGR", "_UPDATE", session) || security.hasRolePermission("ORDERMGR", "_UPDATE", "", "", session)> <#if orderHeader?has_content && orderHeader.statusId != "ORDER_CANCELLED" && orderHeader.statusId != "ORDER_COMPLETED"> + <li><a href="javascript:document.updateItemInfo.action='<@ofbizUrl>cancelSelectedOrderItems</@ofbizUrl>';document.updateItemInfo.submit()">${uiLabelMap.OrderCancelSelectedItems}</a></li> <li><a href="javascript:document.updateItemInfo.action='<@ofbizUrl>cancelOrderItem</@ofbizUrl>';document.updateItemInfo.submit()">${uiLabelMap.OrderCancelAllItems}</a></li> <li><a href="<@ofbizUrl>orderview?${paramString}</@ofbizUrl>">${uiLabelMap.OrderViewOrder}</a></li> </#if> @@ -168,13 +170,6 @@ </#if> </td> <td> </td> - <td> - <#if ("Y" != orderItem.isPromo?if_exists) && ((security.hasEntityPermission("ORDERMGR", "_ADMIN", session) && orderItem.statusId != "ITEM_CANCELLED" && orderItem.statusId != "ITEM_COMPLETED") || (security.hasEntityPermission("ORDERMGR", "_UPDATE", session) && orderItem.statusId != "ITEM_CANCELLED" && orderItem.statusId != "ITEM_COMPLETED" && orderHeader.statusId != "ORDER_SENT"))> - <a href="javascript:document.updateItemInfo.action='<@ofbizUrl>cancelOrderItem</@ofbizUrl>';document.updateItemInfo.submit()" class="buttontext">${uiLabelMap.CommonCancelAll}</a> - <#else> - - </#if> - </td> </#if> </tr> @@ -251,6 +246,7 @@ <td> <#assign itemStatusOkay = (orderItem.statusId != "ITEM_CANCELLED" && orderItem.statusId != "ITEM_COMPLETED" && (shipGroupAssoc.cancelQuantity?default(0) < shipGroupAssoc.quantity?default(0)) && ("Y" != orderItem.isPromo?if_exists))> <#if (security.hasEntityPermission("ORDERMGR", "_ADMIN", session) && itemStatusOkay) || (security.hasEntityPermission("ORDERMGR", "_UPDATE", session) && itemStatusOkay && orderHeader.statusId != "ORDER_SENT")> + <input type="checkbox" name="selectedItem" value="${orderItem.orderItemSeqId}"> <a href="javascript:document.updateItemInfo.action='<@ofbizUrl>cancelOrderItem</@ofbizUrl>';document.updateItemInfo.orderItemSeqId.value='${orderItem.orderItemSeqId}';document.updateItemInfo.shipGroupSeqId.value='${shipGroup.shipGroupSeqId}';document.updateItemInfo.submit()" class="buttontext">${uiLabelMap.CommonCancel}</a> <#else> |
Free forum by Nabble | Edit this page |