[69] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
[165] | 2 | import org.codehaus.groovy.grails.commons.ConfigurationHolder |
---|
[209] | 3 | import com.zeddware.grails.plugins.filterpane.FilterUtils |
---|
[476] | 4 | import org.springframework.web.servlet.support.RequestContextUtils as RCU |
---|
[69] | 5 | |
---|
[298] | 6 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) |
---|
[85] | 7 | class TaskDetailedController extends BaseController { |
---|
[66] | 8 | |
---|
[291] | 9 | def authService |
---|
[180] | 10 | def taskService |
---|
[143] | 11 | def taskSearchService |
---|
[585] | 12 | def taskReportService |
---|
[140] | 13 | def filterService |
---|
[165] | 14 | def exportService |
---|
[214] | 15 | def dateUtilService |
---|
[139] | 16 | |
---|
[181] | 17 | // these actions only accept POST requests |
---|
[418] | 18 | static allowedMethods = [save:'POST',update:'POST',restore:'POST', trash:'POST', |
---|
| 19 | approve:'POST', renegeApproval:'POST', complete:'POST', |
---|
| 20 | reopen:'POST', setAttentionFlag:'POST', clearAttentionFlag:'POST'] |
---|
[66] | 21 | |
---|
[298] | 22 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[196] | 23 | def index = { redirect(action: 'search', params: params) } |
---|
[140] | 24 | |
---|
[298] | 25 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[326] | 26 | def setSearchParamsMax = { |
---|
[262] | 27 | def max = 1000 |
---|
[615] | 28 | if(params.newMax?.isInteger()) { |
---|
[260] | 29 | def i = params.newMax.toInteger() |
---|
[262] | 30 | if(i > 0 && i <= max) |
---|
| 31 | session.taskSearchParamsMax = params.newMax |
---|
| 32 | if(i > max) |
---|
| 33 | session.taskSearchParamsMax = max |
---|
| 34 | } |
---|
[260] | 35 | forward(action: 'search', params: params) |
---|
| 36 | } |
---|
| 37 | |
---|
[298] | 38 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[476] | 39 | def setSearchCalendarParamsMax = { |
---|
| 40 | def max = 1000 |
---|
[615] | 41 | if(params.newMax?.isInteger()) { |
---|
[476] | 42 | def i = params.newMax.toInteger() |
---|
| 43 | if(i > 0 && i <= max) |
---|
| 44 | session.taskSearchCalendarParamsMax = params.newMax |
---|
| 45 | if(i > max) |
---|
| 46 | session.taskSearchCalendarParamsMax = max |
---|
| 47 | } |
---|
| 48 | forward(action: 'searchCalendar', params: params) |
---|
| 49 | } |
---|
| 50 | |
---|
[483] | 51 | /** |
---|
| 52 | * Search for tasks. |
---|
| 53 | */ |
---|
[476] | 54 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[139] | 55 | def search = { |
---|
[143] | 56 | |
---|
[260] | 57 | if(session.taskSearchParamsMax) |
---|
| 58 | params.max = session.taskSearchParamsMax |
---|
| 59 | |
---|
[468] | 60 | // Protect filterPane. |
---|
[525] | 61 | params.max = Math.min( params.max ? params.max.toInteger() : 100, 1000 ) |
---|
[260] | 62 | |
---|
| 63 | def taskInstanceList = [] |
---|
| 64 | def taskInstanceTotal |
---|
[476] | 65 | def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
| 66 | def isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
[260] | 67 | |
---|
[476] | 68 | // Restore search unless a new search is being requested. |
---|
| 69 | if(!params.quickSearch && !filterParams) { |
---|
| 70 | if(session.taskSearchQuickSearch) |
---|
| 71 | params.quickSearch = session.taskSearchQuickSearch |
---|
| 72 | else if(session.taskSearchFilterParams) { |
---|
| 73 | session.taskSearchFilterParams.each() { params[it.key] = it.value } |
---|
| 74 | params.filter = session.taskSearchFilter |
---|
| 75 | isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
[144] | 76 | } |
---|
[476] | 77 | } |
---|
[260] | 78 | |
---|
[486] | 79 | // Remember sort if supplied, otherwise try to restore. |
---|
| 80 | if(params.sort && params.order) { |
---|
[582] | 81 | // Reset to defaultSort if requested. |
---|
| 82 | if(params.sort == 'defaultSort') { |
---|
| 83 | params.sort = null |
---|
| 84 | params.order = null |
---|
| 85 | session.removeAttribute("taskSearchSort") |
---|
| 86 | session.removeAttribute("taskSearchOrder") |
---|
| 87 | } |
---|
| 88 | else { |
---|
| 89 | session.taskSearchSort = params.sort |
---|
| 90 | session.taskSearchOrder = params.order |
---|
| 91 | } |
---|
[486] | 92 | } |
---|
| 93 | else if(session.taskSearchSort && session.taskSearchOrder) { |
---|
| 94 | params.sort = session.taskSearchSort |
---|
| 95 | params.order = session.taskSearchOrder |
---|
| 96 | } |
---|
| 97 | |
---|
[476] | 98 | if(isFilterApplied) { |
---|
[260] | 99 | // filterPane: |
---|
[582] | 100 | params.sort = params.sort ?: "id" |
---|
| 101 | params.order = params.order ?: "desc" |
---|
[513] | 102 | if(params.sort == "attentionFlag") // See ticket #64 in Trac. |
---|
| 103 | params.sort = "id" |
---|
[516] | 104 | // Prevent tasks in the trash being returned unless explicitly requested. |
---|
| 105 | if(!params.filter.op.trash) { |
---|
| 106 | params.filter.op.trash = "Equal" |
---|
| 107 | params.filter.trash = "false" |
---|
| 108 | } |
---|
| 109 | // Call filterService. |
---|
[260] | 110 | taskInstanceList = filterService.filter( params, Task ) |
---|
| 111 | taskInstanceTotal = filterService.count( params, Task ) |
---|
| 112 | filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
[476] | 113 | // Remember search. |
---|
| 114 | session.taskSearchFilterParams = new LinkedHashMap(filterParams) |
---|
| 115 | session.taskSearchFilter = new LinkedHashMap(params.filter) |
---|
[488] | 116 | session.removeAttribute("taskSearchQuickSearch") |
---|
[260] | 117 | } |
---|
[476] | 118 | else { |
---|
| 119 | // Quick Search: |
---|
| 120 | if(!params.quickSearch) params.quickSearch = "myTodays" |
---|
| 121 | def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request)) |
---|
| 122 | taskInstanceList = result.taskInstanceList |
---|
| 123 | taskInstanceTotal = result.taskInstanceList.totalCount |
---|
| 124 | params.message = result.message |
---|
| 125 | filterParams.quickSearch = result.quickSearch |
---|
| 126 | // Remember search. |
---|
[488] | 127 | session.removeAttribute("taskSearchFilterParams") |
---|
| 128 | session.removeAttribute("taskSearchFilter") |
---|
[476] | 129 | session.taskSearchQuickSearch = result.quickSearch |
---|
| 130 | } |
---|
[143] | 131 | |
---|
[260] | 132 | // export plugin: |
---|
| 133 | if(params?.format && params.format != "html") { |
---|
| 134 | |
---|
| 135 | def dateFmt = { date -> |
---|
| 136 | formatDate(format: "EEE, dd-MMM-yyyy", date: date) |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | String title |
---|
| 140 | if(params.quickSearch) |
---|
[476] | 141 | title = params.message |
---|
[260] | 142 | else |
---|
| 143 | title = "Filtered tasks." |
---|
| 144 | |
---|
| 145 | response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] |
---|
[390] | 146 | response.setHeader("Content-disposition", "attachment; filename=Tasks.${params.extension}") |
---|
[475] | 147 | List fields = ["id", "targetStartDate", "description", "leadPerson", "taskPriority", "taskType", "taskStatus"] |
---|
[260] | 148 | Map labels = ["id": "ID", "targetStartDate": "Target Start Date", "description": "Description", |
---|
[475] | 149 | "leadPerson": "Lead Person", "taskPriority": "Task Priority", |
---|
| 150 | "taskType": "Task Type", "taskStatus": "Task Status"] |
---|
[260] | 151 | Map formatters = [ targetStartDate: dateFmt] |
---|
| 152 | Map parameters = [title: title, separator: ","] |
---|
| 153 | |
---|
| 154 | exportService.export(params.format, response.outputStream, taskInstanceList, fields, labels, formatters, parameters) |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | // Add some basic params to filterParams. |
---|
| 158 | filterParams.max = params.max |
---|
| 159 | filterParams.offset = params.offset?.toInteger() ?: 0 |
---|
[582] | 160 | filterParams.sort = params.sort ?: "id" |
---|
[260] | 161 | filterParams.order = params.order ?: "desc" |
---|
| 162 | |
---|
[552] | 163 | // Get some associatedProperty values for filterpane. |
---|
| 164 | def associatedPropertyValues = [:] |
---|
| 165 | def associatedPropertyMax = 10000 |
---|
| 166 | associatedPropertyValues.taskPriorityList = TaskPriority.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 167 | def lastNameQuery = 'select distinct p.lastName from Person p where p.isActive = ? order by p.lastName' |
---|
| 168 | associatedPropertyValues.lastNameList = Person.executeQuery(lastNameQuery, [true], [max:associatedPropertyMax]) |
---|
| 169 | def firstNameQuery = 'select distinct p.firstName from Person p where p.isActive = ? order by p.firstName' |
---|
| 170 | associatedPropertyValues.firstNameList = Person.executeQuery(firstNameQuery, [true], [max:associatedPropertyMax]) |
---|
| 171 | associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 172 | associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 173 | associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 174 | associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 175 | def startOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), -10)) |
---|
| 176 | def endOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), 10)) |
---|
| 177 | associatedPropertyValues.yearRange = startOfYearRange..endOfYearRange |
---|
| 178 | |
---|
[260] | 179 | return[ taskInstanceList: taskInstanceList, |
---|
[476] | 180 | taskInstanceTotal: taskInstanceTotal, |
---|
| 181 | filterParams: filterParams, |
---|
[552] | 182 | params: params, |
---|
[554] | 183 | associatedPropertyValues: associatedPropertyValues ] |
---|
[260] | 184 | |
---|
[476] | 185 | } // search |
---|
[260] | 186 | |
---|
[298] | 187 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[155] | 188 | def searchCalendar = { |
---|
[140] | 189 | |
---|
[476] | 190 | // No pagination for calendar. |
---|
| 191 | params.offset = 0 |
---|
[474] | 192 | |
---|
[476] | 193 | // Restore params.max |
---|
| 194 | if(session.taskSearchCalendarParamsMax) |
---|
| 195 | params.max = session.taskSearchCalendarParamsMax |
---|
| 196 | |
---|
[474] | 197 | // Protect filterPane. |
---|
[476] | 198 | params.max = Math.min( params.max ? params.max.toInteger() : 100, 1000 ) |
---|
[474] | 199 | |
---|
[585] | 200 | def displayList = [] |
---|
[476] | 201 | def taskInstanceList = [] |
---|
| 202 | def taskInstanceTotal |
---|
| 203 | def filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
| 204 | def isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
[474] | 205 | |
---|
[476] | 206 | // Restore search unless a new search is being requested. |
---|
| 207 | if(!params.quickSearch && !filterParams) { |
---|
| 208 | if(session.taskSearchCalendarQuickSearch) |
---|
| 209 | params.quickSearch = session.taskSearchCalendarQuickSearch |
---|
| 210 | else if(session.taskSearchCalendarFilterParams) { |
---|
| 211 | session.taskSearchCalendarFilterParams.each() { params[it.key] = it.value } |
---|
| 212 | params.filter = session.taskSearchCalendarFilter |
---|
| 213 | isFilterApplied = FilterUtils.isFilterApplied(params) |
---|
| 214 | } |
---|
| 215 | } |
---|
[474] | 216 | |
---|
[476] | 217 | // The date the calendar will use to determine the month to show. |
---|
| 218 | // Use session, if not specified in params, otherwise use today. |
---|
| 219 | def showDate = new Date() |
---|
| 220 | if(params.showMonth) { |
---|
| 221 | if(params.showYear) |
---|
| 222 | showDate = dateUtilService.makeDate(params.showYear, params.showMonth) |
---|
| 223 | else |
---|
| 224 | showDate = dateUtilService.makeDate(dateUtilService.getYearFromDate(showDate), params.showMonth) |
---|
| 225 | // Remember the showDate. |
---|
| 226 | session.taskSearchCalendarShowDate = showDate |
---|
| 227 | } |
---|
| 228 | else if(session.taskSearchCalendarShowDate) |
---|
| 229 | showDate = session.taskSearchCalendarShowDate |
---|
[155] | 230 | |
---|
[476] | 231 | // Get the dates for the calendar month controls. |
---|
| 232 | def calendarMonthControls = getCalendarMonthControls(showDate) |
---|
| 233 | |
---|
| 234 | if(isFilterApplied) { |
---|
| 235 | // filterPane: |
---|
[589] | 236 | params.sort = params.sort ?: "id" |
---|
| 237 | params.order = params.order ?: "desc" |
---|
[516] | 238 | if(params.sort == "attentionFlag") // See ticket #64 in Trac. |
---|
| 239 | params.sort = "id" |
---|
| 240 | // Prevent tasks in the trash being returned unless explicitly requested. |
---|
| 241 | if(!params.filter.op.trash) { |
---|
| 242 | params.filter.op.trash = "Equal" |
---|
| 243 | params.filter.trash = "false" |
---|
| 244 | } |
---|
| 245 | // Call filterService. |
---|
[476] | 246 | taskInstanceList = filterService.filter( params, Task ) |
---|
| 247 | taskInstanceTotal = filterService.count( params, Task ) |
---|
| 248 | filterParams = com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params) |
---|
| 249 | // Remember search. |
---|
| 250 | session.taskSearchCalendarFilterParams = new LinkedHashMap(filterParams) |
---|
| 251 | session.taskSearchCalendarFilter = new LinkedHashMap(params.filter) |
---|
[488] | 252 | session.removeAttribute("taskSearchCalendarQuickSearch") |
---|
[139] | 253 | } |
---|
[476] | 254 | else { |
---|
| 255 | // Quick Search: |
---|
| 256 | def result = taskSearchService.getQuickSearch(params, RCU.getLocale(request)) |
---|
| 257 | taskInstanceList = result.taskInstanceList |
---|
| 258 | taskInstanceTotal = result.taskInstanceList.totalCount |
---|
| 259 | params.message = result.message |
---|
| 260 | filterParams.quickSearch = result.quickSearch |
---|
| 261 | // Remember search. |
---|
[488] | 262 | session.removeAttribute("taskSearchCalendarFilterParams") |
---|
| 263 | session.removeAttribute("taskSearchCalendarFilter") |
---|
[476] | 264 | session.taskSearchCalendarQuickSearch = result.quickSearch |
---|
| 265 | } |
---|
[140] | 266 | |
---|
[588] | 267 | // displayList = taskReportService.getWorkLoadSummary( |
---|
| 268 | // [taskInstanceList: taskInstanceList], RCU.getLocale(request) |
---|
| 269 | // ).displayList |
---|
[585] | 270 | |
---|
[476] | 271 | // export plugin: |
---|
| 272 | if(params?.format && params.format != "html") { |
---|
[165] | 273 | |
---|
[476] | 274 | def dateFmt = { date -> |
---|
| 275 | formatDate(format: "EEE, dd-MMM-yyyy", date: date) |
---|
[165] | 276 | } |
---|
[260] | 277 | |
---|
[476] | 278 | String title |
---|
| 279 | if(params.quickSearch) |
---|
| 280 | title = params.message |
---|
| 281 | else |
---|
| 282 | title = "Filtered tasks." |
---|
[165] | 283 | |
---|
[476] | 284 | response.contentType = ConfigurationHolder.config.grails.mime.types[params.format] |
---|
| 285 | response.setHeader("Content-disposition", "attachment; filename=Tasks.${params.extension}") |
---|
| 286 | List fields = ["id", "targetStartDate", "description", "leadPerson", "taskPriority", "taskType", "taskStatus"] |
---|
| 287 | Map labels = ["id": "ID", "targetStartDate": "Target Start Date", "description": "Description", |
---|
| 288 | "leadPerson": "Lead Person", "taskPriority": "Task Priority", |
---|
| 289 | "taskType": "Task Type", "taskStatus": "Task Status"] |
---|
| 290 | Map formatters = [ targetStartDate: dateFmt] |
---|
| 291 | Map parameters = [title: title, separator: ","] |
---|
| 292 | |
---|
| 293 | exportService.export(params.format, response.outputStream, taskInstanceList, fields, labels, formatters, parameters) |
---|
[165] | 294 | } |
---|
| 295 | |
---|
[588] | 296 | if(taskInstanceTotal > params.max) |
---|
| 297 | params.errorMessage = g.message(code:"task.search.calendar.text.too.many.results", args:[params.max]) |
---|
[476] | 298 | |
---|
| 299 | // Add some basic params to filterParams. |
---|
| 300 | filterParams.max = params.max |
---|
| 301 | filterParams.offset = params.offset?.toInteger() ?: 0 |
---|
[589] | 302 | filterParams.sort = params.sort ?: "id" |
---|
| 303 | filterParams.order = params.order ?: "desc" |
---|
[476] | 304 | |
---|
[589] | 305 | // Get some associatedProperty values for filterpane. |
---|
| 306 | def associatedPropertyValues = [:] |
---|
| 307 | def associatedPropertyMax = 10000 |
---|
| 308 | associatedPropertyValues.taskPriorityList = TaskPriority.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 309 | def lastNameQuery = 'select distinct p.lastName from Person p where p.isActive = ? order by p.lastName' |
---|
| 310 | associatedPropertyValues.lastNameList = Person.executeQuery(lastNameQuery, [true], [max:associatedPropertyMax]) |
---|
| 311 | def firstNameQuery = 'select distinct p.firstName from Person p where p.isActive = ? order by p.firstName' |
---|
| 312 | associatedPropertyValues.firstNameList = Person.executeQuery(firstNameQuery, [true], [max:associatedPropertyMax]) |
---|
| 313 | associatedPropertyValues.taskGroupList = TaskGroup.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 314 | associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 315 | associatedPropertyValues.taskStatusList = TaskStatus.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 316 | associatedPropertyValues.taskTypeList = TaskType.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) |
---|
| 317 | def startOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), -10)) |
---|
| 318 | def endOfYearRange = dateUtilService.getYearFromDate(dateUtilService.plusYear(new Date(), 10)) |
---|
| 319 | associatedPropertyValues.yearRange = startOfYearRange..endOfYearRange |
---|
| 320 | |
---|
[588] | 321 | return[taskInstanceList: taskInstanceList, |
---|
[476] | 322 | taskInstanceTotal: taskInstanceTotal, |
---|
| 323 | filterParams: filterParams, |
---|
| 324 | params: params, |
---|
[589] | 325 | associatedPropertyValues: associatedPropertyValues, |
---|
[476] | 326 | showDate: showDate, |
---|
| 327 | today: calendarMonthControls.today, |
---|
| 328 | previousMonth: calendarMonthControls.previousMonth, |
---|
| 329 | nextMonth: calendarMonthControls.nextMonth, |
---|
| 330 | previousYear: calendarMonthControls.previousYear, |
---|
| 331 | nextYear: calendarMonthControls.nextYear] |
---|
| 332 | |
---|
| 333 | } // searchCalendar |
---|
| 334 | |
---|
[298] | 335 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[66] | 336 | def show = { |
---|
[147] | 337 | |
---|
[139] | 338 | // In the case of an actionSubmit button, rewrite action name from 'index'. |
---|
| 339 | if(params._action_Show) |
---|
[375] | 340 | params.action='show' |
---|
[139] | 341 | |
---|
[433] | 342 | // Used by navigation. |
---|
| 343 | if(params.id == 'nav') { |
---|
| 344 | params.id = session.currentTaskId ?: null |
---|
| 345 | redirect(action: show, id: params.id) |
---|
| 346 | return |
---|
| 347 | } |
---|
| 348 | |
---|
[225] | 349 | def showTab = [:] |
---|
| 350 | switch (params.showTab) { |
---|
| 351 | case "showProcedureTab": |
---|
| 352 | showTab.procedure = new String("true") |
---|
| 353 | break |
---|
| 354 | case "showRecurrenceTab": |
---|
| 355 | showTab.recurrence = new String("true") |
---|
| 356 | break |
---|
| 357 | case "showInventoryTab": |
---|
| 358 | showTab.inventory = new String("true") |
---|
| 359 | break |
---|
| 360 | case "showSubTasksTab": |
---|
| 361 | showTab.subTasks = new String("true") |
---|
| 362 | break |
---|
| 363 | default: |
---|
| 364 | showTab.task = new String("true") |
---|
| 365 | } |
---|
| 366 | |
---|
[66] | 367 | def taskInstance = Task.get( params.id ) |
---|
| 368 | |
---|
| 369 | if(!taskInstance) { |
---|
| 370 | flash.message = "Task not found with id ${params.id}" |
---|
[196] | 371 | redirect(action: 'search') |
---|
[66] | 372 | } |
---|
[133] | 373 | else { |
---|
[433] | 374 | // Remember the current task id for use with navigation. |
---|
| 375 | session.currentTaskId = params.id |
---|
| 376 | |
---|
[179] | 377 | params.max = 10 |
---|
| 378 | params.order = "desc" |
---|
| 379 | params.sort = "id" |
---|
[134] | 380 | |
---|
[418] | 381 | def entryFaultList = Entry.withCriteria { |
---|
| 382 | eq("entryType", EntryType.get(1)) |
---|
| 383 | eq("task", taskInstance) |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | def entryCauseList = Entry.withCriteria { |
---|
[190] | 387 | eq("entryType", EntryType.get(2)) |
---|
[179] | 388 | eq("task", taskInstance) |
---|
| 389 | } |
---|
| 390 | |
---|
[418] | 391 | def entryWorkDoneList = Entry.withCriteria { |
---|
| 392 | eq("entryType", EntryType.get(3)) |
---|
[179] | 393 | eq("task", taskInstance) |
---|
| 394 | } |
---|
| 395 | |
---|
[196] | 396 | def subTaskInstanceList = Task.findAllByParentTaskAndTrash(taskInstance, false, params) |
---|
| 397 | def subTaskInstanceTotal = Task.countByParentTaskAndTrash(taskInstance, false) |
---|
[134] | 398 | |
---|
[175] | 399 | def inventoryMovementList = InventoryMovement.findAllByTask(taskInstance, [max:100, sort:"id", order:"desc", offset:0]) |
---|
| 400 | |
---|
[180] | 401 | def taskModificationList = TaskModification.findAllByTask(taskInstance, [max:100, sort:"id", order:"asc", offset:0]) |
---|
| 402 | |
---|
[253] | 403 | def assignedGroupList = taskInstance.assignedGroups.sort { p1, p2 -> p1.personGroup.name.compareToIgnoreCase(p2.personGroup.name) } |
---|
| 404 | def assignedPersonList = taskInstance.assignedPersons.sort { p1, p2 -> p1.person.firstName.compareToIgnoreCase(p2.person.firstName) } |
---|
| 405 | |
---|
[133] | 406 | def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id) |
---|
| 407 | def taskProcedureExits = new Boolean("true") |
---|
| 408 | if(!taskProcedureInstance) { |
---|
| 409 | taskProcedureExits = false |
---|
| 410 | } |
---|
[175] | 411 | |
---|
| 412 | params.order = "asc" |
---|
| 413 | params.sort = "procedureStepNumber" |
---|
| 414 | def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, params) |
---|
| 415 | |
---|
[134] | 416 | def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id) |
---|
| 417 | def taskRecurringScheduleExits= new Boolean("true") |
---|
[175] | 418 | if(!taskRecurringScheduleInstance) { |
---|
[134] | 419 | taskRecurringScheduleExits = false |
---|
| 420 | } |
---|
[179] | 421 | |
---|
[137] | 422 | return [ taskInstance: taskInstance, |
---|
[418] | 423 | entryFaultList: entryFaultList, |
---|
| 424 | entryCauseList: entryCauseList, |
---|
[179] | 425 | entryWorkDoneList: entryWorkDoneList, |
---|
[133] | 426 | taskProcedureInstance: taskProcedureInstance, |
---|
| 427 | taskProcedureExits: taskProcedureExits, |
---|
[225] | 428 | showTab: showTab, |
---|
[179] | 429 | subTaskInstanceList: subTaskInstanceList, |
---|
| 430 | subTaskInstanceTotal: subTaskInstanceTotal, |
---|
| 431 | subTaskInstanceMax: params.max, |
---|
| 432 | maintenanceActionList: maintenanceActionList, |
---|
| 433 | taskRecurringScheduleInstance: taskRecurringScheduleInstance, |
---|
| 434 | taskRecurringScheduleExits: taskRecurringScheduleExits, |
---|
[180] | 435 | inventoryMovementList: inventoryMovementList, |
---|
[253] | 436 | taskModificationList: taskModificationList, |
---|
| 437 | assignedGroupList: assignedGroupList, |
---|
| 438 | assignedPersonList: assignedPersonList] |
---|
[131] | 439 | } |
---|
[66] | 440 | } |
---|
| 441 | |
---|
[418] | 442 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[181] | 443 | def restore = { |
---|
| 444 | |
---|
| 445 | def result = taskService.restore(params) |
---|
| 446 | |
---|
| 447 | if(!result.error) { |
---|
| 448 | flash.message = "Task ${params.id} has been restored." |
---|
[418] | 449 | redirect(action: show, id: params.id) |
---|
| 450 | return |
---|
[181] | 451 | } |
---|
| 452 | |
---|
[418] | 453 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 454 | |
---|
| 455 | if(result.taskInstance) |
---|
| 456 | redirect(action: show, id: params.id) |
---|
| 457 | else |
---|
| 458 | redirect(action: 'search') |
---|
| 459 | |
---|
[181] | 460 | } |
---|
| 461 | |
---|
[418] | 462 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[181] | 463 | def trash = { |
---|
| 464 | |
---|
| 465 | def result = taskService.trash(params) |
---|
| 466 | |
---|
| 467 | if(!result.error) { |
---|
| 468 | flash.message = "Task ${params.id} has been moved to trash." |
---|
[196] | 469 | redirect(action: 'search') |
---|
[418] | 470 | return |
---|
[181] | 471 | } |
---|
| 472 | |
---|
[418] | 473 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 474 | |
---|
| 475 | if(result.taskInstance) |
---|
| 476 | redirect(action: show, id: params.id) |
---|
| 477 | else |
---|
| 478 | redirect(action: 'search') |
---|
| 479 | |
---|
[66] | 480 | } |
---|
| 481 | |
---|
[418] | 482 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) |
---|
[181] | 483 | def approve = { |
---|
| 484 | |
---|
| 485 | def result = taskService.approve(params) |
---|
| 486 | |
---|
| 487 | if(!result.error) { |
---|
| 488 | flash.message = "Task ${params.id} has been approved." |
---|
[418] | 489 | redirect(action: show, id: params.id) |
---|
| 490 | return |
---|
[181] | 491 | } |
---|
| 492 | |
---|
[418] | 493 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 494 | |
---|
| 495 | if(result.taskInstance) |
---|
| 496 | redirect(action: show, id: params.id) |
---|
| 497 | else |
---|
| 498 | redirect(action: 'search') |
---|
| 499 | |
---|
[181] | 500 | } |
---|
| 501 | |
---|
[465] | 502 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) |
---|
[181] | 503 | def renegeApproval = { |
---|
| 504 | |
---|
| 505 | def result = taskService.renegeApproval(params) |
---|
| 506 | |
---|
| 507 | if(!result.error) { |
---|
| 508 | flash.message = "Task ${params.id} has had approval removed." |
---|
[418] | 509 | redirect(action: show, id: params.id) |
---|
| 510 | return |
---|
[181] | 511 | } |
---|
| 512 | |
---|
[418] | 513 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 514 | |
---|
| 515 | if(result.taskInstance) |
---|
| 516 | redirect(action: show, id: params.id) |
---|
| 517 | else |
---|
| 518 | redirect(action: 'search') |
---|
| 519 | |
---|
[181] | 520 | } |
---|
| 521 | |
---|
[298] | 522 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[181] | 523 | def complete = { |
---|
| 524 | |
---|
| 525 | def result = taskService.complete(params) |
---|
| 526 | |
---|
| 527 | if(!result.error) { |
---|
| 528 | flash.message = "Task ${params.id} has been completed." |
---|
[418] | 529 | redirect(action: show, id: params.id) |
---|
| 530 | return |
---|
[181] | 531 | } |
---|
[418] | 532 | |
---|
| 533 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 534 | |
---|
| 535 | if(result.taskInstance) |
---|
| 536 | redirect(action: show, id: params.id) |
---|
| 537 | else |
---|
| 538 | redirect(action: 'search') |
---|
| 539 | |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
| 543 | def setAttentionFlag = { |
---|
| 544 | |
---|
| 545 | def result = taskService.setAttentionFlag(params) |
---|
| 546 | |
---|
| 547 | if(!result.error) { |
---|
| 548 | flash.message = "Task ${params.id} has been flagged for attention." |
---|
| 549 | redirect(action: show, id: params.id) |
---|
| 550 | return |
---|
[181] | 551 | } |
---|
| 552 | |
---|
[418] | 553 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 554 | |
---|
| 555 | if(result.taskInstance) |
---|
| 556 | redirect(action: show, id: params.id) |
---|
| 557 | else |
---|
| 558 | redirect(action: 'search') |
---|
| 559 | |
---|
[181] | 560 | } |
---|
| 561 | |
---|
[298] | 562 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[418] | 563 | def clearAttentionFlag = { |
---|
[181] | 564 | |
---|
[418] | 565 | def result = taskService.clearAttentionFlag(params) |
---|
| 566 | |
---|
| 567 | if(!result.error) { |
---|
| 568 | flash.message = "Task ${params.id} attention flag cleared." |
---|
| 569 | redirect(action: show, id: params.id) |
---|
| 570 | return |
---|
[181] | 571 | } |
---|
| 572 | |
---|
[418] | 573 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 574 | |
---|
| 575 | if(result.taskInstance) |
---|
| 576 | redirect(action: show, id: params.id) |
---|
| 577 | else |
---|
| 578 | redirect(action: 'search') |
---|
| 579 | |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
| 583 | def reopen = { |
---|
| 584 | |
---|
[181] | 585 | def result = taskService.reopen(params) |
---|
| 586 | |
---|
| 587 | if(!result.error) { |
---|
| 588 | flash.message = "Task ${params.id} has been reopened." |
---|
[418] | 589 | redirect(action: show, id: params.id) |
---|
| 590 | return |
---|
[181] | 591 | } |
---|
| 592 | |
---|
[418] | 593 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 594 | |
---|
| 595 | if(result.taskInstance) |
---|
| 596 | redirect(action: show, id: params.id) |
---|
| 597 | else |
---|
| 598 | redirect(action: 'search') |
---|
| 599 | |
---|
[181] | 600 | } |
---|
| 601 | |
---|
[298] | 602 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[66] | 603 | def edit = { |
---|
[147] | 604 | |
---|
[139] | 605 | // In the case of an actionSubmit button, rewrite action name from 'index'. |
---|
| 606 | if(params._action_Edit) |
---|
[375] | 607 | params.action='edit' |
---|
[169] | 608 | |
---|
[433] | 609 | // Used by navigation. |
---|
| 610 | if(params.id == 'nav') { |
---|
| 611 | params.id = session.currentTaskId ?: null |
---|
| 612 | redirect(action: edit, id: params.id) |
---|
| 613 | return |
---|
| 614 | } |
---|
| 615 | |
---|
[66] | 616 | def taskInstance = Task.get( params.id ) |
---|
| 617 | |
---|
| 618 | if(!taskInstance) { |
---|
| 619 | flash.message = "Task not found with id ${params.id}" |
---|
[196] | 620 | redirect(action: 'search') |
---|
[66] | 621 | } |
---|
| 622 | else { |
---|
[433] | 623 | // Remember the current task id for use with navigation. |
---|
| 624 | session.currentTaskId = params.id |
---|
| 625 | |
---|
[181] | 626 | if(taskInstance.trash) { |
---|
[196] | 627 | flash.message = "You may not edit tasks that are in the trash." |
---|
| 628 | redirect(action: 'show', id: taskInstance.id) |
---|
| 629 | return |
---|
[181] | 630 | } |
---|
[246] | 631 | // def possibleParentList = taskService.possibleParentList(taskInstance) |
---|
| 632 | // return [ taskInstance : taskInstance, possibleParentList: possibleParentList ] |
---|
| 633 | return [ taskInstance : taskInstance ] |
---|
[84] | 634 | } |
---|
| 635 | } |
---|
| 636 | |
---|
[298] | 637 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[66] | 638 | def update = { |
---|
[179] | 639 | |
---|
[180] | 640 | def result = taskService.update(params) |
---|
| 641 | |
---|
| 642 | if(!result.error) { |
---|
[66] | 643 | flash.message = "Task ${params.id} updated" |
---|
[418] | 644 | redirect(action: show, id: params.id) |
---|
| 645 | return |
---|
[180] | 646 | } |
---|
| 647 | |
---|
[418] | 648 | if(result.error.code == "task.modifications.failedToSave") |
---|
| 649 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 650 | |
---|
| 651 | render(view:'edit',model:[taskInstance:result.taskInstance.attach()]) |
---|
| 652 | |
---|
[66] | 653 | } |
---|
| 654 | |
---|
[473] | 655 | /** |
---|
| 656 | * The create action is used to create scheduled types of tasks. |
---|
| 657 | */ |
---|
| 658 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager']) |
---|
[66] | 659 | def create = { |
---|
| 660 | def taskInstance = new Task() |
---|
[214] | 661 | |
---|
| 662 | // Set the targetStartDate if specified, used by searchCalendar view. |
---|
[476] | 663 | if(params.year && params.month && params.day) { |
---|
| 664 | def date = dateUtilService.makeDate(params.year, params.month, params.day) |
---|
| 665 | taskInstance.targetStartDate = date |
---|
| 666 | taskInstance.targetCompletionDate = date |
---|
| 667 | } |
---|
[214] | 668 | |
---|
[196] | 669 | // Default leadPerson to current user, unless supplied in params. |
---|
[291] | 670 | taskInstance.leadPerson = authService.currentUser |
---|
[487] | 671 | |
---|
| 672 | // Apply params, overiding anything above. |
---|
[66] | 673 | taskInstance.properties = params |
---|
[433] | 674 | |
---|
| 675 | def scheduledTaskTypes = taskService.scheduledTaskTypes |
---|
| 676 | def scheduledTaskPriorities = taskService.scheduledTaskPriorities |
---|
| 677 | taskInstance.taskPriority = scheduledTaskPriorities.default |
---|
| 678 | return ['taskInstance': taskInstance, |
---|
| 679 | 'scheduledTaskTypes': scheduledTaskTypes, |
---|
| 680 | 'scheduledTaskPriorities': scheduledTaskPriorities.list] |
---|
[66] | 681 | } |
---|
| 682 | |
---|
[298] | 683 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[66] | 684 | def save = { |
---|
[394] | 685 | def result = taskService.save(params) |
---|
[180] | 686 | |
---|
| 687 | if(!result.error) { |
---|
| 688 | flash.message = "Task ${result.taskInstance.id} created." |
---|
[196] | 689 | redirect(action: 'show', id: result.taskInstance.id) |
---|
[418] | 690 | return |
---|
[66] | 691 | } |
---|
[180] | 692 | |
---|
[418] | 693 | if(result.error.code == "task.modifications.failedToSave") |
---|
| 694 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 695 | |
---|
[433] | 696 | |
---|
| 697 | def scheduledTaskTypes = taskService.scheduledTaskTypes |
---|
| 698 | def scheduledTaskPriorities = taskService.scheduledTaskPriorities |
---|
| 699 | render(view:'create', model:[taskInstance:result.taskInstance, |
---|
| 700 | 'scheduledTaskTypes': scheduledTaskTypes, |
---|
| 701 | 'scheduledTaskPriorities': scheduledTaskPriorities.list]) |
---|
[66] | 702 | } |
---|
[179] | 703 | |
---|
[298] | 704 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[179] | 705 | def listSubTasks = { |
---|
| 706 | def parentTaskInstance = Task.get(params.id) |
---|
| 707 | |
---|
[134] | 708 | if(!parentTaskInstance) { |
---|
| 709 | flash.message = "Task not found with id ${params.id}" |
---|
[196] | 710 | redirect(action: 'search') |
---|
[133] | 711 | } |
---|
| 712 | else { |
---|
[179] | 713 | params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) |
---|
[196] | 714 | def subTaskInstanceList = Task.findAllByParentTaskAndTrash(parentTaskInstance, false, params) |
---|
| 715 | def subTaskInstanceTotal = Task.countByParentTaskAndTrash(parentTaskInstance, false) |
---|
[179] | 716 | |
---|
[134] | 717 | [ taskInstanceList: subTaskInstanceList, |
---|
[179] | 718 | taskInstanceTotal: subTaskInstanceTotal, |
---|
| 719 | parentTaskInstance: parentTaskInstance] |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | |
---|
[298] | 723 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[196] | 724 | def createSubTask = { |
---|
| 725 | def parentTaskInstance = Task.get(params.id) |
---|
| 726 | |
---|
| 727 | if(parentTaskInstance) { |
---|
| 728 | |
---|
| 729 | def result = taskService.createSubTask(parentTaskInstance) |
---|
| 730 | if(!result.error) { |
---|
| 731 | flash.message = "Sub Task ${result.taskInstance.id} created, please edit and update to your requirements." |
---|
| 732 | redirect(action: 'edit', id: result.taskInstance.id) |
---|
| 733 | } |
---|
| 734 | else { |
---|
| 735 | if(result.taskInstance.errors.hasFieldErrors("parentTask")) { |
---|
[418] | 736 | flash.errorMessage = g.message(code:"task.operationNotPermittedOnTaskInTrash") |
---|
[196] | 737 | redirect(action: 'show', id: parentTaskInstance.id) |
---|
| 738 | } |
---|
| 739 | else { |
---|
| 740 | render(view: 'create', model:[taskInstance: result.taskInstance]) |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | else { |
---|
| 746 | flash.message = "Task not found with id ${params.id}" |
---|
| 747 | redirect(action: 'search') |
---|
| 748 | } |
---|
| 749 | } |
---|
| 750 | |
---|
[395] | 751 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[433] | 752 | def createUnscheduled = { |
---|
| 753 | def taskInstance = new Task() |
---|
| 754 | |
---|
| 755 | // Default leadPerson to current user, unless supplied in params. |
---|
| 756 | taskInstance.leadPerson = authService.currentUser |
---|
| 757 | taskInstance.properties = params |
---|
| 758 | |
---|
| 759 | // Always for Unscheduled task. |
---|
| 760 | taskInstance.taskType = TaskType.get(2) // Unscheduled Breakin. |
---|
| 761 | def unscheduledTaskPriorities = taskService.unscheduledTaskPriorities |
---|
| 762 | taskInstance.taskPriority = unscheduledTaskPriorities.default |
---|
| 763 | |
---|
| 764 | return ['taskInstance': taskInstance, 'unscheduledTaskPriorities': unscheduledTaskPriorities.list] |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
| 768 | def saveUnscheduled = { |
---|
| 769 | def result = taskService.saveUnscheduled(params) |
---|
| 770 | |
---|
| 771 | if(!result.error) { |
---|
| 772 | flash.message = "Task ${result.taskInstance.id} created." |
---|
| 773 | redirect(action: 'show', id: result.taskInstance.id) |
---|
| 774 | return |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | if(result.error.code == "task.modifications.failedToSave") |
---|
| 778 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 779 | |
---|
| 780 | def unscheduledTaskPriorities = taskService.unscheduledTaskPriorities |
---|
| 781 | |
---|
| 782 | render(view:'createUnscheduled', |
---|
| 783 | model: ['taskInstance': result.taskInstance, 'unscheduledTaskPriorities': unscheduledTaskPriorities.list]) |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[418] | 787 | def createImmediateCallout = { |
---|
[395] | 788 | def taskInstance = new Task() |
---|
| 789 | |
---|
| 790 | def entryFaultInstance = new Entry(entryType: EntryType.get(1)) // Fault. |
---|
[418] | 791 | def entryCauseInstance = new Entry(entryType: EntryType.get(2)) // Cause. |
---|
| 792 | def entryWorkDoneInstance = new Entry(entryType: EntryType.get(3)) // Work Done. |
---|
[395] | 793 | |
---|
| 794 | return ['taskInstance': taskInstance, |
---|
| 795 | 'entryFaultInstance': entryFaultInstance, |
---|
[418] | 796 | 'entryCauseInstance': entryCauseInstance, |
---|
[395] | 797 | 'entryWorkDoneInstance': entryWorkDoneInstance] |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
[418] | 801 | def saveImmediateCallout = { |
---|
| 802 | def result = taskService.saveImmediateCallout(params) |
---|
[395] | 803 | |
---|
| 804 | if(!result.error) { |
---|
| 805 | flash.message = "Task ${result.taskInstance.id} created." |
---|
| 806 | redirect(action: 'show', id: result.taskInstance.id) |
---|
| 807 | return |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | if(result.error.code == "task.modifications.failedToSave") |
---|
| 811 | flash.errorMessage = g.message(code: result.error.code, args: result.error.args) |
---|
| 812 | |
---|
[418] | 813 | render(view:'createImmediateCallout', |
---|
[395] | 814 | model: ['taskInstance': result.taskInstance, |
---|
| 815 | 'entryFaultInstance': result.entryFaultInstance, |
---|
[418] | 816 | 'entryCauseInstance': result.entryCauseInstance, |
---|
[395] | 817 | 'entryWorkDoneInstance': result.entryWorkDoneInstance]) |
---|
| 818 | |
---|
| 819 | } |
---|
| 820 | |
---|
[476] | 821 | /** |
---|
[490] | 822 | * Render a users total work done hours. |
---|
| 823 | */ |
---|
| 824 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser']) |
---|
| 825 | def workDone = { |
---|
| 826 | def result = taskSearchService.getWorkDone(params, RCU.getLocale(request)) |
---|
| 827 | |
---|
| 828 | params.message = result.message |
---|
| 829 | |
---|
| 830 | return[entries: result.entries, |
---|
| 831 | totalEntries : result.totalEntries, |
---|
| 832 | startOfDay: result.startOfDay, |
---|
| 833 | person: result.person, |
---|
| 834 | totalHours: result.totalHours, |
---|
| 835 | totalMinutes: result.totalMinutes] |
---|
| 836 | } // workDone |
---|
| 837 | |
---|
| 838 | /** |
---|
[476] | 839 | * Get some integers for use by the month control links. |
---|
| 840 | */ |
---|
| 841 | private getCalendarMonthControls(Date showDate) { |
---|
| 842 | def result = [:] |
---|
| 843 | result.today = [:] |
---|
| 844 | result.today.date = new Date() |
---|
| 845 | result.today.month = dateUtilService.getMonthFromDate(result.today.date) |
---|
| 846 | result.today.year = dateUtilService.getYearFromDate(result.today.date) |
---|
| 847 | result.nextMonth = [:] |
---|
[553] | 848 | result.nextMonth.date = dateUtilService.plusMonth(showDate) |
---|
[476] | 849 | result.nextMonth.month = dateUtilService.getMonthFromDate(result.nextMonth.date) |
---|
| 850 | result.nextMonth.year = dateUtilService.getYearFromDate(result.nextMonth.date) |
---|
| 851 | result.previousMonth = [:] |
---|
[553] | 852 | result.previousMonth.date = dateUtilService.plusMonth(showDate, -1) |
---|
[476] | 853 | result.previousMonth.month = dateUtilService.getMonthFromDate(result.previousMonth.date) |
---|
| 854 | result.previousMonth.year = dateUtilService.getYearFromDate(result.previousMonth.date) |
---|
| 855 | result.nextYear = [:] |
---|
[552] | 856 | result.nextYear.date = dateUtilService.plusYear(showDate) |
---|
[476] | 857 | result.nextYear.month = dateUtilService.getMonthFromDate(result.nextYear.date) |
---|
| 858 | result.nextYear.year = dateUtilService.getYearFromDate(result.nextYear.date) |
---|
| 859 | result.previousYear = [:] |
---|
[552] | 860 | result.previousYear.date = dateUtilService.plusYear(showDate, -1) |
---|
[476] | 861 | result.previousYear.month = dateUtilService.getMonthFromDate(result.previousYear.date) |
---|
| 862 | result.previousYear.year = dateUtilService.getYearFromDate(result.previousYear.date) |
---|
| 863 | return result |
---|
| 864 | } |
---|
| 865 | |
---|
[196] | 866 | } // end of class. |
---|