Author: ashish
Date: Sat Oct 18 12:31:25 2014
New Revision: 1632780

URL: http://svn.apache.org/r1632780
Log:
Applied bug fix from trunk r1632777.
=============================================
Applied patch from jira issue - OFBIZ-5714 - Comment does not save.
===========================================================
1. find P.O.
2. select approaved p.o.
3. edit items
4 add item (at bottom of screen)
5. Comment does not save.
Note! shouldn't the comment be displayed on some of the P.O. screens?
I only know it does not save as I edited the .FTL on viewpo and pdf to include 
comment. Comments from the orignal create P.O. show up, ALso should be able to 
edit a comment, when edit items is entered.
===========================================================
Thanks Joel for creating the issue and Thanks Akash for providing the patch.

Modified:
    
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
    
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
    
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/editorderitems.ftl
    
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/orderitems.ftl

Modified: 
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1632780&r1=1632779&r2=1632780&view=diff
==============================================================================
--- 
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
 (original)
+++ 
ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/order/OrderServices.java
 Sat Oct 18 12:31:25 2014
@@ -3539,6 +3539,9 @@ public class OrderServices {
                     item.setIsModifiedPrice(true);
                 }
 
+                item.setItemComment(changeComments);
+                item.setDesiredDeliveryDate(itemDesiredDeliveryDate);
+                cart.clearItemShipInfo(item);
                 cart.setItemShipGroupQty(item, item.getQuantity(), 
shipGroupIdx);
             } else {
                 ShoppingCartItem item = ShoppingCartItem.makeItem(null, 
productId, null, quantity, null, null, null, null, null, null, null, null, 
prodCatalogId, null, null, null, dispatcher, cart, null, null, null, 
Boolean.FALSE, Boolean.FALSE);
@@ -3697,6 +3700,15 @@ public class OrderServices {
                     }
                 }
 
+                // Update the item comment
+                if (itemCommentMap != null && 
itemCommentMap.containsKey(itemSeqId)) {
+                    String comments = itemCommentMap.get(itemSeqId);
+                    if (UtilValidate.isNotEmpty(comments)) {
+                        cartItem.setItemComment(comments);
+                        Debug.logInfo("Set item comment: [" + itemSeqId + "] " 
+ comments, module);
+                    }
+                }
+
                 // update the order item attributes
                 if (itemAttributesMap != null) {
                     // go through the item attributes map once to get a list 
of key names
@@ -4223,6 +4235,7 @@ public class OrderServices {
                     String oldItemDescription = 
oldOrderItem.getString("itemDescription") != null ? 
oldOrderItem.getString("itemDescription") : "";
                     BigDecimal oldQuantity = 
oldOrderItem.getBigDecimal("quantity") != null ? 
oldOrderItem.getBigDecimal("quantity") : BigDecimal.ZERO;
                     BigDecimal oldUnitPrice = 
oldOrderItem.getBigDecimal("unitPrice") != null ? 
oldOrderItem.getBigDecimal("unitPrice") : BigDecimal.ZERO;
+                    String oldItemComment = oldOrderItem.getString("comments") 
!= null ? oldOrderItem.getString("comments") : "";
 
                     boolean changeFound = false;
                     Map<String, Object> modifiedItem = FastMap.newInstance();
@@ -4231,6 +4244,11 @@ public class OrderServices {
                         changeFound = true;
                     }
 
+                    if 
(!oldItemComment.equals(valueObj.getString("comments"))) {
+                        modifiedItem.put("changeComments", 
valueObj.getString("comments"));
+                        changeFound = true;
+                    }
+
                     BigDecimal quantityDif = 
valueObj.getBigDecimal("quantity").subtract(oldQuantity);
                     BigDecimal unitPriceDif = 
valueObj.getBigDecimal("unitPrice").subtract(oldUnitPrice);
                     if (quantityDif.compareTo(BigDecimal.ZERO) != 0) {
@@ -4245,15 +4263,10 @@ public class OrderServices {
 
                         //  found changes to store
                         Map<String, String> itemReasonMap = 
UtilGenerics.checkMap(changeMap.get("itemReasonMap"));
-                        Map<String, String> itemCommentMap = 
UtilGenerics.checkMap(changeMap.get("itemCommentMap"));
                         if (UtilValidate.isNotEmpty(itemReasonMap)) {
                             String changeReasonId = 
itemReasonMap.get(valueObj.getString("orderItemSeqId"));
                             modifiedItem.put("reasonEnumId", changeReasonId);
                         }
-                        if (UtilValidate.isNotEmpty(itemCommentMap)) {
-                            String changeComments = 
itemCommentMap.get(valueObj.getString("orderItemSeqId"));
-                            modifiedItem.put("changeComments", changeComments);
-                        }
 
                         modifiedItem.put("orderId", 
valueObj.getString("orderId"));
                         modifiedItem.put("orderItemSeqId", 
valueObj.getString("orderItemSeqId"));

Modified: 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy?rev=1632780&r1=1632779&r2=1632780&view=diff
==============================================================================
--- 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
 (original)
+++ 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
 Sat Oct 18 12:31:25 2014
@@ -55,9 +55,11 @@ def partyId = null;
 orderHeader = null;
 orderItems = null;
 orderAdjustments = null;
+comments = null;
 
 if (orderId) {
     orderHeader = delegator.findByPrimaryKey("OrderHeader", [orderId : 
orderId]);
+    comments = delegator.findList("OrderItemChange", 
EntityCondition.makeCondition("orderId", orderId), ["orderItemSeqId", 
"changeComments", "changeDatetime", "changeUserLogin"] as Set, ["changeDatetime 
DESC"], null, false);
 }
 
 if (orderHeader) {
@@ -73,6 +75,7 @@ if (orderHeader) {
     orderTerms = orderHeader.getRelated("OrderTerm");
 
     context.orderHeader = orderHeader;
+    context.comments = comments;
     context.orderReadHelper = orderReadHelper;
     context.orderItems = orderItems;
     context.orderAdjustments = orderAdjustments;

Modified: 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/editorderitems.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/editorderitems.ftl?rev=1632780&r1=1632779&r2=1632780&view=diff
==============================================================================
--- 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/editorderitems.ftl
 (original)
+++ 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/editorderitems.ftl
 Sat Oct 18 12:31:25 2014
@@ -193,7 +193,7 @@ under the License.
                               </#list>
                             </select>
                             <span 
class="label">${uiLabelMap.CommonComments}</span>
-                            <input type="text" 
name="icm_${orderItem.orderItemSeqId}" value="" size="30" maxlength="60"/>
+                            <input type="text" 
name="icm_${orderItem.orderItemSeqId}" value="${orderItem.comments!}" size="30" 
maxlength="60"/>
                             <#if (orderHeader.orderTypeId == 'PURCHASE_ORDER')>
                               <span 
class="label">${uiLabelMap.OrderEstimatedShipDate}</span>
                               <@htmlTemplate.renderDateTimeField 
name="isdm_${orderItem.orderItemSeqId}" 
value="${orderItem.estimatedShipDate?if_exists}" event="" action="" 
className="" alert="" title="Format: yyyy-MM-dd HH:mm:ss.SSS" size="25" 
maxlength="30" id="isdm_${orderItem.orderItemSeqId}" dateType="date" 
shortDateInput=false timeDropdownParamName="" defaultDateTimeString="" 
localizedIconTitle="" timeDropdown="" timeHourName="" classString="" hour1="" 
hour2="" timeMinutesName="" minutes="" isTwelveHour="" ampmName="" 
amSelected="" pmSelected="" compositeType="" formName=""/>

Modified: 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/orderitems.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/orderitems.ftl?rev=1632780&r1=1632779&r2=1632780&view=diff
==============================================================================
--- 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/orderitems.ftl
 (original)
+++ 
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/order/orderitems.ftl
 Sat Oct 18 12:31:25 2014
@@ -651,6 +651,47 @@ under the License.
                                 </tr>
                             </#list>
                         </#if>
+                        <#if orderItem.comments?has_content>
+                          <tr<#if itemClass == "1"> 
class="alternate-row"</#if>>
+                            <td>&nbsp;</td>
+                            <td>
+                              <div class= "screenlet">
+                                <div class = "screenlet-body">
+                                  <table>
+                                    <tr>
+                                      <td align="right">
+                                        <span 
class="label">${uiLabelMap.CommonComments}</span>
+                                      </td>
+                                      <td align="">
+                                        <span 
class="label">${uiLabelMap.CommonCurrent}:</span>&nbsp;${orderItem.comments}
+                                        <#assign orderItemSeqId = 
orderItem.orderItemSeqId!>
+                                        <#if comments?has_content>
+                                          <hr/>
+                                          <#list comments as comm>
+                                            <#if 
comm.orderItemSeqId?has_content && orderItemSeqId?has_content && 
comm.orderItemSeqId == orderItemSeqId>
+                                              <#if 
comm.changeComments?has_content>
+                                                <div>
+                                                ${comm.changeComments}
+                                                &nbsp;
+                                                <#if 
comm.changeDatetime?has_content>${Static["org.ofbiz.base.util.UtilFormatOut"].formatDateTime(comm.changeDatetime,
 "", locale, timeZone)?default("0000-00-00 00:00:00")}</#if>  &nbsp;  
${uiLabelMap.CommonBy} -  [${comm.changeUserLogin}]
+                                                </div>
+                                              </#if>
+                                            </#if>
+                                          </#list>
+                                        </#if>
+                                      </td>
+                                    </tr>
+                                  </table>
+                                </div>
+                              </div>
+                            </td>
+                            <td></td>
+                            <td></td>
+                            <td></td>
+                            <td></td>
+                            <td></td>
+                          </tr>
+                        </#if>
                         <#if itemClass == "2">
                             <#assign itemClass = "1">
                         <#else>


Reply via email to