Changeset 706 for trunk/grails-app
- Timestamp:
- Nov 10, 2010, 5:30:28 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/ReportController.groovy
r696 r706 173 173 } // assetRegister 174 174 175 def equipmentRegisterOhsGsp = { 176 render(view: 'equipmentRegisterOhs') 177 } 178 175 179 def equipmentRegisterOhs = { 176 180 … … 178 182 params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() 179 183 params.currentUser = authService.currentUser 184 185 params.calculateRegulatoryTaskCompletion = true 186 params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate) 187 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 180 188 181 189 def dataModel = assetReportService.getEquipmentRegister(params, RCU.getLocale(request)) -
trunk/grails-app/services/AssetReportService.groovy
r687 r706 137 137 result.site = result.section.site 138 138 139 // Start date. 140 if(params.startDate) 141 params.startDate = dateUtilService.makeDate(params.startDate_year, params.startDate_month, params.startDate_day) 142 else 143 params.startDate = dateUtilService.oneWeekAgo 144 145 // End date. 146 if(params.endDate) 147 params.endDate = dateUtilService.makeDate(params.endDate_year, params.endDate_month, params.endDate_day) 148 else 149 params.endDate = dateUtilService.today 150 151 // Normalise date range. 152 if(params.endDate < params.startDate) 153 params.endDate = params.startDate 154 139 155 // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes. 140 156 // So the result is only assetSubItem extendedAttributeTypes. … … 166 182 result.assetsWithoutEquipment = AssetSubItem.executeQuery(assetsWithoutEquipmentQ.query, assetsWithoutEquipmentQ.namedParams) 167 183 184 // Subquery to count regulatory tasks. 185 def regulatoryTaskCountQ = new HqlBuilder().query { 186 187 select 'count (distinct task)' 188 from 'Task as task', 189 'left join task.associatedAssets as associatedAsset' 190 where 'task.mandatoryRegulatory = true' 191 and 'task.targetStartDate < :endDate' 192 and 'task.targetCompletionDate >= :startDate' 193 and '(task.primaryAsset.id = asset.id or associatedAsset.id = asset.id)' 194 and 'task.trash = false' 195 } 196 197 def totalRegulatoryTaskCountQ = regulatoryTaskCountQ.query 198 199 regulatoryTaskCountQ.and 'task.taskStatus.id = 3' 200 def completedRegulatoryTaskCountQ = regulatoryTaskCountQ.query 201 168 202 // A result is returned for every level 1 assetSubItem and for any extended attributes. 169 203 def q = new HqlBuilder().query { 204 170 205 select 'new map(asset.name as assetName', 171 206 'assetSubItem.name as name', 172 207 'assetSubItem.description as description', 173 208 'assetSubItem.comment as comment', 209 "0 as totalRegulatoryTaskCount", 210 "0 as completedRegulatoryTaskCount", 174 211 'attribT.name as attribType', 175 212 'attrib.value as attribValue)' … … 187 224 // A result is returned for every asset and for any extended attributes. 188 225 def assetResultsQ = new HqlBuilder().query { 226 227 // Subquery namedParams. 228 namedParams.startDate = params.startDate 229 namedParams.endDate = params.endDate+1 230 189 231 select 'new map(asset.name as assetName', 190 232 "' Asset Details' as name", // Place holder 'equipment' name, 3 leading spaces for sorting. 191 233 'asset.description as description', 192 234 'asset.comment as comment', 235 "($totalRegulatoryTaskCountQ) as totalRegulatoryTaskCount", 236 "($completedRegulatoryTaskCountQ) as completedRegulatoryTaskCount", 193 237 'attribT.name as attribType', 194 238 'attrib.value as attribValue)' … … 211 255 def rows = [:] 212 256 equipmentResults.each { equipmentResult -> 213 // Create row if it does not exist yet. 257 214 258 def rowKey = equipmentResult.assetName+equipmentResult.name 259 260 // Create new row if it does not exist yet. 215 261 if(!rows.containsKey(rowKey)) { 216 262 rows[rowKey] = ['assetName': equipmentResult.assetName, 217 'name':equipmentResult.name, 218 'description':equipmentResult.description, 219 'comment':equipmentResult.comment] 263 'name':equipmentResult.name, 264 'description':equipmentResult.description, 265 'comment':equipmentResult.comment, 266 'Regulatory Task Completion': ' '] 220 267 221 268 // Add all attribType columns. … … 223 270 rows[rowKey][column] = ' ' 224 271 } 225 } 272 273 // Caluculate and assign RegulatoryTaskCompletion, only for Assets. 274 if(params.calculateRegulatoryTaskCompletion) { 275 276 if(equipmentResult.totalRegulatoryTaskCount) { 277 def percentComplete = (equipmentResult.completedRegulatoryTaskCount / equipmentResult.totalRegulatoryTaskCount)*100 278 rows[rowKey]['Regulatory Task Completion'] = "${percentComplete.toInteger()}% (${equipmentResult.completedRegulatoryTaskCount}/${equipmentResult.totalRegulatoryTaskCount})" 279 } 280 else if(equipmentResult.name == ' Asset Details') 281 rows[rowKey]['Regulatory Task Completion'] = 'N/A' 282 } 283 284 } // Create new row. 226 285 227 286 // Assign value to column. 228 287 rows[rowKey][equipmentResult.attribType] = equipmentResult.attribValue 229 } 288 } // each. 230 289 231 290 // The value of each row is the dataList used by the report table. -
trunk/grails-app/views/appCore/start.gsp
r696 r706 138 138 <br /> 139 139 <g:jasperReport controller="report" 140 action="templatePortrait" 141 jasper="templatePortrait" 142 name="Template (Portrait)" 143 format="PDF, XLS"> 144 <g:link controller="report" action="downloadTemplate" params="[fileName: 'templatePortrait.jrxml']"> 145 Download 146 </g:link> 147 </g:jasperReport> 148 <br /> 149 <g:jasperReport controller="report" 150 action="templateLandscape" 151 jasper="templateLandscape" 152 name="Template (Landscape)" 153 format="PDF, XLS"> 154 <g:link controller="report" action="downloadTemplate" params="[fileName: 'templateLandscape.jrxml']"> 155 Download 156 </g:link> 157 </g:jasperReport> 158 <br /> 159 </td> 160 </tr> 161 162 <tr class="prop"> 163 <td valign="top" class="name"> 164 <label>Assets:</label> 165 </td> 166 <td valign="top" class="value"> 167 <g:link controller="report" action="equipmentRegisterOhsGsp"> 168 Equipment Register (OH&S) 169 </g:link> 170 <br /> 171 <br /> 172 <g:jasperReport controller="report" 173 action="equipmentRegisterFinancial" 174 jasper="equipmentRegisterFinancial" 175 name="Equipment Register (Financial)" 176 format="PDF, XLS"> 177 <g:select optionKey="id" 178 from="${sections}" 179 name="section.id"> 180 </g:select> 181 </g:jasperReport> 182 <br /> 183 <g:jasperReport controller="report" 184 action="assetRegister" 185 jasper="assetRegister" 186 name="Asset Register" 187 format="PDF, XLS"> 188 <g:select optionKey="id" 189 from="${sections}" 190 name="section.id"> 191 </g:select> 192 </g:jasperReport> 193 <br /> 194 <g:jasperReport controller="report" 140 195 action="assetDetail" 141 196 jasper="assetDetail" … … 149 204 </g:jasperReport> 150 205 <br /> 151 <g:jasperReport controller="report"152 action="assetRegister"153 jasper="assetRegister"154 name="Asset Register"155 format="PDF, XLS">156 <g:select optionKey="id"157 from="${sections}"158 name="section.id">159 </g:select>160 </g:jasperReport>161 <br />162 <g:jasperReport controller="report"163 action="equipmentRegisterOhs"164 jasper="equipmentRegisterOhs"165 name="Equipment Register (OH&S)"166 format="PDF, XLS">167 <g:select optionKey="id"168 from="${sections}"169 name="section.id">170 </g:select>171 </g:jasperReport>172 <br />173 <g:jasperReport controller="report"174 action="equipmentRegisterFinancial"175 jasper="equipmentRegisterFinancial"176 name="Equipment Register (Financial)"177 format="PDF, XLS">178 <g:select optionKey="id"179 from="${sections}"180 name="section.id">181 </g:select>182 </g:jasperReport>183 <br />184 <g:jasperReport controller="report"185 action="templatePortrait"186 jasper="templatePortrait"187 name="Template (Portrait)"188 format="PDF, XLS">189 <g:link controller="report" action="downloadTemplate" params="[fileName: 'templatePortrait.jrxml']">190 Download191 </g:link>192 </g:jasperReport>193 <br />194 <g:jasperReport controller="report"195 action="templateLandscape"196 jasper="templateLandscape"197 name="Template (Landscape)"198 format="PDF, XLS">199 <g:link controller="report" action="downloadTemplate" params="[fileName: 'templateLandscape.jrxml']">200 Download201 </g:link>202 </g:jasperReport>203 <br />204 </td>205 206 </tr> 206 207
Note: See TracChangeset
for help on using the changeset viewer.