Index: trunk/grails-app/controllers/TaskDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 133)
+++ trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 134)
@@ -20,18 +20,4 @@
     }
 
-//     def show = {
-//         def taskInstance = Task.get( params.id )
-// 
-//         if(!taskInstance) {
-//             flash.message = "Task not found with id ${params.id}"
-//             redirect(action:list)
-//         }
-//         else { 
-//             def taskProcedureInstance = TaskProcedure.get(taskInstance?.taskProcedure?.id)
-//             return [ taskInstance : taskInstance,  taskProcedureInstance: taskProcedureInstance] 
-// 
-//         }
-//     }
-
     def show = {
         def taskInstance = Task.get( params.id )
@@ -42,15 +28,39 @@
         }
         else {
+			params.max = 10
+			params.order = "desc"
+			params.sort = "id"
+
+			def subTaskInstanceList = Task.findAllByParentTask(taskInstance, params)
+			def subTaskInstanceTotal = Task.countByParentTask(taskInstance)					
+            def showTaskTab = new String("true")
+
             def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id)
             def taskProcedureExits = new Boolean("true")
-            def showTaskTab = new String("true")
-
             if(!taskProcedureInstance) {
                 taskProcedureExits = false
             }
+// 			else {
+				params.order = "asc"
+				params.sort = "procedureStepNumber"
+				def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, params)
+// 			}
+						
+            def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id)
+            def taskRecurringScheduleExits= new Boolean("true")
+			if(!taskRecurringScheduleInstance) {
+                taskRecurringScheduleExits = false
+            }
+			
             return [ taskInstance : taskInstance,
                             taskProcedureInstance: taskProcedureInstance,
                             taskProcedureExits: taskProcedureExits,
-                            showTaskTab: showTaskTab] 
+                            showTaskTab: showTaskTab,
+							subTaskInstanceList: subTaskInstanceList,
+	   						subTaskInstanceTotal: subTaskInstanceTotal,
+		  					subTaskInstanceMax: params.max,
+		 					maintenanceActionList: maintenanceActionList,
+							taskRecurringScheduleInstance: taskRecurringScheduleInstance,
+	   						taskRecurringScheduleExits: taskRecurringScheduleExits] 
         }
     }
@@ -136,32 +146,22 @@
         }
     }
-
-    //Generate a new TaskProcedure for a taskInstance.
-    def generateProcedure = {
-        def taskProcedureInstance = new TaskProcedure()
-        taskProcedureInstance.properties = params
-
-        def taskInstance = Task.get(params.taskInstance.id)
-        def taskProcedureExits = new Boolean("true")
-        def showProcedureTab = new String("true")
-
-        if(!taskProcedureInstance.hasErrors() && taskProcedureInstance.save()) {
-            taskProcedureInstance.addToTasks(taskInstance)
-            flash.message = "Procedure created, you can now add steps to the procedure"
-//             redirect(action:show, id:params.taskInstance.id)
+	
+	def listSubTasks = {
+		def parentTaskInstance = Task.get(params.id)
+				
+        if(!parentTaskInstance) {
+            flash.message = "Task not found with id ${params.id}"
+            redirect(action:list)
         }
         else {
-            taskProcedureExits = false
-        }
-
-        render(view:'show',model:[ taskInstance : taskInstance,  
-                                                        taskProcedureInstance: taskProcedureInstance, 
-                                                        taskProcedureExits: taskProcedureExits,
-                                                        showProcedureTab: showProcedureTab])
-    }
-
-    def findProcedure = {
-        redirect(controller:"taskProcedureDetailed", action:"list", id:params.taskInstance.id) 
-    }
+		params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
+		def subTaskInstanceList = Task.findAllByParentTask(parentTaskInstance, params)
+		def subTaskInstanceTotal = Task.countByParentTask(parentTaskInstance)
+				
+        [ taskInstanceList: subTaskInstanceList,
+			taskInstanceTotal:  subTaskInstanceTotal,
+   			parentTaskInstance: parentTaskInstance]
+		}
+	}
         
 }
