← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7679: local/in add iReport in CCEM

 

------------------------------------------------------------
revno: 7679
committer: Samta <samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-24 06:31:29 +0100
message:
  local/in add iReport in CCEM
added:
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/DynamicJasperTemplate.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm
modified:
  local/in/dhis-web-coldchain/pom.xml
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java
  local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-coldchain/src/main/resources/struts.xml
  local/in/dhis-web-coldchain/src/main/webapp/WEB-INF/web.xml
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.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 'local/in/dhis-web-coldchain/pom.xml'
--- local/in/dhis-web-coldchain/pom.xml	2012-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/pom.xml	2012-07-24 05:31:29 +0000
@@ -8,7 +8,13 @@
 		<artifactId>dhis-web</artifactId>
 		<version>2.9-SNAPSHOT</version>
 	</parent>
-	
+	<repositories>
+    <repository>
+      <id>fdvsolution.public</id>
+      <url>http://archiva.fdvs.com.ar/repository/public1/</url>
+    </repository>
+ </repositories>
+
 	<artifactId>dhis-web-coldchain</artifactId>
 	<packaging>war</packaging>
 	<name>DHIS Cold Chain</name>
@@ -73,6 +79,13 @@
 			<groupId>net.sourceforge.jexcelapi</groupId>
 			<artifactId>jxl</artifactId>
 		</dependency>
+		
+		<dependency>
+      <groupId>ar.com.fdvs</groupId>
+      <artifactId>DynamicJasper</artifactId>
+      <version>4.0.0</version>
+    </dependency>
+		
 	</dependencies>
 	<properties>
 		<rootDir>../../</rootDir>

=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/DynamicJasperTemplate.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/DynamicJasperTemplate.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/DynamicJasperTemplate.java	2012-07-24 05:31:29 +0000
@@ -0,0 +1,168 @@
+/**
+ * 
+ */
+package org.hisp.dhis.coldchain.reports.action;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import net.sf.jasperreports.engine.JRDataSource;
+import net.sf.jasperreports.engine.JasperExportManager;
+import net.sf.jasperreports.engine.JasperFillManager;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+import net.sf.jasperreports.engine.data.JRMapCollectionDataSource;
+import ar.com.fdvs.dj.core.DynamicJasperHelper;
+import ar.com.fdvs.dj.core.layout.ClassicLayoutManager;
+import ar.com.fdvs.dj.domain.DynamicReport;
+import ar.com.fdvs.dj.domain.Style;
+import ar.com.fdvs.dj.domain.builders.ColumnBuilder;
+import ar.com.fdvs.dj.domain.builders.DynamicReportBuilder;
+import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
+import ar.com.fdvs.dj.domain.constants.Font;
+import ar.com.fdvs.dj.domain.constants.HorizontalAlign;
+import ar.com.fdvs.dj.domain.constants.VerticalAlign;
+import ar.com.fdvs.dj.domain.entities.columns.AbstractColumn;
+
+/**
+ * @author Samta Bajpai
+ * 
+ * @version DynamicJasperTemplate.java Jul 19, 2012 5:41:06 PM
+ */
+public class DynamicJasperTemplate
+{
+
+    protected JasperPrint jp;
+
+    protected JasperReport jr;
+
+    protected Map params = new HashMap();
+
+    protected DynamicReport dr;
+
+    public void buildReport()
+        throws Exception
+    {  
+
+        FastReportBuilder frb = new FastReportBuilder();
+
+        Font font = new Font( 10, "Arial", true );
+
+        Style headerStyle = new Style();
+
+        headerStyle.setFont( font );
+
+        headerStyle.setHorizontalAlign( HorizontalAlign.LEFT );
+
+        headerStyle.setVerticalAlign( VerticalAlign.MIDDLE );
+
+        font = new Font( 8, "Arial", false );
+
+        Style detailStyle = new Style();
+
+        detailStyle.setFont( font );
+
+        detailStyle.setHorizontalAlign( HorizontalAlign.LEFT );
+
+        detailStyle.setVerticalAlign( VerticalAlign.MIDDLE );
+        AbstractColumn column;
+        for ( int i = 1; i <= 10; i++ )
+        {
+            frb.addColumn("Column" + i, "Column" + i, String.class.getName(), 50,true);          
+        }
+        frb.setColumnsPerPage(1, 10).setUseFullPageWidth(true).setColspan(1, 2, "Estimated");
+        //frb.setUseFullPageWidth( true );
+
+        // Pass the JasperReport Template to DynamicJasper
+
+        frb.setTemplateFile( "C:/report1.jrxml" );
+
+        DynamicReport dr = frb.build();
+
+        List records = new ArrayList();
+
+        for ( int i = 1; i < 10; i++ )
+        {
+
+            Map columns = new HashMap();
+
+           for ( int j = 1; j <= 10; j++ )
+            {
+
+                // The HashMap Key must save with ColumnProperty Name
+
+                columns.put( "Column" + j, "Record " + i + " Column " +j + " data." );
+
+            }
+
+            records.add( columns );
+
+        }
+
+        JRDataSource ds = new JRMapCollectionDataSource( records );
+
+        jr = DynamicJasperHelper.generateJasperReport( dr, new ClassicLayoutManager(), params );
+
+        if ( ds != null )
+        {
+
+            jp = JasperFillManager.fillReport( jr, params, ds );
+
+        }
+        else
+        {
+
+            jp = JasperFillManager.fillReport( jr, params );
+
+        }
+
+        JasperExportManager.exportReportToPdfFile( jp, "C:/report-out.pdf" );
+
+    }
+
+    protected JRDataSource getDataSource()
+    {
+
+        // Generate dummy data to show in the report.
+
+        List records = new ArrayList();
+
+        for ( int i = 1; i < 10; i++ )
+        {
+
+            Map columns = new HashMap();
+
+            for ( int j = 1; j <= 10; j++ )
+            {
+
+                // The HashMap Key must save with ColumnProperty Name
+
+                columns.put( "Column" + j, "Record " + i + " Column " + j + " data." );
+
+            }
+
+            records.add( columns );
+
+        }
+
+        JRDataSource ds = new JRMapCollectionDataSource( records );
+
+        return ds;
+
+    }
+
+    public static void main( String[] args )
+        throws Exception
+    {
+
+        DynamicJasperTemplate djt = new DynamicJasperTemplate();
+
+        djt.buildReport();
+
+    }
+
+}

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java	2012-07-21 10:27:27 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java	2012-07-24 05:31:29 +0000
@@ -348,6 +348,7 @@
             ccemReportOutput.setTableHeadings( tableHeadings );
             ccemReportOutput.setReportHeading( ccemReport.getReportName() );
         }
+        
         else if( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
         {
             ccemReportOutput = new CCEMReportOutput();

=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java	2012-07-24 05:31:29 +0000
@@ -0,0 +1,613 @@
+/**
+ * 
+ */
+package org.hisp.dhis.coldchain.reports.action;
+
+import static org.hisp.dhis.reporttable.ReportTable.SPACE;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import net.sf.jasperreports.engine.JRDataSource;
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JRExporter;
+import net.sf.jasperreports.engine.JRExporterParameter;
+import net.sf.jasperreports.engine.JasperCompileManager;
+import net.sf.jasperreports.engine.JasperExportManager;
+import net.sf.jasperreports.engine.JasperFillManager;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+
+import net.sf.jasperreports.engine.data.JRMapCollectionDataSource;
+import net.sf.jasperreports.engine.export.JRCsvExporter;
+import net.sf.jasperreports.engine.export.JRHtmlExporter;
+import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
+import net.sf.jasperreports.engine.export.JRPdfExporter;
+import net.sf.jasperreports.engine.export.JRRtfExporter;
+import net.sf.jasperreports.engine.export.JRXlsExporter;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.coldchain.reports.CCEMReport;
+import org.hisp.dhis.coldchain.reports.CCEMReportDesign;
+import org.hisp.dhis.coldchain.reports.CCEMReportManager;
+import org.hisp.dhis.coldchain.reports.CCEMReportOutput;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.system.grid.ListGrid;
+import org.hisp.dhis.system.util.DateUtils;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import ar.com.fdvs.dj.core.DynamicJasperHelper;
+import ar.com.fdvs.dj.core.layout.ClassicLayoutManager;
+import ar.com.fdvs.dj.domain.DynamicReport;
+import ar.com.fdvs.dj.domain.Style;
+import ar.com.fdvs.dj.domain.builders.ColumnBuilder;
+import ar.com.fdvs.dj.domain.builders.DynamicReportBuilder;
+import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
+import ar.com.fdvs.dj.domain.constants.Border;
+import ar.com.fdvs.dj.domain.constants.Font;
+import ar.com.fdvs.dj.domain.constants.HorizontalAlign;
+import ar.com.fdvs.dj.domain.constants.Transparency;
+import ar.com.fdvs.dj.domain.constants.VerticalAlign;
+import ar.com.fdvs.dj.domain.entities.columns.AbstractColumn;
+
+import com.lowagie.text.pdf.codec.Base64.InputStream;
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Samta Bajpai
+ * 
+ * @version GenerateJRXMLReportAction.java Jun 26, 2012 12:12:17 PM
+ */
+public class GenerateJRXMLReportAction
+    implements Action
+{
+    private static final String DEFAULT_TYPE = "html";
+
+    protected JasperPrint jasperPrint;
+
+    protected JasperReport jr;
+
+    protected Map param = new HashMap();
+
+    protected DynamicReport dr;
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    private CCEMReportManager ccemReportManager;
+
+    public void setCcemReportManager( CCEMReportManager ccemReportManager )
+    {
+        this.ccemReportManager = ccemReportManager;
+    }
+
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String reportList;
+
+    public void setReportList( String reportList )
+    {
+        this.reportList = reportList;
+    }
+
+    private List<Integer> selOrgUnitList;
+
+    public void setSelOrgUnitList( List<Integer> selOrgUnitList )
+    {
+        this.selOrgUnitList = selOrgUnitList;
+    }
+
+    private List<Integer> orgunitGroupList;
+
+    public void setOrgunitGroupList( List<Integer> orgunitGroupList )
+    {
+        this.orgunitGroupList = orgunitGroupList;
+    }
+
+    private CCEMReport ccemReport;
+
+    public CCEMReport getCcemReport()
+    {
+        return ccemReport;
+    }
+
+    private CCEMReportOutput ccemReportOutput;
+
+    public CCEMReportOutput getCcemReportOutput()
+    {
+        return ccemReportOutput;
+    }
+
+    private String periodRadio;
+
+    public void setPeriodRadio( String periodRadio )
+    {
+        this.periodRadio = periodRadio;
+    }
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    private String pe;
+
+    public void setPe( String pe )
+    {
+        this.pe = pe;
+    }
+
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Grid grid;
+
+    public Grid getGrid()
+    {
+        return grid;
+    }
+
+    private Map<String, Object> params = new HashMap<String, Object>();
+
+    public Map<String, Object> getParams()
+    {
+        return params;
+    }
+
+    // -------------------------------------------------------------------------
+    // Result implementation
+    // -------------------------------------------------------------------------
+    private InputStream fileStream;
+
+    public void setFileStream( InputStream arg )
+    {
+        fileStream = arg;
+    }
+
+    public InputStream getFileStream()
+    {
+        return fileStream;
+    }
+
+    private String ReportPath;
+
+    public String getReportPath()
+    {
+        return ReportPath;
+    }
+
+    public void setReportPath( String reportPath )
+    {
+        ReportPath = reportPath;
+    }
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Connection con = jdbcTemplate.getDataSource().getConnection();
+        String fileName = null;
+        String path = System.getenv("DHIS2_HOME") + File.separator + "ireports" + File.separator;
+        
+        
+        HashMap<String, Object> hash = new HashMap<String, Object>();
+
+        String orgUnitIdsByComma = ccemReportManager.getOrgunitIdsByComma( selOrgUnitList, orgunitGroupList );
+        ccemReport = ccemReportManager.getCCEMReportByReportId( reportList );
+        Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
+        List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager
+            .getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
+        
+        
+        String oName = null;
+        String oUnitGrpName = null;
+        oUnitGrpName = organisationUnitGroupService.getOrganisationUnitGroup( orgunitGroupList.get( 0 ) ).getName()
+            + "";
+        for ( int i = 1; i <= orgunitGroupList.size() - 1; i++ )
+        {
+            oUnitGrpName += ","
+                + organisationUnitGroupService.getOrganisationUnitGroup( orgunitGroupList.get( i ) ).getName();
+            System.out.println( "Group is: "
+                + organisationUnitGroupService.getOrganisationUnitGroup( orgunitGroupList.get( i ) ) );
+        }
+        oName = organisationUnitService.getOrganisationUnit( selOrgUnitList.get( 0 ) ).getName() + "";
+        for ( int j = 1; j <= selOrgUnitList.size() - 1; j++ )
+        {
+            oName += "," + organisationUnitService.getOrganisationUnit( selOrgUnitList.get( j ) ).getName();
+            System.out.println( "Group is: "
+                + organisationUnitService.getOrganisationUnit( selOrgUnitList.get( j ) ) );
+        }
+        hash.put( "orgunitGroup", oUnitGrpName );
+        hash.put( "selOrgUnit", oName );
+        hash.put( "orgUnitIdsByComma", orgUnitIdsByComma );
+        HttpServletResponse response = ServletActionContext.getResponse();
+
+        ccemReport = ccemReportManager.getCCEMReportByReportId( reportList );
+        Date date = pe != null ? DateUtils.getMediumDate( pe ) : new Date();
+
+        hash.put( "reportName", ccemReport.getReportName() );
+        hash.put( "date", date );
+        if ( ccemReport.getReportType().equals( CCEMReport.CATALOGTYPE_ATTRIBUTE_VALUE ) )
+        {
+            CCEMReportDesign ccemReportDesign = reportDesignList.get( 0 );
+            String ccemCellContent = ccemSettingsMap.get( ccemReportDesign.getContent() );
+            Integer inventoryTypeId = Integer.parseInt( ccemCellContent.split( ":" )[0] );
+            Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );           
+            hash.put( "inventoryTypeId", inventoryTypeId );
+            hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );            
+            fileName = "Refrigerators_freezer_models_by_agegroup.jrxml";
+            JasperReport jasperReport = JasperCompileManager.compileReport( path + fileName );
+        jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
+        }
+        else if ( ccemReport.getReportType().equals( CCEMReport.CATALOGTYPE_ATTRIBUTE_VALUE_AGE_GROUP.trim() ) )
+
+        {
+            CCEMReportDesign ccemReportDesign = reportDesignList.get( 0 );
+            String ccemCellContent = ccemSettingsMap.get( ccemReportDesign.getContent() );
+            Integer inventoryTypeId = Integer.parseInt( ccemCellContent.split( ":" )[0] );
+            Integer catalogTypeAttributeId = Integer.parseInt( ccemCellContent.split( ":" )[1] );            
+            hash.put( "inventoryTypeId", inventoryTypeId );
+            hash.put( "catalogTypeAttributeId", catalogTypeAttributeId );            
+            int i = 0;
+            Integer inventoryTypeAttributeId=3;
+            for( CCEMReportDesign ccemReportDesign1 :  reportDesignList )
+            {
+                i++;
+                if( i == 1 ) continue;
+                String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+                if( ccemCellContent1.split( ":" )[3].equalsIgnoreCase( "UNKNOWN" ))
+                {
+                   
+                }
+                else if( ccemCellContent1.split( ":" )[4].equalsIgnoreCase( "MORE" ) )
+                {
+                    inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                    catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );                    
+                }
+                else
+                {
+                    inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                    catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );                                       
+                }
+            }             
+            Map<String, Integer> catalogTypeAttributeValueMap1 = new HashMap<String, Integer>(
+                ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
+                catalogTypeAttributeId, inventoryTypeAttributeId, 0, 2 ) );
+            
+            Map<String, Integer> catalogTypeAttributeValueMap2 = new HashMap<String, Integer>(
+                ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
+                    catalogTypeAttributeId, inventoryTypeAttributeId, 3, 5 ) );
+
+            Map<String, Integer> catalogTypeAttributeValueMap3 = new HashMap<String, Integer>(
+                ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId,
+                    catalogTypeAttributeId, inventoryTypeAttributeId, 6, 10 ) );
+
+            Map<String, Integer> catalogTypeAttributeValueMap4 = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma,inventoryTypeId, catalogTypeAttributeId, 3, 11, -1 ) );
+            
+            hash.put( "Value_0_2", catalogTypeAttributeValueMap1 );
+            hash.put( "Value_3_5", catalogTypeAttributeValueMap2 ); 
+            hash.put( "Value_6_10", catalogTypeAttributeValueMap3 );
+            hash.put( "Value_11_MORE", catalogTypeAttributeValueMap4 );            
+            
+            fileName = "CATALOGTYPE ATTRIBUTE VALUE AGE GROUP.jrxml";
+            JasperReport jasperReport = JasperCompileManager.compileReport( path + fileName );
+            jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
+        }
+        else if( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
+        {  
+            Font font = new Font( 10, "Arial", true );
+            Style headerStyle = new Style();
+            headerStyle.setFont( font );
+            headerStyle.setHorizontalAlign( HorizontalAlign.LEFT );
+            headerStyle.setVerticalAlign( VerticalAlign.MIDDLE );
+            font = new Font( 8, "Arial", false );
+            Style detailStyle = new Style();
+            detailStyle.setFont( font );
+            detailStyle.setHorizontalAlign( HorizontalAlign.LEFT );
+            detailStyle.setVerticalAlign( VerticalAlign.MIDDLE );
+            AbstractColumn column;            
+            ccemReportOutput = new CCEMReportOutput();
+            List<String> tableHeadings = new ArrayList<String>();
+            List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
+            List tableData = new ArrayList();
+            
+            List<String> oneSubHeadingRow = new ArrayList<String>();
+            List<String> content= new ArrayList<String>();
+            
+            FastReportBuilder frb = new FastReportBuilder();
+            
+            Integer periodId = 0;
+            Date date1 = new Date();
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime( date1 );
+            String periodStartDate = "";
+            Map<String, Integer> dataValueCountMap = new HashMap<String, Integer>();
+            if( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
+            {
+                periodStartDate = calendar.get( Calendar.YEAR ) + "-01-01";
+            }
+            else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
+            {
+               periodStartDate = (calendar.get( Calendar.YEAR )-1) + "-01-01";
+            }
+            
+            periodId = ccemReportManager.getPeriodId( periodStartDate, ccemReport.getPeriodRequire() );            
+            tableHeadings.add( "Facility Type" ); 
+            oneSubHeadingRow.add( " " );            
+            tableHeadings.add( "Total Facilities" );           
+            oneSubHeadingRow.add( " " );           
+            String dataElementIdsByComma = "-1";
+            String optComboIdsByComma = "-1";
+            List<String> dataElementOptions = new ArrayList<String>();
+            
+            for( CCEMReportDesign ccemReportDesign1 :  reportDesignList )
+            {                
+                String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+                Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                
+                dataElementIdsByComma += "," + dataElementId;
+                optComboIdsByComma += "," + optComboId;
+                
+                tableHeadings.add( ccemReportDesign1.getDisplayheading() );
+                
+                hash.put( "dataElementId", dataElementId );
+                hash.put( "optComboId", optComboId );
+                List<String> distinctDataElementValues = new ArrayList<String>( ccemReportManager.getDistinctDataElementValue( dataElementId, optComboId, periodId ) );
+                
+                for( int i = 0; i < distinctDataElementValues.size(); i++ )
+                {
+                    if( i != 0 )
+                    {
+                        tableHeadings.add( " " );
+                        
+                    }
+                    oneSubHeadingRow.add( distinctDataElementValues.get( i ).split( ":" )[2] );
+                    dataElementOptions.add( distinctDataElementValues.get( i ) );
+                }                
+            }
+            
+            tableSubHeadings.add( oneSubHeadingRow );            
+            int count=0;
+            
+            for(int i=0;i<=tableHeadings.size()-1;i++)
+            {                
+                if(tableHeadings.get( i )==" " )
+                {                    
+                }
+                else
+                {
+                    if(i==0 || i==1)
+                    {
+                        frb.addColumn(tableHeadings.get( i ), tableHeadings.get( i ), String.class.getName(), 100,true).build();
+                        count++;
+                        
+                    }
+                    else
+                    {                        
+                    }
+                }
+            }
+           for(int j=0;j<=tableSubHeadings.size()-1;j++)
+            { 
+                for(int k=0; k<=tableSubHeadings.get( j ).size()-1;k++)
+                {
+                    if(tableSubHeadings.get( j ).get( k )==" ")
+                    {                                    
+                    }
+                    else
+                    {   
+                        frb.addColumn(tableSubHeadings.get( j ).get( k ),
+                            tableSubHeadings.get( j ).get( k ), String.class.getName(), 100,false).build() ;   
+                        content.add( tableSubHeadings.get( j ).get( k ) );                        
+                            count++;
+                    }
+                }
+             
+            }
+            //frb.build();
+            frb.setPrintColumnNames(true);
+            frb.setColumnsPerPage(1, count).setUseFullPageWidth(true);   
+            Style colspanStyle = new Style();
+            colspanStyle.setBackgroundColor(Color.GRAY);
+            colspanStyle.setTransparency(Transparency.OPAQUE);
+            colspanStyle.setBorder(Border.PEN_1_POINT());
+           
+            frb.setColspan(2, 5, "Estimated", colspanStyle);
+            
+            frb.setTemplateFile( path+"report1.jrxml" );
+            
+            //dynamicReport.getOptions().getDefaultHeaderStyle().setBorder(Border.PEN_1_POINT());
+            
+            for( Integer orgUnitGroupId : orgunitGroupList )
+            {
+                Map numberOfData=new HashMap();
+                List<Integer> orgUnitIds = ccemReportManager.getOrgunitIds( selOrgUnitList, orgUnitGroupId );
+                if( orgUnitIds ==  null || orgUnitIds.size() <= 0 )
+                {  
+                    
+                }
+               else
+                {
+                    OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+    
+                    String orgUnitIdsBycomma = getCommaDelimitedString( orgUnitIds );
+                    System.out.println("Organisation Group"+orgUnitGroup.getName());                    
+                    numberOfData.put( "Facility Type", orgUnitGroup.getName() );                    
+                    numberOfData.put( "Total Facilities", ""+orgUnitIds.size() );                   
+                    Map<String, Integer> dataValueCountMap2 = new HashMap<String, Integer>( ccemReportManager.getDataValueCountforDataElements( dataElementIdsByComma, optComboIdsByComma, periodId, orgUnitIdsBycomma ) );
+                    for(int i=0;i<=dataElementOptions.size()-1;i++)
+                    {                      
+                       Integer temp = dataValueCountMap2.get( dataElementOptions.get(i) );
+                            if( temp == null )
+                            {
+                              numberOfData.put( content.get( i ), "0" );
+                            }
+                            else
+                            {
+                              numberOfData.put( content.get( i ), temp+"" );
+                            }                                               
+                    } 
+                    tableData.add( numberOfData );
+                }               
+            }
+            
+            JRDataSource ds = new JRMapCollectionDataSource(tableData );
+            DynamicReport dynamicReport = frb.build();
+            dynamicReport.getOptions().getDefaultHeaderStyle().setBorder(Border.THIN());
+            dynamicReport.getOptions().getDefaultDetailStyle().setBorder(Border.THIN()); 
+            dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign(HorizontalAlign.CENTER );
+            jr = DynamicJasperHelper.generateJasperReport( dynamicReport, new ClassicLayoutManager(), hash );
+            jasperPrint = JasperFillManager.fillReport( jr, hash, ds );        
+            
+             
+             //JasperExportManager.exportReportToPdfFile( jasperPrint, "C:/report1.pdf" );
+            //hash.put( "periodId", periodId );
+           // hash.put( "tableData", tableData );
+            //hash.put( "tableHeadings", tableHeadings );
+            //hash.put( "tableSubHeadings",tableSubHeadings  );
+            //fileName = "report1.jrxml";
+        }
+        
+        ServletOutputStream ouputStream = response.getOutputStream();
+        JRExporter exporter = null;
+
+        System.out.println( "Type is:" + type );
+        if ( "pdf".equalsIgnoreCase( type ) )
+        {            
+            response.setContentType( "application/pdf" );
+            response.setHeader( "Content-Disposition", "inline; fileName=\"file.pdf\"" );
+
+            exporter = new JRPdfExporter();
+            exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
+            exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
+        }
+        else if ( "rtf".equalsIgnoreCase( type ) )
+        {
+            response.setContentType( "application/rtf" );
+            response.setHeader( "Content-Disposition", "inline; fileName=\"file.rtf\"" );
+
+            exporter = new JRRtfExporter();
+            exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
+            exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
+        }
+        else if ( "html".equalsIgnoreCase( type ) )
+        {
+            exporter = new JRHtmlExporter();
+            exporter.setParameter( JRHtmlExporterParameter.OUTPUT_STREAM, false );
+            exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean( false ) );
+
+            exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
+            exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
+        }
+        else if ( "xls".equalsIgnoreCase( type ) )
+        {
+            response.setContentType( "application/xls" );
+            response.setHeader( "Content-Disposition", "attachment; fileName=\"file.xls\"" );
+
+            exporter = new JRXlsExporter();
+            exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
+            exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
+        }
+        else if ( "csv".equalsIgnoreCase( type ) )
+        {
+            response.setContentType( "application/csv" );
+            response.setHeader( "Content-Disposition", "inline; fileName=\"file.csv\"" );
+
+            exporter = new JRCsvExporter();
+            exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
+            exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
+        }
+        con.close();
+        try
+        {
+            exporter.exportReport();
+        }
+        catch ( JRException e )
+        {
+            throw new ServletException( e );
+        }
+        finally
+        {
+            if ( ouputStream != null )
+            {
+                try
+                {
+                    ouputStream.close();
+                }
+                catch ( IOException ex )
+                {
+                    System.out.println( "exception thrown" );
+                }
+            }
+        }
+
+     
+        return SUCCESS;
+    }
+
+  
+    
+}

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-06-26 08:38:56 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-07-24 05:31:29 +0000
@@ -640,5 +640,15 @@
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     </bean> 
+	
+	<bean id="org.hisp.dhis.coldchain.reports.action.GenerateJRXMLReportAction"
+        class="org.hisp.dhis.coldchain.reports.action.GenerateJRXMLReportAction"
+        scope="prototype">
+       <property name="ccemReportManager" ref="org.hisp.dhis.coldchain.reports.CCEMReportManager" />   
+		<property name="jdbcTemplate" ref="jdbcTemplate"/>
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+		    
+  </bean>
 			
 </beans>
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-06-27 06:56:57 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-07-24 05:31:29 +0000
@@ -7,6 +7,7 @@
 	
 <package name="dhis-web-coldchain" extends="dhis-web-commons" namespace="/dhis-web-coldchain">
 
+	
 <!-- Home page -->
 	<action name="index" class="org.hisp.dhis.coldchain.action.NoAction">
 		<result name="success" type="velocity">/main.vm</result>
@@ -573,6 +574,14 @@
 	</action>	
 
 	<!-- CCEM Reports -->
+	<action name="jrxmlReportsPage" class="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction">
+        <result name="success" type="velocity">/main.vm</result>
+        <param name="page">/dhis-web-coldchain/jrxmlReportsPage.vm</param>
+        <param name="menu">/dhis-web-coldchain/menu.vm</param>
+        <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/ccemReports.js</param>
+        <interceptor-ref name="organisationUnitTreeStack" />
+    </action>
+	
 	<action name="ccemReportsPage" class="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction">
         <result name="success" type="velocity">/main.vm</result>
         <param name="page">/dhis-web-coldchain/ccemReportsPage.vm</param>
@@ -586,13 +595,17 @@
         <param name="requiredAuthorities">F_CCEM_REPORT</param>
     </action>
 	
-	<action name="exportToExcel" class="org.hisp.dhis.coldchain.action.ExportToExcelAction">
+	<!--<action name="exportToExcel" class="org.hisp.dhis.coldchain.action.ExportToExcelAction">
 		<result name="success" type="stream">
 			<param name="contentType">application/vnd.ms-excel</param>
             <param name="inputName">inputStream</param>
             <param name="contentDisposition">attachment;filename="${fileName}"</param>
             <param name="bufferSize">1024</param>
 		</result>
+    </action>-->
+	
+	<action name="exportTable" class="org.hisp.dhis.coldchain.reports.action.GenerateJRXMLReportAction">     
+			<result name="success" type="redirect">jrxmlReportsPage.action</result>			  
     </action>
 		
 </package>

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/WEB-INF/web.xml'
--- local/in/dhis-web-coldchain/src/main/webapp/WEB-INF/web.xml	2012-04-17 10:41:26 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/WEB-INF/web.xml	2012-07-24 05:31:29 +0000
@@ -2,8 +2,8 @@
 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd";>
 <web-app>
-  <display-name>DHIS Dashboard</display-name>
-    
+	
+  <display-name>DHIS Dashboard</display-name>    
   <context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>classpath*:/META-INF/dhis/beans.xml</param-value>
@@ -11,8 +11,7 @@
   <context-param>
     <param-name>automaticAccessType</param-name>
     <param-value>ghostAdmin</param-value>
-  </context-param>
-  
+  </context-param>	
   <filter>
     <filter-name>RedirectFilter</filter-name>
     <filter-class>org.hisp.dhis.servlet.filter.HttpRedirectFilter</filter-class>
@@ -33,7 +32,6 @@
     <filter-name>Struts</filter-name>
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
   </filter>
-  
   <filter-mapping>
     <filter-name>RedirectFilter</filter-name>
     <url-pattern>/</url-pattern>

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js	2012-06-13 06:35:38 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js	2012-07-24 05:31:29 +0000
@@ -1,6 +1,16 @@
 // ----------------------------------------------------------------
 // Organisation Unit Selected
 // ----------------------------------------------------------------
+
+function exportReport( type )
+{
+    var url = "exportTable.action?type=" + type + "&useLast=true";
+
+    url += $( "#id" ).length ? ( "&id=" + $( "#id" ).val() ) : "";
+
+    window.location.href = url;
+}
+
 function organisationUnitSelected( orgUnits )
 {   
 	$.getJSON( 'getOrganisationUnit.action', {orgunitId:orgUnits[0]}
@@ -112,6 +122,19 @@
 //----------------------------------------------------------------
 //Generate CCEM Report
 //----------------------------------------------------------------
+function generateJRXMLReport()
+{
+	if( formValidations() )
+	{		
+		$("#ccemReportForm").attr("action", "exportTable.action"); 
+        $("#ccemReportForm").attr("method", "post");      
+        $("#ccemReportForm").attr('target', '_blank');
+        $("#ccemReportForm").submit();
+		
+	}
+}
+
+
 function generateCCEMReport()
 {
 	if( formValidations() )

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm	2012-07-24 05:31:29 +0000
@@ -0,0 +1,101 @@
+<script>
+    leftBar.hideAnimated();
+</script>
+
+<h3>$i18n.getString( "ccem_reports_page" )</h3>
+
+<form id="ccemReportForm" name="ccemReportForm" >
+	#foreach( $ccemReport in $reportList )
+		<input type="hidden" id="$ccemReport.reportId" value="$ccemReport.periodRequire" />
+    #end
+	<table boarder="1">
+		<tr>
+			<td>
+				<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
+					<tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "orgunit_tree" )</strong></td></tr>
+					<tr><td><div style="height:450px;width:200px;overflow:auto;">#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )</div></td></tr>
+				</table>
+			</td>			
+			<td>				
+				<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
+                    <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "ccem_reports_list" )</strong></td></tr>
+					<tr>
+						<td>		
+                            <select id="reportList" name="reportList" style="width:200px;" onchange="javascript:periodBox( this.value )" >								
+								#foreach( $ccemReport in $reportList )
+									<option value="$ccemReport.reportId" title="$ccemReport.reportName">$ccemReport.reportName</option>
+								#end
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>&nbsp;</td>
+                    </tr>
+                    <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "ccem_reports_period_list" ):</strong></td></tr>
+					<tr>			
+                        <td>
+							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_3_MONTHS" disabled />$i18n.getString( "last_3months" )
+							<input type="radio" id="periodRadio" name="periodRadio" value="CURRENT_YEAR" disabled />$i18n.getString( "current_year" )<br/>
+							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_6_MONTHS" disabled />$i18n.getString( "last_6months" )							
+                            <input type="radio" id="periodRadio" name="periodRadio" value="LAST_YEAR" disabled />$i18n.getString( "last_year" )
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>&nbsp;</td>
+                    </tr>
+                    <tr><td style="background-color: #C0C0C0;"><strong>$i18n.getString( "orgunit_group_list" ):</strong></td></tr>
+					<tr>
+						<td>	
+                            <select id="orgunitGroupList" name="orgunitGroupList" size="7" multiple style="width:200px;">
+								#foreach( $orgUnitGroup in $orgUnitGroupList )
+									<option value="$orgUnitGroup.id">$orgUnitGroup.name</option>
+								#end
+                            </select>							
+                        </td>						
+                    </tr>
+                    <tr>
+                        <td>&nbsp;</td>
+                    </tr>
+                    <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "selected_orgunit_list" )</td></tr>
+					<tr>
+						<td>		
+							<select id="selOrgUnitList" name="selOrgUnitList" size="7" multiple style="width:200px;" ondblclick="javascript:remOUFunction()"></select>
+						</td>
+                    </tr>                   
+                    <tr>
+                        <td>&nbsp;</td>
+                    </tr>
+                    <tr style="background-color: #C0C0C0;"><td><strong>Report Type</td></tr>
+                    <tr>
+                        <td>        
+                            <select name="type" id="type">                            	
+                                <option>pdf</option>	
+                                <option>rtf</option>
+                                <option>html</option>
+                                <option>xls</option>
+                                <option>csv</option>
+                                <option>text</option>
+                            </select>
+                        </td>
+                    </tr>   
+                    <tr>
+                        <td>&nbsp;</td>
+                    </tr>
+                    <tr>
+                        <td>                            
+                            <input type="button" value='$i18n.getString( "generate" )' style="width: 200px;height: 25; font-family:Arial;font-weight:bold; color:#000000" onclick="generateJRXMLReport()"/>
+                        </td>
+                    </tr>
+                </table>
+			</td>
+			<td>
+				<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
+					<tr><td><div>#parse( "/dhis-web-commons/loader/loader.vm" )</div>
+						<div id="resultContent"> </div></td>
+					</tr>
+				</table>
+			</td>
+		</tr>
+	</table>	
+</form>
+

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-06-13 06:35:38 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-07-24 05:31:29 +0000
@@ -19,5 +19,6 @@
 
 <h2>$i18n.getString( "ccem_reports" )</h2>
 <ul>
-	<li><a href="ccemReportsPage.action">$i18n.getString( "ccem_reports_page" )</a></li>    
+	<li><a href="ccemReportsPage.action">$i18n.getString( "ccem_reports_page" )</a></li> 
+	<li><a href="jrxmlReportsPage.action">JRXML Report</a></li>   
 </ul>