← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2427: Added Struts result for Grid for PDF format. Applied to distribution report.

 

------------------------------------------------------------
revno: 2427
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2010-12-26 19:47:16 +0100
message:
  Added Struts result for Grid for PDF format. Applied to distribution report.
added:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionOptionsAction.java
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.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/javascript/orgUnitDistribution.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.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-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2010-12-25 16:43:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2010-12-26 18:47:16 +0000
@@ -92,11 +92,11 @@
                 
         Grid grid = getOrganisationUnitDistribution( groupSet, organisationUnit, true );
         
-        Assert.isTrue( grid != null && grid.getHeight() == 2 );
+        Assert.isTrue( grid != null && grid.getHeight() == 1 );
         
         for ( int i = 1; i < grid.getWidth(); i++ ) // Skip name column
         {
-            categoryValues.put( grid.getRow( 0 ).get( i ), Double.valueOf( grid.getRow( 1 ).get( i ) ) );
+            categoryValues.put( grid.getHeaders().get( i ), Double.valueOf( grid.getRow( 0 ).get( i ) ) );
         }
         
         String title = groupSet.getName() + TITLE_SEP + organisationUnit.getName();

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	2010-12-26 18:47:16 +0000
@@ -0,0 +1,127 @@
+package org.hisp.dhis.result;
+
+/*
+ * Copyright (c) 2004-2010, 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.io.OutputStream;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.system.util.CodecUtils;
+import org.hisp.dhis.util.ContextUtils;
+
+import com.lowagie.text.Document;
+import com.lowagie.text.pdf.PdfPTable;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.Result;
+
+import static org.hisp.dhis.system.util.PDFUtils.*;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GridPdfResult
+    implements Result
+{
+    private static final String DEFAULT_FILENAME = "Grid.pdf";
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Grid grid;
+    
+    public void setGrid( Grid grid )
+    {
+        this.grid = grid;
+    }
+
+    // -------------------------------------------------------------------------
+    // Result implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public void execute( ActionInvocation invocation )
+        throws Exception
+    {
+        // ---------------------------------------------------------------------
+        // Get grid
+        // ---------------------------------------------------------------------
+
+        Grid _grid = (Grid) invocation.getStack().findValue( "grid" );
+        
+        grid = _grid != null ? _grid : grid; 
+
+        // ---------------------------------------------------------------------
+        // Configure response
+        // ---------------------------------------------------------------------
+
+        HttpServletResponse response = ServletActionContext.getResponse();
+
+        OutputStream out = response.getOutputStream();
+
+        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf";
+        
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename );
+
+        // ---------------------------------------------------------------------
+        // Write PDF to output stream
+        // ---------------------------------------------------------------------
+        
+        Document document = openDocument( out );
+        
+        PdfPTable table = new PdfPTable( grid.getWidth() );
+        
+        table.setHeaderRows( 1 );
+
+        table.addCell( getHeader2Cell( grid.getTitle(), grid.getWidth() ) );
+        table.addCell( getCell( grid.getWidth(), 8 ) );
+        
+        for ( String header : grid.getHeaders() )
+        {
+            table.addCell( getItalicCell( header, 1 ) );
+        }
+
+        table.addCell( getCell( grid.getWidth(), 8 ) );
+        
+        for ( List<String> row : grid.getRows() )
+        {
+            for ( String col : row )
+            {
+                table.addCell( getTextCell( col ) );
+            }
+        }
+
+        addTableToDocument( document, table );
+
+        closeDocument( document );
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2010-12-26 18:47:16 +0000
@@ -35,6 +35,8 @@
 				class="org.hisp.dhis.result.GridCsvResult" />
 			<result-type name="gridXlsResult"
 				class="org.hisp.dhis.result.GridXlsResult" />
+			<result-type name="gridPdfResult"
+				class="org.hisp.dhis.result.GridPdfResult" />
 		</result-types>
 
 		<interceptors>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java	2010-12-25 14:36:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionAction.java	2010-12-26 18:47:16 +0000
@@ -27,18 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
 import org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService;
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
 
@@ -50,10 +45,10 @@
 public class GetOrgUnitDistributionAction
     implements Action
 {
-    private static final Comparator<OrganisationUnitGroupSet> GROUPSET_COMPARATOR = new OrganisationUnitGroupSetNameComparator();
-    
     private static final Log log = LogFactory.getLog( GetOrgUnitDistributionAction.class );
     
+    private static final String DEFAULT_TYPE = "html";
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -89,25 +84,18 @@
     {
         this.groupSetId = groupSetId;
     }
+    
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
 
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
 
-    private List<OrganisationUnitGroupSet> groupSets;
-    
-    public List<OrganisationUnitGroupSet> getGroupSets()
-    {
-        return groupSets;
-    }
-    
-    private OrganisationUnitGroupSet selectedGroupSet;
-    
-    public OrganisationUnitGroupSet getSelectedGroupSet()
-    {
-        return selectedGroupSet;
-    }
-
     private Grid grid;
     
     public Grid getGrid()
@@ -121,21 +109,19 @@
 
     public String execute()
     {
-        groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
-        
-        Collections.sort( groupSets, GROUPSET_COMPARATOR );        
-        
-        OrganisationUnit selectedOrganisationUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
+        type = StringUtils.defaultIfEmpty( type, DEFAULT_TYPE );
+        
+        OrganisationUnit unit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
         
         if ( groupSetId != null && groupSetId > 0 )
         {
-            selectedGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( groupSetId );
+            OrganisationUnitGroupSet groupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( groupSetId );
             
-            log.info( "Get distribution for group set: " + selectedGroupSet + " and organisation unit: " + selectedOrganisationUnit );
+            log.info( "Get distribution for group set: " + groupSet + " and organisation unit: " + unit );
         
-            grid = distributionService.getOrganisationUnitDistribution( selectedGroupSet, selectedOrganisationUnit, false );
+            grid = distributionService.getOrganisationUnitDistribution( groupSet, unit, false );
         }
         
-        return SUCCESS;
+        return type;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionOptionsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/orgunitdistribution/action/GetOrgUnitDistributionOptionsAction.java	2010-12-26 18:47:16 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.reporting.orgunitdistribution.action;
+
+/*
+ * Copyright (c) 2004-2009, 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.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetOrgUnitDistributionOptionsAction
+    implements Action
+{
+    private static final Comparator<OrganisationUnitGroupSet> GROUPSET_COMPARATOR = new OrganisationUnitGroupSetNameComparator();
+    
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitGroupService organisationUnitGroupService;
+    
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<OrganisationUnitGroupSet> groupSets;
+    
+    public List<OrganisationUnitGroupSet> getGroupSets()
+    {
+        return groupSets;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
+        
+        Collections.sort( groupSets, GROUPSET_COMPARATOR );        
+        
+        return SUCCESS;
+    }
+}

=== 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	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-12-26 18:47:16 +0000
@@ -505,4 +505,12 @@
     <property name="selectionTreeManager"
       ref="org.hisp.dhis.oust.manager.SelectionTreeManager"/>
   </bean>
+  
+  <bean id="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionOptionsAction"
+  	class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionOptionsAction"
+  	scope="prototype">
+    <property name="organisationUnitGroupService"
+      ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+  </bean>
+  
 </beans>

=== 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	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2010-12-26 18:47:16 +0000
@@ -294,11 +294,15 @@
 category_y_available_periods = Value (Y) - Available periods
 get_current_design = Get current design
 distribution_report = Distribution Report
+please_select_org_unit = Please select organisation unit
+please_select_group_set = Please select group set
 select_group_set = Select group set
 orgunit_distribution = Organisation unit distribution report
 get_report = Get report
 get_chart = Get chart
 group_set = Group set
+select_org_unit = Select organisation unit
 get_report = Get report
 get_report_as_xls = Download as Excel
-get_report_as_csv = Download as CSV
\ No newline at end of file
+get_report_as_csv = Download as CSV
+get_report_as_pdf = Download as PDF
\ 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	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-12-26 18:47:16 +0000
@@ -390,7 +390,14 @@
         
     <!-- Organisation Unit Distribution -->
   
-    <action name="displayOrgUnitDistribution" class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction">
+    <action name="getOrgUnitDistribution" class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionAction">      
+      <result name="csv" type="gridCsvResult"/>
+      <result name="xls" type="gridXlsResult"/>
+      <result name="pdf" type="gridPdfResult"/>
+      <result name="html" type="velocity">/dhis-web-commons/ajax/htmlGrid.vm</result>
+    </action>    
+  
+    <action name="displayOrgUnitDistribution" class="org.hisp.dhis.reporting.orgunitdistribution.action.GetOrgUnitDistributionOptionsAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-reporting/viewOrgUnitDistribution.vm</param>
       <param name="menu">/dhis-web-reporting/menu.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js	2010-12-14 11:36:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js	2010-12-26 18:47:16 +0000
@@ -1,9 +1,63 @@
 
+var selectedOrganisationUnit = null;
+
+function organisationUnitSelected( units ) {
+	if ( units && units[0] ) {	
+		selectedOrganisationUnit = units[0];
+	}
+	else {
+		selectedOrganisationUnit = null;
+	}
+}
+
+function displayOrgUnitDistribution() {
+	alert(selectedOrganisationUnit);
+	if ( inputInvalid() ) {
+		return false;
+	}
+	
+	$( "#chartDiv" ).hide();
+	$( "#tableDiv" ).show();	
+	var groupSetId = $( "#groupSetId" ).val();
+	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=html";
+	$( "#tableDiv" ).load( url, pageInit );
+}
+
+function getOrgUnitDistribution( type ) {	
+	if ( inputInvalid() ) {
+		return false;
+	}
+	
+	var groupSetId = $( "#groupSetId" ).val();
+	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=" + type;
+	window.location.href = url;
+}
+
 function displayOrgUnitDistributionChart() {
+	if ( inputInvalid() ) {
+		return false;
+	}
+	
+	$( "#tableDiv" ).hide();
 	$( "#chartDiv" ).show();
-	$( "#tableDiv" ).hide();
 	var groupSetId = $( "#groupSetId" ).val();
 	var random = getRandomNumber();
 	var source = "getOrgUnitDistributionChart.action?groupSetId=" + groupSetId + "&r=" + random;
 	$( "#chartImg" ).attr( "src", source );
 }
+
+function inputInvalid() {
+	var groupSetId = $( "#groupSetId" ).val();
+	
+	if ( groupSetId == null || groupSetId == 0 ) {
+		setHeaderDelayMessage( i18n_select_group_set );
+		return true;
+	}
+	
+	if ( selectedOrganisationUnit == null || selectedOrganisationUnit == "" ) {
+		setHeaderDelayMessage( i18n_select_org_unit );
+		return true;
+	}
+	
+	return false;
+}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm	2010-12-25 14:36:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm	2010-12-26 18:47:16 +0000
@@ -3,74 +3,50 @@
 
 <!-- Criteria -->
 
-<form action="displayOrgUnitDistribution.action" method="get">
-
 <table>
 
-<tr><th>$i18n.getString( "criteria" )</th></tr>
-
-<tr>
-<td><div id="selectionTree" style="width:325px; height:200px"></div></td>
-</tr>
-
-<tr>
-<td><select id="groupSetId" name="groupSetId" style="width:325px">
+<tr><th>$i18n.getString( "select_org_unit" )</th></tr>
+
+<tr>
+<td>
+<div id="selectionTree" style="width:325px; height:200px"></div>
+</td>
+
+<td valign="bottom">
+<select id="groupSetId" name="groupSetId" style="width:281px">
 <option value="0">[ $i18n.getString( "select_group_set" ) ]</option>
 #foreach( $groupSet in $groupSets )
 <option value="$groupSet.id"
 #if( $selectedGroupSet.id && $groupSet.id == $selectedGroupSet.id ) selected="selected"#end
 >$!encoder.htmlEncode( $groupSet.name )</option>
 #end
-</select></td>
-</tr>
-
-<tr>
-<td><input type="submit" value="$i18n.getString( 'get_report' )" style="width:100px">
-<input type="button" value="$i18n.getString( 'get_chart' )" style="width:100px" onclick="displayOrgUnitDistributionChart()"></td>
-</tr>
-
-<tr><td style="height:15px"></td></tr>
+</select><br><br>
+
+<input type="button" value="$i18n.getString( 'get_report' )" style="width:140px" onclick="displayOrgUnitDistribution( 'html' )">
+<input type="button" value="$i18n.getString( 'get_chart' )" style="width:140px" onclick="displayOrgUnitDistributionChart()"><br><br>
+
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" style="width:140px" onclick="getOrgUnitDistribution( 'xls' )">
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" style="width:140px" onclick="getOrgUnitDistribution( 'csv' )"><br>
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" style="width:140px" onclick="getOrgUnitDistribution( 'pdf' )">
+</td>
+</tr>
+
+<tr><td style="height:10px"></td></tr>
 
 </table>
 
-</form>
-
 <script type="text/javascript">
+selectionTreeSelection.setListenerFunction( organisationUnitSelected );
 selectionTreeSelection.setMultipleSelectionAllowed( false );
-selectionTree.buildSelectionTree();	
+selectionTree.buildSelectionTree();
+
+var i18n_select_group_set = '$encoder.jsEscape( $i18n.getString( "please_select_group_set" ) , "'")';
+var i18n_select_org_unit = '$encoder.jsEscape( $i18n.getString( "please_select_org_unit" ) , "'")';
 </script>
 
 <!-- Table -->
 
-#if( $grid )
-
-<div id="tableDiv">
-
-<table class="listTable gridTable">
-
-<thead>
-<tr>
-#foreach( $header in $grid.getHeaders() )
-<th>$!encoder.htmlEncode( $header )</th>
-#end
-</tr>
-</thead>
-
-<tbody>
-#foreach( $row in $grid.getRows() )
-<tr>
-#foreach( $col in $row )
-<td #if( $velocityCount == 1 )style="text-align:left"#end>$!encoder.htmlEncode( $col )</td>
-#end
-</tr>
-#end
-</tbody>
-
-</table>
-
-</div>
-
-#end
+<div id="tableDiv"></div>
 
 <!-- Chart -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2010-12-26 18:47:16 +0000
@@ -17,7 +17,7 @@
 			</table>
 			<table class="listTable" id="listTable">
 				<col>
-				<col width="165">				
+				<col width="140">				
                 <thead>		       
 				<tr>
 					<th>$i18n.getString( "name" )</th>