← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7281: WorkInProgress: CCEM Reports

 

------------------------------------------------------------
revno: 7281
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-13 07:35:38 +0100
message:
  WorkInProgress: CCEM Reports
added:
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReport.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportDesign.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportOutput.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMSettings.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/action/ExportToExcelAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/CCEMReportPageAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportOutput.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportsPage.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js
modified:
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentInstance.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/EquipmentInstance.hbm.xml
  local/in/dhis-web-alert/src/main/java/org/hisp/dhis/alert/tdb/action/GetPatientDataRecordsAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/AddEquipmentAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/UpdateEquipmentAction.java
  local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
  local/in/dhis-web-coldchain/src/main/resources/struts.xml
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addEquipmentForm.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/IDSPOutbreakAction.java
  local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportFormAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java


--
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-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentInstance.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentInstance.java	2012-06-06 10:13:06 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentInstance.java	2012-06-13 06:35:38 +0000
@@ -3,6 +3,7 @@
 import java.io.Serializable;
 import java.util.Set;
 
+import org.hisp.dhis.coldchain.catalog.Catalog;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 public class EquipmentInstance implements Serializable
@@ -14,6 +15,8 @@
     
     private OrganisationUnit organisationUnit;
     
+    private Catalog catalog;
+    
     private boolean working = false;
     
     private Set<EquipmentStatus> equipmentStatusUpdates;
@@ -126,5 +129,15 @@
     {
         this.equipmentStatusUpdates = equipmentStatusUpdates;
     }
+
+    public Catalog getCatalog()
+    {
+        return catalog;
+    }
+
+    public void setCatalog( Catalog catalog )
+    {
+        this.catalog = catalog;
+    }
     
 }

=== added directory 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports'
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReport.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReport.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReport.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,84 @@
+package org.hisp.dhis.coldchain.reports;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "ccemReport")
+public class CCEMReport
+{
+
+    public static final String CATALOGTYPE_ATTRIBUTE_VALUE = "CATALOGTYPE_ATTRIBUTE_VALUE";
+    public static final String CATALOGTYPE_ATTRIBUTE_VALUE_AGE_GROUP = "CATALOGTYPE_ATTRIBUTE_VALUE_AGE_GROUP";
+    public static final String ORGUNITGROUP_DATAVALUE = "ORGUNITGROUP_DATAVALUE";
+    public static final String ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE = "ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE";
+    
+    public static final String LAST_YEAR = "LAST_YEAR";
+    public static final String CURRENT_YEAR = "CURRENT_YEAR";
+    public static final String LAST_6_MONTHS = "LAST_6_MONTHS";
+    public static final String LAST_3_MONTHS = "LAST_3_MONTHS";
+    
+    private String reportId;
+    
+    private String reportName;
+    
+    private String xmlTemplateName;
+    
+    private String outputType;
+    
+    private String reportType;
+    
+    private String periodRequire;
+    
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+    // -------------------------------------------------------------------------
+
+    public String getReportId()
+    {
+        return reportId;
+    }
+    public void setReportId( String reportId )
+    {
+        this.reportId = reportId;
+    }
+    public String getReportName()
+    {
+        return reportName;
+    }
+    public void setReportName( String reportName )
+    {
+        this.reportName = reportName;
+    }
+    public String getXmlTemplateName()
+    {
+        return xmlTemplateName;
+    }
+    public void setXmlTemplateName( String xmlTemplateName )
+    {
+        this.xmlTemplateName = xmlTemplateName;
+    }
+    public String getOutputType()
+    {
+        return outputType;
+    }
+    public void setOutputType( String outputType )
+    {
+        this.outputType = outputType;
+    }
+    public String getReportType()
+    {
+        return reportType;
+    }
+    public void setReportType( String reportType )
+    {
+        this.reportType = reportType;
+    }
+    public String getPeriodRequire()
+    {
+        return periodRequire;
+    }
+    public void setPeriodRequire( String periodRequire )
+    {
+        this.periodRequire = periodRequire;
+    }
+    
+}

=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportDesign.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportDesign.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportDesign.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,43 @@
+package org.hisp.dhis.coldchain.reports;
+
+public class CCEMReportDesign
+{
+
+    private int row;
+    
+    private String content;
+    
+    private String displayheading;
+    
+
+    public int getRow()
+    {
+        return row;
+    }
+
+    public void setRow( int row )
+    {
+        this.row = row;
+    }
+
+    public String getContent()
+    {
+        return content;
+    }
+
+    public void setContent( String content )
+    {
+        this.content = content;
+    }
+
+    public String getDisplayheading()
+    {
+        return displayheading;
+    }
+
+    public void setDisplayheading( String displayheading )
+    {
+        this.displayheading = displayheading;
+    }
+    
+}

=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportManager.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,29 @@
+package org.hisp.dhis.coldchain.reports;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CCEMReportManager
+{
+    String getOrgunitIdsByComma( List<Integer> selOrgUnitList, List<Integer> orgunitGroupList );
+    
+    Map<String,String> getCCEMSettings();
+    
+    List<CCEMReportDesign> getCCEMReportDesign( String designXMLFile );
+    
+    CCEMReport getCCEMReportByReportId( String selReportId );
+    
+    Map<String, Integer> getCatalogTypeAttributeValue( String orgUnitIdsByComma, Integer inventoryTypeId, Integer catalogTypeAttributeId );
+    
+    Map<String, Integer> getCatalogTypeAttributeValueByAge( String orgUnitIdsByComma, Integer inventoryTypeId, Integer catalogTypeAttributeId, Integer yearInvTypeAttId, Integer ageStart, Integer ageEnd );
+    
+    List<String> getDistinctDataElementValue( Integer dataelementID, Integer optComboId, Integer periodId );
+    
+    List<Integer> getOrgunitIds( List<Integer> selOrgUnitList, Integer orgUnitGroupId );
+    
+    Map<String, Integer> getDataValueCountforDataElements( String dataElementIdsByComma, String optComboIdsByComma, Integer periodId, String orgUnitIdsBycomma );
+    
+    Integer getPeriodId( String startDate, String periodType );
+    
+    Map<String, Integer> getFacilityWiseEquipmentRoutineData( String orgUnitIdsByComma, String periodIdsByComma, String dataElementIdsByComma, String optComboIdsByComma );
+}

=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportOutput.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportOutput.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMReportOutput.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,56 @@
+package org.hisp.dhis.coldchain.reports;
+
+import java.util.List;
+
+public class CCEMReportOutput
+{
+
+    private String reportHeading;
+    
+    private List<String> tableHeadings;
+    
+    private List<List<String>> tableSubHeadings;
+    
+    private List<List<String>> tableData;
+
+    public List<String> getTableHeadings()
+    {
+        return tableHeadings;
+    }
+
+    public void setTableHeadings( List<String> tableHeadings )
+    {
+        this.tableHeadings = tableHeadings;
+    }
+
+    public List<List<String>> getTableData()
+    {
+        return tableData;
+    }
+
+    public void setTableData( List<List<String>> tableData )
+    {
+        this.tableData = tableData;
+    }
+
+    public List<List<String>> getTableSubHeadings()
+    {
+        return tableSubHeadings;
+    }
+
+    public void setTableSubHeadings( List<List<String>> tableSubHeadings )
+    {
+        this.tableSubHeadings = tableSubHeadings;
+    }
+
+    public String getReportHeading()
+    {
+        return reportHeading;
+    }
+
+    public void setReportHeading( String reportHeading )
+    {
+        this.reportHeading = reportHeading;
+    }
+    
+}

=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMSettings.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMSettings.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/reports/CCEMSettings.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,30 @@
+package org.hisp.dhis.coldchain.reports;
+
+public class CCEMSettings
+{
+
+    private String commonId;
+    
+    private String ccemId;
+
+    public String getCommonId()
+    {
+        return commonId;
+    }
+
+    public void setCommonId( String commonId )
+    {
+        this.commonId = commonId;
+    }
+
+    public String getCcemId()
+    {
+        return ccemId;
+    }
+
+    public void setCcemId( String ccemId )
+    {
+        this.ccemId = ccemId;
+    }
+    
+}

=== added directory 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports'
=== added file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,533 @@
+package org.hisp.dhis.coldchain.reports;
+
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class DefaultCCEMReportManager implements CCEMReportManager
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Methods
+    // -------------------------------------------------------------------------
+
+    public Map<String, Integer> getFacilityWiseEquipmentRoutineData( String orgUnitIdsByComma, String periodIdsByComma, String dataElementIdsByComma, String optComboIdsByComma )
+    {
+        Map<String, Integer> equipmentDataValueMap = new HashMap<String, Integer>();
+        try
+        {
+            String query = "SELECT equipmentinstance.organisationunitid, dataelementid, periodid, value FROM equipmentdatavalue "+ 
+                            "INNER JOIN equipmentinstance " +
+                                " ON equipmentinstance.equipmentinstanceid = equipmentdatavalue.equipmentinstanceid " +                                
+                            " WHERE "+
+                                " equipmentinstance.organisationunitid IN ("+ orgUnitIdsByComma +") AND "+
+                                " dataelementid IN ("+ dataElementIdsByComma +") AND " +
+                                " periodid IN ("+ periodIdsByComma +")"; 
+
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer orgUnitId = rs.getInt( 1 );
+                Integer dataElementId = rs.getInt( 2 );
+                Integer periodId = rs.getInt( 3 );                
+                Integer value = rs.getInt( 4 );
+                
+                equipmentDataValueMap.put( orgUnitId+":"+dataElementId+":"+periodId, value );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return equipmentDataValueMap;
+    }
+    
+    public Integer getPeriodId( String startDate, String periodType )
+    {
+        Integer periodId = 0;
+        try
+        {
+            String query = "SELECT periodid FROM period " +
+            		    " INNER JOIN periodtype ON period.periodtypeid = periodtype.periodtypeid " +
+            		    " WHERE " +
+            		        " periodtype.name = '"+ periodType +"' AND " +
+            		        " period.startdate = '"+ startDate +"'"; 
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            if( rs!= null && rs.next() )
+            {
+                periodId = rs.getInt( 1 );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return periodId;
+    }
+    
+    public Map<String, Integer> getDataValueCountforDataElements( String dataElementIdsByComma, String optComboIdsByComma, Integer periodId, String orgUnitIdsBycomma )
+    {
+        Map<String, Integer> dataValueCountMap = new HashMap<String, Integer>();
+        try
+        {
+            String query = "SELECT dataelementid, categoryoptioncomboid, value, COUNT(*) FROM datavalue " +
+            		    " WHERE " +
+            		        " dataelementid IN ("+ dataElementIdsByComma +") AND " +
+            		    	" periodid = "+ periodId +" AND " +
+            		    	" sourceid IN ( "+ orgUnitIdsBycomma +" ) " +
+            		    	" GROUP BY dataelementid,categoryoptioncomboid,value";
+                
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer dataElementId = rs.getInt( 1 );
+                Integer optComboId = rs.getInt( 2 );                
+                String dataElementValue = rs.getString( 3 );
+                Integer totCount = rs.getInt( 4 );
+                
+                dataValueCountMap.put( dataElementId+":"+optComboId+":"+dataElementValue, totCount );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return dataValueCountMap;
+    }
+
+    
+    public List<String> getDistinctDataElementValue( Integer dataelementID, Integer optComboId, Integer periodId )
+    {
+        List<String> distinctDataElementValues = new ArrayList<String>();
+        try
+        {
+            String query = "SELECT DISTINCT(value) FROM datavalue " +                            
+                            " WHERE " +
+                                " dataelementid = "+ dataelementID +" AND " +
+                                " periodid = "+ periodId +" AND " +
+                                " categoryoptioncomboid = "+ optComboId;
+                                
+
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                String dataElementValue = rs.getString( 1 );
+                distinctDataElementValues.add( dataelementID+":"+optComboId+":"+dataElementValue );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return distinctDataElementValues;
+    }
+    
+    
+    public List<Integer> getOrgunitIds( List<Integer> selOrgUnitList, Integer orgUnitGroupId )
+    {
+        String selOrgUnitsByComma = getCommaDelimitedString( selOrgUnitList );
+        
+        int maxOULevels = organisationUnitService.getMaxOfOrganisationUnitLevels();
+        
+        List<Integer> orgUnitIds = new ArrayList<Integer>();
+        
+        try
+        {
+            String query = "select orgunitgroupmembers.organisationunitid from orgunitgroupmembers " +
+                            " inner join _orgunitstructure on orgunitgroupmembers.organisationunitid = _orgunitstructure.organisationunitid " + 
+                            " where orgunitgroupid in (" + orgUnitGroupId + ") and ( ";
+            for( int i = 1; i <= maxOULevels; i++ )
+            {
+                query += " idlevel"+ i +" in (" + selOrgUnitsByComma + ") OR ";
+            }
+            query = query.substring( 0, query.length()-4 );
+            
+            query += ")";
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer orgUnitId = rs.getInt( 1 );
+                orgUnitIds.add( orgUnitId );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return orgUnitIds;
+    }
+    
+    
+    
+    
+    
+    
+    public String getOrgunitIdsByComma( List<Integer> selOrgUnitList, List<Integer> orgunitGroupList )
+    {
+        String selOrgUnitsByComma = getCommaDelimitedString( selOrgUnitList );
+        String selOrgUnitGroupsByComma = getCommaDelimitedString( orgunitGroupList );
+        
+        int maxOULevels = organisationUnitService.getMaxOfOrganisationUnitLevels();
+        
+        String orgUnitIdsByComma = "-1";
+        
+        try
+        {
+            String query = "select orgunitgroupmembers.organisationunitid from orgunitgroupmembers " +
+                            " inner join _orgunitstructure on orgunitgroupmembers.organisationunitid = _orgunitstructure.organisationunitid " + 
+                            " where orgunitgroupid in (" + selOrgUnitGroupsByComma + ") and ( ";
+            for( int i = 1; i <= maxOULevels; i++ )
+            {
+                query += " idlevel"+ i +" in (" + selOrgUnitsByComma + ") OR ";
+            }
+            query = query.substring( 0, query.length()-4 );
+            
+            query += ")";
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer orgUnitId = rs.getInt( 1 );
+                orgUnitIdsByComma += "," + orgUnitId;
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return orgUnitIdsByComma;
+    }
+    
+    public Map<String, Integer> getCatalogTypeAttributeValueByAge( String orgUnitIdsByComma, Integer inventoryTypeId, Integer catalogTypeAttributeId, Integer yearInvTypeAttId, Integer ageStart, Integer ageEnd )
+    {
+        Map<String, Integer> CatalogTypeAttributeValueMap = new HashMap<String, Integer>();
+        try
+        {
+            /*
+            String query = "SELECT catalogdatavalue.value, COUNT(*) FROM equipment INNER JOIN equipmentinstance ON "+ 
+                            " equipmentinstance.equipmentinstanceid = equipment.equipmentinstanceid INNER JOIN catalog ON equipment.value = catalog.name " +
+                            " INNER JOIN catalogdatavalue ON catalog.catalogid = catalogdatavalue.catalogid " + 
+                            " WHERE equipmentinstance.equipmentinstanceid IN " +
+                                            "( SELECT equipmentinstanceid FROM equipment WHERE inventorytypeattributeid = "+yearInvTypeAttId+" AND " +
+                                            		"( YEAR(CURDATE()) - value ) >= "+ageStart+" AND ( YEAR(CURDATE()) - value ) <= "+ageEnd+") AND " +
+                            "organisationunitid IN ("+ orgUnitIdsByComma +") AND inventorytypeattributeid = "+ inventoryTypeAttributeId +" AND " +
+                            " catalog.catalogtypeid = "+ catalogTypeId +" AND catalogdatavalue.catalogtypeattributeid = "+ catalogTypeAttributeId +" GROUP BY catalogdatavalue.value";
+            */
+            
+            String query = "SELECT catalogdatavalue.value, COUNT(*) FROM catalogdatavalue "+
+                           " INNER JOIN equipmentinstance ON catalogdatavalue.catalogid = equipmentinstance.catalogid "+ 
+                           " INNER JOIN equipment on equipmentinstance.equipmentinstanceid = equipment.equipmentinstanceid "+ 
+                           " WHERE "+ 
+                                " equipmentinstance.inventorytypeid = "+ inventoryTypeId +" AND "+ 
+                                " catalogdatavalue.catalogtypeattributeid = "+ catalogTypeAttributeId +" AND "+ 
+                                " equipment.inventorytypeattributeid = "+ yearInvTypeAttId +" AND "+
+                                " ( YEAR(CURDATE()) - equipment.value ) >= "+ ageStart +" AND "; 
+                                
+                                if( ageEnd != -1 )
+                                {
+                                   query +=  " ( YEAR(CURDATE()) - equipment.value ) <= "+ ageEnd +" AND ";
+                                }
+                                
+                                query += " equipmentinstance.organisationunitid IN ( "+orgUnitIdsByComma+" ) " +
+                                " GROUP BY catalogdatavalue.value";
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                String catalogDataValue = rs.getString( 1 );
+                Integer catalogDataValueCount = rs.getInt( 2 );
+                CatalogTypeAttributeValueMap.put( catalogDataValue, catalogDataValueCount );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return CatalogTypeAttributeValueMap;
+    }
+    
+    
+    public Map<String, Integer> getCatalogTypeAttributeValue( String orgUnitIdsByComma, Integer inventoryTypeId, Integer catalogTypeAttributeId )
+    {
+        Map<String, Integer> CatalogTypeAttributeValueMap = new HashMap<String, Integer>();
+        try
+        {
+            /*
+            String query = "SELECT catalogdatavalue.value, COUNT(*) FROM equipment INNER JOIN equipmentinstance ON "+ 
+                            " equipmentinstance.equipmentinstanceid = equipment.equipmentinstanceid INNER JOIN catalog ON equipment.value = catalog.name " +
+                            " INNER JOIN catalogdatavalue ON catalog.catalogid = catalogdatavalue.catalogid " + 
+                            " WHERE organisationunitid IN ("+ orgUnitIdsByComma +") AND inventorytypeattributeid = "+ inventoryTypeAttributeId +" AND " +
+                            " catalog.catalogtypeid = "+ catalogTypeId +" AND catalogdatavalue.catalogtypeattributeid = "+ catalogTypeAttributeId +" GROUP BY catalogdatavalue.value";
+            */
+            
+            String query = "SELECT catalogdatavalue.value, COUNT(*) FROM catalogdatavalue " +
+            		    " INNER JOIN equipmentinstance on catalogdatavalue.catalogid = equipmentinstance.catalogid "+
+            		    " WHERE " +
+            		        " equipmentinstance.inventorytypeid = "+ inventoryTypeId +" AND " +
+            		        " catalogdatavalue.catalogtypeattributeid = "+ catalogTypeAttributeId +" AND "+            		        
+            		        " equipmentinstance.organisationunitid in ("+ orgUnitIdsByComma +")" +
+            		    " GROUP BY catalogdatavalue.value";    
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                String catalogDataValue = rs.getString( 1 );
+                Integer catalogDataValueCount = rs.getInt( 2 );
+                CatalogTypeAttributeValueMap.put( catalogDataValue, catalogDataValueCount );
+            }
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Exception: ", e );
+        }
+        
+        return CatalogTypeAttributeValueMap;
+    }
+    
+    public Map<String,String> getCCEMSettings()
+    {
+        String fileName = "ccemSettings.xml";
+        String path = System.getenv( "DHIS2_HOME" )+ File.separator + "ccemreports" + File.separator + fileName;
+        
+        Map<String, String> ccemSettingsMap = new HashMap<String, String>();
+
+        try
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                System.out.println( "XML File Not Found at user home" );
+                return null;
+            }
+
+            NodeList listOfReports = doc.getElementsByTagName( "ccemSetting" );
+            int totalReports = listOfReports.getLength();
+            for ( int s = 0; s < totalReports; s++ )
+            {
+                Node reportNode = listOfReports.item( s );
+                if ( reportNode.getNodeType() == Node.ELEMENT_NODE )
+                {
+                    Element reportElement = (Element) reportNode;
+
+                    String commonId = reportElement.getAttribute( "commonId" );
+                    String ccemId = reportElement.getAttribute( "ccemId" );
+                    
+                    ccemSettingsMap.put( commonId, ccemId );
+                }
+            }// end of for loop with s var
+        }// try block end
+        catch ( SAXParseException err )
+        {
+            System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
+            System.out.println( " " + err.getMessage() );
+        }
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ((x == null) ? e : x).printStackTrace();
+        }
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+        
+        return ccemSettingsMap;
+    }
+    
+    
+    public List<CCEMReportDesign> getCCEMReportDesign( String designXMLFile )
+    {
+        String path = System.getenv( "DHIS2_HOME" )+ File.separator + "ccemreports" + File.separator + designXMLFile;
+        
+        List<CCEMReportDesign> ccemReportDesignList = new ArrayList<CCEMReportDesign>();
+        
+        try
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                System.out.println( "XML File Not Found at user home" );
+                return null;
+            }
+
+            NodeList listOfReports = doc.getElementsByTagName( "ccemreportcell" );
+            int totalReports = listOfReports.getLength();
+            for ( int s = 0; s < totalReports; s++ )
+            {
+                Node reportNode = listOfReports.item( s );
+                if ( reportNode.getNodeType() == Node.ELEMENT_NODE )
+                {
+                    Element reportElement = (Element) reportNode;
+
+                    Integer row = Integer.parseInt( reportElement.getAttribute( "row" ) );
+                    String content = reportElement.getAttribute( "content" );
+                    String displayheading = reportElement.getAttribute( "displayheading" );
+
+                    CCEMReportDesign ccemReportDesign = new CCEMReportDesign();
+                    ccemReportDesign.setRow( row );
+                    ccemReportDesign.setContent( content );
+                    ccemReportDesign.setDisplayheading( displayheading );
+                    
+                    ccemReportDesignList.add( ccemReportDesign );
+                }
+            }// end of for loop with s var
+        }// try block end
+        catch ( SAXParseException err )
+        {
+            System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
+            System.out.println( " " + err.getMessage() );
+        }
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ((x == null) ? e : x).printStackTrace();
+        }
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+
+        return ccemReportDesignList;
+    }
+    
+    public CCEMReport getCCEMReportByReportId( String selReportId )
+    {
+        String fileName = "ccemReportList.xml";
+        String path = System.getenv( "DHIS2_HOME" )+ File.separator + "ccemreports" + File.separator + fileName;
+        
+        CCEMReport reportObj = new CCEMReport( );
+        
+        try
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                System.out.println( "XML File Not Found at user home" );
+                return null;
+            }
+
+            NodeList listOfReports = doc.getElementsByTagName( "ccemReport" );
+            int totalReports = listOfReports.getLength();
+            for ( int s = 0; s < totalReports; s++ )
+            {
+                Node reportNode = listOfReports.item( s );
+                if ( reportNode.getNodeType() == Node.ELEMENT_NODE )
+                {
+                    Element reportElement = (Element) reportNode;
+
+                    NodeList nodeList1 = reportElement.getElementsByTagName( "reportId" );
+                    Element element1 = (Element) nodeList1.item( 0 );
+                    NodeList textNodeList1 = element1.getChildNodes();
+                    String reportId = ((Node) textNodeList1.item( 0 )).getNodeValue().trim();
+
+                    if( !reportId.equalsIgnoreCase( selReportId ) )
+                    {
+                        continue;
+                    }
+                    
+                    NodeList nodeList2 = reportElement.getElementsByTagName( "reportName" );
+                    Element element2 = (Element) nodeList2.item( 0 );
+                    NodeList textNodeList2 = element2.getChildNodes();
+                    String reportName = ((Node) textNodeList2.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList3 = reportElement.getElementsByTagName( "xmlTemplateName" );
+                    Element element3 = (Element) nodeList3.item( 0 );
+                    NodeList textNodeList3 = element3.getChildNodes();
+                    String xmlTemplateName = ((Node) textNodeList3.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList4 = reportElement.getElementsByTagName( "outputType" );
+                    Element element4 = (Element) nodeList4.item( 0 );
+                    NodeList textNodeList4 = element4.getChildNodes();
+                    String outputType = ((Node) textNodeList4.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList5 = reportElement.getElementsByTagName( "reportType" );
+                    Element element5 = (Element) nodeList5.item( 0 );
+                    NodeList textNodeList5 = element5.getChildNodes();
+                    String reportType = ((Node) textNodeList5.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList6 = reportElement.getElementsByTagName( "periodRequire" );
+                    Element element6 = (Element) nodeList6.item( 0 );
+                    NodeList textNodeList6 = element6.getChildNodes();
+                    String periodRequire = ((Node) textNodeList6.item( 0 )).getNodeValue().trim();
+
+                    reportObj.setOutputType( outputType );
+                    reportObj.setReportId( reportId );
+                    reportObj.setReportName( reportName );
+                    reportObj.setXmlTemplateName( xmlTemplateName );
+                    reportObj.setReportType( reportType );
+                    reportObj.setPeriodRequire( periodRequire );
+                    
+                }
+            }// end of for loop with s var
+        }// try block end
+        catch ( SAXParseException err )
+        {
+            System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
+            System.out.println( " " + err.getMessage() );
+        }
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ((x == null) ? e : x).printStackTrace();
+        }
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+
+        return reportObj;
+        
+    }// getReportList end
+
+    
+}

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-05-23 06:35:17 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-06-13 06:35:38 +0000
@@ -182,6 +182,14 @@
 		<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore"/>
     </bean>		
 
+<!-- CCEM Report Manager -->
+    <bean id="org.hisp.dhis.coldchain.reports.CCEMReportManager"
+        class="org.hisp.dhis.coldchain.reports.DefaultCCEMReportManager">
+        <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+        <property name="jdbcTemplate" ref="jdbcTemplate"/>
+    </bean>     
+
+
 	<!-- DeletionHandlers -->
 	
 </beans>

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/EquipmentInstance.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/EquipmentInstance.hbm.xml	2012-04-17 12:28:23 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/EquipmentInstance.hbm.xml	2012-06-13 06:35:38 +0000
@@ -16,6 +16,9 @@
     <many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
         column="organisationunitid" foreign-key="fk_equipmentinstance_organisationunitid" />
 
+    <many-to-one name="catalog" class="org.hisp.dhis.coldchain.catalog.Catalog" column="catalogid"
+      not-null="false" foreign-key="fk_equipmentinstance_catalogid" />
+
     <property name="working" not-null="true" />
     
 	<set name="equipmentStatusUpdates" cascade="all-delete-orphan" inverse="true" >

=== modified file 'local/in/dhis-web-alert/src/main/java/org/hisp/dhis/alert/tdb/action/GetPatientDataRecordsAction.java'
--- local/in/dhis-web-alert/src/main/java/org/hisp/dhis/alert/tdb/action/GetPatientDataRecordsAction.java	2012-06-02 08:51:09 +0000
+++ local/in/dhis-web-alert/src/main/java/org/hisp/dhis/alert/tdb/action/GetPatientDataRecordsAction.java	2012-06-13 06:35:38 +0000
@@ -309,8 +309,12 @@
          * patientService.sortPatientsByAttribute( patientListByOrgUnit,
          * sortPatientAttribute ); }
          */
-
-        colorMap = programStageInstanceService.colorProgramStageInstances( programStageInstances );
+        
+        /**
+         * TODO 
+         * probably colorProgramStageInstances are removed, need to fix here accordingly
+         */
+        //colorMap = programStageInstanceService.colorProgramStageInstances( programStageInstances );
 
         return SUCCESS;
     }

=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/action/ExportToExcelAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/action/ExportToExcelAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/action/ExportToExcelAction.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,82 @@
+package org.hisp.dhis.coldchain.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Bharath Kumar
+ * 
+ * @version ExportToExcelAction.java June 7, 2012 12:30 PM
+ */
+
+public class ExportToExcelAction
+    implements Action
+{
+    // ---------------------------------------------------------------
+    // Input & Output
+    // ---------------------------------------------------------------
+    
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    private String fileName;
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    private String htmlCode;
+
+    public void setHtmlCode( String htmlCode )
+    {
+        this.htmlCode = htmlCode;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        fileName = "Output.xls";
+        
+        inputStream = new BufferedInputStream( new ByteArrayInputStream( htmlCode.getBytes() ) );
+        
+        return SUCCESS;
+    }  
+}

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/AddEquipmentAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/AddEquipmentAction.java	2012-06-06 10:13:06 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/AddEquipmentAction.java	2012-06-13 06:35:38 +0000
@@ -58,18 +58,30 @@
         this.workingStatus = workingStatus;
     }
 
+    private Integer catalog;
+    
+    public void setCatalog( Integer catalog )
+    {
+        this.catalog = catalog;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
     public String execute()
     {
 
-        System.out.println("inside AddEquipmentAction : "+ouId);
-        
         OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouId );
         
         InventoryType inventoryType = inventoryTypeService.getInventoryType( itypeId );
         
+        Catalog selCatalog = null;
+        
+        if( catalog != null )
+        {    
+            selCatalog = catalogService.getCatalog( catalog );
+        }
+        
         // -----------------------------------------------------------------------------
         // Preparing EquipmentInstance
         // -----------------------------------------------------------------------------
@@ -78,6 +90,10 @@
         equipmentInstance.setInventoryType( inventoryType );
         equipmentInstance.setOrganisationUnit( orgUnit );
         equipmentInstance.setWorking( workingStatus );
+        if( selCatalog != null )
+        {
+            equipmentInstance.setCatalog( selCatalog );
+        }
         
         // -----------------------------------------------------------------------------
         // Preparing Equipment Details

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/UpdateEquipmentAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/UpdateEquipmentAction.java	2012-05-15 10:33:46 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/UpdateEquipmentAction.java	2012-06-13 06:35:38 +0000
@@ -45,6 +45,13 @@
     
     private String message;
     
+    private Integer catalog;
+    
+    public void setCatalog( Integer catalog )
+    {
+        this.catalog = catalog;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -57,6 +64,19 @@
         
         InventoryType inventoryType = equipmentInstance.getInventoryType();
         
+        Catalog selCatalog = null;
+        
+        if( catalog != null )
+        {    
+            selCatalog = catalogService.getCatalog( catalog );
+        }
+        if( selCatalog != null )
+        {
+            equipmentInstance.setCatalog( selCatalog );
+            
+            equipmentInstanceService.updateEquipmentInstance( equipmentInstance );
+        }
+        
         // -----------------------------------------------------------------------------
         // Preparing Equipment Details
         // -----------------------------------------------------------------------------

=== added directory 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports'
=== added directory 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action'
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/CCEMReportPageAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/CCEMReportPageAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/CCEMReportPageAction.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,158 @@
+package org.hisp.dhis.coldchain.reports.action;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.hisp.dhis.coldchain.reports.CCEMReport;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.report.Report;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import com.opensymphony.xwork2.Action;
+
+public class CCEMReportPageAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Properties
+    // -------------------------------------------------------------------------
+    
+    private List<OrganisationUnitGroup> orgUnitGroupList;
+    
+    public List<OrganisationUnitGroup> getOrgUnitGroupList()
+    {
+        return orgUnitGroupList;
+    }
+    
+    private List<CCEMReport> reportList;
+    
+    public List<CCEMReport> getReportList()
+    {
+        return reportList;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        
+        orgUnitGroupList = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getAllOrganisationUnitGroups() );
+        
+        reportList = new ArrayList<CCEMReport>();
+        
+        getCCEMReportList();
+        
+        return SUCCESS;
+    }
+    
+    
+    public void getCCEMReportList()
+    {
+        String fileName = "ccemReportList.xml";
+        String path = System.getenv( "DHIS2_HOME" )+ File.separator + "ccemreports" + File.separator + fileName;
+        
+        //JAXBContext context = JAXBContext.newInstance( CCEMReport.class );
+        //Unmarshaller um = context.createUnmarshaller();
+        //CCEMReport ccemReport = (CCEMReport) um.unmarshal( new FileReader( path ) );
+        
+        try
+        {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+            Document doc = docBuilder.parse( new File( path ) );
+            if ( doc == null )
+            {
+                System.out.println( "XML File Not Found at user home" );
+                return;
+            }
+
+            NodeList listOfReports = doc.getElementsByTagName( "ccemReport" );
+            int totalReports = listOfReports.getLength();
+            for ( int s = 0; s < totalReports; s++ )
+            {
+                Node reportNode = listOfReports.item( s );
+                if ( reportNode.getNodeType() == Node.ELEMENT_NODE )
+                {
+                    Element reportElement = (Element) reportNode;
+
+                    NodeList nodeList1 = reportElement.getElementsByTagName( "reportId" );
+                    Element element1 = (Element) nodeList1.item( 0 );
+                    NodeList textNodeList1 = element1.getChildNodes();
+                    String reportId = ((Node) textNodeList1.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList2 = reportElement.getElementsByTagName( "reportName" );
+                    Element element2 = (Element) nodeList2.item( 0 );
+                    NodeList textNodeList2 = element2.getChildNodes();
+                    String reportName = ((Node) textNodeList2.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList3 = reportElement.getElementsByTagName( "xmlTemplateName" );
+                    Element element3 = (Element) nodeList3.item( 0 );
+                    NodeList textNodeList3 = element3.getChildNodes();
+                    String xmlTemplateName = ((Node) textNodeList3.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList4 = reportElement.getElementsByTagName( "outputType" );
+                    Element element4 = (Element) nodeList4.item( 0 );
+                    NodeList textNodeList4 = element4.getChildNodes();
+                    String outputType = ((Node) textNodeList4.item( 0 )).getNodeValue().trim();
+
+                    NodeList nodeList5 = reportElement.getElementsByTagName( "periodRequire" );
+                    Element element5 = (Element) nodeList5.item( 0 );
+                    NodeList textNodeList5 = element5.getChildNodes();
+                    String periodRequire = ((Node) textNodeList5.item( 0 )).getNodeValue().trim();
+
+                    CCEMReport reportObj = new CCEMReport( );
+                    
+                    reportObj.setOutputType( outputType );
+                    reportObj.setReportId( reportId );
+                    reportObj.setReportName( reportName );
+                    reportObj.setXmlTemplateName( xmlTemplateName );
+                    reportObj.setPeriodRequire( periodRequire );
+                    
+                    reportList.add( reportObj );
+                }
+            }// end of for loop with s var
+        }// try block end
+        catch ( SAXParseException err )
+        {
+            System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
+            System.out.println( " " + err.getMessage() );
+        }
+        catch ( SAXException e )
+        {
+            Exception x = e.getException();
+            ((x == null) ? e : x).printStackTrace();
+        }
+        catch ( Throwable t )
+        {
+            t.printStackTrace();
+        }
+
+    }// getReportList end
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java	2012-06-13 06:35:38 +0000
@@ -0,0 +1,617 @@
+package org.hisp.dhis.coldchain.reports.action;
+
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
+import java.text.SimpleDateFormat;
+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 jxl.write.Label;
+
+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.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+
+import com.opensymphony.xwork2.Action;
+
+public class GenerateCCEMReportAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private CCEMReportManager ccemReportManager;
+    
+    public void setCcemReportManager( CCEMReportManager ccemReportManager )
+    {
+        this.ccemReportManager = ccemReportManager;
+    }
+    
+    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 I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Properties
+    // -------------------------------------------------------------------------
+
+    private String selReportId;
+    
+    public void setSelReportId( String selReportId )
+    {
+        this.selReportId = selReportId;
+    }
+
+    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;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+    public String execute()
+        throws Exception
+    {
+        String orgUnitIdsByComma = ccemReportManager.getOrgunitIdsByComma( selOrgUnitList, orgunitGroupList );
+        
+        ccemReport = ccemReportManager.getCCEMReportByReportId( selReportId );
+        
+        Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
+        
+        List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager.getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
+        
+        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] );
+            Map<String, Integer> catalogTypeAttributeValueMap = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValue( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId ) );            
+        
+            ccemReportOutput = new CCEMReportOutput();
+            List<String> tableHeadings = new ArrayList<String>();
+            List<List<String>> tableData = new ArrayList<List<String>>();
+            List<String> oneTableRowData = new ArrayList<String>();
+            for( String catalogTypeAttributeValueKey : catalogTypeAttributeValueMap.keySet() )
+            {
+                tableHeadings.add( catalogTypeAttributeValueKey );
+                oneTableRowData.add( ""+catalogTypeAttributeValueMap.get( catalogTypeAttributeValueKey ) );                
+            }
+            
+            tableData.add( oneTableRowData );
+            ccemReportOutput.setTableData( tableData );
+            ccemReportOutput.setTableHeadings( tableHeadings );            
+        }
+        else if( ccemReport.getReportType().equals( CCEMReport.CATALOGTYPE_ATTRIBUTE_VALUE_AGE_GROUP ) )
+        {
+
+            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] );
+            Map<String, Integer> catalogTypeAttributeValueMap = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValue( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId ) );            
+
+            ccemReportOutput = new CCEMReportOutput();
+            List<String> tableHeadings = new ArrayList<String>();
+            List<List<String>> tableData = new ArrayList<List<String>>();
+            
+            
+            List<Map<String, Integer>> outPutMap = new ArrayList<Map<String, Integer>>();
+            
+            tableHeadings.add( "Model Name" );
+            tableHeadings.add( "Total #" );
+            
+            int i = 0;
+            for( CCEMReportDesign ccemReportDesign1 :  reportDesignList )
+            {
+                i++;
+                if( i == 1 ) continue;
+                
+                
+                String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+                if( ccemCellContent1.split( ":" )[3].equalsIgnoreCase( "UNKNOWN" ))
+                {
+                    tableHeadings.add( "Unknown" );
+                    tableHeadings.add( "%" );
+                }
+                else if( ccemCellContent1.split( ":" )[4].equalsIgnoreCase( "MORE" ) )
+                {
+                    inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                    catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    Integer inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
+                    Integer ageStart = Integer.parseInt( ccemCellContent1.split( ":" )[3] );
+                    Integer ageEnd = -1;
+
+                    tableHeadings.add( ">"+(ageStart-1)+" Yrs" );
+                    tableHeadings.add( "%" );
+                    
+                    Map<String, Integer> catalogTypeAttributeValueMap1 = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId, inventoryTypeAttributeId, ageStart, ageEnd ) );
+                    outPutMap.add( catalogTypeAttributeValueMap1 );
+                }
+                else
+                {
+                    inventoryTypeId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                    catalogTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    Integer inventoryTypeAttributeId = Integer.parseInt( ccemCellContent1.split( ":" )[2] );
+                    Integer ageStart = Integer.parseInt( ccemCellContent1.split( ":" )[3] );
+                    Integer ageEnd = Integer.parseInt( ccemCellContent1.split( ":" )[4] );
+                    
+                    tableHeadings.add( ageStart+"-"+ageEnd+" Yrs" );
+                    tableHeadings.add( "%" );
+                    
+                    Map<String, Integer> catalogTypeAttributeValueMap1 = new HashMap<String, Integer>( ccemReportManager.getCatalogTypeAttributeValueByAge( orgUnitIdsByComma, inventoryTypeId, catalogTypeAttributeId, inventoryTypeAttributeId, ageStart, ageEnd ) );
+                    outPutMap.add( catalogTypeAttributeValueMap1 );
+                }
+            }
+            
+            Map<Integer, Integer> grandTotal = new HashMap<Integer, Integer>();
+            Integer temp = 0;
+            for( String modelName : catalogTypeAttributeValueMap.keySet() )
+            {
+                List<String> oneTableRowData = new ArrayList<String>();
+                oneTableRowData.add( modelName );
+                
+                Integer modelNameTotalCount = catalogTypeAttributeValueMap.get( modelName );
+                
+                if( modelNameTotalCount == null )
+                    modelNameTotalCount = 0;
+                
+                oneTableRowData.add( ""+modelNameTotalCount );
+                
+                Integer temp1 = grandTotal.get( 0 );
+                if( temp1 == null )
+                {
+                    grandTotal.put( 0, modelNameTotalCount );
+                }
+                else
+                {
+                    grandTotal.put( 0, temp1+modelNameTotalCount );
+                }
+                
+                Integer unknownCount = 0;
+                int rowNo = 1;
+                for( Map<String, Integer> tempMap : outPutMap )
+                {
+                    temp = tempMap.get( modelName );
+                    if( temp == null )
+                        temp = 0;
+                    
+                    oneTableRowData.add( ""+temp );
+                    try
+                    {
+                        double tempD =  ( (double) temp/modelNameTotalCount)*100.0;
+                        tempD = Math.round( tempD * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
+                        oneTableRowData.add( ""+tempD  );
+                    }
+                    catch( Exception e )
+                    {
+                        oneTableRowData.add( ""+0 );
+                    }
+                    
+                    temp1 = grandTotal.get( rowNo );
+                    if( temp1 == null )
+                    {
+                        grandTotal.put( rowNo, temp );
+                    }
+                    else
+                    {
+                        grandTotal.put( rowNo, temp1+temp );
+                    }
+                    
+                    unknownCount += temp;
+                    rowNo++;
+                }
+                
+                oneTableRowData.add( ""+(modelNameTotalCount-unknownCount) );
+
+                try
+                {
+                    double tempD =  ((modelNameTotalCount-unknownCount)/ (double) modelNameTotalCount)*100.0;
+                    
+                    tempD = Math.round( tempD * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
+                    
+                    oneTableRowData.add( ""+tempD  );
+                }
+                catch( Exception e )
+                {
+                    oneTableRowData.add( ""+0 );
+                }
+                
+                tableData.add( oneTableRowData );
+            }
+            
+            List<String> oneTableRowData = new ArrayList<String>();
+            
+            oneTableRowData.add( "Total" );
+            Integer totalCount = grandTotal.get( 0 );
+            if( totalCount == null )
+                totalCount = 0;
+            oneTableRowData.add( ""+totalCount );
+            
+            Integer grandTotalOfUnknown = 0; 
+            for( i = 1; i < grandTotal.size(); i++ )
+            {
+                temp = grandTotal.get( i );
+                
+                if( temp == null )
+                {
+                    temp = 0;
+                }
+                oneTableRowData.add( ""+temp );
+                try
+                {
+                    double tempD =  ((double)temp/totalCount)*100.0;
+                    tempD = Math.round( tempD * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
+                    oneTableRowData.add( ""+ tempD );
+                }
+                catch( Exception e )
+                {
+                    oneTableRowData.add( ""+0 );
+                }
+
+                grandTotalOfUnknown+= temp;
+            }
+            
+            oneTableRowData.add( ""+(totalCount-grandTotalOfUnknown) );
+            try
+            {
+                double tempD =  ((double)(totalCount-grandTotalOfUnknown)/totalCount)*100.0;
+                tempD = Math.round( tempD * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
+                oneTableRowData.add( ""+ tempD );
+            }
+            catch( Exception e )
+            {
+                oneTableRowData.add( ""+0 );
+            }
+            
+            tableData.add( oneTableRowData );
+            ccemReportOutput.setTableData( tableData );
+            ccemReportOutput.setTableHeadings( tableHeadings );  
+        }
+        else if( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
+        {
+            ccemReportOutput = new CCEMReportOutput();
+            List<String> tableHeadings = new ArrayList<String>();
+            List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
+            List<List<String>> tableData = new ArrayList<List<String>>();
+            
+            List<String> oneSubHeadingRow = new ArrayList<String>();
+            
+            Integer periodId = 0;
+            Date date = new Date();
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime( date );
+            String periodStartDate = "";
+            
+            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() );
+            
+            if( periodId == 0 )
+            {
+                ccemReportOutput.setReportHeading( "No Period Exists" );
+                return SUCCESS;
+            }
+            
+            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() );
+                
+                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 );
+            
+            for( Integer orgUnitGroupId : orgunitGroupList )
+            {
+                List<Integer> orgUnitIds = ccemReportManager.getOrgunitIds( selOrgUnitList, orgUnitGroupId );
+
+                if( orgUnitIds ==  null || orgUnitIds.size() <= 0 )
+                {
+                    
+                }
+                else
+                {
+                    OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+    
+                    List<String> oneTableDataRow = new ArrayList<String>();
+                    String orgUnitIdsBycomma = getCommaDelimitedString( orgUnitIds );
+                    
+                    oneTableDataRow.add( orgUnitGroup.getName() );
+                    
+                    oneTableDataRow.add( ""+orgUnitIds.size() );
+                    
+                    Map<String, Integer> dataValueCountMap = new HashMap<String, Integer>( ccemReportManager.getDataValueCountforDataElements( dataElementIdsByComma, optComboIdsByComma, periodId, orgUnitIdsBycomma ) );
+                    for( String dataElementOption : dataElementOptions )
+                    {
+                        Integer temp = dataValueCountMap.get( dataElementOption );
+                        if( temp == null )
+                        {
+                            temp = 0;
+                        }
+                        oneTableDataRow.add( ""+temp );
+                    }
+                    
+                    tableData.add( oneTableDataRow );
+                }
+            }
+            
+            ccemReportOutput.setTableData( tableData );
+            ccemReportOutput.setTableHeadings( tableHeadings );
+            ccemReportOutput.setTableSubHeadings( tableSubHeadings );
+        }
+        else if( ccemReport.getReportType().equals( CCEMReport.ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE ) )
+        {
+            ccemReportOutput = new CCEMReportOutput();
+            List<String> tableHeadings = new ArrayList<String>();
+            List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
+            List<String> oneSubHeadingRow = new ArrayList<String>();
+            List<List<String>> tableData = new ArrayList<List<String>>();
+            
+            Date date = new Date();
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime( date );
+            String periodStartDate = "";
+            String periodEndDate = "";
+            String periodIdsByComma = "";
+            List<Period> periodList = null;
+            PeriodType periodType = periodService.getPeriodTypeByName( ccemReport.getPeriodRequire() );
+            Date sDate = null;
+            Date eDate = null;
+            
+            int monthDays[] = {31,28,31,30,31,30,31,31,30,31,30,31};
+            
+            tableHeadings.add( "OrgUnit Hierarchy" );
+            oneSubHeadingRow.add( " " );
+            tableHeadings.add( "OrgUnit" );
+            oneSubHeadingRow.add( " " );
+            
+            if( periodRadio.equalsIgnoreCase( CCEMReport.CURRENT_YEAR ) )
+            {
+                periodStartDate = calendar.get( Calendar.YEAR ) + "-01-01";
+                periodEndDate = calendar.get( Calendar.YEAR ) + "-12-31";
+                sDate = format.parseDate( periodStartDate );
+                eDate = format.parseDate( periodEndDate );
+            }
+            else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_YEAR ) )
+            {
+               periodStartDate = (calendar.get( Calendar.YEAR )-1) + "-01-01";
+               periodEndDate = (calendar.get( Calendar.YEAR )-1) + "-12-31";
+               sDate = format.parseDate( periodStartDate );
+               eDate = format.parseDate( periodEndDate );
+            }
+            else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_6_MONTHS ) )
+            {
+                calendar.add( Calendar.MONTH, -1 );
+                calendar.set( Calendar.DATE, monthDays[calendar.get( Calendar.MONTH )] );
+                eDate = calendar.getTime();
+                
+                calendar.add( Calendar.MONTH, -5 );
+                calendar.set( Calendar.DATE, 1 );
+                sDate = calendar.getTime();
+            }
+            else if( periodRadio.equalsIgnoreCase( CCEMReport.LAST_3_MONTHS ) )
+            {
+                calendar.add( Calendar.MONTH, -1 );
+                calendar.set( Calendar.DATE, monthDays[calendar.get( Calendar.MONTH )] );
+                eDate = calendar.getTime();
+                
+                calendar.add( Calendar.MONTH, -2 );
+                calendar.set( Calendar.DATE, 1 );
+                sDate = calendar.getTime();
+            }
+            
+            periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( periodType, sDate, eDate ) );
+            Collection<Integer> periodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
+            periodIdsByComma = getCommaDelimitedString( periodIds );
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yy" );
+            System.out.println(simpleDateFormat.format( sDate) +" : "+ simpleDateFormat.format( eDate ) );
+            
+            String dataElementIdsByComma = "-1";
+            String optComboIdsByComma = "-1";
+            
+            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() );
+                int i = 0;
+                for( Period period : periodList )
+                {
+                    oneSubHeadingRow.add( simpleDateFormat.format( period.getStartDate() ) );
+                    if( i != 0 ) 
+                        tableHeadings.add( " " );
+                    i++;
+                }
+            }
+            
+            List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
+            List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>();
+            
+            for( Integer orgUnitGroupId : orgunitGroupList )
+            {
+                OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+                orgUnitGroupMembers.addAll( orgUnitGroup.getMembers() );
+            }
+            
+            for( Integer orgUnitId : selOrgUnitList )
+            {
+                orgUnitList.addAll( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
+            }
+            
+            orgUnitList.retainAll( orgUnitGroupMembers );
+            Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers(OrganisationUnit.class, orgUnitList ) );
+            orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
+            
+            Map<String, Integer> equipmentDataValueMap = new HashMap<String, Integer>( ccemReportManager.getFacilityWiseEquipmentRoutineData( orgUnitIdsByComma, periodIdsByComma, dataElementIdsByComma, optComboIdsByComma ) );
+            
+            for( OrganisationUnit orgUnit : orgUnitList )
+            {
+                List<String> oneTableDataRow = new ArrayList<String>();
+                String orgUnitBranch = "";
+                if( orgUnit.getParent() != null )
+                {
+                    orgUnitBranch = getOrgunitBranch( orgUnit.getParent() );
+                }
+                else
+                {
+                    orgUnitBranch = " ";
+                }
+                
+                oneTableDataRow.add( orgUnitBranch );
+                oneTableDataRow.add( orgUnit.getName() );
+                
+                for( CCEMReportDesign ccemReportDesign1 :  reportDesignList )
+                {                
+                    String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+                    Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
+                    Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    
+                    for( Period period : periodList )
+                    {
+                        Integer temp = equipmentDataValueMap.get( orgUnit.getId()+":"+dataElementId+":"+period.getId() );
+                        if( temp == null )
+                        {
+                            oneTableDataRow.add( " " );
+                        }
+                        else
+                        {
+                            oneTableDataRow.add( ""+temp );
+                        }
+                    }
+                }
+                
+                tableData.add( oneTableDataRow );
+            }
+            
+            tableSubHeadings.add( oneSubHeadingRow );
+            ccemReportOutput.setTableData( tableData );
+            ccemReportOutput.setTableHeadings( tableHeadings );
+            ccemReportOutput.setTableSubHeadings( tableSubHeadings );
+        }
+        
+        return SUCCESS;
+    }
+    
+    private String getOrgunitBranch( OrganisationUnit orgunit )
+    {
+        String hierarchyOrgunit = orgunit.getName();
+
+        while ( orgunit.getParent() != null )
+        {
+            hierarchyOrgunit = orgunit.getParent().getName() + " -> " + hierarchyOrgunit;
+
+            orgunit = orgunit.getParent();
+        }
+
+        return hierarchyOrgunit;
+    }
+}

=== 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-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-06-13 06:35:38 +0000
@@ -522,21 +522,33 @@
 		class="org.hisp.dhis.coldchain.catalog.action.ShowUploadCatalogTypeImageFormAction"
 		scope="prototype">
 		<property name="catalogTypeService" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
-	</bean>	
-		
+	</bean>
 
 	<bean id="org.hisp.dhis.coldchain.catalog.action.UploadCatalogTypeImageAction"
 		class="org.hisp.dhis.coldchain.catalog.action.UploadCatalogTypeImageAction"
 		scope="prototype">
 		<property name="catalogTypeService" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
-	</bean>			
-			
-	
+	</bean>
+				
 	<bean id="org.hisp.dhis.coldchain.catalog.action.ShowCatalogTypeImageAction"
 		class="org.hisp.dhis.coldchain.catalog.action.ShowCatalogTypeImageAction"
 		scope="prototype">
 		<property name="catalogTypeService" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
-	</bean>	
-	
-		
+	</bean>
+
+    <!-- CCEM Reports -->
+    <bean id="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction"
+        class="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction"
+        scope="prototype">
+        <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+    </bean> 
+    <bean id="org.hisp.dhis.coldchain.reports.action.GenerateCCEMReportAction"
+        class="org.hisp.dhis.coldchain.reports.action.GenerateCCEMReportAction"
+        scope="prototype">
+		<property name="ccemReportManager" ref="org.hisp.dhis.coldchain.reports.CCEMReportManager" />
+		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+    </bean> 
+			
 </beans>
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-06-06 10:13:06 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-06-13 06:35:38 +0000
@@ -116,4 +116,16 @@
 ccem_reports = CCEM Reports
 upload_image = Upload image
 upload_catalog_image = Upload catalog image
-working_status = Working status
\ No newline at end of file
+working_status = Working status
+
+ccem_reports_page = CCEM Reports
+ccem_reports_list = Report List
+ccem_reports_period_list = Period
+last_3months = Last 3 Months
+current_year = Current Year
+last_6months = Last 6 Months
+last_year = Last Year
+orgunit_group_list = Orgunit Group List
+selected_orgunit_list = Selected Orgunit List
+generate = Generate
+orgunit_tree = Orgunit Tree
\ 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-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-06-13 06:35:38 +0000
@@ -530,7 +530,6 @@
 		<param name="requiredAuthorities">F_CATALOG_UPDATE</param>
 	</action>	
 	
-
 	<action name="uploadCatalogTypeImage" class="org.hisp.dhis.coldchain.catalog.action.UploadCatalogTypeImageAction">
 		<result name="success" type="velocity">/main.vm</result>
 		<param name="menu">/dhis-web-coldchain/menu.vm</param>
@@ -538,11 +537,32 @@
 		<interceptor-ref name="fileUploadStack" />
 	</action>	
 			
-
-	
 	<action name="showCatalogTypeImage" class="org.hisp.dhis.coldchain.catalog.action.ShowCatalogTypeImageAction">
 		<result name="success" type="velocity">/content.vm</result>
 	</action>	
-			
+
+	<!-- CCEM Reports -->
+	<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>
+		<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="generateCCEMReport" class="org.hisp.dhis.coldchain.reports.action.GenerateCCEMReportAction">
+        <result name="success" type="velocity">/content.vm</result>
+        <param name="page">/dhis-web-coldchain/ccemReportOutput.vm</param>
+        <param name="requiredAuthorities">F_CCEM_REPORT</param>
+    </action>
+	
+	<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>
+		
 </package>
 </struts>
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addEquipmentForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addEquipmentForm.vm	2012-06-06 10:13:06 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addEquipmentForm.vm	2012-06-13 06:35:38 +0000
@@ -50,6 +50,17 @@
 			<td>$i18n.getString( "working_status" ) : </td>
 			<td><input type="checkbox"  id="workingStatus" name="workingStatus" checked="true" ></th>
 		</tr>	
+        <tr>
+            <td>$i18n.getString( "catalog" ) : </td>
+			<td>
+				<select  id="catalog" name="catalog" onChange="catalogDetails( this.value );">
+					<option value="">[$i18n.getString( "please_select" )]</option>
+					#foreach ($catalog in $catalogs )
+						<option value="$catalog.id" >$catalog.name</option>
+					#end
+				</select>
+			</td>			
+		</tr>
 
 		<!-- InventoryType Attributes  -->
 		<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportOutput.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportOutput.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportOutput.vm	2012-06-13 06:35:38 +0000
@@ -0,0 +1,57 @@
+
+<script>
+    
+    function exportToWorkBook()
+    {
+        document.getElementById('htmlCode').value = document.getElementById('formResult').innerHTML;
+        return true;
+    }
+    
+</script>
+
+#set( $tableHeadings = $ccemReportOutput.tableHeadings )
+#set( $tableSubHeadings = $ccemReportOutput.tableSubHeadings )
+#set( $tableData = $ccemReportOutput.tableData )
+
+<form id="form1" name="form1" action="exportToExcel.action" method="post" onsubmit="return exportToWorkBook()" target="_newtab">
+
+<div align="right">
+	<input type="submit" name="ExportToWorkBook" value="Export To WorkBook" style="width: 160; height: 25; font-family:Arial; font-weight:bold; color:#000000" />
+</div>
+
+<input type="hidden" name="htmlCode" id="htmlCode" />
+
+<div id="formResult" style="height:444px;width:650px;overflow:auto;">
+	<div align="center">$!ccemReportOutput.reportHeading</div>	
+	<table class="listTable" id="ccemReportOutput" >
+		<tr>
+			#foreach( $tableHeading in $tableHeadings )
+				<th>$tableHeading</th>
+			#end
+		</tr>
+		
+		#foreach( $oneSubHeadingRow in $tableSubHeadings )
+		<tr>
+			#foreach( $oneSubHeadingCellData in $oneSubHeadingRow )
+				<th>$oneSubHeadingCellData</th>
+			#end
+		</tr>   
+		#end
+	
+		#set( $mark = false )	
+		#foreach( $oneTableRowData in $tableData )
+		<tr #alternate($mark)>
+			#foreach( $oneTableCellData in $oneTableRowData )
+				<td>$oneTableCellData</td>
+			#end
+		</tr>
+		#set( $mark = !$mark)	
+		#end		
+	</table>
+</div>
+
+<script type="text/javascript">
+    jQuery(document).ready(function(){  
+        tableSorter( 'ccemReportOutput' );
+    });
+</script>
\ No newline at end of file

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportsPage.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportsPage.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/ccemReportsPage.vm	2012-06-13 06:35:38 +0000
@@ -0,0 +1,85 @@
+<script>
+    leftBar.hideAnimated();
+</script>
+
+<h3>$i18n.getString( "ccem_reports_page" )</h3>
+
+<form id="ccemReportForm" name="ccemReportForm" action="#" method="post" >
+	#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" disable />$i18n.getString( "last_3months" )
+							<input type="radio" id="periodRadio" name="periodRadio" value="CURRENT_YEAR" disable />$i18n.getString( "current_year" )<br/>
+							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_6_MONTHS" disable />$i18n.getString( "last_6months" )							
+                            <input type="radio" id="periodRadio" name="periodRadio" value="LAST_YEAR" disable />$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>
+                        <td>                            
+                            <input type="button" value='$i18n.getString( "generate" )' style="width: 200px;height: 25; font-family:Arial;font-weight:bold; color:#000000" onclick="javascript:generateCCEMReport()"/>
+                        </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>
+

=== added 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	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/ccemReports.js	2012-06-13 06:35:38 +0000
@@ -0,0 +1,198 @@
+// ----------------------------------------------------------------
+// Organisation Unit Selected
+// ----------------------------------------------------------------
+function organisationUnitSelected( orgUnits )
+{   
+	$.getJSON( 'getOrganisationUnit.action', {orgunitId:orgUnits[0]}
+        , function( json ) 
+        {
+            //json.message
+        	var flag = 0;
+            var orgUnitListBox = document.getElementById('selOrgUnitList');
+            for( var i = 0; i < orgUnitListBox.options.length; i++ )
+            {
+            	if( orgUnits[0] == orgUnitListBox.options[i].value ) 
+                {
+                	flag = 1;
+                	break;
+                }
+            }
+            
+            if( flag == 0 )
+            {
+            	orgUnitListBox.options[orgUnitListBox.options.length] = new Option( json.message, orgUnits[0], false, false);
+            }
+           
+        } );
+}
+
+selection.setListenerFunction( organisationUnitSelected );
+
+//----------------------------------------------------------------
+// Removes selected orgunits from orgunit list
+//----------------------------------------------------------------
+function remOUFunction()
+{
+    var orgUnitListBox = document.getElementById( "selOrgUnitList" );
+
+    for( var i = orgUnitListBox.options.length-1; i >= 0; i-- )
+    {
+        if( orgUnitListBox.options[i].selected )
+        {
+        	orgUnitListBox.options[i] = null;
+        }
+    }    
+}
+
+//----------------------------------------------------------------
+//Select all options in the list
+//----------------------------------------------------------------
+function selectAllOptionsInList( elementId )
+{
+    var element = document.getElementById( elementId );
+
+    for( var i = 0; i < element.options.length; i++ )
+    {
+        element.options[i].selected = true;
+    }    
+}
+
+//----------------------------------------------------------------
+// Enable/Disable radio options for period based on report selection
+//----------------------------------------------------------------
+function periodBox( reportId )
+{
+	if( document.getElementById( reportId ).value == "NO" )
+	{
+		document.forms[0].periodRadio[0].disabled=true;
+        document.forms[0].periodRadio[1].disabled=true;
+        document.forms[0].periodRadio[2].disabled=true;
+        document.forms[0].periodRadio[3].disabled=true;
+	}
+	else if( document.getElementById( reportId ).value == "Yearly" )
+	{
+        document.forms[0].periodRadio[0].disabled=true;
+        document.forms[0].periodRadio[1].disabled=false;
+        document.forms[0].periodRadio[2].disabled=true;
+        document.forms[0].periodRadio[3].disabled=false;
+	}
+    else if( document.getElementById( reportId ).value == "Monthly" )
+    {
+        document.forms[0].periodRadio[0].disabled=false;
+        document.forms[0].periodRadio[1].disabled=false;
+        document.forms[0].periodRadio[2].disabled=false;
+        document.forms[0].periodRadio[3].disabled=false;
+    }   
+}
+
+//----------------------------------------------------------------
+//CCEM Report Form validations
+//----------------------------------------------------------------
+function formValidations()
+{
+	var reportListBox = document.getElementById( "reportList" );
+	var ouGroupListBox = document.getElementById( "orgunitGroupList" );
+	var orgUnitListBox = document.getElementById( "selOrgUnitList" );
+	
+	var selPeriodOption = $( "input[name='periodRadio']:checked" ).val();
+	
+	selectAllOptionsInList( 'selOrgUnitList' );
+	
+	if( reportListBox.selectedIndex < 0 ) { alert( "Please select report" ); return false; }
+	else if( ouGroupListBox.selectedIndex < 0 ) { alert( "Please select orgunit group(s)" ); return false; }
+	else if( orgUnitListBox.selectedIndex < 0 ) { alert( "Please select orgunit(s)" ); return false; }	
+	else if( document.getElementById( reportListBox.options[reportListBox.selectedIndex].value ).value != "NO" ) 
+	{ 
+		if( selPeriodOption == null ) { alert( "Please select period" ); return false; }
+	}
+	
+	return true;
+}
+
+//----------------------------------------------------------------
+//Generate CCEM Report
+//----------------------------------------------------------------
+function generateCCEMReport()
+{
+	if( formValidations() )
+	{
+	
+		var reportListBox = document.getElementById( "reportList" );
+		
+		var selReportId = reportListBox.options[ reportListBox.selectedIndex ].value;
+		
+		var selPeriodOption = $( "input[name='periodRadio']:checked" ).val();
+		
+		hideById('resultContent');
+		
+		jQuery('#loaderDiv').show();
+		
+		var url = "generateCCEMReport.action?";
+		url += getParamStringForSelectedItems( 'selOrgUnitList', 'selOrgUnitList' ) + "&"
+		url += getParamStringForSelectedItems( 'orgunitGroupList', 'orgunitGroupList' ) + "&"
+		//url += "selReportId="+selReportId;
+	
+		jQuery('#resultContent').load(url,{
+			selReportId:selReportId,
+			periodRadio:selPeriodOption,
+			}, 
+			function()
+			{
+				showById('resultContent');
+				jQuery('#loaderDiv').hide();
+			});
+	}
+}
+
+//----------------------------------------------------------------
+//Get Params form Div
+//----------------------------------------------------------------
+
+function getParamStringForSelectedItems( elementId, param )
+{
+	 var result = "";
+	 var element = document.getElementById( elementId );
+	 
+	 var flag = 0;
+	 for( var i = 0; i < element.options.length; i++ )
+	 {
+		 if( element.options[i].selected ) 
+		 {
+			 result += param + "=" + element.options[i].value + "&";
+		 }
+	 }
+
+	 return result.substring( 0, result.length-1 );
+}
+
+//----------------------------------------------------------------
+//Get Params form Div
+//----------------------------------------------------------------
+
+function getParamsForDiv( selectedDiv )
+{
+	var params = '';
+	
+	jQuery("#" + selectedDiv + " :input").each(function()
+		{
+			var elementId = $(this).attr('id');
+			
+			if( $(this).attr('type') == 'checkbox' )
+			{
+				var checked = jQuery(this).attr('checked') ? true : false;
+				params += elementId + "=" + checked + "&";
+			}
+			else if( $(this).attr('type') != 'button' )
+			{
+				var value = "";
+				if( jQuery(this).val() != '' )
+				{
+					value = htmlEncode(jQuery(this).val());
+				}
+				params += elementId + "="+ value + "&";
+			}
+			
+		});
+	
+	return params;
+}

=== 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-05-24 06:15:24 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-06-13 06:35:38 +0000
@@ -19,5 +19,5 @@
 
 <h2>$i18n.getString( "ccem_reports" )</h2>
 <ul>
-    
+	<li><a href="ccemReportsPage.action">$i18n.getString( "ccem_reports_page" )</a></li>    
 </ul>

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm	2012-05-16 07:06:15 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm	2012-06-13 06:35:38 +0000
@@ -44,7 +44,17 @@
 			<td>$i18n.getString( "inventorytype" ) : </th>
 			<td>$equipmentInstance.inventoryType.name</th>
 		</tr>
-
+		<tr>
+			<td>$i18n.getString( "catalog" ) : </td>
+			<td>
+				<select id="catalog" name="catalog" onChange="catalogDetails( this.value );" >
+					<option value="">[$i18n.getString( "please_select" )]</option>
+					#foreach ($catalog in $catalogs )
+						<option value="$catalog.id" #if($equipmentInstance.catalog.id == $catalog.id) selected="selected" #end>$catalog.name</option>
+					#end
+				</select>
+			</td>
+		</tr>
 		<!-- InventoryType Attributes  -->
 		<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
 		<tr><th colspan="2" class="heading-column">$i18n.getString( "inventory_attribute_details" )</th></tr>

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/IDSPOutbreakAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/IDSPOutbreakAction.java	2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/IDSPOutbreakAction.java	2012-06-13 06:35:38 +0000
@@ -292,11 +292,20 @@
         
         navigationString = "IDSP Outbreak";
                 
-        String periodIdString = dashBoardService.getPeriodIdForIDSPOutBreak();
+        //String periodIdString = dashBoardService.getPeriodIdForIDSPOutBreak();
+        /**
+         * TODO commented periodIdString bec it gives error
+         */
+        String periodIdString = "";
         String periodId = periodIdString.split( "::" )[0];
         navigationString += " ( "+ periodIdString.split( "::" )[1] +" )";
         
-        String populationPeriodId = dashBoardService.getPeriodIdForIDSPPopulation();
+        
+        //String populationPeriodId = dashBoardService.getPeriodIdForIDSPPopulation();
+        /**
+         * TODO commented populationPeriodId bec it gives error
+         */
+        String populationPeriodId = "";
         
         normInfo = getNormInfoFromXML();
         

=== modified file 'local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java'
--- local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java	2012-03-19 06:11:45 +0000
+++ local/in/dhis-web-excelimport/src/main/java/org/hisp/dhis/excelimport/action/ExcelImportResultAction.java	2012-06-13 06:35:38 +0000
@@ -662,6 +662,8 @@
 
                 String value = "";
 
+                System.out.println( deCodeString );
+                
                 deAndComboMap = getDeAndCombo( deCodeString );
 
                 for ( DataElement de : deAndComboMap.keySet() )

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportFormAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportFormAction.java	2011-03-01 08:37:19 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportFormAction.java	2012-06-13 06:35:38 +0000
@@ -1,6 +1,7 @@
 package org.hisp.dhis.reports.nbits.action;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.hisp.dhis.program.Program;
@@ -39,6 +40,17 @@
     {
         programList = new ArrayList<Program>( programService.getAllPrograms() );
         
+        Iterator<Program> iterator = programList.iterator();
+        while( iterator.hasNext() )
+        {
+            Program program = iterator.next();
+            if( program.getOrganisationUnits() == null || program.getOrganisationUnits().size() <= 0 )
+                //|| program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
+            {
+                iterator.remove();
+            }
+        }
+        
         return SUCCESS;
     }
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java	2012-06-01 10:13:48 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/nbits/action/NBITSReportResultAction.java	2012-06-13 06:35:38 +0000
@@ -325,13 +325,11 @@
                     
                 }
             }
+            
             rowCount++;
             
             for( OrganisationUnit orgUnit : orgUnitList )
             {
-                
-               
-                
                 if( sDate != null && eDate != null)
                 {
                     query = "SELECT patient.patientid, programinstance.programinstanceid,programinstance.dateofincident,programinstance.enrollmentdate FROM programinstance INNER JOIN patient " +
@@ -352,6 +350,7 @@
                 }
 
                 SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
+                
                 if ( sqlResultSet != null )
                 {
                     int count = 1;
@@ -514,8 +513,8 @@
                             for( DataElement dataElement : programStageDataElementMap.get( programStage ) )
                             {
                                 query = "SELECT value from patientdatavalue WHERE programstageinstanceid = " + programStageInstanceId + 
-                                                " AND dataelementid = " + dataElement.getId() + 
-                                                " AND organisationunitid = " + orgUnit.getId(); 
+                                                " AND dataelementid = " + dataElement.getId(); 
+                                                //" AND organisationunitid = " + orgUnit.getId(); 
 
                                 SqlRowSet sqlResultSet3 = jdbcTemplate.queryForRowSet( query );