svn commit: r791509 - in /ofbiz/trunk/applications/order: servicedef/services.xml src/org/ofbiz/order/order/OrderServices.java webapp/ordermgr/WEB-INF/controller.xml webapp/ordermgr/order/ordershippinginfo.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r791509 - in /ofbiz/trunk/applications/order: servicedef/services.xml src/org/ofbiz/order/order/OrderServices.java webapp/ordermgr/WEB-INF/controller.xml webapp/ordermgr/order/ordershippinginfo.ftl

mor-2
Author: mor
Date: Mon Jul  6 15:06:36 2009
New Revision: 791509

URL: http://svn.apache.org/viewvc?rev=791509&view=rev
Log:
Added an option to Add/Edit Gift Message on Order Detail Page when the order is a gift.
Applied patch from Arun Patidar, part of OFBIZ-2707 (https://issues.apache.org/jira/browse/OFBIZ-2707)

Modified:
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=791509&r1=791508&r2=791509&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Mon Jul  6 15:06:36 2009
@@ -996,4 +996,11 @@
         <attribute name="shipGroupSeqId" type="String" mode="IN" optional="false"/>
         <attribute name="shippingInstructions" type="String" mode="IN" optional="true"/>
     </service>
+    <service name="setGiftMessage" engine="java" auth="true"
+            location="org.ofbiz.order.order.OrderServices" invoke="setGiftMessage">
+        <description>Set Gift message for an order</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+        <attribute name="shipGroupSeqId" type="String" mode="IN" optional="false"/>
+        <attribute name="giftMessage" type="String" mode="IN" optional="true"/>
+    </service>
 </services>
\ No newline at end of file

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?rev=791509&r1=791508&r2=791509&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Mon Jul  6 15:06:36 2009
@@ -5242,4 +5242,19 @@
         }
         return ServiceUtil.returnSuccess();
     }
+
+    public static Map setGiftMessage(DispatchContext dctx, Map context) {
+        GenericDelegator delegator = dctx.getDelegator();
+        String orderId = (String) context.get("orderId");
+        String shipGroupSeqId = (String) context.get("shipGroupSeqId");
+        String giftMessage = (String) context.get("giftMessage");
+        try {
+            GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId,"shipGroupSeqId",shipGroupSeqId)));
+            orderItemShipGroup.set("giftMessage", giftMessage);
+            orderItemShipGroup.store();
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+        }
+        return ServiceUtil.returnSuccess();
+    }
 }
\ No newline at end of file

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=791509&r1=791508&r2=791509&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Mon Jul  6 15:06:36 2009
@@ -304,6 +304,12 @@
         <response name="success" type="view" value="orderview"/>
         <response name="error" type="view" value="orderview"/>
     </request-map>
+    <request-map uri="setGiftMessage">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="setGiftMessage"/>
+        <response name="success" type="view" value="orderview"/>
+        <response name="error" type="view" value="orderview"/>
+    </request-map>
 
     <!-- Order Note Requests -->
     <request-map uri="createnewnote">

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl?rev=791509&r1=791508&r2=791509&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl Mon Jul  6 15:06:36 2009
@@ -32,6 +32,20 @@
     function saveInstruction() {
         document.updateShippingInstructionsForm.submit();
     }
+    function editGiftMessage() {
+        $('giftMessage').style.display="block";
+        $('saveGiftMessage').style.display="inline";
+        $('editGiftMessage').style.display="none";
+        $('message').style.display="none";
+    }
+    function addGiftMessage() {
+        $('giftMessage').style.display="block";
+        $('saveGiftMessage').style.display="inline";
+        $('addGiftMessage').style.display="none";
+    }
+    function saveGiftMessage() {
+        document.setGiftMessageForm.submit();
+    }
 </script>
 
 <#if (security.hasEntityPermission("ORDERMGR", "_UPDATE", session) || security.hasRolePermission("ORDERMGR", "_UPDATE", "", "", session)) && orderHeader.salesChannelEnumId != "POS_SALES_CHANNEL">
@@ -461,23 +475,35 @@
             </td>
             <td width="5">&nbsp;</td>
             <td valign="top" width="80%">
-              <#if shipGroup.isGift?upper_case == "N">${uiLabelMap.OrderThisOrderNotGift}<#else>${uiLabelMap.OrderThisOrderGift}</#if>
+              <#if shipGroup.isGift?upper_case == "N">
+                ${uiLabelMap.OrderThisOrderNotGift}<#else>${uiLabelMap.OrderThisOrderGift}</#if>
             </td>
           </tr>
         </#if>
-        <#if shipGroup.giftMessage?has_content>
-          <tr><td colspan="3"><hr/></td></tr>
-          <tr>
+        <#if shipGroup.isGift?upper_case == "Y">
+          <form name="setGiftMessageForm" method="post" action="<@ofbizUrl>setGiftMessage</@ofbizUrl>">
+            <input type="hidden" name="orderId" value="${orderHeader.orderId}"/>
+            <input type="hidden" name="shipGroupSeqId" value="${shipGroup.shipGroupSeqId}"/>
+            <tr><td colspan="3"><hr/></td></tr>
             <td align="right" valign="top" width="15%">
               <span class="label">&nbsp;${uiLabelMap.OrderGiftMessage}</span>
             </td>
-            <td width="5">&nbsp;</td>
-            <td valign="top" width="80%">
-              ${shipGroup.giftMessage}
+            <#if shipGroup.giftMessage?has_content>
+              <td>&nbsp;</td>
+              <td id="message" colspan="3" >
+                <label>${shipGroup.giftMessage}</label>
+                <a href="javascript:editGiftMessage();" class="buttontext" id="editGiftMessage">${uiLabelMap.CommonEdit}</a>
+              </td>
+            <#else>
+              <td align="right"><a href="javascript:addGiftMessage();" class="buttontext" id="addGiftMessage">${uiLabelMap.CommonAdd}</a></td>
+            </#if>
+            <td>
+              <textarea name="giftMessage" id="giftMessage" style="display:none">${shipGroup.giftMessage?if_exists}</textarea>
+              <a href="javascript:saveGiftMessage();" class="buttontext" id="saveGiftMessage" style="display:none">${uiLabelMap.CommonSave}</a>
             </td>
-          </tr>
+          </form>
         </#if>
-         <#if shipGroup.shipAfterDate?has_content>
+        <#if shipGroup.shipAfterDate?has_content>
          <tr><td colspan="3"><hr/></td></tr>
          <tr>
             <td align="right" valign="top" width="15%">