Index: trunk/grails-app/controllers/TaskDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 147)
+++ trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 155)
@@ -22,5 +22,5 @@
         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
 
-        // Search urls:
+        // Quick Search:
         if(!params.filter)
         {
@@ -28,15 +28,15 @@
             def personInstance = Person.get(authenticateService.userDomain().id)
 
-            if(params.searchMyTodays) {
+            if(params.quickSearch == "searchMyTodays") {
                 taskInstanceList = taskSearchService.getMyTodays(params)
                 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks for ${personInstance.firstName} ${personInstance.lastName}." }
                 else { params.message = "No tasks found for today." }
             }
-            else if(params.searchInTheLastWeek) {
+            else if(params.quickSearch == "searchInTheLastWeek") {
                 taskInstanceList = taskSearchService.getInTheLastWeek(params)
                 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." }
                 else { params.message = "No tasks found for today." }
             }
-            else if(params.searchMyInTheLastWeek) {
+            else if(params.quickSearch == "searchMyInTheLastWeek") {
                 taskInstanceList = taskSearchService.getMyInTheLastWeek(params)
                 if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." }
@@ -48,7 +48,7 @@
                 if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks." }
                 else { params.message = "No tasks found for today." }
-            }
-
-            return[ taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount]
+                params.quickSearch = "searchTodays"
+            }
+            return[taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount, filterParams: params]
         }
         // filterPane:
@@ -59,144 +59,49 @@
     }
 
-    def advancedSearch = {
-        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
-
-        if(!params._action_advancedSearch)
+    def searchCalendar = {
+//         println params
+        params.max = 30
+
+        // Quick Search:
+        if(!params.filter)
         {
-            // Default:
-            def taskInstanceActivesList = Task.findAllByIsActive(true, params)
-            def taskInstanceActivesTotal = Task.countByIsActive(true)
-            return [taskInstanceList: taskInstanceActivesList, taskInstanceTotal: taskInstanceActivesTotal]
-        }
-        render( view:'advancedSearch', 
-            model:[ taskInstanceList: filterService.filter( params, Task ), 
-            taskInstanceTotal: filterService.count( params, Task ), 
-            filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params), 
-            params:params ] )
-    }
-    
-//     def searchTodays = {
-//         def taskInstanceList = taskSearchService.getTodays(params)
-//         
-//         if(taskInstanceList.totalCount > 0)
-//         {
-//             flash.message = "Today's tasks"
-//         }
-//         else { flash.message = "No tasks found for today" }
-//         
-//         render( view:'search', 
-//             model:[ taskInstanceList: taskInstanceList, 
-//             taskInstanceTotal: taskInstanceList.totalCount])
-//     }
-    
-//     def searchMyTodays = {
-//         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
-//             
-//         def taskInstanceList = Task.createCriteria().list() {
-//                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
-//                 ge("targetStartDate", dateUtilService.getToday())
-//                 eq("isActive", true)
-//         }
-//             
-//         def taskInstanceTotal = Task.createCriteria().count() {
-//                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
-//                 ge("targetStartDate", dateUtilService.getToday())
-//                 eq("isActive", true)
-//         }
-//         
-//         if(taskInstanceTotal > 0)
-//         {
-//             flash.message = "Today's tasks"
-//         }
-//         else { flash.message = "No tasks found for today" }
-//         
-//         render( view:'search', 
-//             model:[ taskInstanceList: taskInstanceList, 
-//             taskInstanceTotal: taskInstanceTotal])
-//     }
-    
-    def searchInTheLastWeek = {
-        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
-            
-        def taskInstanceList = Task.createCriteria().list() {
-                ge("targetStartDate", dateUtilService.getToday()-7)
-                eq("isActive", true)
-        }
-            
-        def taskInstanceTotal = Task.createCriteria().count() {
-                ge("targetStartDate", dateUtilService.getToday()-7)
-                eq("isActive", true)
-        }
-        
-        if(taskInstanceTotal > 0)
-        {
-            flash.message = "Tasks with target start date in the last week."
-        }
-        
-        else {flash.message = "No tasks found with target start date in the last week." }
-        
-        render( view:'search', 
-            model:[ taskInstanceList: taskInstanceList, 
-            taskInstanceTotal: taskInstanceTotal])
-    }
-    
-    def searchMyInTheLastWeek = {
-        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
-            
-        def taskInstanceList = Task.createCriteria().list() {
-                eq("leadPerson", Person.get(authenticateService.userDomain().id))
-                ge("targetStartDate", dateUtilService.getToday()-7)
-                eq("isActive", true)
-        }
-            
-        def taskInstanceTotal = Task.createCriteria().count() {
-                eq("leadPerson", Person.get(authenticateService.userDomain().id))
-                ge("targetStartDate", dateUtilService.getToday()-7)
-                eq("isActive", true)
-        }
-        
-        if(taskInstanceTotal > 0)
-        {
-            flash.message = "Tasks with target start date in the last week."
-        }
-        else { flash.message = "No tasks found with target start date in the last week." }
-        
-        render( view:'search', 
-            model:[ taskInstanceList: taskInstanceList, 
-            taskInstanceTotal: taskInstanceTotal])
-    }
-
-//     def search = {
-//         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
-//         
-//         if(!params.order) {
-//             params.sort = "id"
-//             params.order = "desc"
-//         }
-//         
-//         if(params.search == "ShowAll")
-//         {
-//             def taskInstanceActivesList = Task.findAllByIsActive(true, params)
-//             def taskInstanceActivesTotal = Task.countByIsActive(true)
-//             return [taskInstanceList: taskInstanceActivesList, taskInstanceTotal: taskInstanceActivesTotal]
-//         }
-//         if(params.search == "ShowDeleted")
-//         {
-//             def taskInstanceActivesList = Task.findAllByIsActive(false, params)
-//             def taskInstanceActivesTotal = Task.countByIsActive(false)
-//             return [taskInstanceList: taskInstanceActivesList, taskInstanceTotal: taskInstanceActivesTotal]
-//         }
-//         // Default:
-//         def taskInstanceActivesList = Task.findAllByIsActive(true, params)
-//         def taskInstanceActivesTotal = Task.countByIsActive(true)
-//         [taskInstanceList: taskInstanceActivesList, taskInstanceTotal: taskInstanceActivesTotal]
-//     }
-    
-    def searchShowAll = {
-        redirect(action:'search', params:[search:"ShowAll"])
-    }
-    
-    def searchShowDeleted = {
-        redirect(action:'search', params:[search:"ShowDeleted"])
+            def taskInstanceList = []
+            def personInstance = Person.get(authenticateService.userDomain().id)
+
+            if(params.quickSearch == "searchMyTodays") {
+                taskInstanceList = taskSearchService.getMyTodays(params)
+                if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks for ${personInstance.firstName} ${personInstance.lastName}." }
+                else { params.message = "No tasks found for today." }
+                if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }
+            }
+            else if(params.quickSearch == "searchInTheLastWeek") {
+                taskInstanceList = taskSearchService.getInTheLastWeek(params)
+                if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week." }
+                else { params.message = "No tasks found for today." }
+                if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }
+            }
+            else if(params.quickSearch == "searchMyInTheLastWeek") {
+                taskInstanceList = taskSearchService.getMyInTheLastWeek(params)
+                if(taskInstanceList.totalCount > 0) { params.message = "Tasks with Target Start Date in the last week for ${personInstance.firstName} ${personInstance.lastName}." }
+                else { params.message = "No tasks found for today." }
+                if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }
+            }
+            else {
+                //Default:
+                taskInstanceList = taskSearchService.getTodays(params)
+                if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks." }
+                else { params.message = "No tasks found for today." }
+                if(taskInstanceList.totalCount > params.max) { params.message = "Too many results, only the first ${params.max} shown" }
+                params.quickSearch = "searchTodays"
+            }
+            return[taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount, filterParams: params]
+        }
+        // filterPane:
+        def taskInstanceTotal = filterService.count( params, Task )
+        if(taskInstanceTotal > params.max) { params.message = "Too many results, only the first ${params.max} shown" }
+        return[ taskInstanceList: filterService.filter( params, Task ),
+            taskInstanceTotal: taskInstanceTotal,
+            filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
+            params:params ]
     }
 
