Changeset 710


Ignore:
Timestamp:
Nov 16, 2010, 7:56:10 AM (13 years ago)
Author:
gav
Message:

Return error message on equipment register (OH&S) report submit when endDate < startDate.

Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r709 r710  
    199199        params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
    200200
    201         def dataModel = assetReportService.getEquipmentRegister(params, RCU.getLocale(request))
    202 
    203         // Jasper plugin controller expects data to be a Collection.
    204         chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params)
     201        def result = assetReportService.getEquipmentRegister(params, RCU.getLocale(request))
     202
     203        if(!result.error) {
     204            // Jasper plugin controller expects data to be a Collection.
     205            chain(controller:'jasper', action:'index', model:[data: [result]], params:params)
     206            return
     207        }
     208
     209        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     210        redirect(action: 'equipmentRegisterOhsGsp')
    205211
    206212//         render {
  • trunk/grails-app/services/AssetReportService.groovy

    r706 r710  
    134134        def result = [:]
    135135
     136        def fail = { Map m ->
     137            result.error = [ code: m.code, args: [] ]
     138            return result
     139        }
     140
    136141        result.section = Section.get(params.section.id.toLong())
    137142        result.site = result.section.site
     
    149154            params.endDate = dateUtilService.today
    150155
    151         // Normalise date range.
    152156        if(params.endDate < params.startDate)
    153             params.endDate = params.startDate
     157            return fail(code: "default.end.date.before.start.date")
    154158
    155159        // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes.
Note: See TracChangeset for help on using the changeset viewer.