Index: trunk/grails-app/services/TaskService.groovy
===================================================================
--- trunk/grails-app/services/TaskService.groovy	(revision 432)
+++ trunk/grails-app/services/TaskService.groovy	(revision 433)
@@ -29,4 +29,53 @@
 
     /**
+    * Determines and returns a list of possible task types for scheduled tasks.
+    * @returns A list of the possible task types.
+    */
+    def getScheduledTaskTypes() {
+        def criteria = TaskType.createCriteria()
+        def scheduledTaskTypes = criteria {
+            and {
+                eq('isActive', true)
+                gt('id', 2L)
+                }
+        }
+    }
+
+    /**
+    * Determines and returns a list of possible task priorites for Scheduled tasks.
+    * @returns A list of the possible task priorites.
+    */
+    def getScheduledTaskPriorities() {
+        def criteria = TaskPriority.createCriteria()
+        def scheduledTaskPriorities = [:]
+        scheduledTaskPriorities.list = criteria {
+            and {
+                eq('isActive', true)
+                gt('id', 1L)
+                }
+        }
+        scheduledTaskPriorities.default = scheduledTaskPriorities.list.find { it.id == 4L } //  1-Normal.
+        return scheduledTaskPriorities
+    }
+
+    /**
+    * Determines and returns a list of possible task priorites for Unscheduled tasks.
+    * @returns A map containing a list of the possible task priorites and the default priority.
+    */
+    def getUnscheduledTaskPriorities() {
+        def criteria = TaskPriority.createCriteria()
+        def unscheduledTaskPriorities = [:]
+        unscheduledTaskPriorities.list = criteria {
+            and {
+                eq('isActive', true)
+                lt('id', 5L)
+                ne('id', 1L)
+            }
+        }
+        unscheduledTaskPriorities.default = unscheduledTaskPriorities.list.find { it.id == 3L } // 2-High.
+        return unscheduledTaskPriorities
+    }
+
+    /**
     * Creates a new task with the given params.
     * @param params The params to use when creating the new task.
@@ -646,4 +695,49 @@
 
     /**
+    * Creates a new unscheduled breakin task with the given params.
+    * @param params The params to use when creating the new task.
+    * @returns A map containing result.error (if any error) and result.taskInstance.
+    */
+    def saveUnscheduled(params) {
+        Task.withTransaction { status ->
+            def result = [:]
+
+            def fail = { Map m ->
+                status.setRollbackOnly()
+                if(result.taskInstance && m.field)
+                    result.taskInstance.errors.rejectValue(m.field, m.code)
+                result.error = [ code: m.code, args: ["Task", params.id] ]
+                return result
+            }
+
+            // If not supplied.
+            if(!params.taskStatus)
+                params.taskStatus = TaskStatus.get(1) // Not Started.
+
+            result.taskInstance = new Task(params)
+
+            // Always for an unscheduled breakin..
+            result.taskInstance.taskType = TaskType.get(2) // Unscheduled Breakin.
+            result.taskInstance.taskBudgetStatus = TaskBudgetStatus.get(1) // Unplanned.
+
+            if(result.taskInstance.hasErrors() || !result.taskInstance.save())
+                fail(code:"default.create.failure")
+
+            if(!result.error) {
+                def taskModification = new TaskModification(person: authService.currentUser,
+                                                                taskModificationType: TaskModificationType.get(1), // Created.
+                                                                task: result.taskInstance)
+
+                if(taskModification.hasErrors() || !taskModification.save())
+                    fail(field:"taskModifications", code:"task.modifications.failedToSave")
+            }
+
+            // Success.
+            return result
+
+        } //end withTransaction
+    } // end saveUnscheduled()
+
+    /**
     * Creates a new immediate callout task with the given params.
     * @param params The params to use when creating the new task.
@@ -671,5 +765,5 @@
             result.taskInstance.taskType = TaskType.get(1) // Immediate Callout.
             result.taskInstance.taskBudgetStatus = TaskBudgetStatus.get(1) // Unplanned.
-            result.taskInstance.taskPriority = TaskPriority.get(4) // Immediate.
+            result.taskInstance.taskPriority = TaskPriority.get(1) // Immediate.
             result.taskInstance.taskGroup = TaskGroup.get(1) // Engineering Activites.
             result.taskInstance.approved = true
