Added link and event to initialize a cart from an existing order: this implements the ability to clone an order.
The link to run it is at the bottom of the "order view" screen. git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@487781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1038,6 +1038,34 @@ public class ShoppingCartEvents {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Initialize order entry from an existing order **/
|
||||
public static String loadCartFromOrder(HttpServletRequest request, HttpServletResponse response) {
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
HttpSession session = request.getSession();
|
||||
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
|
||||
|
||||
String quoteId = request.getParameter("orderId");
|
||||
|
||||
ShoppingCart cart = null;
|
||||
try {
|
||||
Map outMap = dispatcher.runSync("loadCartFromOrder",
|
||||
UtilMisc.toMap("orderId", quoteId,
|
||||
"userLogin", userLogin));
|
||||
cart = (ShoppingCart) outMap.get("shoppingCart");
|
||||
} catch (GenericServiceException exc) {
|
||||
request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());
|
||||
return "error";
|
||||
}
|
||||
|
||||
cart.setAttribute("addpty", "Y");
|
||||
session.setAttribute("shoppingCart", cart);
|
||||
session.setAttribute("productStoreId", cart.getProductStoreId());
|
||||
session.setAttribute("orderMode", cart.getOrderType());
|
||||
session.setAttribute("orderPartyId", cart.getOrderPartyId());
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
public static String createQuoteFromCart(HttpServletRequest request, HttpServletResponse response) {
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
@@ -475,6 +475,12 @@
|
||||
<response name="success" type="view" value="showcart"/>
|
||||
<response name="error" type="view" value="checkinits"/>
|
||||
</request-map>
|
||||
<request-map uri="loadCartFromOrder">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="loadCartFromOrder"/>
|
||||
<response name="success" type="request" value="finalizeOrder"/>
|
||||
<response name="error" type="view" value="orderview"/>
|
||||
</request-map>
|
||||
<request-map uri="addseperator">
|
||||
<security https="true" auth="true"/>
|
||||
<event type="java" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="addSeparator"/>
|
||||
|
||||
@@ -54,6 +54,9 @@ under the License.
|
||||
<platform-specific>
|
||||
<html><html-template location="component://order/webapp/ordermgr/order/transitions.ftl"/></html>
|
||||
</platform-specific>
|
||||
<container>
|
||||
<link target="loadCartFromOrder?orderId=${parameters.orderId}&finalizeMode=init" text="${uiLabelMap.OrderCreateOrder}" style="buttontext"/>
|
||||
</container>
|
||||
</decorator-section>
|
||||
</decorator-screen>
|
||||
</widgets>
|
||||
|
||||
Reference in New Issue
Block a user