Changeset 490


Ignore:
Timestamp:
Apr 18, 2010, 10:03:40 PM (10 years ago)
Author:
gav
Message:

Add work done by person and date feature with view and search logic.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r488 r490  
    748748
    749749    }
     750
     751    /**
     752    * Render a users total work done hours.
     753    */
     754    @Secured(['ROLE_AppAdmin', 'ROLE_Manager', 'ROLE_TaskManager', 'ROLE_TaskUser'])
     755    def workDone = {
     756        def result = taskSearchService.getWorkDone(params, RCU.getLocale(request))
     757
     758        params.message = result.message
     759
     760        return[entries: result.entries,
     761                    totalEntries : result.totalEntries,
     762                    startOfDay: result.startOfDay,
     763                    person: result.person,
     764                    totalHours: result.totalHours,
     765                    totalMinutes: result.totalMinutes]
     766    } // workDone
    750767
    751768    /**
  • trunk/grails-app/i18n/messages.properties

    r489 r490  
    288288task.search.text.planners.range.none.found=No tasks found in the past week or two weeks ahead.
    289289task.search.calendar.text.too.many.results=Too many results, only {0} are shown.
     290task.search.text.work.done=Work Done
     291task.search.text.work.done.none.found=No entries found for {0} on {1}.
     292task.search.text.work.done.description=Work done by person and date.
     293task.search.text.work.done.message=Work done by {0} on {1}.
    290294
    291295# InventoryItemSearch
  • trunk/grails-app/services/TaskSearchService.groovy

    r483 r490  
    1111    def dateUtilService
    1212    def messageSource
     13
     14    def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib()
    1315
    1416    def paramsMax = 100000
     
    317319            } // createCriteria
    318320    }
    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
  • trunk/grails-app/views/taskDetailed/_quickSearchPane.gsp

    r479 r490  
    9393                </tr>
    9494
     95                <tr class="prop">
     96                    <td valign="top" class="name">
     97                        <label>Links:</label>
     98                    </td>
     99                    <td valign="top" class="value">
     100                        <g:link controller="taskDetailed"
     101                                        action="workDone">
     102                            <g:message code="task.search.text.work.done" />
     103                        </g:link> - <g:message code="task.search.text.work.done.description" />
     104                        <br />
     105                    </td>
     106                </tr>
     107
    95108            </tbody>
    96109        </table>
  • trunk/web-app/css/main.css

    r453 r490  
    261261    vertical-align: top;
    262262}
     263tr.total {
     264    background: #EDEDED;
     265}
     266tr.total td{
     267    color: #555;
     268    font-size: 14px;
     269    font-weight: bold;
     270}
    263271td.idColumn {
    264272    width: 25px;
     
    304312    background: #fff;
    305313    cursor: pointer;
     314}
     315.clickableEven td.notClickable {
     316    cursor: default;
     317}
     318.clickableOdd td.notClickable {
     319    cursor: default;
    306320}
    307321
Note: See TracChangeset for help on using the changeset viewer.