Changeset 490 for trunk/grails-app/services
- Timestamp:
- Apr 18, 2010, 10:03:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskSearchService.groovy
r483 r490 11 11 def dateUtilService 12 12 def messageSource 13 14 def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() 13 15 14 16 def paramsMax = 100000 … … 317 319 } // createCriteria 318 320 } 319 } 321 322 /** 323 * Get work done by person and date. 324 * A person ID and date may be specified in params otherwise the currentUser and today are used. 325 * @param params The request params. 326 * @returns A map containing entries, totalEntries, startOfDay, person, totalHours, totalMinutes. 327 */ 328 def getWorkDone(params, locale) { 329 def result = [:] 330 result.person = params.person?.id ? Person.get(params.person.id.toInteger()) : authService.currentUser 331 332 if(params.date_year && params.date_month && params.date_day) 333 result.startOfDay = dateUtilService.makeDate(params.date_year, params.date_month, params.date_day) 334 else 335 result.startOfDay = dateUtilService.today 336 337 result.startOfNextDay = result.startOfDay + 1 338 339 def formattedStartOfDay = g.formatDate(format: "EEE, dd-MMM-yyyy", date: result.startOfDay) 340 341 def getMessage = { Map m -> 342 messageSource.getMessage(m.code, m.args == null ? null : m.args.toArray(), locale) 343 } 344 345 result.entries = Entry.createCriteria().list() { 346 eq("enteredBy", result.person) 347 ge("dateDone", result.startOfDay) 348 lt("dateDone", result.startOfNextDay) 349 entryType { 350 eq("id", 3L) 351 } 352 } // createCriteria 353 354 result.totalEntries = result.entries.size() 355 356 if(result.totalEntries > 0) 357 result.message = getMessage(code:"task.search.text.work.done.message", 358 args:[result.person, formattedStartOfDay]) 359 else 360 result.message = getMessage(code:"task.search.text.work.done.none.found", 361 args:[result.person, formattedStartOfDay]) 362 363 result.totalHours = 0 364 result.totalMinutes = 0 365 result.entries.each() { 366 result.totalMinutes += (it.durationHour*60) + it.durationMinute 367 } 368 result.totalHours = (result.totalMinutes / 60).toInteger() 369 result.totalMinutes = result.totalMinutes % 60 370 371 return result 372 } 373 374 } // end class
Note: See TracChangeset
for help on using the changeset viewer.