Index: /trunk/application.properties
===================================================================
--- /trunk/application.properties	(revision 198)
+++ /trunk/application.properties	(revision 199)
@@ -1,4 +1,4 @@
 #utf-8
-#Tue Oct 27 09:01:31 EST 2009
+#Tue Nov 24 20:57:54 EST 2009
 plugins.export=0.4
 plugins.acegi=0.5.1
@@ -7,5 +7,5 @@
 plugins.class-diagram=0.4.1
 plugins.help-balloons=1.2
-plugins.quartz=0.4.1-SNAPSHOT
+plugins.quartz=0.4.1
 plugins.richui=0.6
 app.servlet.version=2.4
Index: /trunk/grails-app/conf/BootStrap.groovy
===================================================================
--- /trunk/grails-app/conf/BootStrap.groovy	(revision 198)
+++ /trunk/grails-app/conf/BootStrap.groovy	(revision 199)
@@ -7,18 +7,18 @@
     def init = { servletContext ->
 
-    println "**** BootStrap GrailsUtil.environment = ${GrailsUtil.environment}"
+        log.debug "GrailsUtil.environment = ${GrailsUtil.environment}"
 
         switch (GrailsUtil.environment)
         {
             case "development":
-                        createDataService.ensureAdminAccess()
+                        createDataService.ensureSystemAndAdminAccess()
                         createDataService.createBaseData()
                         createDataService.createDemoData()
                         break
             case "test":
-                        createDataService.ensureAdminAccess()
+                        createDataService.ensureSystemAndAdminAccess()
                         break
             case "production":
-                        createDataService.ensureAdminAccess()
+                        createDataService.ensureSystemAndAdminAccess()
                         break 
         }
Index: /trunk/grails-app/conf/Config.groovy
===================================================================
--- /trunk/grails-app/conf/Config.groovy	(revision 198)
+++ /trunk/grails-app/conf/Config.groovy	(revision 199)
@@ -89,4 +89,5 @@
     error "grails.app.service.PersonService"
     error "grails.app.service.NavigationService"
+    error "grails.app.service.com.zeddware.grails.plugins.filterpane.FilterService"
 }
 
@@ -128,8 +129,9 @@
 } // end environments
 
-/** Navigation plugin menu.
-   * The top level titles are taken from i18n message bundles.
-   * Subitems i18n message bundles are not currently resolving with this plugin.
-   */
+/**
+ * Navigation plugin menu.
+ * The top level titles are taken from i18n message bundles.
+ * Subitems i18n message bundles are not currently resolving with this plugin.
+ */
 navigation.nav = [
     [order:10, controller:'appCore', title:'home', action:'start',
@@ -169,8 +171,9 @@
 ]
 
-/** Navigation plugin alternate menu.
-   * The alternate top level titles are not displayed anywhere.
-   * Subitems i18n message bundles are not currently resolving with this plugin.
-   */
+/**
+ * Navigation plugin alternate menu.
+ * The alternate top level titles are not displayed anywhere.
+ * Subitems i18n message bundles are not currently resolving with this plugin.
+ */
 navigation.navAlt = [
     [order:10, controller:'person', title:'person', action:'list',
@@ -191,2 +194,7 @@
     ]
 ]
+
+/**
+ * Some custom globals.
+ */
+taskRecurringScheduleJob.repeatInterval=10
Index: /trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy
===================================================================
--- /trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy	(revision 198)
+++ /trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy	(revision 199)
@@ -31,5 +31,5 @@
         if(taskRecurringScheduleInstance) {
             try {
-                taskRecurringScheduleInstance.delete()
+                taskRecurringScheduleInstance.delete(flush: true)
                 flash.message = "Recurring Schedule ${params.id} deleted"
                 redirect(action:list)
@@ -73,9 +73,9 @@
                 }
 
-                Date originalDate = taskRecurringScheduleInstance.startDate
+                Date originalDate = taskRecurringScheduleInstance.nextTargetStartDate
                 taskRecurringScheduleInstance.properties = params  // Domain object is now 'dirty'.
-                Date newDate = taskRecurringScheduleInstance.startDate
+                Date newDate = taskRecurringScheduleInstance.nextTargetStartDate
 
-                // If user changes startDate then ensure it is in the future, otherwise it's ok to keep the original date.
+                // If user changes nextTargetStartDate then ensure it is in the future, otherwise it's ok to keep the original date.
                 if(originalDate.getTime() != newDate.getTime())
                 {
@@ -83,5 +83,5 @@
                     {
                         status.setRollbackOnly()  // Only allow the transaction to Rollback, preventing flush due to 'dirty'.
-                        taskRecurringScheduleInstance.errors.rejectValue("startDate", "taskRecurring.startDate.NotInTheFuture")
+                        taskRecurringScheduleInstance.errors.rejectValue("nextTargetStartDate", "taskRecurring.nextTargetStartDate.NotInTheFuture")
                         render(view:'edit',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance])
                         return
@@ -89,9 +89,8 @@
                 }
 
-                taskRecurringScheduleInstance.nextTargetStartDate = taskRecurringScheduleInstance.startDate
-                taskRecurringScheduleInstance.setNextGenerationDate() 
+                taskRecurringScheduleInstance.setNextGenerationDate()
                 taskRecurringScheduleInstance.setNextTargetCompletionDate()
 
-                if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save(flush: true)) 
+                if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save(flush: true))
                 {
                     flash.message = "Recurring Schedule ${params.id} updated"
@@ -121,5 +120,5 @@
         catch(Exception e) {
             flash.message = "Please select a task, then Create a Recurring Schedule for it"
-            redirect(controller:"taskDetailed", action:"list")
+            redirect(controller:"taskDetailed", action:"search")
         }
     } // end create()
@@ -135,6 +134,6 @@
         else {
 
-            if(taskRecurringScheduleInstance.startDate < dateUtilService.getToday()) {
-                taskRecurringScheduleInstance.errors.rejectValue("startDate", "taskRecurring.startDate.NotInTheFuture")
+            if(taskRecurringScheduleInstance.nextTargetStartDate < dateUtilService.getToday()) {
+                taskRecurringScheduleInstance.errors.rejectValue("nextTargetStartDate", "taskRecurring.nextTargetStartDate.NotInTheFuture")
             }
 
Index: /trunk/grails-app/domain/Period.groovy
===================================================================
--- /trunk/grails-app/domain/Period.groovy	(revision 198)
+++ /trunk/grails-app/domain/Period.groovy	(revision 199)
@@ -3,8 +3,4 @@
     String period
     boolean isActive = true
-
-    static hasMany = [taskRecurringSchedules: TaskRecurringSchedule]
-    
-    static mappedBy = [taskRecurringSchedules:"recurPeriod"]
 
 //     static belongsTo = []
Index: /trunk/grails-app/domain/TaskRecurringSchedule.groovy
===================================================================
--- /trunk/grails-app/domain/TaskRecurringSchedule.groovy	(revision 198)
+++ /trunk/grails-app/domain/TaskRecurringSchedule.groovy	(revision 199)
@@ -5,5 +5,4 @@
     Task lastGeneratedSubTask
     Period recurPeriod
-    Period generateAheadPeriod
     Period taskDurationPeriod
 
@@ -11,10 +10,9 @@
     Integer taskDuration = 0
     Integer generateAhead = 1
-    Date startDate = new Date()
-    Date lastGeneratedDate
+    Integer subTasksGenerated = 0
+    Date nextGenerationDate = new Date()
     Date nextTargetStartDate = new Date()
     Date nextTargetCompletionDate = new Date()
-    Date nextGenerationDate = new Date()
-    boolean isEnabled = true
+    boolean enabled = true
 
 //     static hasMany = []
@@ -25,6 +23,5 @@
         recurEvery(min:1, max:365)
         taskDuration(min:0, max:365)
-        generateAhead(min:0, max:365)
-        lastGeneratedDate(nullable:true)
+        generateAhead(min:0, max:62)
         lastGeneratedSubTask(nullable:true)
     }
@@ -38,33 +35,39 @@
     // in the hope that this will be fixed in future versions.
     def beforeInsert = {
-        nextTargetStartDate = startDate
         setNextGenerationDate()
         setNextTargetCompletionDate()
     }
 
-    public void setNextGenerationDate() {
-        switch (generateAheadPeriod.period) {
+    public void setNextTargetStartDate() {
+        switch (recurPeriod.period) {
             case "Day(s)":
                 use(TimeCategory) {
-                    nextGenerationDate = nextTargetStartDate - generateAhead.days
+                    nextTargetStartDate = nextTargetStartDate + recurEvery.days
                 }
                 break
             case "Week(s)":
                 use(TimeCategory) {
-                    nextGenerationDate = nextTargetStartDate - generateAhead.weeks
+                    nextTargetStartDate = nextTargetStartDate + recurEvery.weeks
                 }
                 break
             case "Month(s)":
                 use(TimeCategory) {
-                    nextGenerationDate = nextTargetStartDate - generateAhead.months
+                    nextTargetStartDate = nextTargetStartDate + recurEvery.months
                 }
                 break
             case "Year(s)":
                 use(TimeCategory) {
-                    nextGenerationDate = nextTargetStartDate - generateAhead.years
+                    nextTargetStartDate = nextTargetStartDate + recurEvery.years
                 }
                 break
         default:
+                log.error "No case for recurPeriod.period: ${recurPeriod.period}"
                 break
+        }
+    }
+
+    public void setNextGenerationDate() {
+        use(TimeCategory) {
+            nextGenerationDate = nextTargetStartDate - generateAhead.days
         }
         def now = new Date()
@@ -95,4 +98,5 @@
                 break
             default:
+                log.error "No case for taskDurationPeriod.period: ${taskDurationPeriod.period}"
                 break
         }
Index: /trunk/grails-app/i18n/messages.properties
===================================================================
--- /trunk/grails-app/i18n/messages.properties	(revision 198)
+++ /trunk/grails-app/i18n/messages.properties	(revision 199)
@@ -42,7 +42,7 @@
 task.leadPerson.help=The primay contact person.
 
-taskRecurring.startDate.NotInTheFuture=Please select a start date that is not in the past, or use original date.
-taskRecurring.startDate=Start Date
-taskRecurring.startDate.help=The tartget start date for the first auto generated subTask.
+taskRecurring.nextTargetStartDate.NotInTheFuture=Please select a start date that is not in the past, or use original date.
+taskRecurring.nextTargetStartDate=Next Target Start Date
+taskRecurring.nextTargetStartDate.help=The target start date for the next auto generated subTask.
 
 task.primaryAsset=Primary Asset
Index: /trunk/grails-app/jobs/TaskRecurringScheduleJob.groovy
===================================================================
--- /trunk/grails-app/jobs/TaskRecurringScheduleJob.groovy	(revision 198)
+++ /trunk/grails-app/jobs/TaskRecurringScheduleJob.groovy	(revision 199)
@@ -1,47 +1,34 @@
+import org.codehaus.groovy.grails.commons.*
 
-class TaskRecurringScheduleJob {/*
-    def timeout = 1000 // execute job once in 1 seconds
-//     def timeout = 60000
+/**
+* Provides a quartz job that reviews and generates all recurring tasks.
+* The quartz scheduler is restarted if this file is edited so startDelay will then delay again.
+* The execute method is called once every repeatInterval (in milliseconds).
+* With concurrent=false the repeat interval starts counting after the previous job completes.
+* Apparently we need a hibernate session otherwise we get a LazyInitializationException, default is true but we specify it to be sure.
+*/
+class TaskRecurringScheduleJob {
+
+    def taskRecurringScheduleService
+
+    def concurrent = false
+    def sessionRequired = true
+
+    static triggers = {
+        simple name: "GenerateAll",
+                    startDelay: 60000,
+                    repeatInterval: ConfigurationHolder.config.taskRecurringScheduleJob.repeatInterval*1000
+    }
 
     def execute() {
-        println "TaskRecurringScheduleJob: tick"
-        println "TaskRecurringScheduleJob: tock"/*
-        def recurringScheduleInstanceList = RecurringSchedule.list()
-        def now = new Date()
 
-        recurringScheduleInstanceList.each() {
+        // Some information can be accessed if we run with "def execute(context) ".
+        // For more info see: http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html
+        // log.debug context.getTrigger()
+        // log.debug context.getPreviousFireTime()
+        // log.debug context.getFireTime()
 
-            if ( now > it.nextDueDate) {
-                def taskInstance = it.task
-                def subTaskInstance = new Task()
-    
-                //Make our new Task a subTask.
-                subTaskInstance.parentTask = taskInstance
-    
-                // Set the required properties
-                subTaskInstance.description = "Generated recurring task: "+taskInstance.description
-                subTaskInstance.comment = taskInstance.comment
-                subTaskInstance.taskGroup = taskInstance.taskGroup
-                subTaskInstance.taskStatus = TaskStatus.findByName("Not Started")
-                subTaskInstance.taskPriority = TaskPriority.get(2)
-                subTaskInstance.taskType = TaskType.get(1)
-                subTaskInstance.leadPerson = taskInstance.leadPerson
-                subTaskInstance.save()
-//                 if(subTaskInstance.save()){println "yes"}
-    
-                //Set the assignedPersons
-                taskInstance.assignedPersons.each() {
-    
-                def assignedPerson = new AssignedPerson(person: it.person,
-                                                                                        task: subTaskInstance,
-                                                                                        estimatedHour: it.estimatedHour,
-                                                                                        estimatedMinute: it.estimatedMinute).save()
-                }
-
-                //Set the nextDueDate so that we don't loop ;-)
-                it.nextDueDate = it.nextDueDate + 1
-    
-            }
-        }//recurringScheduleInstanceList.each()
-    }*/
+        // We do everything via services, quartz just sets up and fires off the thread.
+        taskRecurringScheduleService.generateAll()
+    }
 }
Index: /trunk/grails-app/services/CreateDataService.groovy
===================================================================
--- /trunk/grails-app/services/CreateDataService.groovy	(revision 198)
+++ /trunk/grails-app/services/CreateDataService.groovy	(revision 199)
@@ -18,13 +18,18 @@
 
     /**
-    * Always call this at startup to ensure admin access.
+    * Always call this at startup to ensure that we have admin access
+    * and that the system pseudo person is available.
     */
-    def ensureAdminAccess() {
+    def ensureSystemAndAdminAccess() {
         if(!Authority.findByAuthority("ROLE_AppAdmin") ) {
-            println "ROLE_AppAdmin not found, calling createAdminAuthority()."
+            log.warn "ROLE_AppAdmin not found, calling createAdminAuthority()."
             createAdminAuthority()
         }
+        if(!Person.findByloginName("system") ) {
+            log.warn "LoginName 'system' not found, calling createSystemPerson()."
+            createSystemPerson()
+        }
         if(!Person.findByloginName("admin") ) {
-            println "LoginName 'admin' not found, calling createAdminPerson()."
+            log.warn "LoginName 'admin' not found, calling createAdminPerson()."
             createAdminPerson()
         }
@@ -35,9 +40,8 @@
     */
     def createBaseData() {
-        println "Creating base data..."
+        log.info "Creating base data..."
         // Person and Utils
         createBaseAuthorities()
         createBasePersonGroups()
-        createBasePersons()
         createBaseUnitsOfMeasure()
         createBasePeriods()
@@ -64,5 +68,5 @@
     */
     def createDemoData() {
-        println "Creating demo data..."
+        log.info "Creating demo data..."
         // Person and Utils
         createDemoPersons()
@@ -148,4 +152,22 @@
     }
 
+    def createSystemPerson() {
+        //Person
+        def passClearText = "pass"
+        def passwordEncoded = personService.encodePassword(passClearText)
+        def personInstance
+
+        //Person #1
+        personInstance = new Person(loginName:"system",
+                                    firstName:"gnuMims",
+                                    lastName:"System",
+                                    description:'''This is a pseudo person that the application uses to insert data. DO NOT
+                                                        assign login authorities or change the details of this person.''',
+                                    pass:passClearText,
+                                    password:passwordEncoded,
+                                    email:"system@example.com")
+        saveAndTest(personInstance)
+    }
+
     def createAdminPerson() {
         //Person
@@ -154,8 +176,10 @@
         def personInstance
 
-        //Person #1
+        //Person #2
         personInstance = new Person(loginName:"admin",
                                     firstName:"Admin",
                                     lastName:"Powers",
+                                    description:'''Every time the application starts it ensures that the 'admin' login name is available.
+                                                        DO update the password and other details but keep the login name as 'admin'. ''',
                                     pass:passClearText,
                                     password:passwordEncoded,
@@ -166,4 +190,7 @@
 
     def createBasePersons() {
+    }
+
+    def createDemoPersons() {
         //Person
         def passClearText = "pass"
@@ -171,7 +198,8 @@
         def personInstance
 
-        //Person #1 is admin.
-
-        //Person #2
+        //Person #1 is system.
+        //Person #2 is admin.
+
+        //Person #3
         personInstance = new Person(loginName:"manager",
                                     firstName:"Demo",
@@ -185,5 +213,5 @@
         personInstance.addToPersonGroups(PersonGroup.get(5))
 
-        //Person #3
+        //Person #4
         personInstance = new Person(loginName:"user",
                                     firstName:"Demo",
@@ -195,13 +223,6 @@
         personInstance.addToAuthorities(Authority.get(3))
         personInstance.addToPersonGroups(PersonGroup.get(1))
-    }
-
-    def createDemoPersons() {
-        //Person
-        def passClearText = "pass"
-        def passwordEncoded = personService.encodePassword(passClearText)
-        def personInstance
-
-        //Person #4
+
+        //Person #5
         personInstance = new Person(loginName:"craig",
                                     firstName:"Craig",
@@ -214,5 +235,5 @@
         personInstance.addToPersonGroups(PersonGroup.get(1))
 
-        //Person #5
+        //Person #6
         personInstance = new Person(loginName:"john",
                                     firstName:"John",
@@ -225,5 +246,5 @@
         personInstance.addToPersonGroups(PersonGroup.get(2))
 
-        //Person #6
+        //Person #7
         personInstance = new Person(loginName:"mann",
                                     firstName:"Production",
@@ -425,14 +446,14 @@
         def taskPriorityInstance
 
-        taskPriorityInstance = new TaskPriority(name:"Normal")
+        taskPriorityInstance = new TaskPriority(name:"Normal") // #1
         saveAndTest(taskPriorityInstance)
 
-        taskPriorityInstance = new TaskPriority(name:"Low")
+        taskPriorityInstance = new TaskPriority(name:"Low") // #2
         saveAndTest(taskPriorityInstance)
 
-        taskPriorityInstance = new TaskPriority(name:"High")
+        taskPriorityInstance = new TaskPriority(name:"High") // #3
         saveAndTest(taskPriorityInstance)
 
-        taskPriorityInstance = new TaskPriority(name:"Immediate")
+        taskPriorityInstance = new TaskPriority(name:"Immediate") // #4
         saveAndTest(taskPriorityInstance)
     }
@@ -443,17 +464,17 @@
         def taskTypeInstance
 
-        taskTypeInstance = new TaskType(name:"Unscheduled Breakin")
+        taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1
         saveAndTest(taskTypeInstance)
 
-        taskTypeInstance = new TaskType(name:"Preventative Maintenance")
+        taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2
         saveAndTest(taskTypeInstance)
 
-        taskTypeInstance = new TaskType(name:"Project")
+        taskTypeInstance = new TaskType(name:"Project") // #3
         saveAndTest(taskTypeInstance)
 
-        taskTypeInstance = new TaskType(name:"Turnaround")
+        taskTypeInstance = new TaskType(name:"Turnaround") // #4
         saveAndTest(taskTypeInstance)
 
-        taskTypeInstance = new TaskType(name:"Production Run")
+        taskTypeInstance = new TaskType(name:"Production Run") // #5
         saveAndTest(taskTypeInstance)
     }
@@ -481,5 +502,4 @@
         //Task #1
         p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
-                taskStatus:TaskStatus.findByName("Not Started"),
                 taskPriority:TaskPriority.get(2),
                 taskType:TaskType.get(1),
@@ -493,5 +513,4 @@
         //Task #2
         p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
-                taskStatus:TaskStatus.findByName("Not Started"),
                 taskPriority:TaskPriority.get(2),
                 taskType:TaskType.get(1),
@@ -506,5 +525,4 @@
         //Task #3
         p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
-                taskStatus:TaskStatus.findByName("Not Started"),
                 taskPriority:TaskPriority.get(2),
                 taskType:TaskType.get(1),
@@ -519,5 +537,4 @@
         //Task #4
         p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
-                 taskStatus:TaskStatus.findByName("Not Started"),
                  taskPriority:TaskPriority.get(2),
                  taskType:TaskType.get(1),
@@ -532,5 +549,4 @@
         //Task #5
         p = [taskGroup:TaskGroup.findByName("Production Activites"),
-                 taskStatus:TaskStatus.findByName("Not Started"),
                  taskPriority:TaskPriority.get(2),
                  taskType:TaskType.get(5),
@@ -538,17 +554,16 @@
                  description:"Production Report",
                  comment:"Production report for specific production run or shift",
-                targetStartDate:new Date()-7]
+                targetStartDate:new Date()-6]
 
         taskResult = taskService.create(p)
 
         //Task #6
-        p = [taskGroup:TaskGroup.findByName("New Projects"),
-                 taskStatus:TaskStatus.findByName("Not Started"),
-                 taskPriority:TaskPriority.get(2),
-                 taskType:TaskType.get(3),
-                 leadPerson:Person.get(1),
-                 description:"Make killer CMMS app",
-                 comment:"Use Grails and get a move on!",
-                targetStartDate:new Date()-6]
+        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
+                 taskPriority:TaskPriority.get(1),
+                 taskType:TaskType.get(2),
+                 leadPerson:Person.get(4),
+                 description:"This is a recurring task",
+                 comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.",
+                targetStartDate:new Date()]
 
         taskResult = taskService.create(p)
@@ -631,21 +646,21 @@
         taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1),
                                                                                                     recurEvery: 1,
-                                                                                                    recurPeriod: Period.get(1),
-                                                                                                    startDate: new Date(),
+                                                                                                    recurPeriod: Period.get(2),
+                                                                                                    nextTargetStartDate: new Date(),
                                                                                                     generateAhead: 1,
-                                                                                                    generateAheadPeriod: Period.get(1),
-                                                                                                    taskDuration: 1,
-                                                                                                    taskDurationPeriod: Period.get(1))
+                                                                                                    taskDuration: 2,
+                                                                                                    taskDurationPeriod: Period.get(1),
+                                                                                                    enabled: false)
         saveAndTest(taskRecurringScheduleInstance)
 
         //TaskRecurringSchedule #2
-        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2),
+        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6),
                                                                                                     recurEvery: 1,
                                                                                                     recurPeriod: Period.get(1),
-                                                                                                    startDate: new Date(),
+                                                                                                    nextTargetStartDate: new Date(),
                                                                                                     generateAhead: 1,
-                                                                                                    generateAheadPeriod: Period.get(1),
                                                                                                     taskDuration: 1,
-                                                                                                    taskDurationPeriod: Period.get(1))
+                                                                                                    taskDurationPeriod: Period.get(1),
+                                                                                                    enabled: true)
         saveAndTest(taskRecurringScheduleInstance)
     }
@@ -1051,6 +1066,6 @@
         if(!object.save()) {
 //             DemoDataSuccessful = false
-            println "'${object}' failed to save!"
-            println object.errors
+            log.error "'${object}' failed to save!"
+            log.error object.errors
             return false
         }
Index: /trunk/grails-app/services/TaskRecurringScheduleService.groovy
===================================================================
--- /trunk/grails-app/services/TaskRecurringScheduleService.groovy	(revision 199)
+++ /trunk/grails-app/services/TaskRecurringScheduleService.groovy	(revision 199)
@@ -0,0 +1,35 @@
+class TaskRecurringScheduleService {
+
+    boolean transactional = false
+
+    def dateUtilService
+    def taskService
+
+    def generateAll() {
+
+        /// @todo: disable recurringSchedule when moving a task to trash.
+        def taskRecurringScheduleList = TaskRecurringSchedule.findAllByEnabled(true)
+
+        taskRecurringScheduleList.each() {
+
+            if ( dateUtilService.getTomorrow() > it.nextGenerationDate) {
+                    def p = [:]
+                    p.targetStartDate = it.nextTargetStartDate
+                    p.targetCompletionDate = it.nextTargetCompletionDate
+                    def result = taskService.createSubTask(it.task, p)
+                    if( !result.error ) {
+                        it.lastGeneratedSubTask = result.taskInstance
+                        it.subTasksGenerated++
+                        it.setNextTargetStartDate()
+                        it.setNextGenerationDate()
+                        it.setNextTargetCompletionDate()
+                    }
+                    else {
+                        log.error result
+                    }
+            }
+
+        }
+    }
+
+} // end of class
Index: /trunk/grails-app/views/taskDetailed/show.gsp
===================================================================
--- /trunk/grails-app/views/taskDetailed/show.gsp	(revision 198)
+++ /trunk/grails-app/views/taskDetailed/show.gsp	(revision 199)
@@ -462,14 +462,28 @@
 
                                             <td valign="top" class="value">${taskRecurringScheduleInstance.encodeAsHTML()}</td>
-
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Start Date:</td>
+                                        </tr>
+
+                                        <tr class="prop">
+                                            <td valign="top" class="name">Next Generation Date:</td>
 
                                             <td valign="top" class="value">
-                                                <g:formatDate date="${taskRecurringScheduleInstance.startDate}" format="EEE, dd-MMM-yyyy"/>
+                                                <g:formatDate date="${taskRecurringScheduleInstance.nextGenerationDate}" format="EEE, dd-MMM-yyyy"/>
                                             </td>
-
+                                        </tr>
+
+                                        <tr class="prop">
+                                            <td valign="top" class="name">Generate Ahead:</td>
+
+                                            <td valign="top" class="value">
+                                                ${taskRecurringScheduleInstance?.generateAhead} ${Period.get(1).encodeAsHTML()}
+                                            </td>
+                                        </tr>
+
+                                        <tr class="prop">
+                                            <td valign="top" class="name">Next Target Start Date:</td>
+
+                                            <td valign="top" class="value">
+                                                <g:formatDate date="${taskRecurringScheduleInstance.nextTargetStartDate}" format="EEE, dd-MMM-yyyy"/>
+                                            </td>
                                         </tr>
 
@@ -483,71 +497,17 @@
 
                                         <tr class="prop">
-                                            <td valign="top" class="name">Generate Ahead:</td>
-
-                                            <td valign="top" class="value">
-                                                ${taskRecurringScheduleInstance?.generateAhead} ${taskRecurringScheduleInstance?.generateAheadPeriod}
-                                            </td>
-
-                                        </tr>
-
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Is Enabled:</td>
-
-                                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'isEnabled')}</td>
-
-                                        </tr>
-
-                                    </tbody>
-                                </table>
-
-                                <table>
-                                    <tbody>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Next Target Start Date:</td>   
-
-                                            <td valign="top" class="value">
-                                                <g:formatDate date="${taskRecurringScheduleInstance.nextTargetStartDate}" format="EEE, dd-MMM-yyyy"/>
-                                            </td>
-
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Next Target Completion Date:</td>   
+                                            <td valign="top" class="name">Next Target Completion Date:</td>
 
                                             <td valign="top" class="value">
                                                 <g:formatDate date="${taskRecurringScheduleInstance.nextTargetCompletionDate}" format="EEE, dd-MMM-yyyy"/>
                                             </td>
-
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Next Generation Date:</td>
-
-                                            <td valign="top" class="value">
-                                                <g:formatDate date="${taskRecurringScheduleInstance.nextGenerationDate}" format="EEE, dd-MMM-yyyy"/>
-                                            </td>
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Last Generated Date:</td>
-
-                                            <td valign="top" class="value">
-                                                <g:formatDate date="${taskRecurringScheduleInstance.lastGeneratedDate}" format="EEE, dd-MMM-yyyy"/>
-                                            </td>
-
-                                        </tr>
-
-                                        <tr class="prop">
-                                            <td valign="top" class="name">Last Generated Sub Task:</td>
-
-                                            <td valign="top" class="value">
-                                                <g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance?.lastGeneratedSubTask?.id}">
-                                                    ${taskRecurringScheduleInstance?.lastGeneratedSubTask?.encodeAsHTML()}
-                                                </g:link>
-                                            </td>
-                                        </tr>
+                                        </tr>
+
+                                        <tr class="prop">
+                                            <td valign="top" class="name">Enabled:</td>
+
+                                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>
+                                        </tr>
+
                                     </tbody>
                                 </table>
@@ -557,4 +517,5 @@
                                     <input type="hidden" name="id" value="${taskRecurringScheduleInstance?.id}" />
                                     <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
+                                    <span class="button"><g:actionSubmit class="go" value="Show" /></span>
                                 </g:form>
                             </div>
Index: /trunk/grails-app/views/taskRecurringSchedule/create.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringSchedule/create.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringSchedule/create.gsp	(revision 199)
@@ -55,13 +55,4 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="lastGeneratedDate">Last Generated Date:</label>
-                                </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'lastGeneratedDate','errors')}">
-                                    <g:datePicker name="lastGeneratedDate" value="${taskRecurringScheduleInstance?.lastGeneratedDate}" precision="minute" noSelection="['':'']"></g:datePicker>
-                                </td>
-                            </tr> 
-                        
-                            <tr class="prop">
-                                <td valign="top" class="name">
                                     <label for="lastGeneratedSubTask">Last Generated Sub Task:</label>
                                 </td>
@@ -73,17 +64,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="generateAheadPeriod">Generate Ahead Period:</label>
+                                    <label for="enabled">Enabled:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'generateAheadPeriod','errors')}">
-                                    <g:select optionKey="id" from="${Period.list()}" name="generateAheadPeriod.id" value="${taskRecurringScheduleInstance?.generateAheadPeriod?.id}" ></g:select>
-                                </td>
-                            </tr> 
-                        
-                            <tr class="prop">
-                                <td valign="top" class="name">
-                                    <label for="isEnabled">Is Enabled:</label>
-                                </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'isEnabled','errors')}">
-                                    <g:checkBox name="isEnabled" value="${taskRecurringScheduleInstance?.isEnabled}" ></g:checkBox>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}">
+                                    <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox>
                                 </td>
                             </tr> 
@@ -127,8 +109,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="startDate">Start Date:</label>
+                                    <label for="subTasksGenerated">Sub Tasks Generated:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'startDate','errors')}">
-                                    <g:datePicker name="startDate" value="${taskRecurringScheduleInstance?.startDate}" precision="minute" ></g:datePicker>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'subTasksGenerated','errors')}">
+                                    <input type="text" id="subTasksGenerated" name="subTasksGenerated" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'subTasksGenerated')}" />
                                 </td>
                             </tr> 
Index: /trunk/grails-app/views/taskRecurringSchedule/edit.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringSchedule/edit.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringSchedule/edit.gsp	(revision 199)
@@ -58,13 +58,4 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="lastGeneratedDate">Last Generated Date:</label>
-                                </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'lastGeneratedDate','errors')}">
-                                    <g:datePicker name="lastGeneratedDate" value="${taskRecurringScheduleInstance?.lastGeneratedDate}" precision="minute" noSelection="['':'']"></g:datePicker>
-                                </td>
-                            </tr> 
-                        
-                            <tr class="prop">
-                                <td valign="top" class="name">
                                     <label for="lastGeneratedSubTask">Last Generated Sub Task:</label>
                                 </td>
@@ -76,17 +67,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="generateAheadPeriod">Generate Ahead Period:</label>
+                                    <label for="enabled">Enabled:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'generateAheadPeriod','errors')}">
-                                    <g:select optionKey="id" from="${Period.list()}" name="generateAheadPeriod.id" value="${taskRecurringScheduleInstance?.generateAheadPeriod?.id}" ></g:select>
-                                </td>
-                            </tr> 
-                        
-                            <tr class="prop">
-                                <td valign="top" class="name">
-                                    <label for="isEnabled">Is Enabled:</label>
-                                </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'isEnabled','errors')}">
-                                    <g:checkBox name="isEnabled" value="${taskRecurringScheduleInstance?.isEnabled}" ></g:checkBox>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}">
+                                    <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox>
                                 </td>
                             </tr> 
@@ -130,8 +112,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="startDate">Start Date:</label>
+                                    <label for="subTasksGenerated">Sub Tasks Generated:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'startDate','errors')}">
-                                    <g:datePicker name="startDate" value="${taskRecurringScheduleInstance?.startDate}" precision="minute" ></g:datePicker>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'subTasksGenerated','errors')}">
+                                    <input type="text" id="subTasksGenerated" name="subTasksGenerated" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'subTasksGenerated')}" />
                                 </td>
                             </tr> 
Index: /trunk/grails-app/views/taskRecurringSchedule/list.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringSchedule/list.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringSchedule/list.gsp	(revision 199)
@@ -29,8 +29,8 @@
                    	        <g:sortableColumn property="generateAhead" title="Generate Ahead" />
                         
-                   	        <g:sortableColumn property="lastGeneratedDate" title="Last Generated Date" />
-                        
                    	        <th>Last Generated Sub Task</th>
                    	    
+                   	        <g:sortableColumn property="enabled" title="Enabled" />
+                        
                         </tr>
                     </thead>
@@ -47,7 +47,7 @@
                             <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'generateAhead')}</td>
                         
-                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'lastGeneratedDate')}</td>
+                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'lastGeneratedSubTask')}</td>
                         
-                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'lastGeneratedSubTask')}</td>
+                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>
                         
                         </tr>
Index: /trunk/grails-app/views/taskRecurringSchedule/show.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringSchedule/show.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringSchedule/show.gsp	(revision 199)
@@ -51,11 +51,4 @@
                     
                         <tr class="prop">
-                            <td valign="top" class="name">Last Generated Date:</td>
-                            
-                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'lastGeneratedDate')}</td>
-                            
-                        </tr>
-                    
-                        <tr class="prop">
                             <td valign="top" class="name">Last Generated Sub Task:</td>
                             
@@ -65,14 +58,7 @@
                     
                         <tr class="prop">
-                            <td valign="top" class="name">Generate Ahead Period:</td>
+                            <td valign="top" class="name">Enabled:</td>
                             
-                            <td valign="top" class="value"><g:link controller="period" action="show" id="${taskRecurringScheduleInstance?.generateAheadPeriod?.id}">${taskRecurringScheduleInstance?.generateAheadPeriod?.encodeAsHTML()}</g:link></td>
-                            
-                        </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Is Enabled:</td>
-                            
-                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'isEnabled')}</td>
+                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>
                             
                         </tr>
@@ -107,7 +93,7 @@
                     
                         <tr class="prop">
-                            <td valign="top" class="name">Start Date:</td>
+                            <td valign="top" class="name">Sub Tasks Generated:</td>
                             
-                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'startDate')}</td>
+                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'subTasksGenerated')}</td>
                             
                         </tr>
Index: /trunk/grails-app/views/taskRecurringScheduleDetailed/create.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringScheduleDetailed/create.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringScheduleDetailed/create.gsp	(revision 199)
@@ -38,8 +38,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="startDate">Start Date:</label>
+                                    <label for="nextTargetStartDate">Next Target Start Date:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'startDate','errors')}">
-                                    <richui:dateChooser name="startDate" format="dd-MM-yyyy" value="${taskRecurringScheduleInstance?.startDate}" />
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'nextTargetStartDate','errors')}">
+                                    <richui:dateChooser name="nextTargetStartDate" format="dd-MM-yyyy" value="${taskRecurringScheduleInstance?.nextTargetStartDate}" />
                                 </td>
                             </tr>   
@@ -74,5 +74,5 @@
                                     <input type="text" class="time ${hasErrors(bean:taskRecurringScheduleInstance,field:'generateAhead','errors')}"
                                         id="generateAhead" name="generateAhead" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'generateAhead')}" />
-                                    <g:select optionKey="id" from="${Period.list()}" name="generateAheadPeriod.id" value="${taskRecurringScheduleInstance?.generateAheadPeriod?.id}" ></g:select>
+                                        ${Period.get(1).encodeAsHTML()}
                                 </td>
                             </tr>
@@ -80,8 +80,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="isEnabled">Is Enabled:</label>
+                                    <label for="enabled">Enabled:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'isEnabled','errors')}">
-                                    <g:checkBox name="isEnabled" value="${taskRecurringScheduleInstance?.isEnabled}" ></g:checkBox>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}">
+                                    <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox>
                                 </td>
                             </tr>
Index: /trunk/grails-app/views/taskRecurringScheduleDetailed/edit.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringScheduleDetailed/edit.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringScheduleDetailed/edit.gsp	(revision 199)
@@ -39,8 +39,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="startDate">Start Date:</label>
+                                    <label for="nextTargetStartDate">Next Target Start Date:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'startDate','errors')}">
-                                    <richui:dateChooser name="startDate" format="dd-MM-yyyy" value="${taskRecurringScheduleInstance?.startDate}" />
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'nextTargetStartDate','errors')}">
+                                    <richui:dateChooser name="nextTargetStartDate" format="dd-MM-yyyy" value="${taskRecurringScheduleInstance?.nextTargetStartDate}" />
                                 </td>
                             </tr>   
@@ -75,5 +75,5 @@
                                     <input type="text" class="time ${hasErrors(bean:taskRecurringScheduleInstance,field:'generateAhead','errors')}"
                                         id="generateAhead" name="generateAhead" value="${fieldValue(bean:taskRecurringScheduleInstance,field:'generateAhead')}" />
-                                    <g:select optionKey="id" from="${Period.list()}" name="generateAheadPeriod.id" value="${taskRecurringScheduleInstance?.generateAheadPeriod?.id}" ></g:select>
+                                        ${Period.get(1).encodeAsHTML()}
                                 </td>
                             </tr>
@@ -81,8 +81,8 @@
                             <tr class="prop">
                                 <td valign="top" class="name">
-                                    <label for="isEnabled">Is Enabled:</label>
+                                    <label for="enabled">Enabled:</label>
                                 </td>
-                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'isEnabled','errors')}">
-                                    <g:checkBox name="isEnabled" value="${taskRecurringScheduleInstance?.isEnabled}" ></g:checkBox>
+                                <td valign="top" class="value ${hasErrors(bean:taskRecurringScheduleInstance,field:'enabled','errors')}">
+                                    <g:checkBox name="enabled" value="${taskRecurringScheduleInstance?.enabled}" ></g:checkBox>
                                 </td>
                             </tr>
Index: /trunk/grails-app/views/taskRecurringScheduleDetailed/list.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringScheduleDetailed/list.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringScheduleDetailed/list.gsp	(revision 199)
@@ -29,5 +29,5 @@
                    	        <g:sortableColumn property="recurPeriod" title="Recur Period" />
                    	        
-                   	        <g:sortableColumn property="isEnabled" title="Is Enabled" />
+                   	        <g:sortableColumn property="enabled" title="Enabled" />
 
                             <th></th>
@@ -48,5 +48,5 @@
                             <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'recurPeriod')}</td>
                         
-                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'isEnabled')}</td>
+                            <td>${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>
 
                             <td>
Index: /trunk/grails-app/views/taskRecurringScheduleDetailed/show.gsp
===================================================================
--- /trunk/grails-app/views/taskRecurringScheduleDetailed/show.gsp	(revision 198)
+++ /trunk/grails-app/views/taskRecurringScheduleDetailed/show.gsp	(revision 199)
@@ -13,116 +13,123 @@
         <div class="body">
             <g:if test="${flash.message}">
-            <div class="message">${flash.message}</div>
+                <div class="message">${flash.message}</div>
             </g:if>
             <div class="dialog">
                 <table>
-                    <tbody>     
-                                   
+                    <tbody>
                         <tr class="prop">
-                            <td valign="top" class="name">Id:</td>
-                            
-                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'id')}</td>
-                            
+                            <td valign="top" class="name">Recurring Schedule for task:</td>
+
+                            <td valign="top" class="value">
+                                <g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance.task?.id}">
+                                    ${taskRecurringScheduleInstance.task.encodeAsHTML()}
+                                </g:link>
+                            </td>
                         </tr>
 
-						<tr class="prop">
-							<td valign="top" class="name">
-								<label for="recForTask">Recurring Schedule for Task:</label>
-							</td>
-							<td valign="top" name="recForTask" class="value">
-								<g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance?.task?.id}">${taskRecurringScheduleInstance?.task?.encodeAsHTML()}</g:link>
-							</td>
-						</tr>
-                    
                         <tr class="prop">
-                            <td valign="top" class="name">Start Date:</td>
-                            
-                            <td valign="top" class="value">
-                                <g:formatDate date="${taskRecurringScheduleInstance.startDate}" format="EEE, dd-MMM-yyyy"/>
-                            </td>
+                            <td valign="top" class="name"></td>
+
+                            <td valign="top" class="value">${taskRecurringScheduleInstance.encodeAsHTML()}</td>
                         </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Recur Every:</td>
-                            
-                            <td valign="top" class="value">
-								${taskRecurringScheduleInstance?.recurEvery} ${taskRecurringScheduleInstance?.recurPeriod}
-							</td>
-                            
-                        </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Task Duration:</td>
-                            
-                            <td valign="top" class="value">
-                                ${taskRecurringScheduleInstance?.taskDuration} ${taskRecurringScheduleInstance?.taskDurationPeriod}
-                            </td>
-                        </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Generate Ahead:</td>
-                            
-                            <td valign="top" class="value">
-                                ${taskRecurringScheduleInstance?.generateAhead} ${taskRecurringScheduleInstance?.generateAheadPeriod}
-                            </td>
-                            
-                        </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Is Enabled:</td>
-                            
-                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'isEnabled')}</td>
-                            
-                        </tr>
-                    </tbody>
-                </table>
-                
-                <table>
-                    <tbody>
-                        <tr class="prop">
-                            <td valign="top" class="name">Next Target Start Date:</td>
-                            
-                            <td valign="top" class="value">
-								<g:formatDate date="${taskRecurringScheduleInstance.nextTargetStartDate}" format="EEE, dd-MMM-yyyy"/>
-							</td>
-                            
-                        </tr>
-                    
-                        <tr class="prop">
-                            <td valign="top" class="name">Next Target Completion Date:</td>
-                            
-                            <td valign="top" class="value">
-                                <g:formatDate date="${taskRecurringScheduleInstance.nextTargetCompletionDate}" format="EEE, dd-MMM-yyyy"/>
-                            </td>
-                            
-                        </tr>
-                        
+
                         <tr class="prop">
                             <td valign="top" class="name">Next Generation Date:</td>
-                            
+
                             <td valign="top" class="value">
                                 <g:formatDate date="${taskRecurringScheduleInstance.nextGenerationDate}" format="EEE, dd-MMM-yyyy"/>
                             </td>
                         </tr>
-						
+
                         <tr class="prop">
-                            <td valign="top" class="name">Last Generated Date:</td>
-                            
+                            <td valign="top" class="name">Generate Ahead:</td>
+
                             <td valign="top" class="value">
-                           		<g:formatDate date="${taskRecurringScheduleInstance.lastGeneratedDate}" format="EEE, dd-MMM-yyyy"/>
-							</td>
+                                ${taskRecurringScheduleInstance.generateAhead} ${Period.get(1).encodeAsHTML()}
+                            </td>
                         </tr>
-                    
+
                         <tr class="prop">
-                            <td valign="top" class="name">Last Generated Sub Task:</td>
-                            
+                            <td valign="top" class="name">Next Target Start Date:</td>
+
                             <td valign="top" class="value">
-								<g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance?.lastGeneratedSubTask?.id}">
-									${taskRecurringScheduleInstance?.lastGeneratedSubTask?.encodeAsHTML()}
-								</g:link>
-							</td>
-                            
+                                <g:formatDate date="${taskRecurringScheduleInstance.nextTargetStartDate}" format="EEE, dd-MMM-yyyy"/>
+                            </td>
                         </tr>
-                    
+
+                        <tr class="prop">
+                            <td valign="top" class="name">Task Duration:</td>
+
+                            <td valign="top" class="value">
+                                ${taskRecurringScheduleInstance.taskDuration} ${taskRecurringScheduleInstance.taskDurationPeriod}
+                            </td>
+                        </tr>
+
+                        <tr class="prop">
+                            <td valign="top" class="name">Next Target Completion Date:</td>
+
+                            <td valign="top" class="value">
+                                <g:formatDate date="${taskRecurringScheduleInstance.nextTargetCompletionDate}" format="EEE, dd-MMM-yyyy"/>
+                            </td>
+                        </tr>
+
+                        <tr class="prop">
+                            <td valign="top" class="name">Enabled:</td>
+
+                            <td valign="top" class="value">${fieldValue(bean:taskRecurringScheduleInstance, field:'enabled')}</td>
+                        </tr>
+
+                    </tbody>
+                </table>
+                <table>
+                    <tbody>
+
+                        <tr class="prop">
+                            <td valign="top" class="name">Note:</td>
+
+                            <td valign="top" class="value">
+                                Recurring Schedules are reviewed and Sub Tasks generated every ${grailsApplication.config.taskRecurringScheduleJob.repeatInterval.encodeAsHTML()} seconds.
+                            </td>
+                        </tr>
+
+                        <tr class="prop">
+                            <td valign="top" class="name">Sub Tasks Generated:</td>
+
+                            <td valign="top" class="value">
+                                ${fieldValue(bean:taskRecurringScheduleInstance, field:'subTasksGenerated')}
+                            </td>
+                        </tr>
+
+                        <g:if test="${taskRecurringScheduleInstance.lastGeneratedSubTask}">
+
+                            <tr class="prop">
+                                <td valign="top" class="name">Last Generated Sub Task:</td>
+
+                                <td valign="top" class="value">
+                                    <g:link controller="taskDetailed" action="show" id="${taskRecurringScheduleInstance.lastGeneratedSubTask?.id}">
+                                        ${taskRecurringScheduleInstance.lastGeneratedSubTask?.encodeAsHTML()}
+                                    </g:link>
+                                </td>
+                            </tr>
+
+                            <tr class="prop">
+                                <td valign="top" class="name"></td>
+
+                                <td valign="top" class="value">
+                                        ${TaskModification.findByTaskAndTaskModificationType(taskRecurringScheduleInstance.lastGeneratedSubTask, TaskModificationType.get(1))}
+                                </td>
+                            </tr>
+
+                            <tr class="prop">
+                                <td valign="top" class="name"></td>
+
+                                <td valign="top" class="value">
+                                        With target start date:
+                                        <g:formatDate date="${taskRecurringScheduleInstance.lastGeneratedSubTask?.targetStartDate}" format="EEE, dd-MMM-yyyy"/>
+                                </td>
+                            </tr>
+
+                        </g:if>
+
                     </tbody>
                 </table>
@@ -130,5 +137,5 @@
             <div class="buttons">
                 <g:form>
-                    <input type="hidden" name="id" value="${taskRecurringScheduleInstance?.id}" />
+                    <input type="hidden" name="id" value="${taskRecurringScheduleInstance.id}" />
                     <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
 <!--                     <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span> -->
