svn commit: r833323 - in /ofbiz/trunk/applications/order: config/ src/org/ofbiz/order/shoppingcart/ webapp/ordermgr/WEB-INF/ webapp/ordermgr/entry/cart/ webapp/ordermgr/order/ widget/ordermgr/

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

svn commit: r833323 - in /ofbiz/trunk/applications/order: config/ src/org/ofbiz/order/shoppingcart/ webapp/ordermgr/WEB-INF/ webapp/ordermgr/entry/cart/ webapp/ordermgr/order/ widget/ordermgr/

ashish-18
Author: ashish
Date: Fri Nov  6 09:00:16 2009
New Revision: 833323

URL: http://svn.apache.org/viewvc?rev=833323&view=rev
Log:
Applied patch from jira issue: OFBIZ-3165 - Add additional screen for gift card certificate buying functionality by CSR in Order manager application in add item page.
1) Add additional screen for gift card certificate buying functionality by CSR in Order manager application in add item page

2) Also add feature to fill survey on same page.

3) Also if CSR selects "Create as new order" from Actions block for Gift card products then survey responses will be created automatically for the new order, which will be same as last order.

Thanks Arun / Divesh for the contribution.

Added:
    ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl   (with props)
Modified:
    ofbiz/trunk/applications/order/config/OrderUiLabels.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl
    ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.xml?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.xml (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.xml Fri Nov  6 09:00:16 2009
@@ -1323,6 +1323,9 @@
         <value xml:lang="en">Address Verification (AVS)</value>
         <value xml:lang="it">Verifica indirizzo (AVS)</value>
     </property>
+    <property key="OrderAddGiftCertificate">
+        <value xml:lang="en">Add Gift Certificate</value>
+    </property>
     <property key="OrderAdjustment">
         <value xml:lang="de">Anpassung</value>
         <value xml:lang="en">Adjustment</value>
@@ -7233,6 +7236,12 @@
         <value xml:lang="en">Received Quantity History</value>
         <value xml:lang="it">Storia quantità ricevuta</value>
     </property>
+    <property key="OrderRecipientName">
+        <value xml:lang="en">Recipient's Name:</value>
+    </property>
+    <property key="OrderRecipientEmailAdd">
+        <value xml:lang="en">Recipient's Email:</value>
+    </property>
     <property key="OrderReference">
         <value xml:lang="de">Referenz</value>
         <value xml:lang="en">Reference</value>
@@ -8381,6 +8390,9 @@
         <value xml:lang="it">Importo selezionato</value>
         <value xml:lang="zh">选择数量</value>
     </property>
+    <property key="OrderSelectGiftAmount">
+        <value xml:lang="en">Select The Gift Amount</value>
+    </property>
     <property key="OrderSelectAShippingAddress">
         <value xml:lang="de">Wählen Sie eine Lieferadresse</value>
         <value xml:lang="en">Select A Shipping Address</value>
@@ -8658,6 +8670,9 @@
         <value xml:lang="zh">发送电子邮件</value>
         <value xml:lang="zh_CN">发送电子邮件</value>
     </property>
+    <property key="OrderSenderName">
+        <value xml:lang="en">Sender's Name:</value>
+    </property>
     <property key="OrderSendMeThisEveryMonth">
         <value xml:lang="de">Senden Sie mir dies jeden Monat</value>
         <value xml:lang="en">Send me this every month</value>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Fri Nov  6 09:00:16 2009
@@ -3711,21 +3711,29 @@
         while (itemIter.hasNext()) {
             ShoppingCartItem item = (ShoppingCartItem) itemIter.next();
             List responses = (List) item.getAttribute("surveyResponses");
+            GenericValue response = null;
             if (responses != null) {
                 Iterator ri = responses.iterator();
                 while (ri.hasNext()) {
                     String responseId = (String) ri.next();
-                    GenericValue response = null;
                     try {
                         response = this.getDelegator().findByPrimaryKey("SurveyResponse", UtilMisc.toMap("surveyResponseId", responseId));
                     } catch (GenericEntityException e) {
                         Debug.logError(e, "Unable to obtain SurveyResponse record for ID : " + responseId, module);
                     }
-                    if (response != null) {
-                        response.set("orderItemSeqId", item.getOrderItemSeqId());
-                        allInfos.add(response);
-                    }
                 }
+             // this case is executed when user selects "Create as new Order" for Gift cards
+             } else {
+                 String surveyResponseId = (String) item.getAttribute("surveyResponseId");
+                 try {
+                     response = this.getDelegator().findOne("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId), false);
+                 } catch (GenericEntityException e) {
+                     Debug.logError(e, "Unable to obtain SurveyResponse record for ID : " + surveyResponseId, module);
+                 }
+            }
+            if (response != null) {
+                response.set("orderItemSeqId", item.getOrderItemSeqId());
+                allInfos.add(response);
             }
         }
         return allInfos;

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Fri Nov  6 09:00:16 2009
@@ -305,6 +305,34 @@
                 // get the next item sequence id
                 String orderItemSeqId = item.getString("orderItemSeqId");
                 orderItemSeqId = orderItemSeqId.replaceAll("\\P{Digit}", "");
+                // get product Id
+                String productId = item.getString("productId");
+                GenericValue product = null;
+                // creates survey responses for Gift cards same as last Order created
+                Map surveyResponseResult = null;
+                try {
+                    product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+                    if ("DIGITAL_GOOD".equals(product.getString("productTypeId"))) {
+                        Map<String, Object> surveyResponseMap = FastMap.newInstance();
+                        Map<String, Object> answers = FastMap.newInstance();
+                        List<GenericValue> surveyResponseAndAnswers = delegator.findByAnd("SurveyResponseAndAnswer", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
+                        if (UtilValidate.isNotEmpty(surveyResponseAndAnswers)) {
+                            String surveyId = EntityUtil.getFirst(surveyResponseAndAnswers).getString("surveyId");
+                            for (GenericValue surveyResponseAndAnswer : surveyResponseAndAnswers) {
+                                answers.put((surveyResponseAndAnswer.get("surveyQuestionId").toString()), surveyResponseAndAnswer.get("textResponse"));
+                            }
+                            surveyResponseMap.put("answers", answers);
+                            surveyResponseMap.put("surveyId", surveyId);
+                            surveyResponseResult = dispatcher.runSync("createSurveyResponse", surveyResponseMap);
+                        }
+                    }    
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                } catch (GenericServiceException e) {
+                    Debug.logError(e.toString(), module);
+                    return ServiceUtil.returnError(e.toString());
+                }
                 try {
                     long seq = Long.parseLong(orderItemSeqId);
                     if (seq > nextItemSeq) {
@@ -350,7 +378,6 @@
                 } else {
                     // product item
                     String prodCatalogId = item.getString("prodCatalogId");
-                    String productId = item.getString("productId");
 
                     //prepare the rental data
                     Timestamp reservStart = null;
@@ -381,7 +408,7 @@
                     ProductConfigWrapper configWrapper = null;
                     String configId = null;
                     try {
-                        GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
+                        product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
                         if ("AGGREGATED_CONF".equals(product.getString("productTypeId"))) {
                             List<GenericValue>productAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_CONF", "productIdTo", product.getString("productId")));
                             productAssocs = EntityUtil.filterByDate(productAssocs);
@@ -411,7 +438,11 @@
                 // flag the item w/ the orderItemSeqId so we can reference it
                 ShoppingCartItem cartItem = cart.findCartItem(itemIndex);
                 cartItem.setOrderItemSeqId(item.getString("orderItemSeqId"));
-
+                
+                // attach surveyResponseId for each item
+                if (UtilValidate.isNotEmpty(surveyResponseResult)){
+                    cartItem.setAttribute("surveyResponseId",surveyResponseResult.get("surveyResponseId"));
+                }
                 // attach addition item information
                 cartItem.setStatusId(item.getString("statusId"));
                 cartItem.setItemType(item.getString("orderItemTypeId"));

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=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Fri Nov  6 09:00:16 2009
@@ -521,7 +521,16 @@
         <response name="success" type="view" value="showcart"/>
         <response name="error" type="view" value="showcart"/>
     </request-map>
-
+    <request-map uri="AddGiftCertificate">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" value="AddGiftCertificate"/>
+    </request-map>
+    <request-map uri="addGiftCertificateSurvey">
+        <security https="true" auth="false"/>
+        <event type="service" invoke="createSurveyResponse"/>
+        <response name="success" type="request" value="additem"/>
+        <response name="error" type="view" value="AddGiftCertificate"/>
+    </request-map>
     <!-- Create a replacement order from an existing order against a lost shipment etc. -->
     <request-map uri="loadCartForReplacementOrder">
         <security https="true" auth="true"/>
@@ -1719,6 +1728,7 @@
     <view-map name="product" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#product"/>
     <view-map name="compareProducts" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#compareProducts"/>
     <view-map name="quickadd" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#quickadd"/>
+    <view-map name="AddGiftCertificate" type="screen" page="component://order/widget/ordermgr/OrderEntryCartScreens.xml#AddGiftCertificate"/>
 
     <view-map name="custsetting" type="screen" page="component://order/widget/ordermgr/OrderEntryOrderScreens.xml#CustSettings"/>
     <view-map name="shipsetting" type="screen" page="component://order/widget/ordermgr/OrderEntryOrderScreens.xml#ShipSettings"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl Fri Nov  6 09:00:16 2009
@@ -22,6 +22,9 @@
         document.qohAtpForm.productId.value = document.quickaddform.add_product_id.value;
         document.qohAtpForm.submit();
     }
+    function quicklookupGiftCertificate() {
+        window.location='AddGiftCertificate';
+    }
 </script>
 <#if shoppingCart.getOrderType() == "PURCHASE_ORDER">
   <#assign target="productAvailabalityByFacility">
@@ -81,6 +84,7 @@
                       <a href="javascript:call_fieldlookup2(document.quickaddform.add_product_id,'<@ofbizUrl><#if orderType=="PURCHASE_ORDER">LookupSupplierProduct?partyId=${partyId?if_exists}<#else>LookupProduct</#if></@ofbizUrl>');">
                         <img src="<@ofbizContentUrl>/images/fieldlookup.gif</@ofbizContentUrl>" width="15" height="14" border="0" alt="${uiLabelMap.CommonClickHereForFieldLookup}"/>
                       </a>
+                      <a href="javascript:quicklookupGiftCertificate()" class="buttontext">${uiLabelMap.OrderAddGiftCertificate}</a>
                       <#if "PURCHASE_ORDER" == shoppingCart.getOrderType()>
                         <a href="javascript:showQohAtp()" class="buttontext">${uiLabelMap.ProductAtpQoh}</a>
                       </#if>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/showcartitems.ftl Fri Nov  6 09:00:16 2009
@@ -145,10 +145,10 @@
                     <#if Static["org.ofbiz.common.CommonWorkers"].hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG")>
                     ${uiLabelMap.ProductMarketingPackageATP} = ${mktgPkgATPMap.get(productId)}, ${uiLabelMap.ProductMarketingPackageQOH} = ${mktgPkgQOHMap.get(productId)}
                     </#if>
-                    <#if (availableToPromiseMap.get(cartLine.getProductId()) <= 0) && (shoppingCart.getOrderType() == "SALES_ORDER")>
+                    <#if (availableToPromiseMap.get(cartLine.getProductId()) <= 0) && (shoppingCart.getOrderType() == "SALES_ORDER" && product.productTypeId != "DIGITAL_GOOD")>
                       <span style="color: red;">[${cartLine.getQuantity()}&nbsp;${uiLabelMap.OrderBackOrdered}]</span>
                     <#else>
-                      <#if (availableToPromiseMap.get(cartLine.getProductId()) < cartLine.getQuantity()) && (shoppingCart.getOrderType() == "SALES_ORDER")>
+                      <#if (availableToPromiseMap.get(cartLine.getProductId()) < cartLine.getQuantity()) && (shoppingCart.getOrderType() == "SALES_ORDER" && product.productTypeId != "DIGITAL_GOOD")>
                         <#assign backOrdered = cartLine.getQuantity() - availableToPromiseMap.get(cartLine.getProductId())>
                         <span style="color: red;">[${backOrdered?if_exists}&nbsp;${uiLabelMap.OrderBackOrdered}]</span>
                       </#if>

Added: ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl?rev=833323&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl (added)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl Fri Nov  6 09:00:16 2009
@@ -0,0 +1,41 @@
+<form id="addGiftCertificate" action="<@ofbizUrl>addGiftCertificateSurvey</@ofbizUrl>" method="post">
+  <fieldset>
+    <input type="hidden" name="quantity" value="1" />
+    <input type="hidden" name="surveyId" value="1000" />
+    <label>${uiLabelMap.OrderSelectGiftAmount}</label>
+    <div>
+      <input type="radio" name="add_product_id" id="productId_10" value="GC-001-C10" checked="checked" />
+      <label for="productId_10">$10</label>
+    </div>
+    <div>
+      <input type="radio" name="add_product_id" id="productId_25" value="GC-001-C25" />
+      <label for="productId_25">$25</label>
+    </div>
+    <div>
+      <input type="radio" name="add_product_id" id="productId_50" value="GC-001-C50" />
+      <label for="productId_50">$50</label>
+    </div>
+    <div>
+      <input type="radio" name="add_product_id" id="productId_100" value="GC-001-C100" />
+      <label for="productId_100">$100</label>
+    </div>
+    <div>
+      <label for="emailAddress">${uiLabelMap.OrderRecipientEmailAdd}</label>
+      <input type="text" id="emailAddress" name="answers_1002" value="" />
+    </div>
+    <div>
+      <label for="recipientName">${uiLabelMap.OrderRecipientName}</label>
+      <input type="text" id="recipientName" name="answers_1001" value="" />
+    </div>
+    <div>
+      <label for="senderName">${uiLabelMap.OrderSenderName}</label>
+      <input type="text" id="senderName" name="answers_1000" value="" />
+    <div>
+      <label for="message">${uiLabelMap.OrderGiftMessage}:</label>
+      <textarea id="message" name="answers_1003"></textarea>
+    </div>
+    <div>
+      <input type="submit" value="${uiLabelMap.CommonSubmit}" />
+    </div>
+  </fieldset>
+</form>

Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/order/webapp/ordermgr/order/GiftCertificates.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml?rev=833323&r1=833322&r2=833323&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml (original)
+++ ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml Fri Nov  6 09:00:16 2009
@@ -197,4 +197,20 @@
             </widgets>
         </section>
     </screen>
+    <screen name="AddGiftCertificate">
+        <section>
+            <actions>
+                <set field="titleProperty" value="OrderAddGiftCertificate"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonOrderCatalogDecorator" location="component://order/widget/ordermgr/OrderEntryCommonScreens.xml">
+                    <decorator-section name="body">
+                        <platform-specific><html>
+                            <html-template location="component://order/webapp/ordermgr/order/GiftCertificates.ftl"/></html>
+                        </platform-specific>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>