Index: trunk/grails-app/controllers/ReportController.groovy
===================================================================
--- trunk/grails-app/controllers/ReportController.groovy	(revision 705)
+++ trunk/grails-app/controllers/ReportController.groovy	(revision 706)
@@ -173,4 +173,8 @@
     } // assetRegister
 
+    def equipmentRegisterOhsGsp = {
+        render(view: 'equipmentRegisterOhs')
+    }
+
     def equipmentRegisterOhs = {
 
@@ -178,4 +182,8 @@
         params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL()
         params.currentUser = authService.currentUser
+
+        params.calculateRegulatoryTaskCompletion = true
+        params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate)
+        params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate)
 
         def dataModel = assetReportService.getEquipmentRegister(params, RCU.getLocale(request))
Index: trunk/grails-app/services/AssetReportService.groovy
===================================================================
--- trunk/grails-app/services/AssetReportService.groovy	(revision 705)
+++ trunk/grails-app/services/AssetReportService.groovy	(revision 706)
@@ -137,4 +137,20 @@
         result.site = result.section.site
 
+        // Start date.
+        if(params.startDate)
+            params.startDate = dateUtilService.makeDate(params.startDate_year, params.startDate_month, params.startDate_day)
+        else
+            params.startDate = dateUtilService.oneWeekAgo
+
+        // End date.
+        if(params.endDate)
+            params.endDate = dateUtilService.makeDate(params.endDate_year, params.endDate_month, params.endDate_day)
+        else
+            params.endDate = dateUtilService.today
+
+        // Normalise date range.
+        if(params.endDate < params.startDate)
+            params.endDate = params.startDate
+
         // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes.
         // So the result is only assetSubItem extendedAttributeTypes.
@@ -166,10 +182,31 @@
         result.assetsWithoutEquipment = AssetSubItem.executeQuery(assetsWithoutEquipmentQ.query, assetsWithoutEquipmentQ.namedParams)
 
+        // Subquery to count regulatory tasks.
+        def regulatoryTaskCountQ = new HqlBuilder().query {
+
+            select 'count (distinct task)'
+            from 'Task as task',
+                    'left join task.associatedAssets as associatedAsset'
+            where 'task.mandatoryRegulatory = true'
+                and 'task.targetStartDate < :endDate'
+                and 'task.targetCompletionDate >= :startDate'
+                and '(task.primaryAsset.id = asset.id or associatedAsset.id = asset.id)'
+                and 'task.trash = false'
+        }
+
+        def totalRegulatoryTaskCountQ = regulatoryTaskCountQ.query
+
+        regulatoryTaskCountQ.and 'task.taskStatus.id = 3'
+        def completedRegulatoryTaskCountQ = regulatoryTaskCountQ.query
+
         // A result is returned for every level 1 assetSubItem and for any extended attributes.
         def q = new HqlBuilder().query {
+
             select 'new map(asset.name as assetName',
                         'assetSubItem.name as name',
                         'assetSubItem.description as description',
                         'assetSubItem.comment as comment',
+                        "0 as totalRegulatoryTaskCount",
+                        "0 as completedRegulatoryTaskCount",
                         'attribT.name as attribType',
                         'attrib.value as attribValue)'
@@ -187,8 +224,15 @@
         // A result is returned for every asset and for any extended attributes.
         def assetResultsQ = new HqlBuilder().query {
+
+            // Subquery namedParams.
+            namedParams.startDate = params.startDate
+            namedParams.endDate = params.endDate+1
+
             select 'new map(asset.name as assetName',
                         "'   Asset Details' as name", // Place holder 'equipment' name, 3 leading spaces for sorting.
                         'asset.description as description',
                         'asset.comment as comment',
+                        "($totalRegulatoryTaskCountQ) as totalRegulatoryTaskCount",
+                        "($completedRegulatoryTaskCountQ) as completedRegulatoryTaskCount",
                         'attribT.name as attribType',
                         'attrib.value as attribValue)'
@@ -211,11 +255,14 @@
         def rows = [:]
         equipmentResults.each { equipmentResult ->
-            // Create row if it does not exist yet.
+
             def rowKey = equipmentResult.assetName+equipmentResult.name
+
+            // Create new row if it does not exist yet.
             if(!rows.containsKey(rowKey)) {
                 rows[rowKey] = ['assetName': equipmentResult.assetName,
-                                                            'name':equipmentResult.name,
-                                                            'description':equipmentResult.description,
-                                                            'comment':equipmentResult.comment]
+                                            'name':equipmentResult.name,
+                                            'description':equipmentResult.description,
+                                            'comment':equipmentResult.comment,
+                                            'Regulatory Task Completion': ' ']
 
                 // Add all attribType columns.
@@ -223,9 +270,21 @@
                     rows[rowKey][column] = ' '
                 }
-            }
+
+                // Caluculate and assign RegulatoryTaskCompletion, only for Assets.
+                if(params.calculateRegulatoryTaskCompletion) {
+
+                    if(equipmentResult.totalRegulatoryTaskCount) {
+                        def percentComplete = (equipmentResult.completedRegulatoryTaskCount / equipmentResult.totalRegulatoryTaskCount)*100
+                        rows[rowKey]['Regulatory Task Completion'] = "${percentComplete.toInteger()}% (${equipmentResult.completedRegulatoryTaskCount}/${equipmentResult.totalRegulatoryTaskCount})"
+                    }
+                    else if(equipmentResult.name == '   Asset Details')
+                        rows[rowKey]['Regulatory Task Completion'] = 'N/A'
+                }
+
+            } // Create new row.
 
             // Assign value to column.
             rows[rowKey][equipmentResult.attribType] = equipmentResult.attribValue
-        }
+        } // each.
 
         // The value of each row is the dataList used by the report table.
Index: trunk/grails-app/views/appCore/start.gsp
===================================================================
--- trunk/grails-app/views/appCore/start.gsp	(revision 705)
+++ trunk/grails-app/views/appCore/start.gsp	(revision 706)
@@ -138,4 +138,59 @@
                                             <br />
                                             <g:jasperReport controller="report"
+                                                                            action="templatePortrait"
+                                                                            jasper="templatePortrait"
+                                                                            name="Template (Portrait)"
+                                                                            format="PDF, XLS">
+                                                <g:link controller="report" action="downloadTemplate" params="[fileName: 'templatePortrait.jrxml']">
+                                                    Download
+                                                </g:link>
+                                            </g:jasperReport>
+                                            <br />
+                                            <g:jasperReport controller="report"
+                                                                            action="templateLandscape"
+                                                                            jasper="templateLandscape"
+                                                                            name="Template (Landscape)"
+                                                                            format="PDF, XLS">
+                                                <g:link controller="report" action="downloadTemplate" params="[fileName: 'templateLandscape.jrxml']">
+                                                    Download
+                                                </g:link>
+                                            </g:jasperReport>
+                                            <br />
+                                        </td>
+                                    </tr>
+
+                                    <tr class="prop">
+                                        <td valign="top" class="name">
+                                            <label>Assets:</label>
+                                        </td>
+                                        <td valign="top" class="value">
+                                            <g:link controller="report" action="equipmentRegisterOhsGsp">
+                                                Equipment Register (OH&amp;S)
+                                            </g:link>
+                                            <br />
+                                            <br />
+                                            <g:jasperReport controller="report"
+                                                                            action="equipmentRegisterFinancial"
+                                                                            jasper="equipmentRegisterFinancial"
+                                                                            name="Equipment Register (Financial)"
+                                                                            format="PDF, XLS">
+                                                <g:select optionKey="id"
+                                                                    from="${sections}"
+                                                                    name="section.id">
+                                                </g:select>
+                                            </g:jasperReport>
+                                            <br />
+                                            <g:jasperReport controller="report"
+                                                                            action="assetRegister"
+                                                                            jasper="assetRegister"
+                                                                            name="Asset Register"
+                                                                            format="PDF, XLS">
+                                                <g:select optionKey="id"
+                                                                    from="${sections}"
+                                                                    name="section.id">
+                                                </g:select>
+                                            </g:jasperReport>
+                                            <br />
+                                            <g:jasperReport controller="report"
                                                                             action="assetDetail"
                                                                             jasper="assetDetail"
@@ -149,58 +204,4 @@
                                             </g:jasperReport>
                                             <br />
-                                            <g:jasperReport controller="report"
-                                                                            action="assetRegister"
-                                                                            jasper="assetRegister"
-                                                                            name="Asset Register"
-                                                                            format="PDF, XLS">
-                                                <g:select optionKey="id"
-                                                                    from="${sections}"
-                                                                    name="section.id">
-                                                </g:select>
-                                            </g:jasperReport>
-                                            <br />
-                                            <g:jasperReport controller="report"
-                                                                            action="equipmentRegisterOhs"
-                                                                            jasper="equipmentRegisterOhs"
-                                                                            name="Equipment Register (OH&amp;S)"
-                                                                            format="PDF, XLS">
-                                                <g:select optionKey="id"
-                                                                    from="${sections}"
-                                                                    name="section.id">
-                                                </g:select>
-                                            </g:jasperReport>
-                                            <br />
-                                            <g:jasperReport controller="report"
-                                                                            action="equipmentRegisterFinancial"
-                                                                            jasper="equipmentRegisterFinancial"
-                                                                            name="Equipment Register (Financial)"
-                                                                            format="PDF, XLS">
-                                                <g:select optionKey="id"
-                                                                    from="${sections}"
-                                                                    name="section.id">
-                                                </g:select>
-                                            </g:jasperReport>
-                                            <br />
-                                            <g:jasperReport controller="report"
-                                                                            action="templatePortrait"
-                                                                            jasper="templatePortrait"
-                                                                            name="Template (Portrait)"
-                                                                            format="PDF, XLS">
-                                                <g:link controller="report" action="downloadTemplate" params="[fileName: 'templatePortrait.jrxml']">
-                                                    Download
-                                                </g:link>
-                                            </g:jasperReport>
-                                            <br />
-                                            <g:jasperReport controller="report"
-                                                                            action="templateLandscape"
-                                                                            jasper="templateLandscape"
-                                                                            name="Template (Landscape)"
-                                                                            format="PDF, XLS">
-                                                <g:link controller="report" action="downloadTemplate" params="[fileName: 'templateLandscape.jrxml']">
-                                                    Download
-                                                </g:link>
-                                            </g:jasperReport>
-                                            <br />
-                                        </td>
                                     </tr>
 
Index: trunk/grails-app/views/report/equipmentRegisterOhs.gsp
===================================================================
--- trunk/grails-app/views/report/equipmentRegisterOhs.gsp	(revision 706)
+++ trunk/grails-app/views/report/equipmentRegisterOhs.gsp	(revision 706)
@@ -0,0 +1,64 @@
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+        <meta name="layout" content="main" />
+        <title>Equipment Register (OH&amp;S) Report</title>
+        <nav:resources override="true"/>
+        <resource:dateChooser />
+    </head>
+    <body>
+        <div class="nav">
+            <nav:renderSubItems group="nav"/>
+        </div>
+        <div class="body">
+            <h1>Equipment Register (OH&amp;S) Report</h1>
+            <g:render template="/shared/messages" />
+            <div class="dialog">
+                <table>
+                    <tbody>
+
+                        <g:jasperForm controller="report"
+                                                    action="equipmentRegisterOhs"
+                                                    jasper="equipmentRegisterOhs"
+                                                    name="Equipment Register (OH&amp;S)">
+
+                            <tr class="prop">
+                                <td valign="top" class="name">
+                                    <label>Date:</label>
+                                </td>
+                                <td valign="top" class="value">
+                                    <richui:dateChooser name="startDate" id="equipmentRegisterOhs_startDate" format="dd-MM-yyyy" value="${new Date()-7}" />
+                                    to
+                                    <richui:dateChooser name="endDate" id="equipmentRegisterOhs_endDate" format="dd-MM-yyyy" value="${new Date()}" />
+                                </td>
+                            </tr>
+
+                            <tr class="prop">
+                                <td valign="top" class="name">
+                                    <label>Section:</label>
+                                </td>
+                                <td valign="top" class="value">
+                                    <g:select optionKey="id"
+                                                        from="${Section.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}"
+                                                        name="section.id">
+                                    </g:select>
+                                </td>
+                            </tr>
+
+                            <tr class="prop">
+                                <td valign="top" class="name">
+                                    <label>Report:</label>
+                                </td>
+                                <td valign="top" class="value">
+                                    <custom:jasperButtons jasper="equipmentRegisterOhs" format="PDF, XLS" text="PDF" />
+                                </td>
+                            </tr>
+
+                        </g:jasperForm>
+
+                    </tbody>
+                </table>
+            </div> <!--End dialog-->
+        </div> <!--End body-->
+    </body>
+</html>
Index: trunk/web-app/reports/equipmentRegisterOhs.jrxml
===================================================================
--- trunk/web-app/reports/equipmentRegisterOhs.jrxml	(revision 705)
+++ trunk/web-app/reports/equipmentRegisterOhs.jrxml	(revision 706)
@@ -4,6 +4,6 @@
 	<property name="ireport.encoding" value="UTF-8"/>
 	<property name="ireport.zoom" value="1.5"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="624"/>
+	<property name="ireport.x" value="337"/>
+	<property name="ireport.y" value="0"/>
 	<import value="net.sf.jasperreports.engine.*"/>
 	<import value="java.util.*"/>
@@ -49,5 +49,5 @@
 		<field name="Safe Work Procedure" class="java.lang.String"/>
 		<field name="Regulatory Requirement" class="java.lang.String"/>
-		<field name="Maintenance % Completion" class="java.lang.String"/>
+		<field name="Regulatory Task Completion" class="java.lang.String"/>
 		<field name="Registration Required" class="java.lang.String"/>
 		<field name="Registration Expiry Date" class="java.lang.String"/>
@@ -64,4 +64,6 @@
 		<defaultValueExpression><![CDATA["C:\\Documents and Settings\\kromhoutg\\My Documents\\reports\\"]]></defaultValueExpression>
 	</parameter>
+	<parameter name="startDateString" class="java.lang.String"/>
+	<parameter name="endDateString" class="java.lang.String"/>
 	<queryString language="SQL">
 		<![CDATA[]]>
@@ -78,5 +80,5 @@
 		<band height="57" splitType="Stretch">
 			<textField>
-				<reportElement key="staticText-1" x="398" y="14" width="340" height="20"/>
+				<reportElement key="staticText-1" x="398" y="5" width="340" height="20"/>
 				<textElement textAlignment="Center" verticalAlignment="Top" markup="none">
 					<font fontName="Serif" size="14"/>
@@ -89,9 +91,16 @@
 			</image>
 			<textField>
-				<reportElement x="398" y="34" width="340" height="15" isPrintWhenDetailOverflows="true"/>
+				<reportElement x="398" y="25" width="340" height="15" isPrintWhenDetailOverflows="true"/>
 				<textElement textAlignment="Center">
 					<font fontName="Serif" size="10"/>
 				</textElement>
 				<textFieldExpression class="java.lang.String"><![CDATA["Site: "+$F{site}.name+", "+"Section: "+$F{section}.name]]></textFieldExpression>
+			</textField>
+			<textField pattern="dd-MMM-yyyy" isBlankWhenNull="true">
+				<reportElement x="398" y="40" width="340" height="12"/>
+				<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
+					<font fontName="Serif" size="8"/>
+				</textElement>
+				<textFieldExpression class="java.lang.String"><![CDATA[$P{startDateString}+" to "+$P{endDateString}]]></textFieldExpression>
 			</textField>
 		</band>
@@ -324,5 +333,5 @@
 									<font fontName="Serif" size="8" isBold="false"/>
 								</textElement>
-								<text><![CDATA[Regulatory Requirement (Y/N)]]></text>
+								<text><![CDATA[Regulatory Requirement]]></text>
 							</staticText>
 						</jr:columnHeader>
@@ -344,5 +353,5 @@
 									<font fontName="Serif" size="8" isBold="false"/>
 								</textElement>
-								<text><![CDATA[Maintenance % Completion]]></text>
+								<text><![CDATA[Regulatory Task Complete]]></text>
 							</staticText>
 						</jr:columnHeader>
@@ -353,5 +362,5 @@
 									<font fontName="Serif" size="8"/>
 								</textElement>
-								<textFieldExpression class="java.lang.String"><![CDATA[$F{Maintenance % Completion}]]></textFieldExpression>
+								<textFieldExpression class="java.lang.String"><![CDATA[$F{Regulatory Task Completion}]]></textFieldExpression>
 							</textField>
 						</jr:detailCell>
