- Timestamp:
- Oct 5, 2010, 12:50:57 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/ReportController.groovy
r676 r679 178 178 params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() 179 179 params.currentUser = authService.currentUser 180 if(params.section.id == 'all')181 params.section = "All"182 else183 params.section = Section.get(params.section.id.toLong())184 180 185 181 def dataModel = assetReportService.getEquipmentRegister(params, RCU.getLocale(request)) -
trunk/grails-app/services/AssetReportService.groovy
r678 r679 125 125 def result = [:] 126 126 127 result.section = Section.get(params.section.id.toLong()) 128 result.site = result.section.site 129 127 130 // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes. 128 131 // So the result is only assetSubItem extendedAttributeTypes. … … 135 138 result.attribTypes = Asset.executeQuery(attribTypesQ.query, attribTypesQ.namedParams) 136 139 137 // Since there will be nothing to show in the report table for assets without level 1 assetSubItems, 138 // a list needs to be given to the user. 140 // A useful list of assets without subItems to be given to the user. 139 141 def assetsWithoutEquipmentQ = new HqlBuilder().query { 140 142 select 'distinct asset' … … 142 144 'left join asset.assetSubItems as assetSubItem' 143 145 where 'assetSubItem = null' 146 namedParams.section = result.section 147 and 'asset.section = :section' 144 148 } 145 149 result.assetsWithoutEquipment = AssetSubItem.executeQuery(assetsWithoutEquipmentQ.query, assetsWithoutEquipmentQ.namedParams) … … 158 162 'left join attrib.extendedAttributeType as attribT' 159 163 where 'asset != null' // ensure that only level 1 assetSubItems are returned. 160 if(params.section instanceof Section) { 161 namedParams.section = params.section 164 namedParams.section = result.section 162 165 and 'asset.section = :section' 163 }164 166 order 'by asset.name asc, assetSubItem.name asc, attribT.name asc' 165 167 } 166 168 def equipmentResults = AssetSubItem.executeQuery(q.query, q.namedParams) 169 170 // A result is returned for every asset and for any extended attributes. 171 def assetResultsQ = new HqlBuilder().query { 172 select 'new map(asset.name as assetName', 173 "' Asset Details' as name", // Place holder 'equipment' name, 3 leading spaces for sorting. 174 'asset.description as description', 175 'asset.comment as comment', 176 'attribT.name as attribType', 177 'attrib.value as attribValue)' 178 from 'Asset asset', 179 'left join asset.assetExtendedAttributes as attrib', 180 'left join attrib.extendedAttributeType as attribT' 181 where 'asset.section = :section' 182 namedParams.section = result.section 183 order 'by asset.name asc, attribT.name asc' 184 } 185 def assetResults = Asset.executeQuery(assetResultsQ.query, assetResultsQ.namedParams) 186 187 // Add asset details to equipmentResults. 188 equipmentResults.addAll(assetResults) 189 equipmentResults.sort { p1, p2 -> p1.assetName.compareToIgnoreCase(p2.assetName) ?: p1.name.compareToIgnoreCase(p2.name) } 167 190 168 191 // Build the report table rows. -
trunk/grails-app/views/appCore/start.gsp
r676 r679 168 168 <g:select optionKey="id" 169 169 from="${Section.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}" 170 name="section.id" 171 noSelection="['all':/${g.message(code:'default.all.select.text')}/]"> 170 name="section.id"> 172 171 </g:select> 173 172 </g:jasperReport> -
trunk/web-app/reports/equipmentRegister.jrxml
r678 r679 4 4 <property name="ireport.encoding" value="UTF-8"/> 5 5 <property name="ireport.zoom" value="1.5"/> 6 <property name="ireport.x" value=" 31"/>6 <property name="ireport.x" value="0"/> 7 7 <property name="ireport.y" value="0"/> 8 8 <import value="net.sf.jasperreports.engine.*"/> … … 10 10 <import value="net.sf.jasperreports.engine.data.*"/> 11 11 <style name="table" isDefault="false"> 12 <pen lineWidth="0.5"/> 12 13 <box> 13 14 <pen lineWidth="1.0" lineColor="#000000"/> … … 33 34 </box> 34 35 </style> 36 <style name="table_GH" isDefault="false" mode="Opaque" backcolor="#D2EFF7"/> 35 37 <subDataset name="dataset1"> 36 38 <queryString language="SQL"> … … 58 60 <parameter name="currentUser" class="java.lang.String"/> 59 61 <parameter name="logoUrl" class="java.lang.String"/> 60 <parameter name="section" class="java.lang.String"/>61 62 <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> 62 63 <defaultValueExpression><![CDATA["C:\\Documents and Settings\\kromhoutg\\My Documents\\reports\\"]]></defaultValueExpression> … … 68 69 <field name="attribTypes" class="java.lang.String"/> 69 70 <field name="assetsWithoutEquipment" class="java.lang.String"/> 71 <field name="site" class="java.lang.Object"/> 72 <field name="section" class="java.lang.Object"/> 70 73 <background> 71 74 <band splitType="Stretch"/> … … 85 88 </image> 86 89 <textField> 87 <reportElement x="398" y="34" width="340" height="12" />90 <reportElement x="398" y="34" width="340" height="12" isPrintWhenDetailOverflows="true"/> 88 91 <textElement textAlignment="Center"> 89 <font fontName="Serif" size=" 8"/>90 </textElement> 91 <textFieldExpression class="java.lang.String"><![CDATA["S ection: "+$P{section}]]></textFieldExpression>92 <font fontName="Serif" size="10"/> 93 </textElement> 94 <textFieldExpression class="java.lang.String"><![CDATA["Site: "+$F{site}.name+", "+"Section: "+$F{section}.name]]></textFieldExpression> 92 95 </textField> 93 96 </band> … … 105 108 </datasetRun> 106 109 <jr:column width="100"> 107 <jr:groupHeader groupName="assetName"> 108 <jr:cell height="20" rowSpan="1"> 109 <textField isStretchWithOverflow="true"> 110 <reportElement stretchType="RelativeToTallestObject" x="2" y="2" width="96" height="16" isPrintWhenDetailOverflows="true"/> 111 <textElement verticalAlignment="Middle"> 112 <font fontName="Serif" size="10"/> 113 </textElement> 114 <textFieldExpression class="java.lang.String"><![CDATA[$F{assetName}]]></textFieldExpression> 115 </textField> 116 </jr:cell> 117 </jr:groupHeader> 118 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 119 <staticText> 120 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="96" height="16" isPrintWhenDetailOverflows="true"/> 121 <textElement verticalAlignment="Middle"> 122 <font fontName="Serif"/> 110 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 111 <staticText> 112 <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="32" isPrintWhenDetailOverflows="true"/> 113 <textElement textAlignment="Center" verticalAlignment="Middle"> 114 <font fontName="Serif" isBold="false"/> 123 115 </textElement> 124 116 <text><![CDATA[Asset]]></text> 125 </staticText>126 <staticText>127 <reportElement x="2" y="16" width="96" height="16"/>128 <textElement textAlignment="Center"/>129 <text><![CDATA[Equipment]]></text>130 117 </staticText> 131 118 </jr:columnHeader> … … 139 126 <jr:detailCell style="table_TD" height="36" rowSpan="1"> 140 127 <textField isStretchWithOverflow="true"> 141 <reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="2" y="0" width="96" height="20" isPrintWhenDetailOverflows="true" backcolor="#D2EFF7"/> 142 <textElement textAlignment="Center" verticalAlignment="Middle"> 143 <font fontName="Serif" size="10" isBold="true"/> 128 <reportElement positionType="Float" mode="Opaque" x="2" y="0" width="96" height="18" isPrintWhenDetailOverflows="true" backcolor="#D2EFF7"> 129 <printWhenExpression><![CDATA[$F{name}.equals(' Asset Details')]]></printWhenExpression> 130 </reportElement> 131 <textElement textAlignment="Center" verticalAlignment="Middle"> 132 <font fontName="Serif" isBold="false"/> 133 </textElement> 134 <textFieldExpression class="java.lang.String"><![CDATA[$F{assetName}]]></textFieldExpression> 135 </textField> 136 <textField isStretchWithOverflow="true"> 137 <reportElement positionType="Float" x="2" y="18" width="96" height="18" isPrintWhenDetailOverflows="true"> 138 <printWhenExpression><![CDATA[$F{name}.equals(' Asset Details')]]></printWhenExpression> 139 </reportElement> 140 <textElement textAlignment="Center" verticalAlignment="Middle"> 141 <font fontName="Serif"/> 142 </textElement> 143 <textFieldExpression class="java.lang.String"><![CDATA[$F{description}]]></textFieldExpression> 144 </textField> 145 </jr:detailCell> 146 </jr:column> 147 <jr:column width="100"> 148 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 149 <staticText> 150 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="96" height="32" isPrintWhenDetailOverflows="true"/> 151 <textElement textAlignment="Center" verticalAlignment="Middle"> 152 <font fontName="Serif" size="8"/> 153 </textElement> 154 <text><![CDATA[Sub Asset]]></text> 155 </staticText> 156 </jr:columnHeader> 157 <jr:detailCell style="table_TD" height="36" rowSpan="1"> 158 <textField isStretchWithOverflow="true"> 159 <reportElement positionType="Float" mode="Opaque" x="2" y="0" width="96" height="18" isPrintWhenDetailOverflows="true" backcolor="#D2EFF7"> 160 <printWhenExpression><![CDATA[!$F{name}.equals(' Asset Details')]]></printWhenExpression> 161 </reportElement> 162 <textElement textAlignment="Center" verticalAlignment="Middle"> 163 <font fontName="Serif"/> 144 164 </textElement> 145 165 <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression> 146 166 </textField> 147 167 <textField isStretchWithOverflow="true"> 148 <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="2" y="20" width="96" height="15" isPrintWhenDetailOverflows="true"/> 168 <reportElement positionType="Float" x="2" y="18" width="96" height="18" isPrintWhenDetailOverflows="true"> 169 <printWhenExpression><![CDATA[!$F{name}.equals(' Asset Details')]]></printWhenExpression> 170 </reportElement> 149 171 <textElement textAlignment="Center" verticalAlignment="Middle"> 150 172 <font fontName="Serif" size="8"/> … … 154 176 </jr:detailCell> 155 177 </jr:column> 156 <jr:column width="90"> 157 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 158 <staticText> 159 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="86" height="32" isPrintWhenDetailOverflows="true"/> 160 <textElement textAlignment="Center" verticalAlignment="Middle"> 161 <font fontName="Serif" size="8"/> 162 </textElement> 163 <text><![CDATA[Comment]]></text> 164 </staticText> 165 </jr:columnHeader> 166 <jr:detailCell style="table_TD" height="36" rowSpan="1"> 167 <textField isStretchWithOverflow="true"> 168 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="86" height="35" isPrintWhenDetailOverflows="true"/> 169 <textElement textAlignment="Center" verticalAlignment="Middle"> 170 <font fontName="Serif" size="8"/> 171 </textElement> 172 <textFieldExpression class="java.lang.String"><![CDATA[$F{comment}]]></textFieldExpression> 173 </textField> 174 </jr:detailCell> 175 </jr:column> 176 <jr:column width="75"> 177 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 178 <staticText> 179 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="71" height="32" isPrintWhenDetailOverflows="true"/> 178 <jr:column width="55"> 179 <jr:columnHeader style="table_CH" height="32" rowSpan="1"> 180 <staticText> 181 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="51" height="32" isPrintWhenDetailOverflows="true"/> 180 182 <textElement textAlignment="Center" verticalAlignment="Middle"> 181 183 <font fontName="Serif" size="8"/> … … 186 188 <jr:detailCell style="table_TD" height="36" rowSpan="1"> 187 189 <textField isStretchWithOverflow="true"> 188 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width=" 71" height="35" isPrintWhenDetailOverflows="true"/>190 <reportElement stretchType="RelativeToTallestObject" x="2" y="0" width="51" height="35" isPrintWhenDetailOverflows="true"/> 189 191 <textElement textAlignment="Center" verticalAlignment="Middle"> 190 192 <font fontName="Serif" size="8"/> … … 497 499 </textField> 498 500 <textField> 499 <reportElement x="13" y="66" width="824" height="19" forecolor="# FF0033">501 <reportElement x="13" y="66" width="824" height="19" forecolor="#000000"> 500 502 <printWhenExpression><![CDATA[$F{assetsWithoutEquipment}]]></printWhenExpression> 501 503 </reportElement> … … 503 505 <font fontName="Serif"/> 504 506 </textElement> 505 <textFieldExpression class="java.lang.String"><![CDATA["The following assets have no sub items (equipment) and therefore are not listed in the equipment table: \n"+$F{assetsWithoutEquipment}]]></textFieldExpression>507 <textFieldExpression class="java.lang.String"><![CDATA["The following assets have no sub assets (equipment):"]]></textFieldExpression> 506 508 </textField> 507 509 </band>
Note: See TracChangeset
for help on using the changeset viewer.