Changeset 709


Ignore:
Timestamp:
Nov 15, 2010, 12:04:41 PM (14 years ago)
Author:
gav
Message:

Return error message on immediate callouts report submit when endDate < startDate.

Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r708 r709  
    112112        params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    113113
    114         def dataModel = taskReportService.getImmediateCallouts(params, RCU.getLocale(request))
    115 
    116         // Jasper plugin controller expects data to be a Collection.
    117         chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params)
     114        def result = taskReportService.getImmediateCallouts(params, RCU.getLocale(request))
     115
     116        if(!result.error) {
     117            // Jasper plugin controller expects data to be a Collection.
     118            chain(controller:'jasper', action:'index', model:[data: [result]], params:params)
     119            return
     120        }
     121
     122        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     123        redirect(controller: 'appCore', action: 'start', params: [showTab:'showReportsTab'])
    118124
    119125    } // immediateCallouts
  • trunk/grails-app/services/TaskReportService.groovy

    r708 r709  
    169169        def result = [:]
    170170
     171        def fail = { Map m ->
     172            result.error = [ code: m.code, args: [] ]
     173            return result
     174        }
     175
    171176        def namedParams = [:]
    172177        namedParams.startDate = params.startDate ?: dateUtilService.today
    173         namedParams.endDatePlusOne = (params.endDate ?: dateUtilService.today)+1
     178        namedParams.endDate = params.endDate ?: dateUtilService.today
     179
     180        if(namedParams.endDate < namedParams.startDate)
     181            return fail(code: "default.end.date.before.start.date")
     182
     183        namedParams.endDate++ // Start of next day required.
     184
    174185        namedParams.immediateCallout = TaskType.read(1)
    175186
    176187        result.taskQuery = "from Task as task \
    177188                                            where (task.trash = false \
    178                                                         and task.targetStartDate < :endDatePlusOne \
     189                                                        and task.targetStartDate < :endDate \
    179190                                                        and task.targetStartDate >= :startDate \
    180191                                                        and task.taskType = :immediateCallout \
Note: See TracChangeset for help on using the changeset viewer.