[533] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
| 2 | import org.springframework.web.servlet.support.RequestContextUtils as RCU |
---|
| 3 | |
---|
| 4 | class ReportController extends BaseController { |
---|
| 5 | |
---|
| 6 | def authService |
---|
| 7 | def dateUtilService |
---|
| 8 | def taskReportService |
---|
| 9 | |
---|
| 10 | def index = { redirect(action:templatePortrait,params:params) } |
---|
| 11 | |
---|
| 12 | // the delete, save and update actions only accept POST requests |
---|
| 13 | //static allowedMethods = [list:'POST'] |
---|
| 14 | |
---|
| 15 | def templatePortrait = { |
---|
| 16 | params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) |
---|
| 17 | |
---|
| 18 | params.reportTitle = "Template Report (Portrait)" |
---|
| 19 | params.currentUser = authService.currentUser |
---|
| 20 | def dataModel = createTemplateData() |
---|
| 21 | |
---|
| 22 | chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | def templateLandscape = { |
---|
| 26 | params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) |
---|
| 27 | |
---|
| 28 | params.reportTitle = "Template Report (Landscape)" |
---|
| 29 | params.currentUser = authService.currentUser |
---|
| 30 | def dataModel = createTemplateData() |
---|
| 31 | |
---|
| 32 | chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | private createTemplateData() { |
---|
| 36 | def dataModel = [] |
---|
| 37 | for(i in 1..5) { |
---|
| 38 | def data = [:] |
---|
| 39 | data.description = "Data description " + i.toString() |
---|
| 40 | dataModel.add(data) |
---|
| 41 | } |
---|
| 42 | return dataModel |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | def reactiveRatio = { |
---|
| 46 | |
---|
| 47 | params.reportTitle = "Reactive Ratio Report" |
---|
[538] | 48 | params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() |
---|
[533] | 49 | params.currentUser = authService.currentUser |
---|
[535] | 50 | |
---|
| 51 | if(params.startDate == 'struct') |
---|
| 52 | params.startDate = dateUtilService.makeDate(params.startDate_year, params.startDate_month, params.startDate_day) |
---|
| 53 | else |
---|
| 54 | params.startDate = dateUtilService.today-7 |
---|
| 55 | params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate) |
---|
| 56 | |
---|
| 57 | if(params.endDate == 'struct') |
---|
| 58 | params.endDate = dateUtilService.makeDate(params.endDate_year, params.endDate_month, params.endDate_day) |
---|
| 59 | else |
---|
| 60 | params.endDate = dateUtilService.today |
---|
| 61 | params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) |
---|
| 62 | |
---|
[533] | 63 | def dataModel = [taskReportService.getReactiveRatio(params, RCU.getLocale(request))] |
---|
| 64 | |
---|
| 65 | chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | def test = { |
---|
| 69 | render taskReportService.getReactiveRatio(params, RCU.getLocale(request)) |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | } // end of class. |
---|