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

Auto swap date range in all reports, part 2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.