svn commit: r503391 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/order/OrderListState.java webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh webapp/ordermgr/order/orderlist.ftl

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

svn commit: r503391 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/order/OrderListState.java webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh webapp/ordermgr/order/orderlist.ftl

jleroux@apache.org
Author: jleroux
Date: Sun Feb  4 03:40:32 2007
New Revision: 503391

URL: http://svn.apache.org/viewvc?view=rev&rev=503391
Log:
A slightly enhanced patch from Leon Torres (I added filters) "Pagination in https://host_name:8443/ordermgr/control/orderlist needed" (https://issues.apache.org/jira/browse/OFBIZ-644)
I kept how one-line getters and setters are formatted. Not sure it would be better to put them on more lines.
I deleted the "TODO: Bug: Clicking All so none are selected shows all orders anyway". Because I think this is a good behaviour (rechecking some options by default). Who would want to search for an empty list ?

Added:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderListState.java   (with props)
Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh
    ofbiz/trunk/applications/order/webapp/ordermgr/order/orderlist.ftl

Added: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderListState.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderListState.java?view=auto&rev=503391
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderListState.java (added)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderListState.java Sun Feb  4 03:40:32 2007
@@ -0,0 +1,248 @@
+package org.ofbiz.order.order;
+
+import java.util.*;
+import javax.servlet.http.*;
+import javolution.util.*;
+import org.ofbiz.base.util.*;
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.condition.*;
+import org.ofbiz.entity.util.*;
+
+/**
+ * Session object for keeping track of the list of orders.
+ * The state of the list is preserved here instead of
+ * via url parameters, which can get messy.  There
+ * are three types of state:  Order State, Order Type,
+ * and pagination position.
+ *
+ * Also provides convenience methods for retrieving
+ * the right set of data for a particular state.
+ *
+ * Configuration for this may be found in
+ * applications/order/config/OrderListState.properties
+ *
+ * TODO: this can be generalized to use a set of State
+ * objects, including Pagination. Think about design
+ * patterns in Fowler.
+ */
+public class OrderListState {
+
+    public static final String module = OrderListState.class.getName();
+    //Integer.parseInt(UtilProperties.getPropertyValue("OrderListState.properties", "view_size", "10"));
+    public static final String SESSION_KEY = "__ORDER_LIST_STATUS__";
+    public static final String VIEW_SIZE_PARAM = "viewSize";
+    public static final String VIEW_INDEX_PARAM = "viewIndex";
+
+    // state variables
+    protected int viewSize;
+    protected int viewIndex;
+    protected Map orderStatusState;
+    protected Map orderTypeState;
+    protected Map orderFilterState;
+    protected int orderListSize;
+
+    // parameter to ID maps
+    protected static final Map parameterToOrderStatusId;
+    protected static final Map parameterToOrderTypeId;
+    protected static final Map parameterToFilterId;
+    static {
+        Map map = FastMap.newInstance();
+        map.put("viewcompleted", "ORDER_COMPLETED");
+        map.put("viewcancelled", "ORDER_CANCELLED");
+        map.put("viewrejected", "ORDER_REJECTED");
+        map.put("viewapproved", "ORDER_APPROVED");
+        map.put("viewcreated", "ORDER_CREATED");
+        map.put("viewprocessing", "ORDER_PROCESSING");
+        map.put("viewsent", "ORDER_SENT");
+        parameterToOrderStatusId = map;
+
+        map = FastMap.newInstance();
+        map.put("view_SALES_ORDER", "SALES_ORDER");
+        map.put("view_PURCHASE_ORDER", "PURCHASE_ORDER");
+        parameterToOrderTypeId = map;
+
+        map = FastMap.newInstance();
+        map.put("filterInventoryProblems", "filterInventoryProblems");
+        map.put("filterAuthProblems", "filterAuthProblems");
+        map.put("filterPartiallyReceivedPOs", "filterPartiallyReceivedPOs");
+        map.put("filterPOsOpenPastTheirETA", "filterPOsOpenPastTheirETA");
+        map.put("filterPOsWithRejectedItems", "filterPOsWithRejectedItems");        
+        parameterToFilterId = map;
+    }
+
+    //=============   Initialization and Request methods   ===================//
+
+    /**
+     * Initializes the order list state with default values. Do not use directly,
+     * instead use getInstance().
+     */
+    protected OrderListState() {
+        viewSize = Integer.parseInt(UtilProperties.getPropertyValue("OrderListState.properties", "view_size", "10"));
+        viewIndex = 0;
+        orderStatusState = FastMap.newInstance();
+        orderTypeState = FastMap.newInstance();
+        orderFilterState = FastMap.newInstance();        
+
+        // defaults (TODO: configuration)
+        orderStatusState.put("viewcreated", "Y");
+        orderStatusState.put("viewprocessing", "Y");
+        orderStatusState.put("viewapproved", "Y");
+        orderTypeState.put("view_SALES_ORDER", "Y");
+    }
+
+    /**
+     * Retrieves the current user's OrderListState from the session
+     * or creates a new one with defaults.
+     */
+    public static OrderListState getInstance(HttpServletRequest request) {
+        HttpSession session = request.getSession();
+        OrderListState status = (OrderListState) session.getAttribute(SESSION_KEY);
+        if (status == null) {
+            status = new OrderListState();
+            session.setAttribute(SESSION_KEY, status);
+        }
+        return status;
+    }
+
+    /**
+     * Given a request, decides what state to change.  If a parameter changeStatusAndTypeState
+     * is present with value "Y", the status and type state will be updated.  Otherwise, if the
+     * viewIndex and viewSize parameters are present, the pagination changes.
+     */
+    public void update(HttpServletRequest request) {
+        if ("Y".equals(request.getParameter("changeStatusAndTypeState"))) {
+            changeOrderListStates(request);
+        } else {
+            String viewSizeParam = request.getParameter(VIEW_SIZE_PARAM);
+            String viewIndexParam = request.getParameter(VIEW_INDEX_PARAM);
+            if (!UtilValidate.isEmpty(viewSizeParam) && !UtilValidate.isEmpty(viewIndexParam))
+                changePaginationState(viewSizeParam, viewIndexParam);
+        }
+    }
+
+    private void changePaginationState(String viewSizeParam, String viewIndexParam) {
+        try {
+            viewSize = Integer.parseInt(viewSizeParam);
+            viewIndex = Integer.parseInt(viewIndexParam);
+        } catch (NumberFormatException e) {
+            Debug.logWarning("Values of " + VIEW_SIZE_PARAM + " ["+viewSizeParam+"] and " + VIEW_INDEX_PARAM + " ["+viewIndexParam+"] must both be Integers. Not paginating order list.", module);
+        }
+    }
+
+    private void changeOrderListStates(HttpServletRequest request) {
+        for (Iterator iter = parameterToOrderStatusId.keySet().iterator(); iter.hasNext(); ) {
+            String param = (String) iter.next();
+            String value = request.getParameter(param);
+            if ("Y".equals(value)) {
+                orderStatusState.put(param, "Y");
+            } else {
+                orderStatusState.put(param, "N");
+            }
+        }
+        for (Iterator iter = parameterToOrderTypeId.keySet().iterator(); iter.hasNext(); ) {
+            String param = (String) iter.next();
+            String value = request.getParameter(param);
+            if ("Y".equals(value)) {
+                orderTypeState.put(param, "Y");
+            } else {
+                orderTypeState.put(param, "N");
+            }
+        }
+        for (Iterator iter = parameterToFilterId.keySet().iterator(); iter.hasNext(); ) {
+            String param = (String) iter.next();
+            String value = request.getParameter(param);
+            if ("Y".equals(value)) {
+                orderFilterState.put(param, "Y");
+            } else {
+                orderFilterState.put(param, "N");
+            }
+        }
+        viewIndex = 0;
+    }
+
+
+    //==============   Get and Set methods   =================//
+
+
+    public Map getOrderStatusState() { return orderStatusState; };
+    public Map getOrderTypeState() { return orderTypeState; }
+    public Map getorderFilterState() { return orderFilterState; }
+    
+    public boolean hasStatus(String param) { return ("Y".equals(orderStatusState.get(param))); }
+    public boolean hasType(String param) { return ("Y".equals(orderTypeState.get(param))); }
+    public boolean hasFilter(String param) { return ("Y".equals(orderFilterState.get(param))); }
+    
+    public boolean hasAllStatus() {
+        for (Iterator iter = orderStatusState.values().iterator(); iter.hasNext(); ) {
+            if (!"Y".equals(iter.next())) return false;
+        }
+        return true;
+    }
+
+    public int getViewSize() { return viewSize; }
+    public int getViewIndex() { return viewIndex; }
+    public int getSize() { return orderListSize; }
+
+    public boolean hasPrevious() { return (viewIndex > 0); }
+    public boolean hasNext() { return (viewIndex < getSize() / viewSize); }
+
+    /**
+     * Get the OrderHeaders corresponding to the state.
+     */
+    public List getOrders(String facilityId, GenericDelegator delegator) throws GenericEntityException {
+        List allConditions = new ArrayList();
+
+        if (facilityId != null) {
+            allConditions.add(new EntityExpr("originFacilityId", EntityOperator.EQUALS, facilityId));
+        }
+
+        List statusConditions = new ArrayList();
+        for (Iterator iter = orderStatusState.keySet().iterator(); iter.hasNext(); ) {
+            String status = (String) iter.next();
+            if (!hasStatus(status)) continue;
+            statusConditions.add( new EntityExpr("statusId", EntityOperator.EQUALS, parameterToOrderStatusId.get(status)) );
+        }
+        List typeConditions = new ArrayList();
+        for (Iterator iter = orderTypeState.keySet().iterator(); iter.hasNext(); ) {
+            String type = (String) iter.next();
+            if (!hasType(type)) continue;
+            typeConditions.add( new EntityExpr("orderTypeId", EntityOperator.EQUALS, parameterToOrderTypeId.get(type)) );
+        }
+        List filterConditions = new ArrayList();
+        for (Iterator iter = orderFilterState.keySet().iterator(); iter.hasNext(); ) {
+            String type = (String) iter.next();
+            if (!hasType(type)) continue;
+            filterConditions.add( new EntityExpr("orderFiltersStateId", EntityOperator.EQUALS, parameterToFilterId.get(type)) );
+        }
+                
+        EntityCondition statusConditionsList = new EntityConditionList(statusConditions,  EntityOperator.OR);
+        EntityCondition typeConditionsList = new EntityConditionList(typeConditions, EntityOperator.OR);
+        EntityCondition filterConditionsList = new EntityConditionList(filterConditions, EntityOperator.OR);
+        if ((typeConditions.size() > 0) && (statusConditions.size() > 0) && (filterConditions.size() > 0)) {
+            allConditions.add(statusConditionsList);
+            allConditions.add(typeConditionsList);
+            allConditions.add(filterConditionsList);
+        }
+
+        EntityCondition queryConditionsList = new EntityConditionList(allConditions, EntityOperator.AND);
+        EntityFindOptions options = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true);
+        EntityListIterator iterator = delegator.findListIteratorByCondition("OrderHeader", queryConditionsList, null, null, UtilMisc.toList("orderDate DESC"), options);
+
+        // get subset corresponding to pagination state
+        List orders = iterator.getPartialList(viewSize * viewIndex, viewSize);
+        iterator.last();
+        orderListSize = iterator.currentIndex();
+        iterator.close();
+        //Debug.logInfo("### size of list: " + orderListSize, module);
+        return orders;
+    }
+
+    public String toString() {
+        StringBuffer buff = new StringBuffer("OrderListState:\n\t");
+        buff.append("viewIndex=").append(viewIndex).append(", viewSize=").append(viewSize).append("\n\t");
+        buff.append(getOrderStatusState().toString()).append("\n\t");
+        buff.append(getOrderTypeState().toString()).append("\n\t");
+        buff.append(getorderFilterState().toString()).append("\n\t");
+        return buff.toString();
+    }
+}

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

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

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

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh?view=diff&rev=503391&r1=503390&r2=503391
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/filterorderlist.bsh Sun Feb  4 03:40:32 2007
@@ -22,13 +22,14 @@
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.order.order.OrderReadHelper;
 import org.ofbiz.product.store.ProductStoreWorker;
+import org.ofbiz.order.order.OrderListState;
 
 orderHeaderList = context.get("orderHeaderList");
 productStore = ProductStoreWorker.getProductStore(request);
 
 List filterInventoryProblems = new ArrayList();
 
-if ("Y".equals(requestParameters.get("filterInventoryProblems")) && UtilValidate.isNotEmpty(orderHeaderList)) {
+if (state.hasFilter("view_InventoryProblems") && UtilValidate.isNotEmpty(orderHeaderList)) {
     for (ohi = orderHeaderList.iterator(); ohi.hasNext();) {
         orderHeader = (GenericValue) ohi.next();
         orderReadHelper = OrderReadHelper.getHelper(orderHeader);
@@ -43,9 +44,12 @@
 List filterPOsWithRejectedItems = new ArrayList();
 List filterPartiallyReceivedPOs = new ArrayList();
 
-if (("Y".equals(requestParameters.get("filterPartiallyReceivedPOs")) ||
-        "Y".equals(requestParameters.get("filterPOsOpenPastTheirETA")) ||
-        "Y".equals(requestParameters.get("filterPOsWithRejectedItems"))) &&
+state = OrderListState.getInstance(request);
+//print("### " + state.toString());
+
+if ((state.hasFilter("filterPartiallyReceivedPOs") ||
+        state.hasFilter("filterPOsOpenPastTheirETA") ||
+        state.hasFilter("filterPOsWithRejectedItems")) &&
         UtilValidate.isNotEmpty(orderHeaderList)) {    
     for (ohi = orderHeaderList.iterator(); ohi.hasNext();) {
         orderHeader = (GenericValue) ohi.next();
@@ -56,17 +60,17 @@
         orderReadHelper = OrderReadHelper.getHelper(orderHeader);
         if ("PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) {                
             if (orderReadHelper.getRejectedOrderItems() &&
-                    "Y".equals(requestParameters.get("filterPOsWithRejectedItems"))) {
+                    state.hasFilter("filterPOsWithRejectedItems")) {
                 filterPOsWithRejectedItems.add(orderHeader.get("orderId"));
                 continue;
             }
             if (orderReadHelper.getPastEtaOrderItems(orderHeader.get("orderId")) &&
-                    "Y".equals(requestParameters.get("filterPOsOpenPastTheirETA"))) {
+                    state.hasFilter("filterPOsOpenPastTheirETA")) {
                 filterPOsOpenPastTheirETA.add(orderHeader.get("orderId"));
                 continue;
             }
             if (orderReadHelper.getPartiallyReceivedItems() &&
-                    "Y".equals(requestParameters.get("filterPartiallyReceivedPOs"))) {
+                    state.hasFilter("filterPartiallyReceivedPOs")) {
                 filterPartiallyReceivedPOs.add(orderHeader.get("orderId"));
                 continue;
             }            
@@ -76,7 +80,7 @@
 
 List filterAuthProblems = new ArrayList();
 
-if ("Y".equals(requestParameters.get("filterAuthProblems")) && UtilValidate.isNotEmpty(orderHeaderList)) {
+if (state.hasFilter("filterAuthProblems") && UtilValidate.isNotEmpty(orderHeaderList)) {
     for (ohi = orderHeaderList.iterator(); ohi.hasNext();) {
         orderHeader = (GenericValue) ohi.next();
         orderReadHelper = OrderReadHelper.getHelper(orderHeader);

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh?view=diff&rev=503391&r1=503390&r2=503391
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/orderlist.bsh Sun Feb  4 03:40:32 2007
@@ -21,6 +21,7 @@
 import org.ofbiz.entity.*;
 import org.ofbiz.entity.util.*;
 import org.ofbiz.entity.condition.*;
+import org.ofbiz.order.order.OrderListState;
 
 delegator = request.getAttribute("delegator");
 session = request.getSession(true);
@@ -30,125 +31,24 @@
 partyId = request.getParameter("partyId");
 facilityId = request.getParameter("facilityId");
 
-// checkboxes
-viewcompleted = request.getParameter("viewcompleted");
-viewcancelled = request.getParameter("viewcancelled");
-viewrejected = request.getParameter("viewrejected");
-viewapproved = request.getParameter("viewapproved");
-viewcreated = request.getParameter("viewcreated");
-viewprocessing = request.getParameter("viewprocessing");
-viewsent = request.getParameter("viewsent");
-viewall = request.getParameter("viewall");
-view_SALES_ORDER = request.getParameter("view_SALES_ORDER");
-view_PURCHASE_ORDER = request.getParameter("view_PURCHASE_ORDER");
-
-
-// if no status is selected, view created, processing, and approved orders by default
-if ((viewcompleted == null) && (viewcancelled == null) && (viewrejected == null) && (viewapproved == null) && (viewcreated == null) && (viewprocessing == null) && (viewsent == null)) {
-    viewcreated = "Y";
-    viewprocessing = "Y";
-    viewapproved = "Y";
-}
-
-// put back in context for pre-checking checkboxes
-context.put("viewcompleted", viewcompleted);
-context.put("viewcancelled", viewcancelled);
-context.put("viewrejected", viewrejected);
-context.put("viewapproved", viewapproved);
-context.put("viewcreated", viewcreated);
-context.put("viewprocessing", viewprocessing);
-context.put("viewsent", viewsent);
-context.put("viewall", viewall);
-
-// when no constraints are evident, default to view all sales
-if ((view_SALES_ORDER == null) && (view_PURCHASE_ORDER == null)) {
-    view_SALES_ORDER = "Y";
-}
-context.put("view_SALES_ORDER", view_SALES_ORDER);
-context.put("view_PURCHASE_ORDER", view_PURCHASE_ORDER);
-
-typeConditions = new ArrayList();       // list of order type conditions
-statusConditions = new ArrayList();     // list of order status conditions
-allConditions = new ArrayList();        // type and status conditions joined by AND
-
-// condition for facility Id
-if (facilityId != null) {
-    allConditions.add(new EntityExpr("originFacilityId", EntityOperator.EQUALS, facilityId));
-}
-
-// conditions for order status
-completedOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_COMPLETED");
-cancelledOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_CANCELLED");
-rejectedOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_REJECTED");
-approvedOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_APPROVED");
-createdOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_CREATED");
-processingOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_PROCESSING");
-sentOrdersCondition = new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_SENT");
-
-// conditions for order type
-salesOrdersCondition = null;
-purchaseOrdersCondition = null;
-workOrdersCondition = null;
-
+state = OrderListState.getInstance(request);
+state.update(request);
+context.put("state", state);
+//print("### " + state.toString());
+
 // check permission for each order type
 hasPermission = false;
-if ((view_SALES_ORDER != null) && security.hasEntityPermission("ORDERMGR", "_VIEW", session)) {
+if (state.hasType("view_SALES_ORDER") && security.hasEntityPermission("ORDERMGR", "_VIEW", session)) {
     hasPermission = true;
     salesOrdersCondition = new EntityExpr("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER");
 }
-if ((view_PURCHASE_ORDER != null) && security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", session)) {
+if (state.hasType("view_PURCHASE_ORDER") && security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", session)) {
     hasPermission = true;
     purchaseOrdersCondition = new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER");
 }
 context.put("hasPermission", hasPermission);
 
-
-// this is for convenience
-allStatus = false;
-if ((viewall != null) && (viewall.equals("Y"))) {
-    allStatus = true;
-}
-
-if (allStatus || (viewcompleted != null)) {
-    statusConditions.add(completedOrdersCondition);
-}
-if (allStatus || (viewcancelled != null)) {
-    statusConditions.add(cancelledOrdersCondition);
-}
-if (allStatus || (viewrejected != null)) {
-    statusConditions.add(rejectedOrdersCondition);
-}
-if (allStatus || (viewapproved != null)) {
-    statusConditions.add(approvedOrdersCondition);
-}
-if (allStatus || (viewcreated != null)) {
-    statusConditions.add(createdOrdersCondition);
-}
-if (allStatus || (viewprocessing != null)) {
-    statusConditions.add(processingOrdersCondition);
-}
-if (allStatus || (viewsent != null)) {
-    statusConditions.add(sentOrdersCondition);
-}
-if (salesOrdersCondition != null) {
-    typeConditions.add(salesOrdersCondition);
-}
-if (purchaseOrdersCondition != null) {
-    typeConditions.add(purchaseOrdersCondition);
-}
-if (workOrdersCondition != null) {
-    typeConditions.add(workOrdersCondition);
-}
-
-// construct conditions and find orderheaders: select ORH where (status1 OR status2 OR ...) AND (type1 OR type2 OR ...)
-statusConditionsList = new EntityConditionList(statusConditions,  EntityOperator.OR);
-typeConditionsList = new EntityConditionList(typeConditions, EntityOperator.OR);
-if ((typeConditions.size() > 0) && (statusConditions.size() > 0)) {
-    allConditions.add(statusConditionsList);
-    allConditions.add(typeConditionsList);
-}
-queryConditionsList = new EntityConditionList(allConditions, EntityOperator.AND);
-orderHeaderList = delegator.findByCondition("OrderHeader", queryConditionsList, null, UtilMisc.toList("orderDate DESC"));
+orderHeaderList = state.getOrders(facilityId, delegator);
 context.put("orderHeaderList", orderHeaderList);
 
 locale = UtilHttp.getLocale(request);

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderlist.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderlist.ftl?view=diff&rev=503391&r1=503390&r2=503391
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderlist.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderlist.ftl Sun Feb  4 03:40:32 2007
@@ -35,24 +35,49 @@
     
 </script>
 
+<#macro pagination>
+  <tr>
+    <td>
+      <table border="0" width="100%">
+        <tr>
+          <td>
+            <#if state.hasPrevious()>
+            <a href="<@ofbizUrl>orderlist?viewIndex=${state.getViewIndex() - 1}&viewSize=${state.getViewSize()}</@ofbizUrl>" class="buttontext">Previous</a>
+            </#if>
+          </td>
+          <td align="right">
+            <#if state.hasNext()>
+            <a href="<@ofbizUrl>orderlist?viewIndex=${state.getViewIndex() + 1}&viewSize=${state.getViewSize()}</@ofbizUrl>" class="buttontext">Next</a>
+            </#if>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+</#macro>
+  
+
+<#-- order list -->
+
 <table border="0" width="100%" cellspacing="0" cellpadding="0" class="boxoutside">
   <tr>
     <td width="100%">
       <form method="post" name="findorder" action="<@ofbizUrl>orderlist</@ofbizUrl>">
+        <input type="hidden" name="changeStatusAndTypeState" value="Y">
         <table border="0" cellspacing="0" cellpadding="0" class="boxbottom">
           <tr>
             <td><div class="tableheadtext">${uiLabelMap.CommonStatus}:</div></td>
             <td>&nbsp;&nbsp;</td>
             <td nowrap>
                 <div class="tabletext">
-                    <input type="checkbox" name="viewall" value="Y" onclick="javascript:setCheckboxes()" <#if viewall?exists>checked="checked"</#if> />${uiLabelMap.CommonAll}
-                    <input type="checkbox" name="viewcreated" value="Y" <#if viewcreated?exists>checked="checked"</#if> />${uiLabelMap.CommonCreated}
-                    <input type="checkbox" name="viewprocessing" value="Y" <#if viewprocessing?exists>checked="checked"</#if> />${uiLabelMap.CommonProcessing}
-                    <input type="checkbox" name="viewapproved" value="Y" <#if viewapproved?exists>checked="checked"</#if> />${uiLabelMap.CommonApproved}
-                    <input type="checkbox" name="viewcompleted" value="Y" <#if viewcompleted?exists>checked="checked"</#if> />${uiLabelMap.CommonCompleted}
-                    <input type="checkbox" name="viewsent" value="Y" <#if viewsent?exists>checked="checked"</#if> />${uiLabelMap.CommonSent}
-                    <input type="checkbox" name="viewrejected" value="Y" <#if viewrejected?exists>checked="checked"</#if> />${uiLabelMap.CommonRejected}
-                    <input type="checkbox" name="viewcancelled" value="Y" <#if viewcancelled?exists>checked="checked"</#if> />${uiLabelMap.CommonCancelled}
+                    <input type="checkbox" name="viewall" value="Y" onclick="javascript:setCheckboxes()" <#if state.hasAllStatus()>checked="checked"</#if> />${uiLabelMap.CommonAll}
+                    <input type="checkbox" name="viewcreated" value="Y" <#if state.hasStatus('viewcreated')>checked="checked"</#if> />${uiLabelMap.CommonCreated}
+                    <input type="checkbox" name="viewprocessing" value="Y" <#if state.hasStatus('viewprocessing')>checked="checked"</#if> />${uiLabelMap.CommonProcessing}
+                    <input type="checkbox" name="viewapproved" value="Y" <#if state.hasStatus('viewapproved')>checked="checked"</#if> />${uiLabelMap.CommonApproved}
+                    <input type="checkbox" name="viewcompleted" value="Y" <#if state.hasStatus('viewcompleted')>checked="checked"</#if> />${uiLabelMap.CommonCompleted}
+                    <input type="checkbox" name="viewsent" value="Y" <#if state.hasStatus('viewsent')>checked="checked"</#if> />${uiLabelMap.CommonSent}
+                    <input type="checkbox" name="viewrejected" value="Y" <#if state.hasStatus('viewrejected')>checked="checked"</#if> />${uiLabelMap.CommonRejected}
+                    <input type="checkbox" name="viewcancelled" value="Y" <#if state.hasStatus('viewcancelled')>checked="checked"</#if> />${uiLabelMap.CommonCancelled}
                 </div>
             </td>            
             <td rowspan="2">&nbsp;&nbsp;</td>
@@ -65,9 +90,9 @@
             <td>&nbsp;&nbsp;</td>
             <td nowrap>
                 <div class="tabletext">
-                    <input type="checkbox" name="view_SALES_ORDER" value="Y" <#if view_SALES_ORDER?exists>checked="checked"</#if>/>
+                    <input type="checkbox" name="view_SALES_ORDER" value="Y" <#if state.hasType('view_SALES_ORDER')>checked="checked"</#if>/>
                     ${descr_SALES_ORDER}
-                    <input type="checkbox" name="view_PURCHASE_ORDER" value="Y" <#if view_PURCHASE_ORDER?exists>checked="checked"</#if>/>
+                    <input type="checkbox" name="view_PURCHASE_ORDER" value="Y" <#if state.hasType('view_PURCHASE_ORDER')>checked="checked"</#if>/>
                     ${descr_PURCHASE_ORDER}
                 </div>
             </td>            
@@ -78,10 +103,10 @@
             <td nowrap>
                 <div class="tabletext">
                     <input type="checkbox" name="filterInventoryProblems" value="Y"
-                        <#if requestParameters.filterInventoryProblems?default("N") == "Y">checked="checked"</#if>/>
+                        <#if state.hasFilter('filterInventoryProblems')>checked="checked"</#if>/>
                         ${uiLabelMap.OrderFilterInventoryProblems}
                     <input type="checkbox" name="filterAuthProblems" value="Y"
-                        <#if requestParameters.filterAuthProblems?default("N") == "Y">checked="checked"</#if>/>
+                        <#if state.hasFilter('filterAuthProblems')>checked="checked"</#if>/>
                         ${uiLabelMap.OrderFilterAuthProblems}
                 </div>
             </td>
@@ -92,13 +117,13 @@
             <td nowrap>
                 <div class="tabletext">
                     <input type="checkbox" name="filterPartiallyReceivedPOs" value="Y"
-                        <#if requestParameters.filterPartiallyReceivedPOs?default("N") == "Y">checked="checked"</#if>/>
+                        <#if state.hasFilter('filterPartiallyReceivedPOs')>checked="checked"</#if>/>
                         ${uiLabelMap.OrderFilterPartiallyReceivedPOs}
                     <input type="checkbox" name="filterPOsOpenPastTheirETA" value="Y"
-                        <#if requestParameters.filterPOsOpenPastTheirETA?default("N") == "Y">checked="checked"</#if>/>
+                        <#if state.hasFilter('filterPOsOpenPastTheirETA')>checked="checked"</#if>/>
                         ${uiLabelMap.OrderFilterPOsOpenPastTheirETA}
                     <input type="checkbox" name="filterPOsWithRejectedItems" value="Y"
-                        <#if requestParameters.filterPOsWithRejectedItems?default("N") == "Y">checked="checked"</#if>/>
+                        <#if state.hasFilter('filterPOsWithRejectedItems')>checked="checked"</#if>/>
                         ${uiLabelMap.OrderFilterPOsWithRejectedItems}
                 </div>
             </td>
@@ -238,6 +263,9 @@
       </table>
     </td>
   </tr>
+
+  <@pagination/>
+
 <#else>
 <tr><td><div class="tableheadtext">${uiLabelMap.OrderViewPermissionError}</div></td></tr>
 </#if>