Index: trunk/grails-app/controllers/EntryDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/EntryDetailedController.groovy	(revision 185)
+++ trunk/grails-app/controllers/EntryDetailedController.groovy	(revision 186)
@@ -4,4 +4,5 @@
 
     def personService
+    def taskService
 
     def index = { redirect(action:list,params:params) }
@@ -20,5 +21,5 @@
         if(!entryInstance) {
             flash.message = "Entry not found with id ${params.id}"
-            redirect(action:list)
+            redirect(controller: 'taskDetailed', action: 'search')
         }
         else { return [ entryInstance : entryInstance ] }
@@ -42,5 +43,5 @@
         else {
             flash.message = "Entry not found with id ${params.id}"
-            redirect(action:list)
+            redirect(controller: "taskDetailed", action:"search")
         }
     }
@@ -50,5 +51,5 @@
         if(!entryInstance) {
                 flash.message = "Entry not found with id ${params.id}"
-                redirect(action:list)
+                redirect(controller: "taskDetailed", action:"search")
         }
         else {
@@ -86,5 +87,5 @@
         else {
             flash.message = "Entry not found with id ${params.id}"
-            redirect(action:edit,id:params.id)
+            redirect(controller: "taskDetailed", action:"search")
         }
     }
@@ -98,20 +99,27 @@
         }
         catch(Exception e) {
-            flash.message = "Please select a task, then 'Add Entry'"
-            redirect(controller:"taskDetailed", action:"list")
+            flash.message = "Please select a task, then 'Add Entry'."
+            redirect(controller:"taskDetailed", action:"search")
         }
     }
 
     def save = {
-        def entryInstance = new Entry(params)
+        def result = taskService.createEntry(params)
 
-        entryInstance.enteredBy = personService.currentUser()
-        if(!entryInstance.hasErrors() && entryInstance.save(flush: true)) {
-            flash.message = "Entry ${entryInstance.id} created"
-            redirect(controller:"taskDetailed", action:"show", id: params.task.id)
+        if(!result.error) {
+            flash.message = "Entry created."
+            redirect(controller: "taskDetailed", action: "show", id: result.taskId)
         }
         else {
-            render(view:'create',model:[entryInstance:entryInstance])
+            if(result.entryInstance) {
+                render(view:'create',model:[entryInstance: result.entryInstance])
+            }
+            else {
+                flash.message = "Could not create entry."
+                redirect(controller: "taskDetailed", action:"search")
+            }
+
         }
     }
+
 }
Index: trunk/grails-app/i18n/messages.properties
===================================================================
--- trunk/grails-app/i18n/messages.properties	(revision 185)
+++ trunk/grails-app/i18n/messages.properties	(revision 186)
@@ -51,4 +51,9 @@
 inventoryMovement.quantity.insufficientItemsInStock=Could not complete operation, insufficient items in stock.
 inventoryMovement.inventoryItem.notFound=Inventory Item not found.
+
+entry.task.notFound=Could not complete operation, task not found.
+entry.task.failedToSave=Could not complete operation, task failed to save.
+entry.task.failedToSaveTaskModification=Could not complete operation, task modification failed to save.
+entry.task.taskIsComplete=This operation is not permitted on a complete task.
 
 default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}]
Index: trunk/grails-app/services/TaskService.groovy
===================================================================
--- trunk/grails-app/services/TaskService.groovy	(revision 185)
+++ trunk/grails-app/services/TaskService.groovy	(revision 186)
@@ -36,7 +36,70 @@
     } // end create()
 
-    def start() {
-        //TaskModificationType.get(2)
-    }  // end start()
+    def createEntry(params) {
+        Task.withTransaction { status ->
+            def result = [:]
+            result.entryInstance = new Entry(params)
+            result.entryInstance.enteredBy = personService.currentUser()
+
+            if(result.entryInstance.validate()) {
+                def taskInstance = Task.lock(result.entryInstance.task.id)
+                result.taskId = result.entryInstance.task.id
+
+                if(!taskInstance) {
+                    status.setRollbackOnly()
+                    result.entryInstance.errors.rejectValue('task', "entry.task.notFound")
+                    result.error = true
+                    return result
+                }
+
+                if(taskInstance.taskStatus.id == 3) {
+                    status.setRollbackOnly()
+                    result.entryInstance.errors.rejectValue('task', "entry.task.taskIsComplete")
+                    result.error = true
+                    return result
+                }
+
+                // If task status is "Not Started" and entry type is "Work Done" then we create the started modification and set the status.
+                if(taskInstance.taskStatus.id == 1 && result.entryInstance.entryType.id == 2) {
+
+                    // Create the "Started" task modification, this provides the "Actual started date".
+                    def taskModification = new TaskModification(person: personService.currentUser(),
+                                                            taskModificationType: TaskModificationType.get(2),
+                                                            task: taskInstance)
+
+                    if(!taskModification.save()) {
+                        status.setRollbackOnly()
+                        taskInstance.errors.rejectValue("task", "entry.task.failedToSaveTaskModification")
+                        result.error = true
+                        return result
+                    }
+
+                    // Set task status to "In progress".
+                    taskInstance.taskStatus = TaskStatus.get(2)
+
+                    if(!taskInstance.save()) {
+                        status.setRollbackOnly()
+                        result.entryInstance.errors.rejectValue("task", "entry.task.failedToSave")
+                        result.error = true
+                        return result
+                    }
+                }
+
+                if(!result.entryInstance.save()) {
+                    status.setRollbackOnly()
+                    result.error = true
+                    return result
+                }
+
+                // All went well if we get to here.
+                return result
+            }
+            else {
+                result.error = true
+                return result
+            }
+
+        } //end withTransaction
+    } // end create()
 
     def update(params) {
Index: trunk/grails-app/views/entryDetailed/create.gsp
===================================================================
--- trunk/grails-app/views/entryDetailed/create.gsp	(revision 185)
+++ trunk/grails-app/views/entryDetailed/create.gsp	(revision 186)
@@ -33,5 +33,5 @@
                                 </td>
                                 <td valign="top" class="name">
-                                    ${entryInstance?.task?.description}
+                                    ${entryInstance?.task}
                                 </td>
                             </tr> 
