Changeset 733


Ignore:
Timestamp:
Nov 30, 2010, 10:48:14 AM (14 years ago)
Author:
gav
Message:

Auto swap date range in all reports, part 2.

Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r732 r733  
    191191    def equipmentRegisterOhs = {
    192192
     193        params.calculateRegulatoryTaskCompletion = true
     194        def result = assetReportService.getEquipmentRegister(params, RCU.getLocale(request))
     195
    193196        params.reportTitle = "Equipment Register OH&S"
    194197        params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL()
    195198        params.currentUser = authService.currentUser
    196 
    197         params.calculateRegulatoryTaskCompletion = true
    198         params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate)
    199         params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    200 
    201         def result = assetReportService.getEquipmentRegister(params, RCU.getLocale(request))
     199        params.startDateString = result.startDateString
     200        params.endDateString = result.endDateString
    202201
    203202        if(!result.error) {
  • trunk/grails-app/services/AssetReportService.groovy

    r732 r733  
    142142        result.site = result.section.site
    143143
    144         // Start date.
    145         if(params.startDate)
    146             params.startDate = dateUtilService.makeDate(params.startDate_year, params.startDate_month, params.startDate_day)
    147         else
    148             params.startDate = dateUtilService.oneWeekAgo
    149 
    150         // End date.
    151         if(params.endDate)
    152             params.endDate = dateUtilService.makeDate(params.endDate_year, params.endDate_month, params.endDate_day)
    153         else
    154             params.endDate = dateUtilService.today
    155 
     144        result.startDate = params.startDate ?: dateUtilService.oneWeekAgo
     145        result.endDate = params.endDate ?: dateUtilService.today
    156146        // Auto swap date range.
    157         if(params.startDate > params.endDate) {
    158             def tempStartDate = params.startDate
    159             params.startDate = params.endDate
    160             params.endDate = tempStartDate
    161         }
     147        if(result.startDate > result.endDate) {
     148            def tempStartDate = result.startDate
     149            result.startDate = result.endDate
     150            result.endDate = tempStartDate
     151        }
     152
     153        result.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: result.startDate)
     154        result.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: result.endDate)
    162155
    163156        // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes.
     
    234227
    235228            // Subquery namedParams.
    236             namedParams.startDate = params.startDate
    237             namedParams.endDate = params.endDate+1
     229            namedParams.startDate = result.startDate
     230            namedParams.endDate = result.endDate+1
    238231
    239232            select 'new map(asset.name as assetName',
Note: See TracChangeset for help on using the changeset viewer.