← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9612: Impl support for HTML/javascript based standard reports. Lets you upload HTML/javascript document...

 

------------------------------------------------------------
revno: 9612
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-01-25 17:24:37 +0200
message:
  Impl support for HTML/javascript based standard reports. Lets you upload HTML/javascript documents which will be renedered as standard reports. Gives access to relative periods and report params as usual. The idea is that data can be retrieved using javascript/ajax from the web api, in particular the new analytics resource. Requires a bit of development skills but allows for complex and tailored reports.
added:
  dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm
renamed:
  dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml => dhis-2/dhis-support/dhis-support-system/src/main/resources/jasper-report-template.jrxml
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/print.css
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2012-09-24 12:52:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2013-01-25 15:24:37 +0000
@@ -27,11 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -41,6 +36,12 @@
 import org.hisp.dhis.reporttable.ReportParams;
 import org.hisp.dhis.reporttable.ReportTable;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 /**
  * @author Lars Helge Overland
  */
@@ -51,7 +52,13 @@
     private static final long serialVersionUID = 7880117720157807526L;
 
     public static final String TEMPLATE_DIR = "templates";
+    
+    public static final String TYPE_JASPER_REPORT_TABLE = "jasperReportTable";
+    public static final String TYPE_JASPER_JDBC = "jasperJdbc";
+    public static final String TYPE_HTML = "html";
 
+    private String type;
+    
     private String designContent;
 
     private ReportTable reportTable;
@@ -70,14 +77,14 @@
     {
     }
 
-    public Report( String name, String designContent, ReportTable reportTable )
+    public Report( String name, String type, String designContent, ReportTable reportTable )
     {
         this.name = name;
         this.designContent = designContent;
         this.reportTable = reportTable;
     }
     
-    public Report( String name, String designContent, RelativePeriods relatives, ReportParams reportParams )
+    public Report( String name, String type, String designContent, RelativePeriods relatives, ReportParams reportParams )
     {
         this.name = name;
         this.designContent = designContent;
@@ -89,16 +96,21 @@
     // Logic
     // -------------------------------------------------------------------------
 
-    public boolean isReportTableDataSource()
-    {
-        return reportTable != null;
-    }
-    
-    public boolean isJdbcDataSource()
-    {
-        return reportTable == null;
-    }
-    
+    public boolean isTypeReportTable()
+    {
+        return type != null && TYPE_JASPER_REPORT_TABLE.equals( type );
+    }
+    
+    public boolean isTypeJdbc()
+    {
+        return type != null && TYPE_JASPER_JDBC.equals( type );
+    }
+    
+    public boolean isTypeHtml()
+    {
+        return type != null && TYPE_HTML.equals( type );
+    }
+        
     public boolean hasReportTable()
     {
         return reportTable != null;
@@ -171,6 +183,19 @@
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getDesignContent()
     {
         return designContent;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-01-22 15:07:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-01-25 15:24:37 +0000
@@ -478,6 +478,9 @@
         executeSql( "ALTER TABLE dataset ALTER COLUMN shortname TYPE character varying(50)" );
         executeSql( "ALTER TABLE organisationunit ALTER COLUMN shortname TYPE character varying(50)" );
 
+        executeSql( "update report set type='jasperReportTable' where type is null and reporttableid is not null" );
+        executeSql( "update report set type='jasperJdbc' where type is null and reporttableid is null" );
+        
         // upgrade authorities
 
         executeSql( "UPDATE userroleauthorities SET authority='F_DOCUMENT_PUBLIC_ADD' WHERE authority='F_DOCUMENT_ADD'" );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2013-01-17 15:31:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2013-01-25 15:24:37 +0000
@@ -15,6 +15,8 @@
     </id>
     &identifiableProperties;
 
+    <property name="type" />
+
     <property name="designContent" type="text" />
 
     <many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java	2012-11-20 17:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java	2013-01-25 15:24:37 +0000
@@ -30,6 +30,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.hisp.dhis.report.Report.TYPE_JASPER_REPORT_TABLE;
 
 import org.hibernate.NonUniqueObjectException;
 import org.hisp.dhis.DhisSpringTest;
@@ -73,7 +74,7 @@
         userA = createUser( 'A' );
         userService.addUser( userA );
         
-        reportA = new Report( "ReportA", "DesignA", new ReportTable() );
+        reportA = new Report( "ReportA", TYPE_JASPER_REPORT_TABLE, "DesignA", new ReportTable() );
         reportService.saveReport( reportA );
         
         contentA = new DashboardContent();

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java	2012-11-20 17:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java	2013-01-25 15:24:37 +0000
@@ -31,6 +31,7 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.hisp.dhis.report.Report.TYPE_JASPER_REPORT_TABLE;
 
 import java.util.Collection;
 
@@ -77,8 +78,8 @@
     @Test
     public void testSaveGet()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
-        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
+        Report reportA = new Report( "ReportA", TYPE_JASPER_REPORT_TABLE, "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", TYPE_JASPER_REPORT_TABLE, "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -90,8 +91,8 @@
     @Test
     public void testSaveGetUpdate()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
-        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
+        Report reportA = new Report( "ReportA", TYPE_JASPER_REPORT_TABLE, "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", TYPE_JASPER_REPORT_TABLE, "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -115,8 +116,8 @@
     @Test
     public void testDelete()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
-        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
+        Report reportA = new Report( "ReportA", TYPE_JASPER_REPORT_TABLE, "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", TYPE_JASPER_REPORT_TABLE, "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -138,8 +139,8 @@
     @Test
     public void testGetAll()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
-        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
+        Report reportA = new Report( "ReportA", TYPE_JASPER_REPORT_TABLE, "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", TYPE_JASPER_REPORT_TABLE, "DesignB", reportTableA );
         
         reportStore.save( reportA );
         reportStore.save( reportB );

=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-01-25 15:24:37 +0000
@@ -0,0 +1,64 @@
+<style type="text/css" media="screen">
+
+/* Put your CSS styling here */
+
+</style>
+
+<script type="text/javascript">
+
+// Put your javscript here
+
+</script>
+
+<div>
+
+<!-- Put your HTML mark-up here -->
+
+</div>
+
+<!-- Remove text after this point after reading it -->
+
+<h3>This is a template for HTML/javascript based reports</h3>
+
+<p>You have the jQuery javascript library at your disposal when writing reports. It can be accessed with the usual jQuery or $ symbols.</p>
+
+<p>
+You can embed javascript through the usual &lt;script type="text/javascript"&gt;&lt;script&gt; tag.
+You can embed CSS styling through the usual &lt;style type="text/css"&gt;&lt;style&gt; tag.
+You should not include &lt;html&gt;, &lt;body&gt; or &lt;head&gt; tags in your report.
+</p>
+
+<p>
+You can utilize the DHIS 2 Web API to render meta-data and data in your report. 
+The Web API can be accessed from ../api. For instance, to retrieve the first page
+of data elements in JSON format you can link to ../api/dataElements.json . To 
+get access to aggregate data you can utilize the analytics controller at
+../api/analytics.</p>
+
+<p>
+HTML-based standard reports can use relative periods and report parameters in
+the same way as other standard reports. If you select relative periods or report
+parameters for period and organisation unit, you can access the resulting periods
+and organisation unit in the dhis2.report javascript namespace like below. 
+</p>
+
+<div style="font-family:courier,sans-serif; padding:20px; border: 1px solid #ddd;">
+var organisationUnit = dhis2.report.organisationUnit; // An object<br><br>
+
+var name = organisationUnit.name;<br>
+var shortName = organisationUnit.shortName;<br>
+var code = organisationUnit.code;<br><br>
+
+var periods = dhis2.report.periods; // An array with period identifiers
+</div> 
+
+<p>
+Right-click and view page source to see the structure of this template. You can upload 
+your HTML report through the "add new report" screen in DHIS 2 under "design file".
+</p>
+
+<p>
+jQuery documentation can be found <a href="http://docs.jquery.com/";>here</a>.
+DHIS 2 Web API documentation can be found  
+<a href="http://dhis2.org/doc/snapshot/en/user/html/ch23.html";>here</a>.
+</p>
\ No newline at end of file

=== renamed file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml' => 'dhis-2/dhis-support/dhis-support-system/src/main/resources/jasper-report-template.jrxml'
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/print.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/print.css	2013-01-24 16:40:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/print.css	2013-01-25 15:24:37 +0000
@@ -4,7 +4,7 @@
   -webkit-print-color-adjust: exact;
 }
 
-div#header, div#headerMessage, div#leftBar, div#headerMessage, div#rightBar
+div#header, div#headerMessage, div#leftBar, div#headerMessage, div#rightBar, .hideInPrint
 {
   display: none;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2013-01-16 10:31:12 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2013-01-25 15:24:37 +0000
@@ -30,7 +30,6 @@
 import com.opensymphony.xwork2.Action;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.AccessStringHelper;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
 import org.hisp.dhis.external.location.LocationManager;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2012-11-07 13:38:42 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2013-01-25 15:24:37 +0000
@@ -95,6 +95,13 @@
     {
         this.name = name;
     }
+    
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
 
     private Integer reportTableId;
     
@@ -199,6 +206,7 @@
         ReportParams reportParams = new ReportParams( paramReportingMonth, false, false, paramOrganisationUnit );
         
         report.setName( name );
+        report.setType( type );
         report.setReportTable( reportTable );
         report.setUsingOrgUnitGroupSets( usingOrgUnitGroupSets );
         report.setRelatives( getRelativePeriods() );

=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	2013-01-25 15:24:37 +0000
@@ -0,0 +1,137 @@
+package org.hisp.dhis.reporting.reportviewer.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Date;
+import java.util.List;
+
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.report.Report;
+import org.hisp.dhis.report.ReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetReportAndParamsAction
+    implements Action
+{
+    @Autowired
+    private ReportService reportService;
+    
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String uid;
+
+    public void setUid( String uid )
+    {
+        this.uid = uid;
+    }
+
+    private String pe;
+
+    public void setPe( String pe )
+    {
+        this.pe = pe;
+    }
+
+    private String ou;
+
+    public void setOu( String ou )
+    {
+        this.ou = ou;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Report report;
+    
+    public Report getReport()
+    {
+        return report;
+    }
+    
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+
+    private List<Period> periods;
+    
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        report = reportService.getReport( uid );
+        
+        if ( ou != null )
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+        }
+        
+        Date date = new Date();
+        
+        if ( pe != null )
+        {
+            date = PeriodType.getPeriodFromIsoString( pe ).getStartDate();
+        }
+        
+        if ( report != null && report.hasRelativePeriods() )
+        {
+            periods = report.getRelatives().getRelativePeriods( date, format, true );
+        }
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java	2012-10-01 10:50:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java	2013-01-25 15:24:37 +0000
@@ -2,6 +2,8 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -15,7 +17,18 @@
 public class GetReportTemplateAction
     implements Action
 {
-    private static final String TEMPLATE = "template.jrxml";
+    private static final String TEMPLATE_JASPER = "jasper-report-template.jrxml";
+    private static final String TEMPLATE_HTML = "html-report-template.html";
+    
+    private static final String TYPE_JASPER = "jasper";
+    private static final String TYPE_HTML = "html";
+    
+    private String type;
+        
+    public void setType( String type )
+    {
+        this.type = type;
+    }
 
     @Override
     public String execute()
@@ -23,10 +36,24 @@
     {
         HttpServletResponse response = ServletActionContext.getResponse();
 
-        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, false, TEMPLATE, true );
-        
-        StreamUtils.streamcopy( new BufferedInputStream( new ClassPathResource( TEMPLATE ).getInputStream() ), 
-            new BufferedOutputStream( response.getOutputStream() ) );
+        Map<String, String> typeTemplateMap = new HashMap<String, String>();
+        typeTemplateMap.put( TYPE_JASPER, TEMPLATE_JASPER );
+        typeTemplateMap.put( TYPE_HTML, TEMPLATE_HTML );
+        
+        Map<String, String> typeContentTypeMap = new HashMap<String, String>();
+        typeContentTypeMap.put( TYPE_JASPER, ContextUtils.CONTENT_TYPE_XML );
+        typeContentTypeMap.put( TYPE_HTML, ContextUtils.CONTENT_TYPE_HTML );
+        
+        if ( type != null & typeTemplateMap.containsKey( type ) )
+        {
+            String template = typeTemplateMap.get( type );
+            String contentType = typeContentTypeMap.get( type );
+            
+            ContextUtils.configureResponse( response, contentType, false, template, true );
+            
+            StreamUtils.streamcopy( new BufferedInputStream( new ClassPathResource( template ).getInputStream() ), 
+                new BufferedOutputStream( response.getOutputStream() ) );
+        }
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2012-09-24 05:42:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2013-01-25 15:24:37 +0000
@@ -105,7 +105,19 @@
     {
         this.mode = mode;
     }
-        
+    
+    private String type;
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -151,12 +163,12 @@
         {
             Report report = reportService.getReport( uid );
             
-            if ( report != null && report.isReportTableDataSource() )
+            if ( report != null && report.isTypeReportTable() )
             {
                 reportParams = report.getReportTable().getReportParams();                
                 relatives = report.getReportTable().getRelatives();
             }
-            else if ( report != null && report.isJdbcDataSource() )
+            else if ( report != null && ( report.isTypeJdbc() || report.isTypeHtml() ) )
             {
                 reportParams = report.getReportParams();                
                 relatives = report.getRelatives();

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-01-25 15:24:37 +0000
@@ -173,6 +173,10 @@
 	scope="prototype">
     <property name="reportService" ref="org.hisp.dhis.report.ReportService" />
   </bean>
+  
+  <bean id="org.hisp.dhis.reporting.reportviewer.action.GetReportAndParamsAction" class="org.hisp.dhis.reporting.reportviewer.action.GetReportAndParamsAction"
+    scope="prototype">
+  </bean>
 
   <!-- PivotTable -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2013-01-09 14:10:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2013-01-25 15:24:37 +0000
@@ -229,3 +229,9 @@
 percent_on_time=Percent On Time
 view_all=View all
 write_your_interpretation_of_report=Write a comment, question or interpretation of this report
+jasper_report_report_table_data_source=Jasper report with report table data source
+jasper_report_jdbc_data_source=Jasper report with JDBC data source
+html_report=HTML report
+design_file=Design file
+get_jasper_report_template=Get Jasper report template
+get_html_report_template=Get HTML report template
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2013-01-17 15:00:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2013-01-25 15:24:37 +0000
@@ -122,6 +122,12 @@
     <action name="getReportTemplate" class="org.hisp.dhis.reporting.reportviewer.action.GetReportTemplateAction">
       <result name="success" type="outputStreamResult" />
     </action>
+    
+    <action name="generateHtmlReport" class="org.hisp.dhis.reporting.reportviewer.action.GetReportAndParamsAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-reporting/renderHtmlReport.vm</param>
+      <param name="hideMenu">true</param>
+    </action>
 
     <!-- ReportTable -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm	2012-10-17 18:53:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm	2013-01-25 15:24:37 +0000
@@ -1,5 +1,8 @@
 <script type="text/javascript">
 	var i18n_please_specify_file = '$encoder.jsEscape( $i18n.getString( "please_specify_file" ) , "'")';
+	jQuery( document ).ready( function() {
+        setReportType();
+	} );
 </script>
 
 <h3>$i18n.getString( 'create_new_report' )</h3>
@@ -17,23 +20,44 @@
     </tr>
     <tr>
         <td><label for="name">$i18n.getString( "name" )</label></td>
-        <td><input type="text" id="name" name="name" value="$!report.name"></td>
+        <td><input type="text" id="name" name="name" value="$!{report.name}"></td>
+    </tr>
+    <tr>
+    	<td><label for="type">$i18n.getString( "type" )</label></td>
+    	<td>
+    		<select id="type" name="type" onchange="setReportType()">
+    			<option value="jasperReportTable"#if( ${report.type} == "jasperReportTable" ) selected="selected"#end>$i18n.getString( "jasper_report_report_table_data_source" )</option>
+    			<option value="jasperJdbc"#if( ${report.type} == "jasperJdbc" ) selected="selected"#end>$i18n.getString( "jasper_report_jdbc_data_source" )</option>
+    			<option value="html"#if( ${report.type} == "html" ) selected="selected"#end>$i18n.getString( "html_report" )</option>
+		    </select>
+	    </td>
     </tr>
 	<tr>
-		<td><label for="upload">$i18n.getString( "jasper_design" )</label></td>
+		<td><label for="upload">$i18n.getString( "design_file" )</label></td>
 		<td><input type="file" id="upload" name="upload" size="30" /></td>
 	</tr>
+	#if( $report )
 	<tr>
 		<td></td>
-		<td>
-		#if( $report )
+		<td>		
 			<input type="button" value="$i18n.getString( 'get_current_design' )" onclick="window.location.href='getReportDesign.action?id=${report.id}'">
-		#else
-		    <input type="button" value="$i18n.getString( 'get_report_template' )" onclick="window.location.href='getReportTemplate.action'">
-		#end
-		</td>
-	</tr>
-    <tr>
+		</td>
+	</tr>
+	#else
+	<tr class="jasperReportTableDataSource jasperJdbcDataSource">
+		<td></td>
+		<td>
+			<input type="button" value="$i18n.getString( 'get_jasper_report_template' )" onclick="window.location.href='getReportTemplate.action?type=jasper'">
+		</td>
+	</tr>
+    <tr class="htmlDataSource">
+        <td></td>
+        <td>
+            <input type="button" value="$i18n.getString( 'get_html_report_template' )" onclick="window.location.href='getReportTemplate.action?type=html'">
+        </td>
+    </tr>
+    #end
+    <tr class="jasperReportTableDataSource">
         <td><label for="usingOrgUnitGroupSets">$i18n.getString( "include_organisation_unit_group_sets" )</label></td>
         <td>
             <select id="usingOrgUnitGroupSets" name="usingOrgUnitGroupSets">
@@ -42,14 +66,7 @@
             </select>
         </td>
     </tr>
-    <tr>
-    	<td></td>
-        <td style="height:25px">
-        	<a class="reportTableDataSource" onclick="toggleDataSource()" style="cursor:pointer">Use JDBC data source</a>
-        	<a class="jdbcDataSource" onclick="toggleDataSource()" style="cursor:pointer; display:none">Use report table data source</a>
-        </td>
-    </tr>
-	<tr class="reportTableDataSource">
+	<tr class="jasperReportTableDataSource">
 		<td>$i18n.getString( "report_table" )</td>
 		<td>
 			<select id="reportTableId" name="reportTableId">
@@ -60,19 +77,19 @@
 			</select>
 		</td>
 	</tr>
-	<tr class="jdbcDataSource" style="display:none">
+	<tr class="jasperJdbcDataSource htmlDataSource">
 		<th colspan="2">$i18n.getString( "relative_periods" )</th>
 	</tr>
-	<tr class="jdbcDataSource" style="display:none">
+	<tr class="jasperJdbcDataSource htmlDataSource">
         <td colspan="2">#parse( "/dhis-web-reporting/relativePeriodsInput.vm" )</td>
     </tr>
-    <tr class="jdbcDataSource" style="display:none">
+    <tr class="jasperJdbcDataSource htmlDataSource">
         <td colspan="2" style="height:15px"></td>
     </tr>
-    <tr class="jdbcDataSource" style="display:none">
+    <tr class="jasperJdbcDataSource htmlDataSource">
         <th colspan="2">$i18n.getString( "report_parameters" )</th>
     </tr>
-    <tr class="jdbcDataSource" style="display:none">
+    <tr class="jasperJdbcDataSource htmlDataSource">
         <td colspan="2">
             <label for="paramReportingMonth">$i18n.getString( "reporting_period" )</label>
             <input type="checkbox" id="paramReportingMonth" name="paramReportingMonth" value="true"#if( $report.reportParams.isParamReportingMonth() ) checked#end>&nbsp;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2012-11-06 15:22:51 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2013-01-25 15:24:37 +0000
@@ -5,9 +5,11 @@
 	viewReport( '' );
 	#end
 	
+	#if ( $!reportParams.isOrganisationUnitSet() )
     selectionTree.clearSelectedOrganisationUnits();
 	selectionTreeSelection.setMultipleSelectionAllowed( false );
 	selectionTree.buildSelectionTree();
+	#end
 });
 
 var i18n_process_completed = '$encoder.jsEscape( $i18n.getString( "process_completed" ), "'")';
@@ -16,8 +18,9 @@
 
 <h3>$i18n.getString( "report_table_parameters" )</h3>
 
-<input type="hidden" id="uid" name="uid" value="$!uid" />
-<input type="hidden" id="mode" name="mode" value="$!mode" />
+<input type="hidden" id="uid" name="uid" value="$!{uid}" />
+<input type="hidden" id="mode" name="mode" value="$!{mode}" />
+<input type="hidden" id="type" name="type" value="$!{type}" />
 
 <table>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2012-12-07 18:16:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2013-01-25 15:24:37 +0000
@@ -1,6 +1,8 @@
 var MODE_REPORT = "report";
 var MODE_TABLE = "table";
 
+var TYPE_HTML = "html";
+
 // -----------------------------------------------------------------------------
 // Validation
 // -----------------------------------------------------------------------------
@@ -28,16 +30,24 @@
     {
         return false;
     }
-    
+
+    var uid = $( "#uid" ).val();
     var mode = $( "#mode" ).val();
-    var uid = $( "#uid" ).val();
+    var type = $( "#type" ).val();
 
     setMessage( i18n_process_completed );
 
-    if ( mode == MODE_REPORT )
+    if ( MODE_REPORT == mode )
     {
-    	window.location.href = "../api/reports/" + uid + "/data." + reportType + "?" + getUrlParams();
-    } 
+    	if ( TYPE_HTML == type )
+    	{
+    		window.location.href= "generateHtmlReport.action?uid=" + uid + "&" + getUrlParams();
+    	}
+    	else // JASPER
+    	{
+    		window.location.href = "../api/reports/" + uid + "/data." + reportType + "?" + getUrlParams();
+    	}
+    }
     else // MODE_TABLE
     {
         window.location.href = "exportTable.action?uid=" + uid + "&type=html&" + getUrlParams();

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js	2012-09-23 14:24:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js	2013-01-25 15:24:37 +0000
@@ -35,10 +35,28 @@
     }
 }
 
-function toggleDataSource()
+function setReportType()
 {
-	$( ".reportTableDataSource" ).toggle();
-	$( ".jdbcDataSource" ).toggle();
+	var type = $( "#type :selected" ).val();
+	
+	if ( "jasperReportTable" == type )
+	{
+		$( ".jasperJdbcDataSource" ).hide();
+		$( ".htmlDataSource" ).hide();
+		$( ".jasperReportTableDataSource" ).show();
+	}
+	else if ( "jasperJdbc" == type )
+	{
+		$( ".jasperReportTableDataSource" ).hide();
+		$( ".htmlDataSource" ).hide();
+		$( ".jasperJdbcDataSource" ).show();
+	}
+	else if ( "html" == type )
+	{
+		$( ".jasperReportTableDataSource" ).hide();
+		$( ".jasperJdbcDataSource" ).hide();
+		$( ".htmlDataSource" ).show();
+	}
 }
 
 // -----------------------------------------------------------------------------

=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm	2013-01-25 15:24:37 +0000
@@ -0,0 +1,31 @@
+<script type="text/javascript">
+
+dhis2.util.namespace( 'dhis2.report' );
+
+dhis2.report.organisationUnit = {
+#if ( $organisationUnit )
+    "id": "$!{organisationUnit.uid}",
+    "name": "$!{organisationUnit.name}",
+    "shortName": "$!{organisationUnit.shortName}",
+    "code": "$!{organisationUnit.code}"
+#end
+};
+
+dhis2.report.periods = {
+#if ( $periods )
+#set( $size = $periods.size() )
+#foreach( $period in $periods )
+"$period.getIsoDate()"#if( $velocityCount < $size ),#end
+#end
+#end
+};
+
+</script>
+
+<div style="margin-bottom:16px" class="hideInPrint">
+<input type="button" value="$i18n.getString( 'print' )" onclick="window.print()" id="printButton" style="width:120px"/>
+</div>
+
+<div>
+${report.designContent}
+</div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2013-01-17 15:31:26 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2013-01-25 15:24:37 +0000
@@ -42,7 +42,7 @@
                 <tr id="tr${report.id}">
                     <td>$encoder.htmlEncode( $report.name )</td>
                     <td style="text-align:right">
-                    	<a href="getReportParams.action?uid=${report.uid}&mode=report" title="$i18n.getString( 'create' )">                    	
+                    	<a href="getReportParams.action?uid=${report.uid}&mode=report&type=${report.type}" title="$i18n.getString( 'create' )">                    	
                     	<img src="../images/start_process.png" alt="$i18n.getString( 'create' )"></a>                   
 
                         #if ( $security.canManage( $report ) )