Index: trunk/grails-app/controllers/InventoryItemDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/InventoryItemDetailedController.groovy	(revision 453)
+++ trunk/grails-app/controllers/InventoryItemDetailedController.groovy	(revision 485)
@@ -1,4 +1,6 @@
 import org.codehaus.groovy.grails.plugins.springsecurity.Secured
 import org.codehaus.groovy.grails.commons.ConfigurationHolder
+import com.zeddware.grails.plugins.filterpane.FilterUtils
+import org.springframework.web.servlet.support.RequestContextUtils as RCU
 
 @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager'])
@@ -9,4 +11,5 @@
     def inventoryCsvService
     def inventoryItemService
+    def inventoryItemSearchService
     def inventoryMovementService
 
@@ -114,4 +117,7 @@
     }
 
+    /**
+    * Search for Inventory items.
+    */
     @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_InventoryManager', 'ROLE_InventoryUser'])
     def search = {
@@ -120,21 +126,55 @@
             params.max = session.inventoryItemSearchParamsMax
 
-        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
+        // Protect filterPane.
+        params.max = Math.min( params.max ? params.max.toInteger() : 10,  1000)
 
         def inventoryItemInstanceList = []
         def inventoryItemInstanceTotal
-        def filterParams = [:]
-
-        // Quick Search:
-        if(!params.filter) {
-            inventoryItemInstanceList = InventoryItem.list( params )
-            inventoryItemInstanceTotal = InventoryItem.count()
-            filterParams = params
-        }
-        else {
-        // filterPane:
+        def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params)
+        def isFilterApplied = FilterUtils.isFilterApplied(params)
+
+        // Restore search unless a new search is being requested.
+        if(!params.quickSearch && !filterParams) {
+            if(session.inventoryItemQuickSearch)
+                params.quickSearch = session.inventoryItemQuickSearch
+            else if(session.inventoryItemSearchFilterParams) {
+                session.inventoryItemSearchFilterParams.each() { params[it.key] = it.value }
+                params.filter = session.inventoryItemSearchFilter
+                isFilterApplied = FilterUtils.isFilterApplied(params)
+            }
+        }
+
+        // Remember sort if supplied, otherwise try to restore.
+        if(params.sort && params.order) {
+             session.inventoryItemSearchSort = params.sort
+             session.inventoryItemSearchOrder = params.order
+        }
+        else if(session.inventoryItemSearchSort && session.inventoryItemSearchOrder) {
+            params.sort = session.inventoryItemSearchSort
+            params.order = session.inventoryItemSearchOrder
+        }
+
+        if(isFilterApplied) {
+            // filterPane:
             inventoryItemInstanceList = filterService.filter( params, InventoryItem )
             inventoryItemInstanceTotal = filterService.count( params, InventoryItem )
             filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params)
+            // Remember search.
+            session.inventoryItemSearchFilterParams = new LinkedHashMap(filterParams)
+            session.inventoryItemSearchFilter = new LinkedHashMap(params.filter)
+            session.inventoryItemQuickSearch = null
+        }
+        else {
+            // Quick Search:
+            if(!params.quickSearch) params.quickSearch = "all"
+            def result = inventoryItemSearchService.getQuickSearch(params, RCU.getLocale(request))
+            inventoryItemInstanceList = result.inventoryItemList
+            inventoryItemInstanceTotal = result.inventoryItemList.totalCount
+            params.message = result.message
+            filterParams.quickSearch = result.quickSearch
+            // Remember search.
+            session.inventoryItemSearchFilterParams = null
+            session.inventoryItemSearchFilter = null
+            session.inventoryItemQuickSearch = result.quickSearch
         }
 
@@ -145,5 +185,10 @@
                 formatDate(format: "EEE, dd-MMM-yyyy", date: date)
             }
-            String title = "Inventory List."
+
+            String title
+            if(params.quickSearch)
+                title = params.message
+            else
+                title = "Filtered Inventory List."
 
             response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]
@@ -152,4 +197,5 @@
                                 "description",
                                 "unitsInStock",
+                                "reorderPoint",
                                 "unitOfMeasure",
                                 "inventoryLocation",
@@ -158,4 +204,5 @@
                                 "description": "Description",
                                 "unitsInStock":"In Stock",
+                                "reorderPoint":"Reorder Point",
                                 "unitOfMeasure": "UOM",
                                 "inventoryLocation": "Location",
@@ -177,10 +224,11 @@
         filterParams.max = params.max
         filterParams.offset = params.offset?.toInteger() ?: 0
-        filterParams.sort = params.sort ?: "id"
-        filterParams.order = params.order ?: "desc"
+        filterParams.sort = params.sort ?: "name"
+        filterParams.order = params.order ?: "asc"
 
         return[ inventoryItemInstanceList: inventoryItemInstanceList,
                 inventoryItemInstanceTotal: inventoryItemInstanceTotal,
-                filterParams: filterParams ]
+                filterParams: filterParams,
+                params: params ]
     } // end search()
 
