Changeset 743 for trunk/grails-app
- Timestamp:
- Dec 13, 2010, 10:14:05 PM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/ReportController.groovy
r740 r743 285 285 286 286 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 287 redirect(action: 'equipmentRegisterOhsGsp') 288 289 // render { 290 // p("DataList:") 291 // result.dataList?.each { 292 // p("$it") 293 // } 294 // } 287 redirect(action: 'regulatoryRequirementsGsp') 295 288 296 289 } // regulatoryRequirements 297 290 291 def mandatoryRequirementsGsp = { 292 render(view: 'mandatoryRequirements') 293 } 294 295 def mandatoryRequirements = { 296 297 def result = assetReportService.getMandatoryRequirements(params, RCU.getLocale(request)) 298 299 params.reportTitle = "Asset Mandatory Requirements" 300 params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() 301 params.currentUser = authService.currentUser 302 params.startDateString = result.startDateString 303 params.endDateString = result.endDateString 304 305 if(!result.error) { 306 // Jasper plugin controller expects data to be a Collection. 307 chain(controller:'jasper', action:'index', model:[data: [result]], params:params) 308 return 309 } 310 311 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 312 redirect(action: 'mandatoryRequirementsGsp') 313 314 } // mandatoryRequirements 315 298 316 } // end of class. -
trunk/grails-app/services/AssetReportService.groovy
r741 r743 300 300 } // getEquipmentRegister 301 301 302 303 302 /** 304 303 * Selects and returns assets regulatory requirements as specified in recurring regulatory tasks. … … 330 329 331 330 result.summary = "This report only selects primary assets and not associated assets. \n" 332 result.summary += "Tasks must have arecurrence enabled and regulatory requirement set."331 result.summary += "Tasks must have recurrence enabled and regulatory requirement set." 333 332 334 333 // Subquery to count subTasks.. … … 388 387 } // getRegulatoryRequirements 389 388 389 /** 390 * Selects and returns assets mandatory requirements as specified in recurring mandatory tasks. 391 * @param params The request params, may contain params to specify the search. 392 * @param locale The locale to use when generating result.message. 393 */ 394 def getMandatoryRequirements(params, locale) { 395 def result = [:] 396 397 def fail = { Map m -> 398 result.error = [ code: m.code, args: [] ] 399 return result 400 } 401 402 result.section = Section.get(params.section.id.toLong()) 403 result.site = result.section.site 404 405 result.startDate = params.startDate ?: dateUtilService.oneWeekAgo 406 result.endDate = params.endDate ?: dateUtilService.today 407 // Auto swap date range. 408 if(result.startDate > result.endDate) { 409 def tempStartDate = result.startDate 410 result.startDate = result.endDate 411 result.endDate = tempStartDate 412 } 413 414 result.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: result.startDate) 415 result.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: result.endDate) 416 417 result.summary = "This report only selects primary assets and not associated assets. \n" 418 result.summary += "Tasks must have recurrence enabled and mandatory requirement set." 419 420 // Subquery to count subTasks.. 421 def subTaskQ = new HqlBuilder().query { 422 select 'count(subTask)' 423 from 'task.subTasks as subTask' 424 where 'subTask.trash = false' 425 and 'subTask.targetStartDate < :endDate' 426 and 'subTask.targetCompletionDate >= :startDate' 427 } 428 def subTaskTotalQ = subTaskQ.query 429 430 subTaskQ.and 'subTask.taskStatus.id = 3' // Complete. 431 def subTaskCompletedQ = subTaskQ.query 432 433 def mandatoryTaskQ = new HqlBuilder().query { 434 select 'new map(primaryAsset.name as assetName', 435 'primaryAsset.description as assetDescription', 436 'primaryAsset.isActive as assetIsActive', 437 'task.id as taskId', 438 'task.description as taskDescription', 439 "($subTaskTotalQ) as subTaskTotalCount", 440 "($subTaskCompletedQ) as subTaskCompletedCount)" 441 namedParams.startDate = result.startDate 442 namedParams.endDate = result.endDate 443 from 'Task task', 444 'left join task.primaryAsset as primaryAsset', 445 'left join task.taskRecurringSchedule as taskRecurringSchedule' 446 where 'task.mandatoryRequirement = true' 447 and 'taskRecurringSchedule.enabled = true' 448 and 'task.trash = false' 449 namedParams.sectionId = result.section.id 450 and 'primaryAsset.section.id = :sectionId' 451 } 452 result.tasks = Task.executeQuery(mandatoryTaskQ.query, mandatoryTaskQ.namedParams) 453 454 // Build the report table row for each task. 455 result.tasks.each { task -> 456 457 // Caluculate percentages and build description. 458 def percentComplete 459 def completionFigures 460 if(task.subTaskTotalCount) { 461 percentComplete = (task.subTaskCompletedCount / task.subTaskTotalCount) * 100 462 task.completionFigures = "${percentComplete.toInteger()}% ($task.subTaskCompletedCount/$task.subTaskTotalCount)" 463 } 464 else 465 task.completionFigures = '0 sub tasks in date range' 466 } // tasks.each 467 468 result.dataList = result.tasks 469 result.dataList.sort { p1, p2 -> p1.assetName.compareToIgnoreCase(p2.assetName) } 470 471 // Success. 472 return result 473 474 } // getMandatoryRequirements 475 390 476 } // end class -
trunk/grails-app/views/appCore/start.gsp
r740 r743 171 171 <br /> 172 172 <g:link controller="report" action="regulatoryRequirementsGsp"> 173 <img src="${resource(dir:'images/skin',file:'script_lightning.png')}" alt="Regulatory Requirement" title="Regulatory Requirement" /> 173 174 Regulatory Requirements 175 </g:link> 176 <br /> 177 <br /> 178 <g:link controller="report" action="mandatoryRequirementsGsp"> 179 <img src="${resource(dir:'images/skin',file:'script.png')}" alt="Mandatory Requirement" title="Mandatory Requirement" /> 180 Mandatory Requirements 174 181 </g:link> 175 182 <br />
Note: See TracChangeset
for help on using the changeset viewer.