← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6288: Impl support for base line and reporting rates in PNG version of Chart

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 6288 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-03-18 15:00:41 +0100
message:
  Impl support for base line and reporting rates in PNG version of Chart
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java
  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/webapp/dhis-web-reporting/javascript/dataSetReport.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.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/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-03-09 02:29:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-03-18 12:41:41 +0000
@@ -207,6 +207,7 @@
         {
             list.addAll( dataElements );
             list.addAll( indicators );
+            list.addAll( dataSets );
         }
         else if ( DIMENSION_PERIOD.equals( dimension ) )
         {
@@ -298,6 +299,11 @@
         return dataElements != null && dataElements.size() > 0;
     }
     
+    public boolean hasDataSets()
+    {
+        return dataSets != null && dataSets.size() > 0;
+    }
+    
     public boolean isType( String type )
     {
         return this.type != null && this.type.equals( type );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2012-03-05 16:37:17 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2012-03-18 12:15:26 +0000
@@ -459,6 +459,21 @@
     }
 
     /**
+     * Returns a horizontal line marker for the given x value and label.
+     */
+    private Marker getMarker( Double value, String label )
+    {
+        Marker marker = new ValueMarker( value );
+        marker.setPaint( Color.BLACK );
+        marker.setStroke( new BasicStroke( 1.1f ) );
+        marker.setLabel( label );
+        marker.setLabelOffset( new RectangleInsets( -10, 50, 0, 0 ) );
+        marker.setLabelFont( subTitleFont );
+        
+        return marker;
+    }
+
+    /**
      * Returns a JFreeChart of type defined in the chart argument.
      */
     private JFreeChart getJFreeChart( Chart chart, boolean subTitle )
@@ -501,14 +516,12 @@
 
         if ( chart.isTargetLine() )
         {
-            Marker marker = new ValueMarker( chart.getTargetLineValue() );
-            marker.setPaint( Color.BLACK );
-            marker.setStroke( new BasicStroke( 1.1f ) );
-            marker.setLabel( chart.getTargetLineLabel() );
-            marker.setLabelOffset( new RectangleInsets( -10, 40, 0, 0 ) );
-            marker.setLabelFont( subTitleFont );
-
-            plot.addRangeMarker( marker );
+            plot.addRangeMarker( getMarker( chart.getTargetLineValue(), chart.getTargetLineLabel() ) );
+        }
+        
+        if ( chart.isBaseLine() )
+        {
+            plot.addRangeMarker( getMarker( chart.getBaseLineValue(), chart.getBaseLineLabel() ) );
         }
 
         if ( subTitle )
@@ -543,7 +556,7 @@
 
         return jFreeChart;
     }
-
+    
     private JFreeChart getStackedBarChart( Chart chart, CategoryDataset dataSet )
     {
         JFreeChart stackedBarChart = null;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2012-03-05 16:37:17 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2012-03-18 12:41:41 +0000
@@ -259,6 +259,8 @@
             ConversionUtils.getIdentifiers( DataElement.class, chart.getDataElements() ) );
         String indicatorIds = TextUtils.getCommaDelimitedString( 
             ConversionUtils.getIdentifiers( Indicator.class, chart.getIndicators() ) );
+        String dataSetIds = TextUtils.getCommaDelimitedString(
+            ConversionUtils.getIdentifiers( DataSet.class, chart.getDataSets() ) );
         String periodIds = TextUtils.getCommaDelimitedString( 
             ConversionUtils.getIdentifiers( Period.class, chart.getRelativePeriods() ) );
         String unitIds = TextUtils.getCommaDelimitedString( 
@@ -299,6 +301,23 @@
             }
         }
         
+        if ( chart.hasDataSets() )
+        {
+            final String sql = "SELECT datasetid, periodid, organisationunitid, value FROM aggregateddatasetcompleteness " +
+                "WHERE datasetid IN (" + dataSetIds + ") AND periodid IN (" + periodIds + ") AND organisationunitid IN (" + unitIds + ")";
+
+            SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+            
+            while ( rowSet.next() )
+            {
+                String id = getIdentifier( getIdentifier( DataSet.class, rowSet.getInt( 1 ) ),
+                    getIdentifier( Period.class, rowSet.getInt( 2 ) ),
+                    getIdentifier( OrganisationUnit.class, rowSet.getInt( 3 ) ) );
+
+                map.put( id, rowSet.getDouble( 4 ) );
+            }
+        }
+        
         return map;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java	2012-03-16 18:28:34 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java	2012-03-18 12:15:26 +0000
@@ -36,10 +36,17 @@
 import java.util.HashSet;
 
 import org.hisp.dhis.DhisTest;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -61,7 +68,9 @@
     
     private CompleteDataSetRegistrationService registrationService;
     
-    private DataSetCompletenessService completenessService;
+    private DataSetCompletenessService registrationCompletenessService;
+    
+    private DataSetCompletenessService compulsoryCompletenessService;
     
     private PeriodType periodType;
     
@@ -92,6 +101,11 @@
     
     private int dataSetIdA;
     
+    private DataElement dataElementA;
+    private DataElement dataElementB;
+    
+    private DataElementCategoryOptionCombo categoryOptionCombo;
+    
     private Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
 
     private Date onTimeA;
@@ -116,10 +130,20 @@
         
         dataSetService = (DataSetService) getBean( DataSetService.ID );
         
+        dataElementService = (DataElementService) getBean( DataElementService.ID );
+        
+        categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );
+        
+        dataValueService = (DataValueService) getBean( DataValueService.ID );
+        
         registrationService = (CompleteDataSetRegistrationService) getBean( CompleteDataSetRegistrationService.ID );
         
-        completenessService = (DataSetCompletenessService) getBean( "registrationDataCompletenessService" );
+        registrationCompletenessService = (DataSetCompletenessService) getBean( "registrationDataCompletenessService" );
+        
+        compulsoryCompletenessService = (DataSetCompletenessService) getBean( "compulsoryDataCompletenessService" );
 
+        categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        
         periodType = new MonthlyPeriodType();
         
         periodA = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 1, 31 ) );
@@ -175,6 +199,16 @@
         dataSetB = createDataSet( 'B', periodType );
         dataSetC = createDataSet( 'C', periodType );
 
+        dataElementA = createDataElement( 'A' );
+        dataElementB = createDataElement( 'B' );
+        dataElementService.addDataElement( dataElementA );
+        dataElementService.addDataElement( dataElementB );
+        
+        dataSetA.getCompulsoryDataElementOperands().add( new DataElementOperand( dataElementA, categoryOptionCombo ) );
+        dataSetA.getCompulsoryDataElementOperands().add( new DataElementOperand( dataElementB, categoryOptionCombo ) );
+        
+        dataSetB.getCompulsoryDataElementOperands().add( new DataElementOperand( dataElementA, categoryOptionCombo ) );
+        
         onTimeA = getDate( 2000, 2, 10 );
         tooLateA = getDate( 2000, 2, 25 );
         onTimeB = getDate( 2000, 3, 10 );
@@ -203,6 +237,10 @@
         assertEquals( 50.0, resultA.getPercentageOnTime() );
         assertEquals( 0.0, resultB.getPercentageOnTime() );
     }
+    
+    // -------------------------------------------------------------------------
+    // Complete registration based completeness
+    // -------------------------------------------------------------------------
 
     @Test
     public void testGetDataSetCompletenessByDataSetA()
@@ -232,7 +270,7 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitC, tooLateA, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodB, unitA, tooLateB, "" ) );
         
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );        
@@ -240,7 +278,7 @@
         assertTrue( results.contains( new DataSetCompletenessResult( dataSetB.getName(), 2, 1, 0 ) ) );
         assertTrue( results.contains( new DataSetCompletenessResult( dataSetC.getName(), 2, 0, 0 ) ) );  
 
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdA );
    
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -278,7 +316,7 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitA, tooLateA, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitB, onTimeA, "" ) );
         
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );        
@@ -286,7 +324,7 @@
         assertTrue( results.contains( new DataSetCompletenessResult( dataSetB.getName(), 2, 2, 2 ) ) );
         assertTrue( results.contains( new DataSetCompletenessResult( dataSetC.getName(), 2, 1, 1 ) ) );
         
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );        
@@ -318,13 +356,13 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitF, onTimeB, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, tooLateB, "" ) );
 
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdA );
         
         assertNotNull( results );
         assertEquals( 1, results.size() );        
         assertTrue( results.contains( new DataSetCompletenessResult( dataSetA.getName(), 7, 5, 3 ) ) );
 
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdA );
         
         assertNotNull( results );
         assertEquals( 1, results.size() );        
@@ -349,7 +387,7 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitF, onTimeA, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeA, "" ) );
         
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -357,7 +395,7 @@
         assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 2, 1, 0 ) ) );
         assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 4, 3, 0 ) ) );
         
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
 
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -383,7 +421,7 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeB, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitH, onTimeB, "" ) );
 
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -391,7 +429,7 @@
         assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 1, 1, 0 ) ) );
         assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 3, 2, 0 ) ) );
 
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -420,7 +458,7 @@
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeB, "" ) );
         registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitH, tooLateB, "" ) );
 
-        Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
+        Collection<DataSetCompletenessResult> results = registrationCompletenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
 
         assertNotNull( results );
         assertEquals( 3, results.size() );
@@ -428,7 +466,7 @@
         assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 2, 2, 1 ) ) );
         assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 4, 4, 2 ) ) );
         
-        results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+        results = registrationCompletenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
         
         assertNotNull( results );
         assertEquals( 3, results.size() );

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2012-02-16 12:58:37 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2012-03-18 12:15:26 +0000
@@ -84,7 +84,6 @@
         emptyTable( "datavalue" );
         emptyTable( "completedatasetregistration" );
 
-        emptyTable( "reporttable_categoryoptioncombos" );
         emptyTable( "reporttable_dataelements" );
         emptyTable( "reporttable_datasets" );
         emptyTable( "reporttable_indicators" );
@@ -93,12 +92,6 @@
         emptyTable( "reporttable_orgunitgroups" );
         emptyTable( "reporttable" );
 
-        emptyTable( "datamartexportdataelements" );
-        emptyTable( "datamartexportindicators" );
-        emptyTable( "datamartexportorgunits" );
-        emptyTable( "datamartexportperiods" );
-        emptyTable( "datamartexport" );
-
         emptyTable( "orgunitgroupsetmembers" );
         emptyTable( "orgunitgroupset" );
         emptyTable( "orgunitgroupmembers" );
@@ -114,6 +107,8 @@
 
         emptyTable( "datasetsource" );
         emptyTable( "datasetmembers" );
+        emptyTable( "datasetindicators" );
+        emptyTable( "datasetoperands" );
         emptyTable( "dataset" );
 
         emptyTable( "minmaxdataelement" );
@@ -125,6 +120,7 @@
         emptyTable( "dataelementgroupmembers" );
         emptyTable( "dataelementgroup" );
         emptyTable( "dataelementaggregationlevels" );
+        emptyTable( "dataelementoperand" );
         emptyTable( "dataelement" );
         emptyTable( "categoryoptioncombos_categoryoptions" );
         emptyTable( "categorycombos_optioncombos" );
@@ -134,7 +130,6 @@
         emptyTable( "organisationunit" );
         emptyTable( "version" );
         emptyTable( "mocksource" );
-        emptyTable( "source" );
         emptyTable( "period" );
 
         emptyTable( "indicatorgroupsetmembers" );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2012-03-18 14:00:41 +0000
@@ -122,6 +122,11 @@
 
     private boolean selectedUnitOnly;
 
+    public boolean isSelectedUnitOnly()
+    {
+        return selectedUnitOnly;
+    }
+
     public void setSelectedUnitOnly( boolean selectedUnitOnly )
     {
         this.selectedUnitOnly = selectedUnitOnly;
@@ -140,7 +145,7 @@
     {
         this.type = type;
     }
-
+    
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------

=== 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	2012-03-06 17:26:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2012-03-18 14:00:41 +0000
@@ -202,4 +202,5 @@
 start_export=Start export
 period_types=Period types
 include_cumulative=Include cumulative
-include_regression=Include regression
\ No newline at end of file
+include_regression=Include regression
+print=Print
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2012-01-06 04:56:54 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2012-03-18 14:00:41 +0000
@@ -1,12 +1,5 @@
 
 // -----------------------------------------------------------------------------
-// Global variables
-// ----------------------------------------------------------------------------
-
-var selectedOrganisationUnitIds = null;
-var currentParams = null;
-
-// -----------------------------------------------------------------------------
 // Validation
 // ----------------------------------------------------------------------------
 
@@ -39,7 +32,7 @@
         setHeaderMessage( i18n_select_period );
         return false;
     }
-    if ( !selectedOrganisationUnitIds || !selectedOrganisationUnitIds.length )
+    if ( !selectionTreeSelection.isSelected() )
     {
         setHeaderMessage( i18n_select_organisation_unit );
         return false;
@@ -54,7 +47,7 @@
     var periodId = $( "#periodId" ).val();
     var selectedUnitOnly = $( "#selectedUnitOnly" ).is( ":checked" ); 
     
-    currentParams = { dataSetId: dataSetId, periodId: periodId, selectedUnitOnly: selectedUnitOnly };
+    var currentParams = { dataSetId: dataSetId, periodId: periodId, selectedUnitOnly: selectedUnitOnly };
     
     $( '#content' ).load( 'generateDataSetReport.action', currentParams, function() {
     	hideLoader();
@@ -65,16 +58,13 @@
 
 function exportDataSetReport( type )
 {
-	if ( currentParams != null )
-	{
-	    var url = "generateDataSetReport.action?useLast=true" + 
-	    	"&dataSetId=" + currentParams.dataSetId +
-	    	"&periodId=" + currentParams.periodId +
-	    	"&selectedUnitOnly=" + currentParams.selectedUnitOnly +
-	    	"&type=" + type;
+	var url = "generateDataSetReport.action?useLast=true" + 
+		"&dataSetId=" + $( "#dataSetId" ).val() +
+	    "&periodId=" + $( "#periodId" ).val() +
+	    "&selectedUnitOnly=" + $( "#selectedUnitOnly" ).val() +
+	    "&type=" + type;
 	    
-	    window.location.href = url;
-	}
+	window.location.href = url;
 }
 
 function showCriteria()

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm	2011-09-07 12:03:18 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm	2012-03-18 14:00:41 +0000
@@ -1,5 +1,7 @@
 
 <input type="hidden" id="dataSetId" value="${selectedDataSet.id}">
+<input type="hidden" id="periodId" value="${selectedPeriod.externalId}">
+<input type="hidden" id="selectedUnitOnly" value="${selectedUnitOnly}">
 
 <h3>$i18n.getString('reporting_unit'): $encoder.htmlEncode( $selectedOrgunit.name ) &nbsp; $i18n.getString('reporting_period'): $format.formatPeriod( $selectedPeriod )</h3>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm	2012-02-10 17:32:13 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm	2012-03-18 14:00:41 +0000
@@ -1,5 +1,7 @@
 
 <input type="hidden" id="dataSetId" value="${selectedDataSet.id}">
+<input type="hidden" id="periodId" value="${selectedPeriod.externalId}">
+<input type="hidden" id="selectedUnitOnly" value="${selectedUnitOnly}">
 
 <h3>$encoder.htmlEncode( $selectedOrgunit.name ) - $format.formatPeriod( $selectedPeriod )</h3>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm	2012-02-10 17:32:13 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm	2012-03-18 14:00:41 +0000
@@ -8,6 +8,8 @@
 </style>
 
 <input type="hidden" id="dataSetId" value="${selectedDataSet.id}">
+<input type="hidden" id="periodId" value="${selectedPeriod.externalId}">
+<input type="hidden" id="selectedUnitOnly" value="${selectedUnitOnly}">
 
 <h3>$encoder.htmlEncode( $selectedOrgunit.name ) - $format.formatPeriod( $selectedPeriod )</h3>