Changeset 732 for trunk/grails-app


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

Auto swap date range in all reports.

Location:
trunk/grails-app
Files:
4 edited

Legend:

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

    r710 r732  
    8585    def reactiveRatio = {
    8686
     87        def result = taskReportService.getReactiveRatio(params, RCU.getLocale(request))
     88
    8789        params.reportTitle = "Reactive Ratio Report"
    8890        params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL()
    8991        params.currentUser = authService.currentUser
    90         params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate)
    91         params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    92 
    93         def result = taskReportService.getReactiveRatio(params, RCU.getLocale(request))
     92        params.startDateString = result.startDateString
     93        params.endDateString = result.endDateString
    9494
    9595        if(!result.error) {
     
    106106    def immediateCallouts = {
    107107
     108        def result = taskReportService.getImmediateCallouts(params, RCU.getLocale(request))
     109
    108110        params.reportTitle = "Immediate Callouts"
    109111        params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL()
    110112        params.currentUser = authService.currentUser
    111         params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate)
    112         params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    113 
    114         def result = taskReportService.getImmediateCallouts(params, RCU.getLocale(request))
     113        params.startDateString = result.startDateString
     114        params.endDateString = result.endDateString
    115115
    116116        if(!result.error) {
  • trunk/grails-app/i18n/messages.properties

    r728 r732  
    312312default.file.no.header=The supplied file does not have the correct header lines, please see the template file.
    313313default.not.development.environment.failure=Could not complete operation, dev environment not detected.
    314 default.end.date.before.start.date=The end date must be equal to or greater than \
    315     the start date.
    316314
    317315default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}]
  • trunk/grails-app/services/AssetReportService.groovy

    r728 r732  
    154154            params.endDate = dateUtilService.today
    155155
    156         if(params.endDate < params.startDate)
    157             return fail(code: "default.end.date.before.start.date")
     156        // 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        }
    158162
    159163        // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes.
  • trunk/grails-app/services/TaskReportService.groovy

    r709 r732  
    3333        namedParams.endDate = params.endDate ?: dateUtilService.today
    3434
    35         if(namedParams.endDate < namedParams.startDate)
    36             return fail(code: "default.end.date.before.start.date")
     35        // Auto swap date range.
     36        if(namedParams.startDate > namedParams.endDate) {
     37            def tempStartDate = namedParams.startDate
     38            namedParams.startDate = namedParams.endDate
     39            namedParams.endDate = tempStartDate
     40        }
     41
     42        result.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: namedParams.startDate)
     43        result.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: namedParams.endDate)
    3744
    3845        namedParams.endDate++ // Start of next day required.
     
    178185        namedParams.endDate = params.endDate ?: dateUtilService.today
    179186
    180         if(namedParams.endDate < namedParams.startDate)
    181             return fail(code: "default.end.date.before.start.date")
     187        // Auto swap date range.
     188        if(namedParams.startDate > namedParams.endDate) {
     189            def tempStartDate = namedParams.startDate
     190            namedParams.startDate = namedParams.endDate
     191            namedParams.endDate = tempStartDate
     192        }
     193
     194        result.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: namedParams.startDate)
     195        result.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: namedParams.endDate)
    182196
    183197        namedParams.endDate++ // Start of next day required.
Note: See TracChangeset for help on using the changeset viewer.