svn commit: r788976 - in /ofbiz/trunk/applications/product: ./ config/ data/ webapp/catalog/WEB-INF/actions/product/ webapp/catalog/product/ widget/catalog/

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

svn commit: r788976 - in /ofbiz/trunk/applications/product: ./ config/ data/ webapp/catalog/WEB-INF/actions/product/ webapp/catalog/product/ widget/catalog/

ashish-18
Author: ashish
Date: Sat Jun 27 14:15:15 2009
New Revision: 788976

URL: http://svn.apache.org/viewvc?rev=788976&view=rev
Log:
Applied patch from jira issue OFBIZ-2664 (Portlet to show best selling products of the day).
Thanks Chirag for your contribution.

Added:
    ofbiz/trunk/applications/product/data/ProductPortletData.xml   (with props)
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy   (with props)
Modified:
    ofbiz/trunk/applications/product/config/ProductUiLabels.xml
    ofbiz/trunk/applications/product/ofbiz-component.xml
    ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.xml?rev=788976&r1=788975&r2=788976&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.xml Sat Jun 27 14:15:15 2009
@@ -7200,6 +7200,9 @@
         <value xml:lang="th">ราคาพื้นฐาน</value>
         <value xml:lang="zh">价格底线</value>
     </property>
+    <property key="ProductBestSellingProductsOf">
+        <value xml:lang="en">Best Selling Products of</value>
+    </property>
     <property key="ProductBeTheFirstToReviewThisProduct">
         <value xml:lang="cs">Staňte se prvním, kdo zhodnotí tetnto výrobek</value>
         <value xml:lang="de">Seien Sie der Erste, der dieses Produkt beurteilt!</value>
@@ -13317,6 +13320,9 @@
         <value xml:lang="th">ไม่พบข้อบังคับราคา</value>
         <value xml:lang="zh">没有找到价格规则</value>
     </property>
+    <property key="ProductNoProductFound">
+        <value xml:lang="en">No Product Found</value>
+    </property>
     <property key="ProductNoProductsInCategory">
         <value xml:lang="de">Keine Produkte in der Kategorie</value>
         <value xml:lang="en">No products in category</value>

Added: ofbiz/trunk/applications/product/data/ProductPortletData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductPortletData.xml?rev=788976&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductPortletData.xml (added)
+++ ofbiz/trunk/applications/product/data/ProductPortletData.xml Sat Jun 27 14:15:15 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<entity-engine-xml>
+    
+    <PortletCategory portletCategoryId="PRODUCTS" description="List of Products"/>
+    <PortalPortlet portalPortletId="BestSellingProducts"
+        portletName="List of Days Best Selling Products"
+        screenName="BestSellingProducts"
+        screenLocation="component://product/widget/catalog/ProductScreens.xml"
+        description="List of best selling products of the day"/>
+    <PortletPortletCategory portalPortletId="BestSellingProducts" portletCategoryId="PRODUCTS"/>
+
+</entity-engine-xml>
\ No newline at end of file

Propchange: ofbiz/trunk/applications/product/data/ProductPortletData.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/product/data/ProductPortletData.xml
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/product/data/ProductPortletData.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/applications/product/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/ofbiz-component.xml?rev=788976&r1=788975&r2=788976&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/product/ofbiz-component.xml Sat Jun 27 14:15:15 2009
@@ -38,6 +38,7 @@
     <entity-resource type="data" reader-name="demo" loader="main" location="data/ProductUserDemoData.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/ApiSchemaDhl.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/DimensionTypeData.xml"/>
+    <entity-resource type="data" reader-name="seed" loader="main" location="data/ProductPortletData.xml"/>
 
     <service-resource type="model" loader="main" location="servicedef/services.xml"/>
     <service-resource type="model" loader="main" location="servicedef/services_facility.xml"/>

Added: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy?rev=788976&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy (added)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy Sat Jun 27 14:15:15 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * For cases when the ApplyFeaturesFromCategory.ftl is actually supposed to get its list of ProductFeatures from a productFeatureGroupId.
+ * Puts productFeatureGroup and productFeatures which are put of this group into the context.  Currently does not break out the features by view size.
+ */
+
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
+
+bestSellingProducts = [];
+exprList = [];
+exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.getDayStart(filterDate)));
+exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, UtilDateTime.getDayEnd(filterDate)));
+exprList.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"));
+
+orderHeaderList = delegator.findList("OrderHeader", EntityCondition.makeCondition(exprList, EntityOperator.AND), null, null, null, false);
+
+orderHeaderList.each { orderHeader ->
+    exprList = [];
+    exprList.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderHeader.orderId));
+    exprList.add(EntityCondition.makeCondition("orderItemTypeId", EntityOperator.EQUALS, "PRODUCT_ORDER_ITEM"));
+    exprList.add(EntityCondition.makeCondition("isPromo", EntityOperator.EQUALS, "N"));
+    orderItemList = delegator.findList("OrderItem", EntityCondition.makeCondition(exprList, EntityOperator.AND), null, null, null, false);
+    
+    orderItemList.each { orderItem ->
+        orderItemDetail = [:];
+        qtyOrdered = BigDecimal.ZERO;
+        qtyOrdered += orderItem.quantity;
+        if (orderItem.cancelQuantity) {
+            qtyOrdered -= orderItem.cancelQuantity;
+        }
+        amount = BigDecimal.ZERO;;
+        amount = qtyOrdered * orderItem.unitPrice;
+        inListFlag = false
+        
+        bestSellingProducts.each { bestSellingProduct ->
+            if ((bestSellingProduct.productId).equals(orderItem.productId)) {
+                inListFlag = true;
+                bestSellingProduct.amount += amount;
+                bestSellingProduct.qtyOrdered += qtyOrdered;
+            }
+        }
+        
+        if (inListFlag == false) {
+            orderItemDetail.productId = orderItem.productId;
+            orderItemDetail.amount = amount;
+            orderItemDetail.qtyOrdered = qtyOrdered;
+            bestSellingProducts.add(orderItemDetail);
+        }
+    }
+}
+
+// Sorting List
+topSellingProducts = [];
+itr = 1;
+while (itr <= 5) {
+    orderItemDetail = [:];
+    bestSellingProducts.each { bestSellingProduct ->
+        if (!(orderItemDetail.isEmpty())) {
+            if (bestSellingProduct.qtyOrdered > orderItemDetail.qtyOrdered) {
+                orderItemDetail = bestSellingProduct;
+            }
+            if (bestSellingProduct.qtyOrdered == orderItemDetail.qtyOrdered && bestSellingProduct.amount > orderItemDetail.amount) {
+                orderItemDetail = bestSellingProduct;
+            }
+        } else {
+            orderItemDetail = bestSellingProduct;
+        }
+    }
+    if (!orderItemDetail.isEmpty()) {
+        topSellingProducts.add(orderItemDetail);
+        bestSellingProducts.remove(orderItemDetail);
+    }
+    itr++;
+}
+
+context.bestSellingProducts= topSellingProducts;
\ No newline at end of file

Propchange: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml?rev=788976&r1=788975&r2=788976&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/product/ProductForms.xml Sat Jun 27 14:15:15 2009
@@ -1887,4 +1887,14 @@
         </field>
         <field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
+    
+    <form name="ListBestProduct" type="list" paginate="false" list-name="bestSellingProducts" view-size="5"
+            header-row-style="header-row" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+        <row-actions>
+            <entity-one entity-name="Product" value-field="product"/>
+        </row-actions>
+        <field name="productName"><display description="${product.productName}"/></field>
+        <field name="amount"><display/></field>
+        <field name="qtyOrdered"><display/></field>
+    </form>
  </forms>

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml?rev=788976&r1=788975&r2=788976&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml Sat Jun 27 14:15:15 2009
@@ -1816,4 +1816,31 @@
             </widgets>
         </section>
     </screen>
+    
+    <screen name="BestSellingProducts">
+        <section>
+            <actions>
+                <set field="filterDate" type="Timestamp" from-field="nowTimestamp"/>
+                <set field="date" type="Date" from-field="nowTimestamp"/>
+                <script location="component://product/webapp/catalog/WEB-INF/actions/product/BestProducts.groovy"/>
+            </actions>
+            <widgets>
+                <screenlet title="${uiLabelMap.ProductBestSellingProductsOf} ${date}">
+                    <section>
+                        <condition>
+                            <not>
+                                <if-empty field="bestSellingProducts"/>
+                            </not>
+                        </condition>
+                        <widgets>
+                            <include-form name="ListBestProduct" location="component://product/webapp/catalog/product/ProductForms.xml"/>
+                        </widgets>
+                        <fail-widgets>
+                            <label style="h3" text="${uiLabelMap.ProductNoProductFound}"></label>
+                        </fail-widgets>
+                    </section>
+                </screenlet>
+            </widgets>
+        </section>
+    </screen>
 </screens>