You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/04/18 23:13:37 UTC

svn commit: r530158 - in /ofbiz/trunk/applications/order: servicedef/ src/org/ofbiz/order/order/ webapp/ordermgr/WEB-INF/ webapp/ordermgr/WEB-INF/actions/order/ webapp/ordermgr/order/

Author: jaz
Date: Wed Apr 18 14:13:36 2007
New Revision: 530158

URL: http://svn.apache.org/viewvc?view=rev&rev=530158
Log:
refactored order find; now uses a re-usable service to do lookups; a lot more powerful now utilizing dynamic view entity; will also now lookup inventory items (serial number, soft identifier) from orders issued to shipments; will also now query all variant products when search by a virtual ID; can now pass a list of values  (status, store, website, etc) so that multi-select can be enbaled (not yet enabled in the UI)

Added:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java   (with props)
Modified:
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/findOrders.bsh
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?view=diff&rev=530158&r1=530157&r2=530158
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Wed Apr 18 14:13:36 2007
@@ -672,4 +672,75 @@
         <attribute name="orderItemValue" type="BigDecimal" mode="OUT" optional="true"/>
     </service>
 
+    <!-- order lookup services -->
+    <service name="findOrders" engine="java" transaction-timeout="300" auth="true"
+            location="org.ofbiz.order.order.OrderLookupServices" invoke="findOrders">
+        <description>Uses dynamic view entity to find orders; returns a list of Order (OrderHeader) objects</description>
+        <!-- order header fields -->
+        <attribute name="orderId" type="String" mode="IN" optional="true"/>
+        <attribute name="orderName" type="String" mode="IN" optional="true"/>
+        <attribute name="orderTypeId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="orderStatusId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="productStoreId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="orderWebSiteId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="salesChannelEnumId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="createdBy" type="String" mode="IN" optional="true"/>
+        <attribute name="terminalId" type="String" mode="IN" optional="true"/>
+        <attribute name="transactionId" type="String" mode="IN" optional="true"/>
+        <attribute name="externalId" type="String" mode="IN" optional="true"/>
+        <attribute name="internalCode" type="String" mode="IN" optional="true"/>
+        <attribute name="useEntryDate" type="String" mode="IN" optional="true"/> <!-- Y/N use entryDate instead of orderDate -->
+        <attribute name="minDate" type="String" mode="IN" optional="true"/> <!-- converted to Timestamp -->
+        <attribute name="maxDate" type="String" mode="IN" optional="true"/> <!-- converted to Timestamp -->
+
+        <!-- order role fields -->
+        <attribute name="userLoginId" type="String" mode="IN" optional="true"/>
+        <attribute name="roleTypeId" type="List" mode="IN" optional="true"/> <!-- can pass multiple values as list -->
+        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+
+        <!-- order item fields -->
+        <attribute name="correspondingPoId" type="String" mode="IN" optional="true"/>
+        <attribute name="subscriptionId" type="String" mode="IN" optional="true"/>
+        <attribute name="productId" type="String" mode="IN" optional="true"/>
+        <attribute name="budgetId" type="String" mode="IN" optional="true"/>
+        <attribute name="quoteId" type="String" mode="IN" optional="true"/>
+
+        <attribute name="billingAccountId" type="String" mode="IN" optional="true"/>
+        <attribute name="finAccountId" type="String" mode="IN" optional="true"/>
+        <attribute name="cardNumber" type="String" mode="IN" optional="true"/>
+        <attribute name="accountNumber" type="String" mode="IN" optional="true"/>
+
+        <!-- shipment/inventory fields -->
+        <attribute name="inventoryItemId" type="String" mode="IN" optional="true"/>
+        <attribute name="softIdentifier" type="String" mode="IN" optional="true"/>
+        <attribute name="serialNumber" type="String" mode="IN" optional="true"/>
+        <attribute name="shipmentId" type="String" mode="IN" optional="true"/>
+
+        <!-- inventory problem fields -->
+        <attribute name="filterInventoryProblems" type="String" mode="IN" optional="true"/>
+        <attribute name="filterPOsWithRejectedItems" type="String" mode="IN" optional="true"/>
+        <attribute name="filterPOsOpenPastTheirETA" type="String" mode="IN" optional="true"/>
+        <attribute name="filterPartiallyReceivedPOs" type="String" mode="IN" optional="true"/>
+
+        <!-- view and page fields -->
+        <attribute name="viewIndex" type="Integer" mode="INOUT" optional="false"/>
+        <attribute name="viewSize" type="Integer" mode="INOUT" optional="false"/>
+        <attribute name="showAll" type="String" mode="INOUT" optional="true"/>
+
+        <!-- index fields -->
+        <attribute name="highIndex" type="Integer" mode="OUT" optional="false"/>
+        <attribute name="lowIndex" type="Integer" mode="OUT" optional="false"/>
+
+        <!-- inventory problem results -->
+        <attribute name="filterInventoryProblemsList" type="List" mode="OUT" optional="true"/>
+        <attribute name="filterPOsWithRejectedItemsList" type="List" mode="OUT" optional="true"/>
+        <attribute name="filterPOsOpenPastTheirETAList" type="List" mode="OUT" optional="true"/>
+        <attribute name="filterPartiallyReceivedPOsList" type="List" mode="OUT" optional="true"/>
+
+        <!-- actual results -->
+        <attribute name="paramList" type="String" mode="OUT" optional="false"/>
+        <attribute name="orderList" type="List" mode="OUT" optional="false"/>
+        <attribute name="orderListSize" type="Integer" mode="OUT" optional="false"/>
+    </service>
+
 </services>

Added: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java?view=auto&rev=530158
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java (added)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java Wed Apr 18 14:13:36 2007
@@ -0,0 +1,627 @@
+/*
+ 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.
+ */
+
+package org.ofbiz.order.order;
+
+import javolution.util.FastList;
+import org.ofbiz.base.util.*;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.model.DynamicViewEntity;
+import org.ofbiz.entity.model.ModelKeyMap;
+import org.ofbiz.entity.util.EntityFindOptions;
+import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.security.Security;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
+
+import java.math.BigDecimal;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * OrderLookupServices
+ */
+public class OrderLookupServices {
+
+    public static final String module = OrderLookupServices.class.getName();
+
+    public static Map findOrders(DispatchContext dctx, Map context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericDelegator delegator = dctx.getDelegator();
+        Security security = dctx.getSecurity();
+
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Integer viewIndex = (Integer) context.get("viewIndex");
+        Integer viewSize = (Integer) context.get("viewSize");
+        String showAll = (String) context.get("showAll");
+        String useEntryDate = (String) context.get("useEntryDate");
+        if (showAll == null) {
+            showAll = "N";
+        }
+
+        // list of fields to select (initial list)
+        List fieldsToSelect = FastList.newInstance();
+        fieldsToSelect.add("orderId");
+        fieldsToSelect.add("statusId");
+        fieldsToSelect.add("orderTypeId");
+        fieldsToSelect.add("orderDate");
+        fieldsToSelect.add("currencyUom");
+        fieldsToSelect.add("grandTotal");
+        fieldsToSelect.add("remainingSubTotal");
+
+        // sorting by order date newest first
+        List orderBy = UtilMisc.toList("-orderDate", "-orderId");
+
+        // list to hold the parameters
+        List paramList = FastList.newInstance();
+
+        // list of conditions
+        List conditions = FastList.newInstance();
+
+        // check security flag for purchase orders
+        boolean canViewPo = security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", userLogin);
+        if (!canViewPo) {
+            conditions.add(new EntityExpr("orderTypeId", EntityOperator.NOT_EQUAL, "PURCHASE_ORDER"));
+        }
+
+        // dynamic view entity
+        DynamicViewEntity dve = new DynamicViewEntity();
+        dve.addMemberEntity("OH", "OrderHeader");
+        dve.addAliasAll("OH", ""); // no prefix
+        dve.addRelation("one-nofk", "", "OrderType", UtilMisc.toList(new ModelKeyMap("orderTypeId", "orderTypeId")));
+        dve.addRelation("one-nofk", "", "StatusItem", UtilMisc.toList(new ModelKeyMap("statusId", "statusId")));
+
+        // start the lookup
+        String orderId = (String) context.get("orderId");
+        if (UtilValidate.isNotEmpty(orderId)) {
+            paramList.add("orderId=" + orderId);
+            conditions.add(new EntityExpr("orderId", EntityOperator.EQUALS, orderId));
+        } else {
+            // the base order header fields
+            List orderTypeList = (List) context.get("orderTypeId");
+            if (orderTypeList != null) {
+                Iterator i = orderTypeList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String orderTypeId = (String) i.next();
+                    paramList.add("orderTypeId=" + orderTypeId);
+
+                    if (!"PURCHASE_ORDER".equals(orderTypeId) || ("PURCHASE_ORDER".equals(orderTypeId) && canViewPo)) {
+                        orExprs.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderTypeId));
+                    }
+                }
+            }
+
+            String orderName = (String) context.get("orderName");
+            if (UtilValidate.isNotEmpty(orderName)) {
+                paramList.add("orderName=" + orderName);
+                conditions.add(new EntityExpr("orderName", EntityOperator.LIKE, "%" + orderName + "%"));
+            }
+
+            List orderStatusList = (List) context.get("orderStatusId");
+            if (orderStatusList != null) {
+                Iterator i = orderStatusList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String orderStatusId = (String) i.next();
+                    paramList.add("orderStatusId=" + orderStatusId);
+                    if ("PENDING".equals(orderStatusId)) {
+                        List pendExprs = FastList.newInstance();
+                        pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_CREATED"));
+                        pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_PROCESSING"));
+                        pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_APPROVED"));
+                        orExprs.add(new EntityConditionList(pendExprs, EntityOperator.OR));
+                    } else {
+                        orExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatusId));
+                    }
+                }
+                conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+            }
+
+            List productStoreList = (List) context.get("productStoreId");
+            if (productStoreList != null) {
+                Iterator i = productStoreList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String productStoreId = (String) i.next();
+                    paramList.add("productStoreId=" + productStoreId);
+                    orExprs.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId));
+                }
+                conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+            }
+
+            List webSiteList = (List) context.get("orderWebSiteId");
+            if (webSiteList != null) {
+                Iterator i = webSiteList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String webSiteId = (String) i.next();
+                    paramList.add("webSiteId=" + webSiteId);
+                    orExprs.add(new EntityExpr("webSiteId", EntityOperator.EQUALS, webSiteId));
+                }
+                conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+            }
+
+            List saleChannelList = (List) context.get("salesChannelEnumId");
+            if (saleChannelList != null) {
+                Iterator i = saleChannelList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String salesChannelEnumId = (String) i.next();
+                    paramList.add("salesChannelEnumId=" + salesChannelEnumId);
+                    orExprs.add(new EntityExpr("salesChannelEnumId", EntityOperator.EQUALS, salesChannelEnumId));
+                }
+                conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+            }
+
+            String createdBy = (String) context.get("createdBy");
+            if (UtilValidate.isNotEmpty(createdBy)) {
+                paramList.add("createdBy=" + createdBy);
+                conditions.add(new EntityExpr("createdBy", EntityOperator.EQUALS, createdBy));
+            }
+
+            String terminalId = (String) context.get("terminalId");
+            if (UtilValidate.isNotEmpty(terminalId)) {
+                paramList.add("terminalId=" + terminalId);
+                conditions.add(new EntityExpr("terminalId", EntityOperator.EQUALS, terminalId));
+            }
+
+            String transactionId = (String) context.get("transactionId");
+            if (UtilValidate.isNotEmpty(transactionId)) {
+                paramList.add("transactionId=" + transactionId);
+                conditions.add(new EntityExpr("transactionId", EntityOperator.EQUALS, transactionId));
+            }
+
+            String externalId = (String) context.get("externalId");
+            if (UtilValidate.isNotEmpty(externalId)) {
+                paramList.add("externalId=" + externalId);
+                conditions.add(new EntityExpr("externalId", EntityOperator.EQUALS, externalId));
+            }
+
+            String internalCode = (String) context.get("internalCode");
+            if (UtilValidate.isNotEmpty(internalCode)) {
+                paramList.add("internalCode=" + internalCode);
+                conditions.add(new EntityExpr("internalCode", EntityOperator.EQUALS, internalCode));
+            }
+
+            String dateField = "Y".equals(useEntryDate) ? "entryDate" : "orderDate";
+            String minDate = (String) context.get("minDate");
+            if (UtilValidate.isNotEmpty(minDate) && minDate.length() > 8) {
+                minDate = minDate.trim();
+                if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000";
+                paramList.add("minDate=" + minDate);
+
+                try {
+                    Object converted = ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null);
+                    if (converted != null) {
+                        conditions.add(new EntityExpr(dateField, EntityOperator.GREATER_THAN_EQUAL_TO, converted));
+                    }
+                } catch (GeneralException e) {
+                    Debug.logWarning(e.getMessage(), module);
+                }
+            }
+
+            String maxDate = (String) context.get("maxDate");
+            if (UtilValidate.isNotEmpty(minDate) && maxDate.length() > 8) {
+                maxDate = maxDate.trim();
+                if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999";
+                paramList.add("maxDate=" + maxDate);
+
+                try {
+                    Object converted = ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null);
+                    if (converted != null) {
+                        conditions.add(new EntityExpr("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, converted));
+                    }
+                } catch (GeneralException e) {
+                    Debug.logWarning(e.getMessage(), module);
+                }
+            }
+
+            // party (role) fields
+            String userLoginId = (String) context.get("userLoginId");
+            String partyId = (String) context.get("partyId");
+            List roleTypeList = (List) context.get("roleTypeId");
+
+            if (UtilValidate.isNotEmpty(userLoginId) && UtilValidate.isEmpty(partyId)) {
+                GenericValue ul = null;
+                try {
+                    ul = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", userLoginId));
+                } catch (GenericEntityException e) {
+                    Debug.logWarning(e.getMessage(), module);
+                }
+                if (ul != null) {
+                    partyId = ul.getString("partyId");
+                }
+            }
+
+            // add the role data to the view
+            if (roleTypeList != null || partyId != null) {
+                dve.addMemberEntity("OT", "OrderRole");
+                dve.addAlias("OT", "partyId");
+                dve.addAlias("OT", "roleTypeId");
+                dve.addViewLink("OH", "OT", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
+            }
+
+            if (UtilValidate.isNotEmpty(partyId)) {
+                paramList.add("partyId=" + partyId);
+                fieldsToSelect.add("partyId");
+                conditions.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));
+            }
+
+            if (roleTypeList != null) {
+                fieldsToSelect.add("roleTypeId");
+                Iterator i = roleTypeList.iterator();
+                List orExprs = FastList.newInstance();
+                while (i.hasNext()) {
+                    String roleTypeId = (String) i.next();
+                    paramList.add("roleTypeId=" + roleTypeId);
+                    orExprs.add(new EntityExpr("roleTypeId", EntityOperator.EQUALS, roleTypeId));
+                }
+                conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+            }
+            
+            // order item fields
+            String correspondingPoId = (String) context.get("correspondingPoId");
+            String subscriptionId = (String) context.get("subscriptionId");
+            String productId = (String) context.get("productId");
+            String budgetId = (String) context.get("budgetId");
+            String quoteId = (String) context.get("quoteId");
+
+            if (correspondingPoId != null || subscriptionId != null || productId != null || budgetId != null || quoteId != null) {
+                dve.addMemberEntity("OI", "OrderItem");
+                dve.addAlias("OI", "correspondingPoId");
+                dve.addAlias("OI", "subscriptionId");
+                dve.addAlias("OI", "productId");
+                dve.addAlias("OI", "budgetId");
+                dve.addAlias("OI", "quoteId");
+                dve.addViewLink("OH", "OI", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
+            }
+
+            if (UtilValidate.isNotEmpty(correspondingPoId)) {
+                paramList.add("correspondingPoId=" + correspondingPoId);
+                conditions.add(new EntityExpr("correspondingPoId", EntityOperator.EQUALS, correspondingPoId));
+            }
+
+            if (UtilValidate.isNotEmpty(subscriptionId)) {
+                paramList.add("subscriptionId=" + subscriptionId);
+                conditions.add(new EntityExpr("subscriptionId", EntityOperator.EQUALS, subscriptionId));
+            }
+
+            if (UtilValidate.isNotEmpty(productId)) {
+                paramList.add("productId=" + productId);
+                GenericValue product = null;
+                try {
+                    product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
+                } catch (GenericEntityException e) {
+                    Debug.logWarning(e.getMessage(), module);
+                }
+                if (product != null) {
+                    String isVirtual = product.getString("isVirtual");
+                    if (isVirtual != null && "Y".equals(isVirtual)) {
+                        List orExprs = FastList.newInstance();
+                        orExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));
+
+                        Map varLookup = null;
+                        try {
+                            varLookup = dispatcher.runSync("getAllProductVariants", UtilMisc.toMap("productId", productId));
+                        } catch (GenericServiceException e) {
+                            Debug.logWarning(e.getMessage(), module);
+                        }
+                        List variants = (List) varLookup.get("assocProducts");
+                        if (variants != null) {
+                            Iterator i = variants.iterator();
+                            while (i.hasNext()) {
+                                GenericValue v = (GenericValue) i.next();
+                                orExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, v.getString("productIdTo")));
+                            }
+                        }
+                        conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
+                    } else {
+                        conditions.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));
+                    }
+                }                                
+            }
+
+            if (UtilValidate.isNotEmpty(budgetId)) {
+                paramList.add("budgetId=" + budgetId);
+                conditions.add(new EntityExpr("budgetId", EntityOperator.EQUALS, budgetId));
+            }
+
+            if (UtilValidate.isNotEmpty(quoteId)) {
+                paramList.add("quoteId=" + quoteId);
+                conditions.add(new EntityExpr("quoteId", EntityOperator.EQUALS, quoteId));
+            }
+
+            // payment preference fields
+            String billingAccountId = (String) context.get("billingAccountId");
+            String finAccountId = (String) context.get("finAccountId");
+            String cardNumber = (String) context.get("cardNumber");
+            String accountNumber = (String) context.get("accountNumber");
+
+            if (billingAccountId != null || finAccountId != null || cardNumber != null || accountNumber != null) {
+                dve.addMemberEntity("OP", "OrderPaymentPreference");
+                dve.addAlias("OP", "billingAccountId");
+                dve.addAlias("OP", "finAccountId");
+                dve.addAlias("OP", "paymentMethodId");
+                dve.addViewLink("OH", "OP", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
+            }
+
+            // search by billing account ID
+            if (UtilValidate.isNotEmpty(billingAccountId)) {
+                paramList.add("billingAccountId=" + billingAccountId);
+                conditions.add(new EntityExpr("billingAccountId", EntityOperator.EQUALS, billingAccountId));
+            }
+
+            // search by fin account ID
+            if (UtilValidate.isNotEmpty(finAccountId)) {
+                paramList.add("finAccountId=" + finAccountId);
+                conditions.add(new EntityExpr("finAccountId", EntityOperator.EQUALS, finAccountId));
+            }
+
+            // search by card number
+            if (UtilValidate.isNotEmpty(cardNumber)) {
+                dve.addMemberEntity("CC", "CreditCard");
+                dve.addAlias("CC", "cardNumber");
+                dve.addViewLink("OP", "CC", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("paymentMethodId", "paymentMethodId")));
+
+                paramList.add("cardNumber=" + cardNumber);
+                conditions.add(new EntityExpr("cardNumber", EntityOperator.EQUALS, cardNumber));
+            }
+
+            // search by eft account number
+            if (UtilValidate.isNotEmpty(accountNumber)) {
+                dve.addMemberEntity("EF", "EftAccount");
+                dve.addAlias("EF", "accountNumber");
+                dve.addViewLink("OP", "EF", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("paymentMethodId", "paymentMethodId")));
+
+                paramList.add("accountNumber=" + accountNumber);
+                conditions.add(new EntityExpr("accountNumber", EntityOperator.EQUALS, accountNumber));
+            }
+
+            // shipment/inventory item
+            String inventoryItemId = (String) context.get("inventoryItemId");
+            String softIdentifier = (String) context.get("softIdentifier");
+            String serialNumber = (String) context.get("serialNumber");
+            String shipmentId = (String) context.get("shipmentId");
+
+            if (shipmentId != null || inventoryItemId != null || softIdentifier != null || serialNumber != null) {
+                dve.addMemberEntity("II", "ItemIssuance");
+                dve.addAlias("II", "shipmentId");
+                dve.addAlias("II", "inventoryItemId");
+                dve.addViewLink("OH", "II", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
+
+                if (softIdentifier != null || serialNumber != null) {
+                    dve.addMemberEntity("IV", "InventoryItem");
+                    dve.addAlias("IV", "softIdentifier");
+                    dve.addAlias("IV", "serialNumber");
+                    dve.addViewLink("II", "IV", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("inventoryItemId", "inventoryItemId")));
+                }
+            }
+
+            if (UtilValidate.isNotEmpty(inventoryItemId)) {
+                paramList.add("inventoryItemId=" + inventoryItemId);
+                conditions.add(new EntityExpr("inventoryItemId", EntityOperator.EQUALS, inventoryItemId));
+            }
+
+            if (UtilValidate.isNotEmpty(softIdentifier)) {
+                paramList.add("softIdentifier=" + softIdentifier);
+                conditions.add(new EntityExpr("softIdentifier", EntityOperator.EQUALS, softIdentifier));
+            }
+
+            if (UtilValidate.isNotEmpty(serialNumber)) {
+                paramList.add("serialNumber=" + serialNumber);
+                conditions.add(new EntityExpr("serialNumber", EntityOperator.EQUALS, serialNumber));
+            }
+
+            if (UtilValidate.isNotEmpty(shipmentId)) {
+                paramList.add("shipmentId=" + shipmentId);
+                conditions.add(new EntityExpr("shipmentId", EntityOperator.EQUALS, shipmentId));
+            }
+
+            // back order checking
+            String hasBackOrders = (String) context.get("hasBackOrders");
+            if (UtilValidate.isNotEmpty(hasBackOrders)) {
+                dve.addMemberEntity("IR", "OrderItemShipGrpInvRes");
+                dve.addAlias("IR", "quantityNotAvailable");
+                dve.addViewLink("OH", "IR", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
+
+                paramList.add("hasBackOrders=" + hasBackOrders);
+                if ("Y".equals(hasBackOrders)) {
+                    conditions.add(new EntityExpr("quantityNotAvailable", EntityOperator.NOT_EQUAL, null));
+                    conditions.add(new EntityExpr("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0)));
+                } else if ("N".equals(hasBackOrders)) {
+                    List orExpr = FastList.newInstance();
+                    orExpr.add(new EntityExpr("quantityNotAvailable", EntityOperator.EQUALS, null));
+                    orExpr.add(new EntityExpr("quantityNotAvailable", EntityOperator.EQUALS, new Double(0)));
+                    conditions.add(new EntityConditionList(orExpr, EntityOperator.OR));
+                }
+            }
+        }
+
+        // set distinct on so we only get one row per order
+        EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true);
+
+        // create the main condition
+        EntityCondition cond = null;
+        if (conditions.size() > 0 || showAll.equalsIgnoreCase("Y")) {
+            cond = new EntityConditionList(conditions, EntityOperator.AND);
+        }
+
+        if (Debug.verboseOn()) {
+            Debug.log("Find order query: " + cond.toString());
+        }
+
+        List orderList = FastList.newInstance();
+        int orderCount = 0;
+
+        // get the index for the partial list
+        int lowIndex = (((viewIndex.intValue() - 1) * viewSize.intValue()) + 1);
+        int highIndex = viewIndex.intValue() * viewSize.intValue();
+
+        if (cond != null) {
+            EntityListIterator eli = null;
+            try {
+                // do the lookup
+                eli = delegator.findListIteratorByCondition(dve, cond, null, fieldsToSelect, orderBy, findOpts);
+
+                // attempt to get the full size
+                eli.last();
+                orderCount = eli.currentIndex();
+
+                // get the partial list for this page
+                eli.beforeFirst();
+                if (orderCount > viewSize.intValue()) {
+                    orderList = eli.getPartialList(lowIndex, viewSize.intValue());
+                } else if (orderCount > 0) {
+                    orderList = eli.getCompleteList();
+                }
+
+                if (highIndex > orderCount) {
+                    highIndex = orderCount;
+                }
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+                return ServiceUtil.returnError(e.getMessage());
+            } finally {
+                if (eli != null) {
+                    try {
+                        eli.close();
+                    } catch (GenericEntityException e) {
+                        Debug.logWarning(e, e.getMessage(), module);
+                    }
+                }
+            }
+        }
+
+        // create the result map
+        Map result = ServiceUtil.returnSuccess();
+
+        // filter out requested inventory problems
+        filterInventoryProblems(context, result, orderList, paramList);
+
+        // format the param list
+        String paramString = StringUtil.join(paramList, "&amp;");
+
+        result.put("highIndex", new Integer(highIndex));
+        result.put("lowIndex", new Integer(lowIndex));
+        result.put("viewIndex", viewIndex);
+        result.put("viewSize", viewSize);
+        result.put("showAll", showAll);
+
+        result.put("paramList", paramString);
+        result.put("orderList", orderList);
+        result.put("orderListSize", new Integer(orderCount));
+
+        return result;
+    }
+
+    public static void filterInventoryProblems(Map context, Map result, List orderList, List paramList) {
+        List filterInventoryProblems = FastList.newInstance();
+
+        String doFilter = (String) context.get("filterInventoryProblems");
+        if (doFilter == null) {
+            doFilter = "N";
+        }
+
+        if ("Y".equals(doFilter) && orderList.size() > 0) {
+            paramList.add("filterInventoryProblems=Y");
+            Iterator i = orderList.iterator();
+            while (i.hasNext()) {
+                GenericValue orderHeader = (GenericValue) i.next();
+                OrderReadHelper orh = new OrderReadHelper(orderHeader);
+                BigDecimal backorderQty = orh.getOrderBackorderQuantityBd();
+                if (backorderQty.compareTo(new BigDecimal("0")) == 1) {
+                    filterInventoryProblems.add(orh.getOrderId());
+                }
+            }
+        }
+
+        List filterPOsOpenPastTheirETA = FastList.newInstance();
+        List filterPOsWithRejectedItems = FastList.newInstance();
+        List filterPartiallyReceivedPOs = FastList.newInstance();
+
+        String filterPOReject = (String) context.get("filterPOsWithRejectedItems");
+        String filterPOPast = (String) context.get("filterPOsOpenPastTheirETA");
+        String filterPartRec = (String) context.get("filterPartiallyReceivedPOs");
+        if (filterPOReject == null) {
+            filterPOReject = "N";
+        }
+        if (filterPOPast == null) {
+            filterPOPast = "N";
+        }
+        if (filterPartRec == null) {
+            filterPartRec = "N";
+        }
+
+        boolean doPoFilter = false;
+        if ("Y".equals(filterPOReject)) {
+            paramList.add("filterPOsWithRejectedItems=Y");
+            doPoFilter = true;
+        }
+        if ("Y".equals(filterPOPast)) {
+            paramList.add("filterPOsOpenPastTheirETA=Y");
+            doPoFilter = true;
+        }
+        if ("Y".equals(filterPartRec)) {
+            paramList.add("filterPartiallyReceivedPOs=Y");
+            doPoFilter = true;
+        }
+
+        if (doPoFilter && orderList.size() > 0) {
+            Iterator i = orderList.iterator();
+            while (i.hasNext()) {
+                GenericValue orderHeader = (GenericValue) i.next();
+                OrderReadHelper orh = new OrderReadHelper(orderHeader);
+                String orderType = orh.getOrderTypeId();
+                String orderId = orh.getOrderId();
+
+                if ("PURCHASE_ORDER".equals(orderType)) {
+                    if ("Y".equals(filterPOReject) && orh.getRejectedOrderItems()) {
+                        filterPOsWithRejectedItems.add(orderId);
+                    }
+                    else if ("Y".equals(filterPOPast) && orh.getPastEtaOrderItems(orderId)) {
+                        filterPOsOpenPastTheirETA.add(orderId);
+                    }
+                    else if ("Y".equals(filterPartRec) && orh.getPartiallyReceivedItems()) {
+                        filterPartiallyReceivedPOs.add(orderId);
+                    }
+                }
+            }
+        }
+
+        result.put("filterInventoryProblemsList", filterInventoryProblems);
+        result.put("filterPOsWithRejectedItemsList", filterPOsWithRejectedItems);
+        result.put("filterPOsOpenPastTheirETAList", filterPOsOpenPastTheirETA);
+        result.put("filterPartiallyReceivedPOsList", filterPartiallyReceivedPOs);
+    }
+
+    protected boolean validateField(String field) {
+        boolean notEmpty = UtilValidate.isNotEmpty(field);
+        return notEmpty && !"ANY".equals(field);
+    }
+}

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/findOrders.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/findOrders.bsh?view=diff&rev=530158&r1=530157&r2=530158
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/findOrders.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/findOrders.bsh Wed Apr 18 14:13:36 2007
@@ -19,15 +19,8 @@
 
 import java.util.*;
 import java.sql.Timestamp;
-import java.math.BigDecimal;
 import org.ofbiz.entity.*;
-import org.ofbiz.entity.util.*;
-import org.ofbiz.entity.condition.*;
-import org.ofbiz.entity.transaction.*;
 import org.ofbiz.base.util.*;
-import org.ofbiz.product.product.*;
-import org.ofbiz.order.order.OrderReadHelper;
-import org.ofbiz.product.store.ProductStoreWorker;
 
 module = "findOrders.bsh";
 
@@ -79,7 +72,7 @@
 }
 
 // current website
-currentWebSiteId = request.getParameter("webSiteId");
+currentWebSiteId = request.getParameter("orderWebSiteId");
 if (currentWebSiteId != null && currentWebSiteId.length() > 0) {
     currentWebSite = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", currentWebSiteId));
     context.put("currentWebSite", currentWebSite);
@@ -102,7 +95,7 @@
 // create the fromDate for calendar
 fromCal = Calendar.getInstance();
 fromCal.setTime(new java.util.Date());
-//fromCal.set(Calendar.DAY_OF_WEEK, fromCal.getActualMinimum(Calendar.DAY_OF_WEEK));
+fromCal.set(Calendar.DAY_OF_WEEK, fromCal.getActualMinimum(Calendar.DAY_OF_WEEK));
 fromCal.set(Calendar.HOUR_OF_DAY, fromCal.getActualMinimum(Calendar.HOUR_OF_DAY));
 fromCal.set(Calendar.MINUTE, fromCal.getActualMinimum(Calendar.MINUTE));
 fromCal.set(Calendar.SECOND, fromCal.getActualMinimum(Calendar.SECOND));
@@ -115,7 +108,7 @@
 // create the thruDate for calendar
 toCal = Calendar.getInstance();
 toCal.setTime(new java.util.Date());
-//toCal.set(Calendar.DAY_OF_WEEK, toCal.getActualMaximum(Calendar.DAY_OF_WEEK));
+toCal.set(Calendar.DAY_OF_WEEK, toCal.getActualMaximum(Calendar.DAY_OF_WEEK));
 toCal.set(Calendar.HOUR_OF_DAY, toCal.getActualMaximum(Calendar.HOUR_OF_DAY));
 toCal.set(Calendar.MINUTE, toCal.getActualMaximum(Calendar.MINUTE));
 toCal.set(Calendar.SECOND, toCal.getActualMaximum(Calendar.SECOND));
@@ -127,7 +120,7 @@
 // set the page parameters
 viewIndex = 1;
 try {
-    viewIndex = Integer.valueOf((String) request.getParameter("VIEW_INDEX")).intValue();
+    viewIndex = Integer.valueOf((String) request.getParameter("viewIndex")).intValue();
 } catch (Exception e) {
     viewIndex = 1;
 }
@@ -135,7 +128,7 @@
 
 viewSize = 20;
 try {
-    viewSize = Integer.valueOf((String) request.getParameter("VIEW_SIZE")).intValue();
+    viewSize = Integer.valueOf((String) request.getParameter("viewSize")).intValue();
 } catch (Exception e) {
     viewSize = 20;
 }
@@ -144,321 +137,21 @@
 // get the lookup flag
 lookupFlag = request.getParameter("lookupFlag");
 
-// blank param list
-paramList = "";
-
-// defined
-orderHeaderList = null;
-orderHeaderListSize = 0;
-lowIndex = 0;
-highIndex = 0;
-
-if (lookupFlag != null) {
-    showAll = request.getParameter("showAll") != null ? request.getParameter("showAll") : "N";
-    paramList = paramList + "&amp;lookupFlag=" + lookupFlag + "&amp;showAll=" + showAll;
-    locale = UtilHttp.getLocale(request);
-    uiLabelMap = UtilProperties.getResourceBundleMap("OrderErrorUiLabels", locale);
-
-    lookupErrorMessage = null;
-    andExprs = new ArrayList();
-    entityName = "OrderHeader";
-
-    // check for a orderId (happens in some browsers)
-    orderId = request.getParameter("orderId");
-    if (orderId != null && orderId.length() > 0) {
-        paramList = paramList + "&amp;orderId=" + orderId;
-        andExprs.add(new EntityExpr("orderId", EntityOperator.EQUALS, orderId));
-    }
-
-    // find the orders for party
-    partyId = request.getParameter("partyId");
-    userLoginId = request.getParameter("userLoginId");
-    if (userLoginId != null && userLoginId.length() > 0) {
-        requestedUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", userLoginId));
-        if (requestedUserLogin != null) {
-            partyId = requestedUserLogin.getString("partyId");
-        } else {
-            lookupErrorMessage = uiLabelMap.get("OrderNoUserLoginFoundForUserLoginId") + userLoginId;
-        }
-    }
-
-    if (partyId != null && partyId.length() > 0) {
-        paramList = paramList + "&amp;partyId=" + partyId;
-        entityName = "OrderHeaderAndRoles";
-        andExprs.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));
-    }
-
-    // item related
-    correspondingPoId = request.getParameter("correspondingPoId");
-    if (correspondingPoId != null && correspondingPoId.length() > 0) {
-        paramList = paramList + "&amp;correspondingPoId=" + correspondingPoId;
-        entityName= "OrderHeaderItemAndRoles";
-        andExprs.add(new EntityExpr("correspondingPoId", EntityOperator.EQUALS, correspondingPoId));
-    }
-
-    productId = request.getParameter("productId");
-    if (productId != null && productId.length() > 0) {
-        paramList = paramList + "&amp;productId=" + productId;
-        entityName = "OrderHeaderItemAndRoles";
-        andExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, ProductWorker.findProductId(delegator, productId)));
-    }
-
-    hasBackOrders = request.getParameter("hasBackOrders");
-    if (hasBackOrders != null){
-        paramList = paramList + "&amp;hasBackOrders=" + hasBackOrders;
-        if ("Y".equals(hasBackOrders)) {
-            // Y = only show backorders
-        entityName = "OrderHeaderItemAndInvRoles";
-        andExprs.add(new EntityExpr("quantityNotAvailable", EntityOperator.NOT_EQUAL, null));
-        andExprs.add(new EntityExpr("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0)));
-        } else if ("N".equals(hasBackOrders)) {
-            // N = exclude backorders... we might also need to include and OR condition: qty not available == 0
-            entityName = "OrderHeaderItemAndInvRoles";
-            andExprs.add(new EntityExpr("quantityNotAvailable", EntityOperator.EQUALS, null));
-    }
-    }
-
-    
-
-    // define the main condition
-    mainCond = null;
-
-    // now do the filtering
-    if (lookupErrorMessage == null) {
-        roleType = request.getParameter("roleTypeId");
-        orderType = request.getParameter("orderTypeId");
-        orderStatus = request.getParameter("orderStatusId");
-        productStoreId = request.getParameter("productStoreId");
-        webSiteId = request.getParameter("webSiteId");
-        salesChannelEnumId = request.getParameter("salesChannelEnumId");
-
-        createdBy = request.getParameter("createdBy");
-        externalId = request.getParameter("externalId");
-        internalCode = request.getParameter("internalCode");
-        billAcct = request.getParameter("billingAccountId");
-        minDate = request.getParameter("minDate");
-        maxDate = request.getParameter("maxDate");
-
-        if (productStoreId == null) productStoreId = "ANY";
-        if (webSiteId == null) webSiteId = "ANY";
-        if (roleType == null) roleType = "ANY";
-        if (orderType == null) orderType = "ANY";
-        if (orderStatus == null) orderStatus = "ANY";
-        if (salesChannelEnumId == null) salesChannelEnumId = "ANY";
-
-        paramList = paramList + "&amp;productStoreId=" + productStoreId;
-        if (!"ANY".equals(productStoreId)) {
-            andExprs.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId));
-        }
-        paramList = paramList + "&amp;webSiteId=" + webSiteId;
-        if (!"ANY".equals(webSiteId)) {
-            andExprs.add(new EntityExpr("webSiteId", EntityOperator.EQUALS, webSiteId));
-        }
-        paramList = paramList + "&amp;roleTypeId=" + roleType;
-        if (!"ANY".equals(roleType)) {
-            entityName = "OrderHeaderAndRoles";
-            andExprs.add(new EntityExpr("roleTypeId", EntityOperator.EQUALS, roleType));
-        }
-        paramList = paramList + "&amp;orderTypeId=" + orderType;
-        if (!"ANY".equals(orderType)) {
-            andExprs.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderType));
-        }
-        paramList = paramList + "&amp;orderStatusId=" + orderStatus;
-        if (!"ANY".equals(orderStatus)) {
-            andExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatus));
-        }
-        paramList = paramList + "&amp;salesChannelEnumId=" + salesChannelEnumId;
-        if (!"ANY".equals(salesChannelEnumId)) {
-            andExprs.add(new EntityExpr("salesChannelEnumId", EntityOperator.EQUALS, salesChannelEnumId));
-        }
-
-        if (billAcct != null && billAcct.length() > 0) {
-            paramList = paramList + "&amp;billingAccountId=" + billAcct;
-            andExprs.add(new EntityExpr("billingAccountId", EntityOperator.EQUALS, billAcct));
-        }
-        if (createdBy != null && createdBy.length() > 0) {
-            paramList = paramList + "&amp;createdBy=" + createdBy;
-            andExprs.add(new EntityExpr("createdBy", EntityOperator.EQUALS, createdBy));
-        }
-        if (externalId != null && externalId.length() > 0) {
-            paramList = paramList + "&amp;externalId=" + externalId;
-            andExprs.add(new EntityExpr("externalId", EntityOperator.EQUALS, externalId));
-        }
-        if (internalCode != null && internalCode.length() > 0) {
-            paramList = paramList + "&amp;internalCode=" + internalCode;
-            andExprs.add(new EntityExpr("internalCode", EntityOperator.EQUALS, internalCode));
-        }
-        if (minDate != null && minDate.length() > 8) {
-            minDate = minDate.trim();
-            if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000";
-            paramList = paramList + "&amp;minDate=" + minDate;
-            andExprs.add(new EntityExpr("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null)));
-        }
-        if (maxDate != null && maxDate.length() > 8) {
-            maxDate = maxDate.trim();
-            if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999";
-            paramList = paramList + "&amp;maxDate=" + maxDate;
-            andExprs.add(new EntityExpr("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null)));
-        }
-
-        if (andExprs.size() > 0 || showAll.equalsIgnoreCase("Y")) mainCond = new EntityConditionList(andExprs, EntityOperator.AND);
-
-    } else {
-        Debug.log("Error messages: " + lookupErrorMessage, module);
-    }
-
-    // do the lookup
-    if (lookupErrorMessage == null && mainCond != null) {
-        // field we need to select; will be used to set distinct
-        List fieldsToSelect = UtilMisc.toList("orderId", "orderTypeId", "orderDate", "currencyUom", "grandTotal", "remainingSubTotal");
-        fieldsToSelect.add("statusId");
-        if (!"OrderHeader".equals(entityName)) {
-            if (partyId != null && partyId.length() > 0) {
-                fieldsToSelect.add("partyId");
-            }
-            if (!"ANY".equals(roleType)) {
-                fieldsToSelect.add("roleTypeId");
-            }
-        }
-
-        // sorting by order date newest first
-        List orderBy = UtilMisc.toList("-orderDate", "-orderId");
-
-        // set distinct on so we only get one row per order
-        EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true);
-
-        boolean beganTransaction = false;
-        try {
-            beganTransaction = TransactionUtil.begin();
-
-            // using list iterator
-            EntityListIterator ohli = delegator.findListIteratorByCondition(entityName, mainCond, null, fieldsToSelect, orderBy, findOpts);
-
-            // get the indexes for the partial list
-            lowIndex = (((viewIndex - 1) * viewSize) + 1);
-            highIndex = viewIndex * viewSize;
-
-            // attempt to get the full size
-            ohli.last();
-            orderHeaderListSize = ohli.currentIndex();
-            if (highIndex > orderHeaderListSize) {
-                highIndex = orderHeaderListSize;
-            }
-
-            // get the partial list for this page
-            ohli.beforeFirst();
-            if (orderHeaderListSize > viewSize) {
-                orderHeaderList = ohli.getPartialList(lowIndex, viewSize);
-                //Debug.log("Got partial list [" + lowIndex + " / " + viewSize + "] : " + orderHeaderList);
-            } else if (orderHeaderListSize > 0) {
-                orderHeaderList = ohli.getCompleteList();
-                //Debug.log("Got full list [" + orderHeaderList.size() + "] : " + orderHeaderList);
-            } else {
-                orderHeaderList = new ArrayList();
-            }
-
-            // close the iterator
-            ohli.close();
-        } catch (GenericEntityException e) {
-            String errMsg = "Failure in operation, rolling back transaction";
-            Debug.logError(e, errMsg, module);
-            try {
-                // only rollback the transaction if we started one...
-                TransactionUtil.rollback(beganTransaction, errMsg, e);
-            } catch (GenericEntityException e2) {
-                Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module);
-            }
-            // after rolling back, rethrow the exception
-            throw e;
-        } finally {
-            // only commit the transaction if we started one... this will throw an exception if it fails
-            TransactionUtil.commit(beganTransaction);
-        }
-    } else {
-        orderHeaderList = new ArrayList();
-        orderHeaderListSize = 0;
-    }
-
-    // viewing of purchase orders requires a special permission.  if user doesn't have it, only SALES_ORDER
-    if (!security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", session)) {
-        orderHeaderList = EntityUtil.filterOutByCondition(orderHeaderList, new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"));
-    }
-    
-    productStore = ProductStoreWorker.getProductStore(request);
-    List filterInventoryProblems = new ArrayList();
-    
-    if ("Y".equals(parameters.get("filterInventoryProblems")) && UtilValidate.isNotEmpty(orderHeaderList)) {
-        paramList = paramList + "&amp;filterInventoryProblems=" + "Y";
-        for (ohi = orderHeaderList.iterator(); ohi.hasNext();) {
-            orderHeader = (GenericValue) ohi.next();
-            orderReadHelper = OrderReadHelper.getHelper(orderHeader);
-            backorderQty = orderReadHelper.getOrderBackorderQuantityBd();
-            if (backorderQty.compareTo(new BigDecimal("0")) == 1) {
-                filterInventoryProblems.add(orderHeader.get("orderId"));
-            }
-        }
-    }
-
-    List filterPOsOpenPastTheirETA = new ArrayList();
-    List filterPOsWithRejectedItems = new ArrayList();
-    List filterPartiallyReceivedPOs = new ArrayList();
-    
-    if ("Y".equals(parameters.get("filterPOsWithRejectedItems"))) {
-                        paramList = paramList + "&amp;filterPOsWithRejectedItems=" + "Y";
-    }    
-    if ("Y".equals(parameters.get("filterPOsOpenPastTheirETA"))) {
-                        paramList = paramList + "&amp;filterPOsOpenPastTheirETA=" + "Y";
-    }    
-    if ("Y".equals(parameters.get("filterPartiallyReceivedPOs"))) {
-                        paramList = paramList + "&amp;filterPartiallyReceivedPOs=" + "Y";
-    }
-        
-    if (("Y".equals(parameters.get("filterPartiallyReceivedPOs")) ||
-            "Y".equals(parameters.get("filterPOsOpenPastTheirETA")) ||
-            "Y".equals(parameters.get("filterPOsWithRejectedItems"))) &&
-            UtilValidate.isNotEmpty(orderHeaderList)) {
-        for (ohi = orderHeaderList.iterator(); ohi.hasNext();) {
-            orderHeader = (GenericValue) ohi.next();
-            facilityId = orderHeader.getString("originFacilityId");
-            if (facilityId == null) {
-            facilityId = productStore.getString("inventoryFacilityId");
-            }
-            orderReadHelper = OrderReadHelper.getHelper(orderHeader);
-            if ("PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) {                
-                if (orderReadHelper.getRejectedOrderItems() &&
-                        "Y".equals(parameters.get("filterPOsWithRejectedItems"))) {                    
-                    filterPOsWithRejectedItems.add(orderHeader.get("orderId"));
-                    paramList = paramList + "&amp;filterPOsWithRejectedItems=" + "Y";
-                    continue;
-                }
-                if (orderReadHelper.getPastEtaOrderItems(orderHeader.get("orderId")) &&
-                        "Y".equals(parameters.get("filterPOsOpenPastTheirETA"))) {
-                    filterPOsOpenPastTheirETA.add(orderHeader.get("orderId"));
-                    continue;
-                }
-                if (orderReadHelper.getPartiallyReceivedItems() &&
-                        "Y".equals(parameters.get("filterPartiallyReceivedPOs"))) {
-                    filterPartiallyReceivedPOs.add(orderHeader.get("orderId"));
-                    paramList = paramList + "&amp;filterPartiallyReceivedPOs=" + "Y";
-                    continue;
-                }            
-            }
-        }
-    }
-
-    context.put("filterInventoryProblems", filterInventoryProblems);
-    context.put("filterPOsWithRejectedItems", filterPOsWithRejectedItems);
-    context.put("filterPOsOpenPastTheirETA", filterPOsOpenPastTheirETA);
-    context.put("filterPartiallyReceivedPOs", filterPartiallyReceivedPOs);   
-
-    context.put("orderHeaderList", orderHeaderList);
-    context.put("orderHeaderListSize", orderHeaderListSize); // TODO : orderHeaderListSize here is not reactualized. Date from "if user doesn't have it, only SALES_ORDER" comment above...    
-
-    if (lookupErrorMessage != null) {
-        context.put("lookupErrorMessage", lookupErrorMessage);
-    }
+// fields from the service call
+paramList = request.getAttribute("paramList");
+if (paramList == null) {
+    paramList = "";
 }
-
 context.put("paramList", paramList);
-context.put("highIndex", highIndex);
+
+orderList = request.getAttribute("orderList");
+context.put("orderList", orderList);
+
+orderListSize = request.getAttribute("orderListSize");
+context.put("orderListSize", orderListSize);
+
+lowIndex = request.getAttribute("lowIndex");
 context.put("lowIndex", lowIndex);
+
+highIndex = request.getAttribute("highIndex");
+context.put("highIndex", highIndex);

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?view=diff&rev=530158&r1=530157&r2=530158
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Wed Apr 18 14:13:36 2007
@@ -110,6 +110,12 @@
         <security https="true" auth="true"/>
         <response name="success" type="view" value="findorders"/>
     </request-map>
+    <request-map uri="searchorders">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="findOrders"/>
+        <response name="success" type="view" value="findorders"/>
+        <response name="error" type="view" value="findorders"/>
+    </request-map>
     <request-map uri="tasklist">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="ordertasklist"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl?view=diff&rev=530158&r1=530157&r2=530158
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl Wed Apr 18 14:13:36 2007
@@ -25,7 +25,7 @@
         document.lookuporder.action = "<@o...@ofbizUrl>";
         document.lookuporder.method = "get";
     } else {
-        document.lookuporder.action = "<@o...@ofbizUrl>";
+        document.lookuporder.action = "<@o...@ofbizUrl>";
     }
 
     if (click) {
@@ -62,9 +62,12 @@
 </script>
 
 <#if security.hasEntityPermission("ORDERMGR", "_VIEW", session)>
-<form method="post" name="lookuporder" action="<@o...@ofbizUrl>" onsubmit="javascript:lookupOrders();">
+<form method="post" name="lookuporder" action="<@o...@ofbizUrl>" onsubmit="javascript:lookupOrders();">
 <input type="hidden" name="lookupFlag" value="Y"/>
 <input type="hidden" name="hideFields" value="Y"/>
+<input type="hidden" name="viewSize" value="${viewSize}"/>
+<input type="hidden" name="viewIndex" value="${viewIndex}"/>
+
 <table border="0" width='100%' cellspacing='0' cellpadding='0' class='boxoutside'>
   <tr>
     <td width='100%'>
@@ -74,9 +77,9 @@
           <td align='right'>
             <div class="tabletext">
               <#if requestParameters.hideFields?default("N") == "Y">
-                <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonShowLookupFields}</a>
+                <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonShowLookupFields}</a>
               <#else>
-                <#if orderHeaderList?exists><a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonHideFields}</a></#if>
+                <#if orderList?exists><a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonHideFields}</a></#if>
                 <a href="javascript:lookupOrders(true);" class="buttontext">${uiLabelMap.OrderLookupOrder}</a>
                 <a href="/partymgr/control/findparty?externalLoginKey=${requestAttributes.externalLoginKey?if_exists}" class="buttontext">${uiLabelMap.PartyLookupParty}</a>
               </#if>
@@ -115,6 +118,21 @@
                 <td><input type='text' class='inputBox' name='productId' value='${requestParameters.productId?if_exists}'/></td>
               </tr>
               <tr>
+                <td width='25%' align='right'><div class='tableheadtext'>${uiLabelMap.ProductInventoryItemId}</div></td>
+                <td width='5%'>&nbsp;</td>
+                <td><input type='text' class='inputBox' name='inventoryItemId' value='${requestParameters.inventoryItemId?if_exists}'/></td>
+              </tr>
+              <tr>
+                <td width='25%' align='right'><div class='tableheadtext'>${uiLabelMap.ProductSerialNumber}</div></td>
+                <td width='5%'>&nbsp;</td>
+                <td><input type='text' class='inputBox' name='serialNumber' value='${requestParameters.serialNumber?if_exists}'/></td>
+              </tr>
+              <tr>
+                <td width='25%' align='right'><div class='tableheadtext'>${uiLabelMap.ProductSoftIdentifier}</div></td>
+                <td width='5%'>&nbsp;</td>
+                <td><input type='text' class='inputBox' name='softIdentifier' value='${requestParameters.softIdentifier?if_exists}'/></td>
+              </tr>
+              <tr>
                 <td width='25%' align='right'><div class='tableheadtext'>${uiLabelMap.PartyRoleType}</div></td>
                 <td width='5%'>&nbsp;</td>
                 <td>
@@ -123,7 +141,7 @@
                     <option value="${currentRole.roleTypeId}">${currentRole.get("description", locale)}</option>
                     <option value="${currentRole.roleTypeId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnyRoleType}</option>
+                    <option value="">${uiLabelMap.CommonAnyRoleType}</option>
                     <#list roleTypes as roleType>
                       <option value="${roleType.roleTypeId}">${roleType.get("description", locale)}</option>
                     </#list>
@@ -154,7 +172,7 @@
                     <option value="${currentType.orderTypeId}">${currentType.get("description", locale)}</option>
                     <option value="${currentType.orderTypeId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnyOrderType}</option>
+                    <option value="">${uiLabelMap.CommonAnyOrderType}</option>
                     <#list orderTypes as orderType>
                       <option value="${orderType.orderTypeId}">${orderType.get("description", locale)}</option>
                     </#list>
@@ -180,7 +198,7 @@
                     <option value="${currentSalesChannel.enumId}">${currentSalesChannel.get("description", locale)}</option>
                     <option value="${currentSalesChannel.enumId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnySalesChannel}</option>
+                    <option value="">${uiLabelMap.CommonAnySalesChannel}</option>
                     <#list salesChannels as channel>
                       <option value="${channel.enumId}">${channel.get("description", locale)}</option>
                     </#list>
@@ -196,7 +214,7 @@
                     <option value="${currentProductStore.productStoreId}">${currentProductStore.storeName?if_exists}</option>
                     <option value="${currentProductStore.productStoreId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnyStore}</option>
+                    <option value="">${uiLabelMap.CommonAnyStore}</option>
                     <#list productStores as store>
                       <option value="${store.productStoreId}">${store.storeName?if_exists}</option>
                     </#list>
@@ -207,12 +225,12 @@
                 <td width='25%' align='right'><div class='tableheadtext'>${uiLabelMap.ProductWebSite}</div></td>
                 <td width='5%'>&nbsp;</td>
                 <td>
-                  <select name='webSiteId' class='selectBox'>
+                  <select name='orderWebSiteId' class='selectBox'>
                     <#if currentWebSite?has_content>
                     <option value="${currentWebSite.webSiteId}">${currentWebSite.siteName}</option>
                     <option value="${currentWebSite.webSiteId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnyWebSite}</option>
+                    <option value="">${uiLabelMap.CommonAnyWebSite}</option>
                     <#list webSites as webSite>
                       <option value="${webSite.webSiteId}">${webSite.siteName}</option>
                     </#list>
@@ -228,7 +246,7 @@
                     <option value="${currentStatus.statusId}">${currentStatus.get("description", locale)}</option>
                     <option value="${currentStatus.statusId}">---</option>
                     </#if>
-                    <option value="ANY">${uiLabelMap.CommonAnyOrderStatus}</option>
+                    <option value="">${uiLabelMap.CommonAnyOrderStatus}</option>
                     <#list orderStatuses as orderStatus>
                       <option value="${orderStatus.statusId}">${orderStatus.get("description", locale)}</option>
                     </#list>
@@ -364,7 +382,6 @@
 </script>
 </#if>
 
-<#if orderHeaderList?exists>
 <br/>
 <form name="massOrderChangeForm" method="post" action="javascript:void();">
 <table border="0" width='100%' cellspacing='0' cellpadding='0' class='boxoutside'>
@@ -375,17 +392,17 @@
           <td width="50%"><div class="boxhead">${uiLabelMap.OrderOrderFound}</div></td>
           <td width="50%">
             <div class="boxhead" align="right">
-              <#if 0 < orderHeaderList?size>
+              <#if (orderList?has_content && 0 < orderList?size)>
                 <#if (viewIndex > 1)>
-                  <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonPrevious}</a>
+                  <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonPrevious}</a>
                 <#else>
                   <span class="buttontextdisabled">${uiLabelMap.CommonPrevious}</span>
                 </#if>
-                <#if (orderHeaderListSize > 0)>
-                  <span class="submenutextinfo">${lowIndex} - ${highIndex} ${uiLabelMap.CommonOf} ${orderHeaderListSize}</span>
+                <#if (orderListSize > 0)>
+                  <span class="submenutextinfo">${lowIndex} - ${highIndex} ${uiLabelMap.CommonOf} ${orderListSize}</span>
                 </#if>
-                <#if (orderHeaderListSize > highIndex)>
-                  <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonNext}</a>
+                <#if (orderListSize > highIndex)>
+                  <a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonNext}</a>
                 <#else>
                   <span class="buttontextdisabled">${uiLabelMap.CommonNext}</span>
                 </#if>
@@ -444,9 +461,9 @@
         <tr>
           <td colspan='15'><hr class='sepbar'/></td>
         </tr>
-        <#if orderHeaderList?has_content>
+        <#if orderList?has_content>
           <#assign rowClass = "viewManyTR2">
-          <#list orderHeaderList as orderHeader>
+          <#list orderList as orderHeader>
             <#assign orh = Static["org.ofbiz.order.order.OrderReadHelper"].getHelper(orderHeader)>
             <#assign statusItem = orderHeader.getRelatedOneCache("StatusItem")>
             <#assign orderType = orderHeader.getRelatedOneCache("OrderType")>
@@ -557,7 +574,6 @@
 </table>
 </form>
 
-</#if>
 <#else>
   <h3>${uiLabelMap.OrderViewPermissionError}</h3>
 </#if>