← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2442: Cleaning Code: Aggregation Report Section

 

------------------------------------------------------------
revno: 2442
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2010-12-29 17:49:53 +0530
message:
  Cleaning Code: Aggregation Report Section
modified:
  local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserFormAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/routine/action/GenerateRoutineReportAnalyserResultAction.java
  local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/aggregationReportAnalysisFront.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2010-12-29 07:57:25 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2010-12-29 12:19:53 +0000
@@ -130,7 +130,6 @@
         this.organisationUnitService = organisationUnitService;
     }
     
-    int deFlag2;
     // -------------------------------------------------------------------------
     // Report_in
     // -------------------------------------------------------------------------
@@ -560,9 +559,8 @@
     public String getResultDataValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit , String reportModelTB )
     {
         int deFlag1 = 0;
-        //int deFlag2 = 0;
         int isAggregated = 0;
-       
+
         try
         {
             Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
@@ -594,34 +592,28 @@
                     matcher.appendReplacement( buffer, replaceString );
                     continue;
                 }
-               // if ( dataElement.getType().equalsIgnoreCase( "int" ) )
-                if ( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )   
+                if ( dataElement.getType().equalsIgnoreCase( "int" ) )
                 {
-                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo, startDate, endDate, organisationUnit );
-                   
-                    //System.out.println( "dataelement id is : " + dataElementId + ", option combo id is : " + optionComboId  );
-                    //System.out.println( "Start date is  : " + startDate + ", end date is  : " + endDate + ", orgunit is : " + organisationUnit.getName() + ", aggvalue is : " + aggregatedValue );
+                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
+                        startDate, endDate, organisationUnit );
+                    System.out.println( dataElement.getId() + " : " + optionCombo.getId() + " : " + startDate + " : " + endDate + " : " + organisationUnit + " : " + aggregatedValue);
                     if ( aggregatedValue == null )
                     {
-                        //System.out.println( "Aggregated value is null" );
                         replaceString = NULL_REPLACEMENT;
-                        deFlag2 = 0;
                     }
                     else
                     {
                         replaceString = String.valueOf( aggregatedValue );
-                       // System.out.println( " Aggregated value is not null : "  + replaceString );
-                        deFlag2 = 1;
+
                         isAggregated = 1;
                     }
                 }
                 else
                 {
                     deFlag1 = 1;
-                    deFlag2 = 0;
                     PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType(
-                        dePeriodType, startDate, endDate ) );
+                    //List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( dePeriodType, startDate, endDate ) );
                     Period tempPeriod = new Period();
                     if ( periodList == null || periodList.isEmpty() )
                     {
@@ -657,7 +649,7 @@
             }
 
             matcher.appendTail( buffer );
-
+            
             if ( deFlag1 == 0 )
             {
                 double d = 0.0;
@@ -692,17 +684,15 @@
 
                     // These line are to display non financial data that do not
                     // require decimals
-                    
-                   if ( !(reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" )) )
+                    if ( !(reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" )) )
                     {
-                       resultValue = "" + (int) d;
-                   }
+                        resultValue = "" + (int) d;
+                    }
                 }
 
             }
             else
             {
-                deFlag2 = 0;
                 resultValue = buffer.toString();
             }
 
@@ -716,7 +706,6 @@
                 resultValue = " ";
             }
 
-            //System.out.println( "result value is : " + resultValue );
             return resultValue;
         }
         catch ( NumberFormatException ex )
@@ -760,16 +749,16 @@
 
                 if ( dataElement == null || optionCombo == null )
                 {
-                    //System.out.println( "dataelement id is : " + dataElementId + ", option combo id is : " + optionComboId );
                     replaceString = "";
                     matcher.appendReplacement( buffer, replaceString );
                     continue;
                 }
-                if ( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
+                if ( dataElement.getType().equalsIgnoreCase( "int" ) )
                 {
 
                     PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    //List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( dePeriodType, startDate, endDate ) );
 
                     if ( periodList == null || periodList.isEmpty() )
                     {
@@ -799,7 +788,8 @@
                 {
                     deFlag1 = 1;
                     PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    //List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( dePeriodType, startDate, endDate ) );
                     Period tempPeriod = new Period();
                     if ( periodList == null || periodList.isEmpty() )
                     {
@@ -893,7 +883,7 @@
             {
                 resultValue = " ";
             }
-           // System.out.println( resultValue );
+
             return resultValue;
         }
         catch ( NumberFormatException ex )
@@ -942,8 +932,8 @@
                     deFlag1 = 1;
                     deFlag2 = 0;
                     PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType(
-                        dePeriodType, startDate, endDate ) );
+                    //List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType( dePeriodType, startDate, endDate ) );
+                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( dePeriodType, startDate, endDate ) );
                     Period tempPeriod = new Period();
                     if ( periodList == null || periodList.isEmpty() )
                     {

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserFormAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserFormAction.java	2010-08-28 10:15:38 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserFormAction.java	2010-12-29 12:19:53 +0000
@@ -1,12 +1,8 @@
 package org.hisp.dhis.reports.aggregation.action;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-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 org.hisp.dhis.reports.ReportType;
@@ -27,46 +23,10 @@
         this.periodService = periodService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    public OrganisationUnitService getOrganisationUnitService()
-    {
-        return organisationUnitService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Constants
-    // -------------------------------------------------------------------------
-    
-    private final int ALL = 0;
-
-    public int getALL()
-    {
-        return ALL;
-    }
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
     
-    private Collection<OrganisationUnit> organisationUnits;
-
-    public Collection<OrganisationUnit> getOrganisationUnits()
-    {
-        return organisationUnits;
-    }
-
-    private Collection<Period> periods = new ArrayList<Period>();
-
-    public Collection<Period> getPeriods()
-    {
-        return periods;
-    }
-
     private Collection<PeriodType> periodTypes;
 
     public Collection<PeriodType> getPeriodTypes()
@@ -81,33 +41,29 @@
         return reportTypeName;
     }
     
-    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
     
-    
     public String execute()
         throws Exception
     {
-        /* Report Info */
         reportTypeName = ReportType.RT_AGGREGATION;
         
-        /* Period Info */
         periodTypes = periodService.getAllPeriodTypes();
 
-        Iterator<PeriodType> alldeIterator = periodTypes.iterator();
-        while ( alldeIterator.hasNext() )
+        // Filtering Periodtypes other than Daily, Monthly, Quarterly and Yearly
+        Iterator<PeriodType> periodTypeIterator = periodTypes.iterator();
+        while ( periodTypeIterator.hasNext() )
         {
-            PeriodType type = alldeIterator.next();
-            if ( type.getName().equalsIgnoreCase( "Monthly" ) || type.getName().equalsIgnoreCase( "quarterly" )
+            PeriodType type = periodTypeIterator.next();
+            if ( type.getName().equalsIgnoreCase( "daily" ) || type.getName().equalsIgnoreCase( "Monthly" ) || type.getName().equalsIgnoreCase( "quarterly" )
                 || type.getName().equalsIgnoreCase( "yearly" ) )
             {
-                periods.addAll( periodService.getPeriodsByPeriodType( type ) );
             }
             else
             {
-                alldeIterator.remove();
+                periodTypeIterator.remove();
             }
         }
 

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java	2010-11-26 12:48:06 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/aggregation/action/GenerateAggregationReportAnalyserResultAction.java	2010-12-29 12:19:53 +0000
@@ -7,17 +7,11 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 
 import jxl.CellType;
 import jxl.Workbook;
@@ -25,7 +19,6 @@
 import jxl.format.Border;
 import jxl.format.BorderLineStyle;
 import jxl.format.CellFormat;
-import jxl.format.VerticalAlignment;
 import jxl.write.Blank;
 import jxl.write.Label;
 import jxl.write.Number;
@@ -35,43 +28,21 @@
 import jxl.write.WritableWorkbook;
 
 import org.amplecode.quick.StatementManager;
-import org.apache.velocity.tools.generic.MathTool;
-import org.hisp.dhis.aggregation.AggregationService;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
-import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.reports.ReportService;
 import org.hisp.dhis.reports.Report_in;
-import org.hisp.dhis.system.util.MathUtils;
-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 org.hisp.dhis.reports.Report_inDesign;
 
 import com.opensymphony.xwork2.Action;
 
 public class GenerateAggregationReportAnalyserResultAction
     implements Action
 {
-
-    private static final String NULL_REPLACEMENT = "0";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -82,13 +53,6 @@
         this.statementManager = statementManager;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
     private ReportService reportService;
 
     public void setReportService( ReportService reportService )
@@ -103,13 +67,6 @@
         this.periodService = periodService;
     }
 
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
     private OrganisationUnitService organisationUnitService;
 
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -117,40 +74,6 @@
         this.organisationUnitService = organisationUnitService;
     }
 
-    public OrganisationUnitService getOrganisationUnitService()
-    {
-        return organisationUnitService;
-    }
-
-    private AggregationService aggregationService;
-
-    public void setAggregationService( AggregationService aggregationService )
-    {
-        this.aggregationService = aggregationService;
-    }
-
-    private IndicatorService indicatorService;
-
-    public void setIndicatorService( IndicatorService indicatorService )
-    {
-        this.indicatorService = indicatorService;
-    }
-
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-
-    private DataElementCategoryService dataElementCategoryOptionComboService;
-
-    public void setDataElementCategoryOptionComboService(
-        DataElementCategoryService dataElementCategoryOptionComboService )
-    {
-        this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
-    }
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -160,14 +83,8 @@
 
     // -------------------------------------------------------------------------
     // Properties
-    /*
-     * //
-     * -------------------------------------------------------------------------
-     * private PeriodStore periodStore;
-     * 
-     * public void setPeriodStore( PeriodStore periodStore ) { this.periodStore
-     * = periodStore; }
-     */
+    // -------------------------------------------------------------------------
+
     private InputStream inputStream;
 
     public InputStream getInputStream()
@@ -175,11 +92,6 @@
         return inputStream;
     }
 
-    /*
-     * private String contentType;
-     * 
-     * public String getContentType() { return contentType; }
-     */
     private String fileName;
 
     public String getFileName()
@@ -187,90 +99,6 @@
         return fileName;
     }
 
-    /*
-     * private int bufferSize;
-     * 
-     * public int getBufferSize() { return bufferSize; }
-     */
-    private MathTool mathTool;
-
-    public MathTool getMathTool()
-    {
-        return mathTool;
-    }
-
-    // private OrganisationUnit selectedOrgUnit;
-    // public OrganisationUnit getSelectedOrgUnit()
-    // {
-    // return selectedOrgUnit;
-    // }
-    private List<OrganisationUnit> orgUnitList;
-
-    public List<OrganisationUnit> getOrgUnitList()
-    {
-        return orgUnitList;
-    }
-
-    private List<String> dataValueList;
-
-    public List<String> getDataValueList()
-    {
-        return dataValueList;
-    }
-
-    private List<String> services;
-
-    public List<String> getServices()
-    {
-        return services;
-    }
-
-    private List<String> slNos;
-
-    public List<String> getSlNos()
-    {
-        return slNos;
-    }
-
-    private SimpleDateFormat simpleDateFormat;
-
-    public SimpleDateFormat getSimpleDateFormat()
-    {
-        return simpleDateFormat;
-    }
-
-    private SimpleDateFormat monthFormat;
-
-    public SimpleDateFormat getMonthFormat()
-    {
-        return monthFormat;
-    }
-
-    private SimpleDateFormat simpleMonthFormat;
-
-    public SimpleDateFormat getSimpleMonthFormat()
-    {
-        return simpleMonthFormat;
-    }
-
-    private SimpleDateFormat yearFormat;
-
-    public SimpleDateFormat getYearFormat()
-    {
-        return yearFormat;
-    }
-
-    private SimpleDateFormat simpleYearFormat;
-
-    public SimpleDateFormat getSimpleYearFormat()
-    {
-        return simpleYearFormat;
-    }
-
-    private List<String> deCodeType;
-
-    private List<String> serviceType;
-
     private String reportFileNameTB;
 
     public void setReportFileNameTB( String reportFileNameTB )
@@ -278,11 +106,11 @@
         this.reportFileNameTB = reportFileNameTB;
     }
 
-    private String reportModelTB;
+    private int ouIDTB;
 
-    public void setReportModelTB( String reportModelTB )
+    public void setOuIDTB( int ouIDTB )
     {
-        this.reportModelTB = reportModelTB;
+        this.ouIDTB = ouIDTB;
     }
 
     private String reportList;
@@ -306,32 +134,6 @@
         this.endDate = endDate;
     }
 
-    private Period selectedPeriod;
-
-    public Period getSelectedPeriod()
-    {
-        return selectedPeriod;
-    }
-
-    /*
-     * private List<String> orgUnitListCB;
-     * 
-     * public void setOrgUnitListCB( List<String> orgUnitListCB ) {
-     * this.orgUnitListCB = orgUnitListCB; }
-     */
-    private int ouIDTB;
-
-    public void setOuIDTB( int ouIDTB )
-    {
-        this.ouIDTB = ouIDTB;
-    }
-
-    /*
-     * private int availablePeriods;
-     * 
-     * public void setAvailablePeriods( int availablePeriods ) {
-     * this.availablePeriods = availablePeriods; }
-     */
     private String aggCB;
 
     public void setAggCB( String aggCB )
@@ -339,13 +141,16 @@
         this.aggCB = aggCB;
     }
 
-    // private Hashtable<String, String> serviceList;
-
-    private List<Integer> sheetList;
-
-    private List<Integer> rowList;
-
-    private List<Integer> colList;
+    private String periodTypeId;
+
+    public void setPeriodTypeId( String periodTypeId )
+    {
+        this.periodTypeId = periodTypeId;
+    }
+
+    private String reportModelTB;
+
+    private List<OrganisationUnit> orgUnitList;
 
     private Date sDate;
 
@@ -357,47 +162,8 @@
 
     private PeriodType periodType;
 
-    public PeriodType getPeriodType()
-    {
-        return periodType;
-    }
-
-    private String periodTypeId;
-
-    public void setPeriodTypeId( String periodTypeId )
-    {
-        this.periodTypeId = periodTypeId;
-    }
-
-    private String periodTypeIdTB;
-
-    public String setPeriodTypeIdTB()
-    {
-        return periodTypeIdTB;
-    }
-
-    private List<Period> periods;
-
-    public List<Period> getPeriods()
-    {
-        return periods;
-    }
-
-    // private List<Integer> totalOrgUnitsCountList;
-
     private String raFolderName;
 
-    private List<OrganisationUnit> childOrgUnits;
-
-    public List<OrganisationUnit> getChildOrgUnits()
-    {
-        return childOrgUnits;
-    }
-
-    private int deFlag1;
-
-    private int deFlag2;
-
     private Integer monthCount;
 
     // -------------------------------------------------------------------------
@@ -406,26 +172,17 @@
     public String execute()
         throws Exception
     {
-
-        deFlag1 = 0;
-        deFlag2 = 0;
         statementManager.initialise();
+        
         // Initialization
         raFolderName = reportService.getRAFolderName();
-        double tempNum = 0;
-
-        mathTool = new MathTool();
-        services = new ArrayList<String>();
-        slNos = new ArrayList<String>();
-        deCodeType = new ArrayList<String>();
-        serviceType = new ArrayList<String>();
-        // totalOrgUnitsCountList = new ArrayList<Integer>();
         String deCodesXMLFileName = "";
-        simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
-        monthFormat = new SimpleDateFormat( "MMMM" );
-        simpleMonthFormat = new SimpleDateFormat( "MMM" );
-        yearFormat = new SimpleDateFormat( "yyyy" );
-        simpleYearFormat = new SimpleDateFormat( "yy" );
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
+        SimpleDateFormat dayFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        SimpleDateFormat monthFormat = new SimpleDateFormat( "MMMM" );
+        SimpleDateFormat simpleMonthFormat = new SimpleDateFormat( "MMM" );
+        SimpleDateFormat yearFormat = new SimpleDateFormat( "yyyy" );
+        SimpleDateFormat simpleYearFormat = new SimpleDateFormat( "yy" );
 
         Report_in selReportObj = reportService.getReport( Integer.parseInt( reportList ) );
 
@@ -433,41 +190,24 @@
         reportModelTB = selReportObj.getModel();
         reportFileNameTB = selReportObj.getExcelTemplateName();
 
-        System.out.println( reportModelTB + " : " + reportFileNameTB + " : " + deCodesXMLFileName );
-
-        System.out.println( "Report Generation Start Time is : \t" + new Date() );
-
         String parentUnit = "";
 
-        sheetList = new ArrayList<Integer>();
-        rowList = new ArrayList<Integer>();
-        colList = new ArrayList<Integer>();
-
-        String inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
-            + "template" + File.separator + reportFileNameTB;
-        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
-            + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
-        Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
-
-        WritableWorkbook outputReportWorkbook = Workbook
-            .createWorkbook( new File( outputReportPath ), templateWorkbook );
-
-        if ( reportModelTB.equalsIgnoreCase( "DYNAMIC-ORGUNIT" ) )
+        String inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "template" + File.separator + reportFileNameTB;
+        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
+
+        if( reportModelTB.equalsIgnoreCase( "DYNAMIC-ORGUNIT" ) )
         {
             OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
             orgUnitList = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
             Collections.sort( orgUnitList, new OrganisationUnitNameComparator() );
         }
-
-        if ( reportModelTB.equalsIgnoreCase( "STATIC" ) )
+        else if( reportModelTB.equalsIgnoreCase( "STATIC" ) || reportModelTB.equalsIgnoreCase( "STATIC-DATAELEMENTS" ) || reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" ) )
         {
             orgUnitList = new ArrayList<OrganisationUnit>();
             OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
             orgUnitList.add( orgUnit );
-
         }
-
-        if ( reportModelTB.equalsIgnoreCase( "dynamicwithrootfacility" ) )
+        else if( reportModelTB.equalsIgnoreCase( "dynamicwithrootfacility" ) )
         {
             OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
             orgUnitList = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
@@ -475,1263 +215,454 @@
             orgUnitList.add( orgUnit );
 
             parentUnit = orgUnit.getName();
-
-        }
-
-        if ( reportModelTB.equalsIgnoreCase( "STATIC-DATAELEMENTS" ) )
-        {
-            orgUnitList = new ArrayList<OrganisationUnit>();
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
-            orgUnitList.add( orgUnit );
-        }
-
-        if ( reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" ) )
-        {
-            orgUnitList = new ArrayList<OrganisationUnit>();
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
-            orgUnitList.add( orgUnit );
-        }
-
-        if ( reportModelTB.equalsIgnoreCase( "INDICATOR-AGAINST-PARENT" ) )
-        {
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
-            // OrganisationUnit parent = orgUnit.getParent();
-            orgUnitList = new ArrayList<OrganisationUnit>();
-
-            Collections.sort( orgUnitList, new OrganisationUnitNameComparator() );
-
-            // orgUnitList.add( 0, parent );
-
-            orgUnitList.add( orgUnit );
-
-        }
-        if ( reportModelTB.equalsIgnoreCase( "INDICATOR-AGAINST-SIBLINGS" ) )
-        {
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
-
-            orgUnitList = new ArrayList<OrganisationUnit>();
-
-            orgUnitList.addAll( orgUnit.getChildren() );
-
-            Collections.sort( orgUnitList, new OrganisationUnitNameComparator() );
-
-            orgUnitList.add( 0, orgUnit );
-        }
-
-        if ( reportModelTB.equalsIgnoreCase( "INDICATOR-FOR-FEEDBACK" ) )
-        {
-            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
-
-            orgUnitList = new ArrayList<OrganisationUnit>();
-
-            orgUnitList.addAll( orgUnit.getChildren() );
-
-            Collections.sort( orgUnitList, new OrganisationUnitNameComparator() );
-
-            orgUnitList.add( 0, orgUnit );
-        }
-
-        // selectedPeriod = periodService.getPeriod( availablePeriods );
-
+        }
+
+        System.out.println( orgUnitList.get( 0 ).getName()+ " : " + selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
+ 
         sDate = format.parseDate( startDate );
 
         eDate = format.parseDate( endDate );
 
-        simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
+        Calendar tempStartDate = Calendar.getInstance();
+        Calendar tempEndDate = Calendar.getInstance();
+        tempStartDate.setTime( sDate );
+        tempEndDate.setTime( eDate );
+
+        Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
+
+        WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook );
 
         // Getting DataValues
-        dataValueList = new ArrayList<String>();
-        List<String> deCodesList = getDECodes( deCodesXMLFileName );
+        List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
+        int orgUnitCount = 0;
 
         Iterator<OrganisationUnit> it = orgUnitList.iterator();
-        int orgUnitCount = 0;
-        int orgUnitGroupCount = 0;
-
-        int rowCounter = 0;
-
-        //----------------------------------------------------------------------
-        // -----------------------------
-        // Feedback without orgunit START
-        // This part is for generating feedback reports for orgunits without any
-        // children
-        //----------------------------------------------------------------------
-        // -----------------------------
-
-        OrganisationUnit checkChildOrgunit = new OrganisationUnit();
-
-        checkChildOrgunit = organisationUnitService.getOrganisationUnit( ouIDTB );
-
-        childOrgUnits = new ArrayList<OrganisationUnit>();
-
-        childOrgUnits.addAll( checkChildOrgunit.getChildren() );
-
-        int children = 1;
-
-        if ( reportModelTB.equalsIgnoreCase( "INDICATOR-FOR-FEEDBACK" )
-            && (childOrgUnits == null || childOrgUnits.size() == 0) )
-        {
-            children = 0;
-        }
-
-        if ( children == 0 )
-        {
-            // int quarterPeriod = 0;
-
-            OrganisationUnit currentOrgUnit = (OrganisationUnit) it.next();
-
-            Iterator<String> it1 = deCodesList.iterator();
-            int count1 = 0;
-
-            while ( it1.hasNext() )
-            {
-                String deCodeString = (String) it1.next();
-
-                String deType = (String) deCodeType.get( count1 );
-                // String sType = (String) serviceType.get( count1 );
-                // int count = 0;
-                // double sum = 0.0;
-                // int flag1 = 0;
-                String tempStr = "";
-
-                Calendar tempStartDate = Calendar.getInstance();
-                Calendar tempEndDate = Calendar.getInstance();
-                List<Calendar> calendarList = new ArrayList<Calendar>( getStartingEndingPeriods( deType ) );
-                if ( calendarList == null || calendarList.isEmpty() )
-                {
-                    tempStartDate.setTime( sDate );
-                    tempEndDate.setTime( eDate );
-                    return SUCCESS;
-                }
-                else
-                {
-                    tempStartDate = calendarList.get( 0 );
-                    tempEndDate = calendarList.get( 1 );
-                }
-
-                if ( deCodeString.equalsIgnoreCase( "FACILITY" ) )
-                {
-                    tempStr = "";
-
-                }
-                else
-                {
-                    if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
-                    {
-                        tempStr = currentOrgUnit.getName();
-
-                    }
-                    else
-                    {
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                        {
-                            OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                            orgUnitP = currentOrgUnit.getParent();
-
-                            tempStr = orgUnitP.getName();
-
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                            {
-                                OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                                OrganisationUnit orgUnitPP = new OrganisationUnit();
-
-                                orgUnitP = currentOrgUnit.getParent();
-
-                                orgUnitPP = orgUnitP.getParent();
-
-                                tempStr = orgUnitPP.getName();
-
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                {
-                                    OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                                    OrganisationUnit orgUnitPP = new OrganisationUnit();
-
-                                    OrganisationUnit orgUnitPPP = new OrganisationUnit();
-
-                                    orgUnitP = currentOrgUnit.getParent();
-
-                                    orgUnitPP = orgUnitP.getParent();
-
-                                    orgUnitPPP = orgUnitPP.getParent();
-
-                                    tempStr = orgUnitPPP.getName();
-
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "PERIOD-MONTH" ) )
-                                    {
-                                        tempStr = monthFormat.format( sDate );
-
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-
-                                            sDateTemp = sDate;
-
-                                            eDateTemp = eDate;
-
-                                            Calendar tempQuarterYear = Calendar.getInstance();
-
-                                            String startYear = "";
-
-                                            String endYear = "";
-
-                                            String startMonth = "";
-
-                                            startMonth = monthFormat.format( sDateTemp );
-
-                                            // periodService.getPeriod(
-                                            // periodTypeIdTB );
-
-                                            periodType = periodService.getPeriodTypeByName( periodTypeId );
-                                            // periodType =
-                                            // selectedPeriod.getPeriodType();
-
-                                            tempQuarterYear.setTime( sDateTemp );
-
-                                            if ( (startMonth.equalsIgnoreCase( "January" )
-                                                || startMonth.equalsIgnoreCase( "February" ) || startMonth
-                                                .equalsIgnoreCase( "March" )) )
-                                            {
-                                                tempQuarterYear.roll( Calendar.YEAR, -1 );
-
-                                                sDateTemp = tempQuarterYear.getTime();
-
-                                            }
-
-                                            startYear = yearFormat.format( sDateTemp );
-
-                                            tempQuarterYear.setTime( eDateTemp );
-
-                                            if ( !(startMonth.equalsIgnoreCase( "January" )
-                                                || startMonth.equalsIgnoreCase( "February" ) || startMonth
-                                                .equalsIgnoreCase( "March" )) )
-                                            {
-                                                tempQuarterYear.roll( Calendar.YEAR, 1 );
-
-                                                eDateTemp = tempQuarterYear.getTime();
-
-                                            }
-                                            endYear = yearFormat.format( eDateTemp );
-
-                                            tempStr = startYear + " - " + endYear;
-
-                                        }
-                                        else
-                                        {
-                                            tempStr = "";
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-
-                WritableCellFormat wCellformat = new WritableCellFormat();
-                wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                wCellformat.setWrap( true );
-                wCellformat.setAlignment( Alignment.CENTRE );
-
-                int tempRowNo = rowList.get( count1 );
-                int tempColNo = colList.get( count1 );
-                int sheetNo = sheetList.get( count1 ) + orgUnitGroupCount;
-                WritableSheet sheet0 = outputReportWorkbook.getSheet( sheetNo );
-
-                if ( tempStr == null || tempStr.equals( " " ) )
-                {
-                    sheet0.addCell( new Blank( tempColNo, tempRowNo, wCellformat ) );
-                }
-
-                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-
-                count1++;
-            }
-
-        }
-
-        //----------------------------------------------------------------------
-        // -----------------------------
-        // Feedback without orgunit END
-        //----------------------------------------------------------------------
-        // -----------------------------
-
-        //----------------------------------------------------------------------
-        // -----------------------------
-        // All other reports START
-        //----------------------------------------------------------------------
-        // -----------------------------
-
-        while ( it.hasNext() && children != 0 )
-        {
-
-            // int quarterPeriod = 0;
-
-            OrganisationUnit currentOrgUnit = (OrganisationUnit) it.next();
-
-            Iterator<String> it1 = deCodesList.iterator();
-            int count1 = 0;
-            while ( it1.hasNext() )
-            {
-                String deCodeString = (String) it1.next();
-
-                String deType = (String) deCodeType.get( count1 );
-                String sType = (String) serviceType.get( count1 );
-                // int count = 0;
-                // double sum = 0.0;
-                // int flag1 = 0;
-                String tempStr = "";
-
-                Calendar tempStartDate = Calendar.getInstance();
-                Calendar tempEndDate = Calendar.getInstance();
-                List<Calendar> calendarList = new ArrayList<Calendar>( getStartingEndingPeriods( deType ) );
-                if ( calendarList == null || calendarList.isEmpty() )
-                {
-                    tempStartDate.setTime( sDate );
-                    tempEndDate.setTime( eDate );
-                    return SUCCESS;
-                }
-                else
-                {
-                    tempStartDate = calendarList.get( 0 );
-                    tempEndDate = calendarList.get( 1 );
-                }
-
-                if ( deCodeString.equalsIgnoreCase( "FACILITY" ) )
+        while ( it.hasNext() )
+        {
+            OrganisationUnit currentOrgUnit = (OrganisationUnit) it.next();
+
+            int count1 = 0;
+
+            Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
+            while ( reportDesignIterator.hasNext() )
+            {
+                Report_inDesign report_inDesign = (Report_inDesign) reportDesignIterator.next();
+
+                String sType = report_inDesign.getStype();
+                String deCodeString = report_inDesign.getExpression();
+                String tempStr = "";
+
+                if( deCodeString.equalsIgnoreCase( "FACILITY" ) )
                 {
                     tempStr = currentOrgUnit.getName();
-
                 }
-                else if ( deCodeString.equalsIgnoreCase( "MONTHCOUNT" ) )
+                else if( deCodeString.equalsIgnoreCase( "MONTHCOUNT" ) )
                 {
-
                     int endYear = tempEndDate.get( Calendar.YEAR );
                     int startYear = tempStartDate.get( Calendar.YEAR );
                     int endMonth = tempEndDate.get( Calendar.MONTH );
                     int startMonth = tempStartDate.get( Calendar.MONTH );
 
                     monthCount = ((endYear - startYear) * 12) - startMonth + endMonth + 1;
-                    System.out.println( "MonthCount : " + monthCount );
-
                     tempStr = monthCount.toString();
-
+                }
+                else if( deCodeString.equalsIgnoreCase( "FACILITY-NOREPEAT" ) )
+                {
+                    tempStr = parentUnit;
+                }
+                else if( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
+                {
+                    tempStr = currentOrgUnit.getParent().getName();
+                }
+                else if( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
+                {
+                    tempStr = currentOrgUnit.getParent().getParent().getName();
+                }
+                else if( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
+                {
+                    tempStr = currentOrgUnit.getParent().getParent().getParent().getName();
+                }
+                else if( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
+                {
+                    tempStr = currentOrgUnit.getParent().getParent().getParent().getParent().getName();
+                }
+                else if( deCodeString.equalsIgnoreCase( "PERIOD" ) || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" ) )
+                {
+                    tempStr = simpleDateFormat.format( sDate );
+                }
+                else if( deCodeString.equalsIgnoreCase( "PERIODSDED" ) )
+                {
+                    tempStr = simpleDateFormat.format( sDate ) + " To " + simpleDateFormat.format( eDate );
+                }
+                else if( deCodeString.equalsIgnoreCase( "DATE-START-END" ) )
+                {
+                    tempStr = dayFormat.format( sDate ) + " To " + dayFormat.format( eDate );
+                }
+                else if( deCodeString.equalsIgnoreCase( "PERIOD-MONTH" ) )
+                {
+                    tempStr = monthFormat.format( sDate );
+                }
+                else if( deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" ) )
+                {
+                    tempStr = simpleMonthFormat.format( sDate );
+                }
+                else if( deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" ) )
+                {
+                    tempStr = simpleMonthFormat.format( eDate );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "MONTH-START" ) )
+                {
+                    tempStr = monthFormat.format( sDate );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "MONTH-END" ) )
+                {
+                    tempStr = monthFormat.format( eDate );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "PERIOD-WEEK" ) )
+                {
+                    tempStr = String.valueOf( tempStartDate.get( Calendar.WEEK_OF_MONTH ) );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+
+                    if( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "Quarter I";
+                    }
+                    else if( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "Quarter II";
+                    }
+                    else if( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "Quarter III";
+                    }
+                    else
+                    {
+                        tempStr = "Quarter IV";
+                    }
+                }
+                else if( deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+
+                    if ( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "Q1";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "Q2";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "Q3";
+                    }
+                    else
+                    {
+                        tempStr = "Q4";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+
+                    if ( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "Apr - Jun";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "Jul - Sep";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "Oct - Dec";
+                    }
+                    else
+                    {
+                        tempStr = "Jan - Mar";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+
+                    if ( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "April - June";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "July - September";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "October - December";
+                    }
+                    else
+                    {
+                        tempStr = "January - March";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+    
+                    if ( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "Apr";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "Jul";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "Oct";
+                    }
+                    else
+                    {
+                        tempStr = "Jan";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-START" ) )
+                {
+                    String startMonth = monthFormat.format( sDate );
+
+                    if ( startMonth.equalsIgnoreCase( "April" ) )
+                    {
+                        tempStr = "April";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "July" ) )
+                    {
+                        tempStr = "July";
+                    }
+                    else if ( startMonth.equalsIgnoreCase( "October" ) )
+                    {
+                        tempStr = "October";
+                    }
+                    else
+                    {
+                        tempStr = "January";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" ) )
+                {
+                    String endMonth = monthFormat.format( eDate );
+
+                    if ( endMonth.equalsIgnoreCase( "June" ) )
+                    {
+                        tempStr = "Jun";
+                    }
+                    else if ( endMonth.equalsIgnoreCase( "September" ) )
+                    {
+                        tempStr = "Sep";
+                    }
+                    else if ( endMonth.equalsIgnoreCase( "December" ) )
+                    {
+                        tempStr = "Dec";
+                    }
+                    else
+                    {
+                        tempStr = "Mar";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "QUARTER-END" ) )
+                {
+                    String endMonth = monthFormat.format( eDate );
+
+                    if ( endMonth.equalsIgnoreCase( "June" ) )
+                    {
+                        tempStr = "June";
+                    }
+                    else if ( endMonth.equalsIgnoreCase( "September" ) )
+                    {
+                        tempStr = "September";
+                    }
+                    else if ( endMonth.equalsIgnoreCase( "December" ) )
+                    {
+                        tempStr = "December";
+                    }
+                    else
+                    {
+                        tempStr = "March";
+                    }
+                }
+                else if ( deCodeString.equalsIgnoreCase( "PERIOD-YEAR" ) )
+                {
+                    sDateTemp = sDate;
+
+                    Calendar tempQuarterYear = Calendar.getInstance();
+
+                    tempQuarterYear.setTime( sDateTemp );
+
+                    String startMonth = monthFormat.format( sDateTemp );
+
+                    periodType = periodService.getPeriodTypeByName( periodTypeId );
+
+                    if ( periodType.getName().equalsIgnoreCase("Yearly" ) )
+                    {
+                        sDateTemp = sDate;
+                    }
+                    else if ( (startMonth.equalsIgnoreCase( "January" ) || startMonth.equalsIgnoreCase( "February" ) || startMonth.equalsIgnoreCase( "March" )) && periodType.getName().equalsIgnoreCase("Quarterly" ) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, -1 );
+                        sDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    tempStr = yearFormat.format( sDateTemp );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" ) )
+                {
+                    sDateTemp = sDate;
+
+                    Calendar tempQuarterYear = Calendar.getInstance();
+
+                    tempQuarterYear.setTime( sDateTemp );
+
+                    String startMonth = "";
+
+                    startMonth = monthFormat.format( sDateTemp );
+
+                    periodType = periodService.getPeriodTypeByName( periodTypeId );
+
+                    if ( periodType.getName().equalsIgnoreCase( "Yearly" ) )
+                    {
+                        sDateTemp = sDate;
+                    }
+                    else if ( (startMonth.equalsIgnoreCase( "January" ) || startMonth.equalsIgnoreCase( "February" ) || startMonth.equalsIgnoreCase( "March" ))
+                            && periodType.getName().equalsIgnoreCase( "Quarterly" ) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, -1 );
+                        sDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    tempStr = simpleYearFormat.format( sDateTemp );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "YEAR-END" ) )
+                {
+                    sDateTemp = sDate;
+
+                    Calendar tempQuarterYear = Calendar.getInstance();
+
+                    tempQuarterYear.setTime( sDate );
+
+                    sDate = tempQuarterYear.getTime();
+
+                    String startMonth = "";
+
+                    startMonth = monthFormat.format( sDateTemp );
+
+                    periodType = periodService.getPeriodTypeByName( periodTypeId );
+
+                    if ( periodType.getName().equalsIgnoreCase( "Yearly" ) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, 1 );
+                        sDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    if ( !(startMonth.equalsIgnoreCase( "January" ) || startMonth.equalsIgnoreCase( "February" ) || startMonth.equalsIgnoreCase( "March" )) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, 1 );
+                        sDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    tempStr = yearFormat.format( sDateTemp );
+                }
+                else if ( deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
+                {
+                    sDateTemp = sDate;
+
+                    eDateTemp = eDate;
+
+                    Calendar tempQuarterYear = Calendar.getInstance();
+
+                    String startYear = "";
+
+                    String endYear = "";
+
+                    String startMonth = monthFormat.format( sDateTemp );
+
+                    System.out.println( "The value for periodType is " + periodTypeId );
+
+                    periodType = periodService.getPeriodTypeByName( periodTypeId );
+
+                    tempQuarterYear.setTime( sDateTemp );
+
+                    if ( periodType.getName().equalsIgnoreCase( "Yearly" ) )
+                    {
+                        sDateTemp = sDate;
+                    }
+                    else if ( (startMonth.equalsIgnoreCase( "January" ) || startMonth.equalsIgnoreCase( "February" ) || startMonth.equalsIgnoreCase( "March" )) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, -1 );
+
+                        sDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    startYear = yearFormat.format( sDateTemp );
+
+                    tempQuarterYear.setTime( eDateTemp );
+
+                    if ( periodType.getName().equalsIgnoreCase( "Yearly" ) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, 1 );
+
+                        eDateTemp = tempQuarterYear.getTime();
+                    }
+
+                    if ( !(startMonth.equalsIgnoreCase( "January" ) || startMonth.equalsIgnoreCase( "February" ) || startMonth.equalsIgnoreCase( "March" )) )
+                    {
+                        tempQuarterYear.roll( Calendar.YEAR, 1 );
+
+                        eDateTemp = tempQuarterYear.getTime();
+                    }
+                    endYear = yearFormat.format( eDateTemp );
+
+                    tempStr = startYear + " - " + endYear;
+                }
+                else if ( deCodeString.equalsIgnoreCase( "SLNO" ) )
+                {
+                    tempStr = "" + (orgUnitCount + 1);
+                }
+                else if ( deCodeString.equalsIgnoreCase( "NA" ) )
+                {
+                    tempStr = " ";
                 }
                 else
                 {
-                    if ( deCodeString.equalsIgnoreCase( "FACILITY-NOREPEAT" ) )
+                    if( sType.equalsIgnoreCase( "dataelement" ) )
                     {
-                        tempStr = parentUnit;
+                        if ( aggCB == null )
+                        {
+                            tempStr = reportService.getIndividualResultDataValue(deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
+                        } 
+                        else
+                        {
+                            tempStr = reportService.getResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
+                        }
                     }
                     else
                     {
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
+                        if ( aggCB == null )
                         {
-                            tempStr = currentOrgUnit.getParent().getName();
-
-                        }
+                            tempStr = reportService.getIndividualResultIndicatorValue( deCodeString, tempStartDate.getTime(), tempEndDate.getTime(), currentOrgUnit );
+                        } 
                         else
                         {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                                OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                                orgUnitP = currentOrgUnit.getParent();
-
-                                tempStr = orgUnitP.getParent().getName();
-
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                    OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                                    OrganisationUnit orgUnitPP = new OrganisationUnit();
-
-                                    orgUnitP = currentOrgUnit.getParent();
-
-                                    orgUnitPP = orgUnitP.getParent();
-
-                                    tempStr = orgUnitPP.getParent().getName();
-
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                        OrganisationUnit orgUnitP = new OrganisationUnit();
-
-                                        OrganisationUnit orgUnitPP = new OrganisationUnit();
-
-                                        OrganisationUnit orgUnitPPP = new OrganisationUnit();
-
-                                        orgUnitP = currentOrgUnit.getParent();
-
-                                        orgUnitPP = orgUnitP.getParent();
-
-                                        orgUnitPPP = orgUnitPP.getParent();
-
-                                        tempStr = orgUnitPPP.getParent().getName();
-
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" ) )
-                                        {
-                                            tempStr = simpleDateFormat.format( sDate );
-
-                                        }
-                                        else if ( deCodeString.equalsIgnoreCase( "PERIODSDED" ) )
-                                        {
-                                            tempStr = simpleDateFormat.format( sDate ) + " To "
-                                                + simpleDateFormat.format( eDate );
-                                        }
-                                        else
-                                        {
-                                            if ( deCodeString.equalsIgnoreCase( "PERIOD-MONTH" ) )
-                                            {
-                                                tempStr = monthFormat.format( sDate );
-
-                                            }
-                                            else
-                                            {
-                                                if ( deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" ) )
-                                                {
-                                                    tempStr = simpleMonthFormat.format( sDate );
-
-                                                }
-                                                else
-                                                {
-                                                    if ( deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" ) )
-                                                    {
-                                                        tempStr = simpleMonthFormat.format( eDate );
-
-                                                    }
-                                                    else
-                                                    {
-                                                        if ( deCodeString.equalsIgnoreCase( "MONTH-START" ) )
-                                                        {
-                                                            tempStr = monthFormat.format( sDate );
-
-                                                        }
-                                                        else
-                                                        {
-                                                            if ( deCodeString.equalsIgnoreCase( "MONTH-END" ) )
-                                                            {
-                                                                tempStr = monthFormat.format( eDate );
-
-                                                            }
-                                                            else
-                                                            {
-                                                                if ( deCodeString.equalsIgnoreCase( "PERIOD-WEEK" ) )
-                                                                {
-                                                                    tempStr = String.valueOf( tempStartDate
-                                                                        .get( Calendar.WEEK_OF_MONTH ) );
-
-                                                                }
-                                                                else
-                                                                {
-                                                                    if ( deCodeString
-                                                                        .equalsIgnoreCase( "PERIOD-QUARTER" ) )
-                                                                    {
-                                                                        String startMonth = "";
-
-                                                                        startMonth = monthFormat.format( sDate );
-
-                                                                        if ( startMonth.equalsIgnoreCase( "April" ) )
-                                                                        {
-                                                                            tempStr = "Quarter I";
-                                                                        }
-                                                                        else
-                                                                        {
-                                                                            if ( startMonth.equalsIgnoreCase( "July" ) )
-                                                                            {
-                                                                                tempStr = "Quarter II";
-                                                                            }
-                                                                            else
-                                                                            {
-                                                                                if ( startMonth
-                                                                                    .equalsIgnoreCase( "October" ) )
-                                                                                {
-                                                                                    tempStr = "Quarter III";
-                                                                                }
-                                                                                else
-                                                                                {
-                                                                                    tempStr = "Quarter IV";
-
-                                                                                    // quarterPeriod
-                                                                                    // =
-                                                                                    // 1
-                                                                                    // ;
-
-                                                                                }
-                                                                            }
-                                                                        }
-                                                                    }
-                                                                    else
-                                                                    {
-                                                                        if ( deCodeString
-                                                                            .equalsIgnoreCase( "SIMPLE-QUARTER" ) )
-                                                                        {
-                                                                            String startMonth = "";
-
-                                                                            startMonth = monthFormat.format( sDate );
-
-                                                                            if ( startMonth.equalsIgnoreCase( "April" ) )
-                                                                            {
-                                                                                tempStr = "Q1";
-                                                                            }
-                                                                            else
-                                                                            {
-                                                                                if ( startMonth
-                                                                                    .equalsIgnoreCase( "July" ) )
-                                                                                {
-                                                                                    tempStr = "Q2";
-                                                                                }
-                                                                                else
-                                                                                {
-                                                                                    if ( startMonth
-                                                                                        .equalsIgnoreCase( "October" ) )
-                                                                                    {
-                                                                                        tempStr = "Q3";
-                                                                                    }
-                                                                                    else
-                                                                                    {
-                                                                                        tempStr = "Q4";
-
-                                                                                        // quarterPeriod
-                                                                                        // =
-                                                                                        // 1
-                                                                                        // ;
-
-                                                                                    }
-                                                                                }
-                                                                            }
-                                                                        }
-                                                                        else
-                                                                        {
-                                                                            if ( deCodeString
-                                                                                .equalsIgnoreCase( "QUARTER-MONTHS-SHORT" ) )
-                                                                            {
-                                                                                String startMonth = "";
-
-                                                                                startMonth = monthFormat.format( sDate );
-
-                                                                                if ( startMonth
-                                                                                    .equalsIgnoreCase( "April" ) )
-                                                                                {
-                                                                                    tempStr = "Apr - Jun";
-                                                                                }
-                                                                                else
-                                                                                {
-                                                                                    if ( startMonth
-                                                                                        .equalsIgnoreCase( "July" ) )
-                                                                                    {
-                                                                                        tempStr = "Jul - Sep";
-                                                                                    }
-                                                                                    else
-                                                                                    {
-                                                                                        if ( startMonth
-                                                                                            .equalsIgnoreCase( "October" ) )
-                                                                                        {
-                                                                                            tempStr = "Oct - Dec";
-                                                                                        }
-                                                                                        else
-                                                                                        {
-                                                                                            tempStr = "Jan - Mar";
-
-                                                                                            // quarterPeriod
-                                                                                            // =
-                                                                                            // 1
-                                                                                            // ;
-
-                                                                                        }
-                                                                                    }
-                                                                                }
-                                                                            }
-                                                                            else
-                                                                            {
-                                                                                if ( deCodeString
-                                                                                    .equalsIgnoreCase( "QUARTER-MONTHS" ) )
-                                                                                {
-                                                                                    String startMonth = "";
-
-                                                                                    startMonth = monthFormat
-                                                                                        .format( sDate );
-
-                                                                                    if ( startMonth
-                                                                                        .equalsIgnoreCase( "April" ) )
-                                                                                    {
-                                                                                        tempStr = "April - June";
-                                                                                    }
-                                                                                    else
-                                                                                    {
-                                                                                        if ( startMonth
-                                                                                            .equalsIgnoreCase( "July" ) )
-                                                                                        {
-                                                                                            tempStr = "July - September";
-                                                                                        }
-                                                                                        else
-                                                                                        {
-                                                                                            if ( startMonth
-                                                                                                .equalsIgnoreCase( "October" ) )
-                                                                                            {
-                                                                                                tempStr = "October - December";
-                                                                                            }
-                                                                                            else
-                                                                                            {
-                                                                                                tempStr = "January - March";
-
-                                                                                                // quarterPeriod
-                                                                                                // =
-                                                                                                // 1
-                                                                                                // ;
-
-                                                                                            }
-                                                                                        }
-                                                                                    }
-                                                                                }
-                                                                                else
-                                                                                {
-                                                                                    if ( deCodeString
-                                                                                        .equalsIgnoreCase( "QUARTER-START-SHORT" ) )
-                                                                                    {
-                                                                                        String startMonth = "";
-
-                                                                                        startMonth = monthFormat
-                                                                                            .format( sDate );
-
-                                                                                        if ( startMonth
-                                                                                            .equalsIgnoreCase( "April" ) )
-                                                                                        {
-                                                                                            tempStr = "Apr";
-                                                                                        }
-                                                                                        else
-                                                                                        {
-                                                                                            if ( startMonth
-                                                                                                .equalsIgnoreCase( "July" ) )
-                                                                                            {
-                                                                                                tempStr = "Jul";
-                                                                                            }
-                                                                                            else
-                                                                                            {
-                                                                                                if ( startMonth
-                                                                                                    .equalsIgnoreCase( "October" ) )
-                                                                                                {
-                                                                                                    tempStr = "Oct";
-                                                                                                }
-                                                                                                else
-                                                                                                {
-                                                                                                    tempStr = "Jan";
-
-                                                                                                    // quarterPeriod
-                                                                                                    // =
-                                                                                                    // 1
-                                                                                                    // ;
-
-                                                                                                }
-                                                                                            }
-                                                                                        }
-                                                                                    }
-                                                                                    else
-                                                                                    {
-                                                                                        if ( deCodeString
-                                                                                            .equalsIgnoreCase( "QUARTER-START" ) )
-                                                                                        {
-                                                                                            String startMonth = "";
-
-                                                                                            startMonth = monthFormat
-                                                                                                .format( sDate );
-
-                                                                                            if ( startMonth
-                                                                                                .equalsIgnoreCase( "April" ) )
-                                                                                            {
-                                                                                                tempStr = "April";
-                                                                                            }
-                                                                                            else
-                                                                                            {
-                                                                                                if ( startMonth
-                                                                                                    .equalsIgnoreCase( "July" ) )
-                                                                                                {
-                                                                                                    tempStr = "July";
-                                                                                                }
-                                                                                                else
-                                                                                                {
-                                                                                                    if ( startMonth
-                                                                                                        .equalsIgnoreCase( "October" ) )
-                                                                                                    {
-                                                                                                        tempStr = "October";
-                                                                                                    }
-                                                                                                    else
-                                                                                                    {
-                                                                                                        tempStr = "January";
-
-                                                                                                        // quarterPeriod
-                                                                                                        // =
-                                                                                                        // 1
-                                                                                                        // ;
-
-                                                                                                    }
-                                                                                                }
-                                                                                            }
-                                                                                        }
-                                                                                        else
-                                                                                        {
-                                                                                            if ( deCodeString
-                                                                                                .equalsIgnoreCase( "QUARTER-END-SHORT" ) )
-                                                                                            {
-                                                                                                String endMonth = "";
-
-                                                                                                endMonth = monthFormat
-                                                                                                    .format( eDate );
-
-                                                                                                if ( endMonth
-                                                                                                    .equalsIgnoreCase( "June" ) )
-                                                                                                {
-                                                                                                    tempStr = "Jun";
-                                                                                                }
-                                                                                                else
-                                                                                                {
-                                                                                                    if ( endMonth
-                                                                                                        .equalsIgnoreCase( "September" ) )
-                                                                                                    {
-                                                                                                        tempStr = "Sep";
-                                                                                                    }
-                                                                                                    else
-                                                                                                    {
-                                                                                                        if ( endMonth
-                                                                                                            .equalsIgnoreCase( "December" ) )
-                                                                                                        {
-                                                                                                            tempStr = "Dec";
-                                                                                                        }
-                                                                                                        else
-                                                                                                        {
-                                                                                                            tempStr = "Mar";
-
-                                                                                                            // quarterPeriod
-                                                                                                            // =
-                                                                                                            // 1
-                                                                                                            // ;
-
-                                                                                                        }
-                                                                                                    }
-                                                                                                }
-                                                                                            }
-                                                                                            else
-                                                                                            {
-                                                                                                if ( deCodeString
-                                                                                                    .equalsIgnoreCase( "QUARTER-END" ) )
-                                                                                                {
-                                                                                                    String endMonth = "";
-
-                                                                                                    endMonth = monthFormat
-                                                                                                        .format( eDate );
-
-                                                                                                    if ( endMonth
-                                                                                                        .equalsIgnoreCase( "June" ) )
-                                                                                                    {
-                                                                                                        tempStr = "June";
-                                                                                                    }
-                                                                                                    else
-                                                                                                    {
-                                                                                                        if ( endMonth
-                                                                                                            .equalsIgnoreCase( "September" ) )
-                                                                                                        {
-                                                                                                            tempStr = "September";
-                                                                                                        }
-                                                                                                        else
-                                                                                                        {
-                                                                                                            if ( endMonth
-                                                                                                                .equalsIgnoreCase( "December" ) )
-                                                                                                            {
-                                                                                                                tempStr = "December";
-                                                                                                            }
-                                                                                                            else
-                                                                                                            {
-                                                                                                                tempStr = "March";
-
-                                                                                                                // quarterPeriod
-                                                                                                                // =
-                                                                                                                // 1
-                                                                                                                // ;
-
-                                                                                                            }
-                                                                                                        }
-                                                                                                    }
-                                                                                                }
-                                                                                                else
-                                                                                                {
-                                                                                                    if ( deCodeString
-                                                                                                        .equalsIgnoreCase( "PERIOD-YEAR" ) )
-                                                                                                    {
-                                                                                                        sDateTemp = sDate;
-
-                                                                                                        Calendar tempQuarterYear = Calendar
-                                                                                                            .getInstance();
-
-                                                                                                        tempQuarterYear
-                                                                                                            .setTime( sDateTemp );
-
-                                                                                                        String startMonth = "";
-
-                                                                                                        startMonth = monthFormat
-                                                                                                            .format( sDateTemp );
-
-                                                                                                        periodType = periodService
-                                                                                                            .getPeriodTypeByName( periodTypeId );
-
-                                                                                                        if ( periodType
-                                                                                                            .getName()
-                                                                                                            .equalsIgnoreCase(
-                                                                                                                "Yearly" ) )
-                                                                                                        {
-                                                                                                            sDateTemp = sDate;
-                                                                                                        }
-                                                                                                        else
-                                                                                                        {
-                                                                                                            if ( (startMonth
-                                                                                                                .equalsIgnoreCase( "January" )
-                                                                                                                || startMonth
-                                                                                                                    .equalsIgnoreCase( "February" ) || startMonth
-                                                                                                                .equalsIgnoreCase( "March" ))
-                                                                                                                && periodType
-                                                                                                                    .getName()
-                                                                                                                    .equalsIgnoreCase(
-                                                                                                                        "Quarterly" ) )
-                                                                                                            {
-                                                                                                                tempQuarterYear
-                                                                                                                    .roll(
-                                                                                                                        Calendar.YEAR,
-                                                                                                                        -1 );
-
-                                                                                                                sDateTemp = tempQuarterYear
-                                                                                                                    .getTime();
-
-                                                                                                            }
-                                                                                                        }
-
-                                                                                                        tempStr = yearFormat
-                                                                                                            .format( sDateTemp );
-                                                                                                    }
-                                                                                                    else
-                                                                                                    {
-                                                                                                        if ( deCodeString
-                                                                                                            .equalsIgnoreCase( "SIMPLE-YEAR" ) )
-                                                                                                        {
-                                                                                                            sDateTemp = sDate;
-
-                                                                                                            Calendar tempQuarterYear = Calendar
-                                                                                                                .getInstance();
-
-                                                                                                            tempQuarterYear
-                                                                                                                .setTime( sDateTemp );
-
-                                                                                                            String startMonth = "";
-
-                                                                                                            startMonth = monthFormat
-                                                                                                                .format( sDateTemp );
-
-                                                                                                            periodType = periodService
-                                                                                                                .getPeriodTypeByName( periodTypeId );
-
-                                                                                                            if ( periodType
-                                                                                                                .getName()
-                                                                                                                .equalsIgnoreCase(
-                                                                                                                    "Yearly" ) )
-                                                                                                            {
-                                                                                                                sDateTemp = sDate;
-                                                                                                            }
-                                                                                                            else
-                                                                                                            {
-                                                                                                                if ( (startMonth
-                                                                                                                    .equalsIgnoreCase( "January" )
-                                                                                                                    || startMonth
-                                                                                                                        .equalsIgnoreCase( "February" ) || startMonth
-                                                                                                                    .equalsIgnoreCase( "March" ))
-                                                                                                                    && periodType
-                                                                                                                        .getName()
-                                                                                                                        .equalsIgnoreCase(
-                                                                                                                            "Quarterly" ) )
-                                                                                                                {
-                                                                                                                    tempQuarterYear
-                                                                                                                        .roll(
-                                                                                                                            Calendar.YEAR,
-                                                                                                                            -1 );
-
-                                                                                                                    sDateTemp = tempQuarterYear
-                                                                                                                        .getTime();
-
-                                                                                                                }
-                                                                                                            }
-
-                                                                                                            tempStr = simpleYearFormat
-                                                                                                                .format( sDateTemp );
-                                                                                                        }
-                                                                                                        else
-                                                                                                        {
-                                                                                                            if ( deCodeString
-                                                                                                                .equalsIgnoreCase( "YEAR-END" ) )
-                                                                                                            {
-
-                                                                                                                sDateTemp = sDate;
-
-                                                                                                                Calendar tempQuarterYear = Calendar
-                                                                                                                    .getInstance();
-
-                                                                                                                tempQuarterYear
-                                                                                                                    .setTime( sDate );
-
-                                                                                                                sDate = tempQuarterYear
-                                                                                                                    .getTime();
-
-                                                                                                                String startMonth = "";
-
-                                                                                                                startMonth = monthFormat
-                                                                                                                    .format( sDateTemp );
-
-                                                                                                                periodType = periodService
-                                                                                                                    .getPeriodTypeByName( periodTypeId );
-
-                                                                                                                if ( periodType
-                                                                                                                    .getName()
-                                                                                                                    .equalsIgnoreCase(
-                                                                                                                        "Yearly" ) )
-                                                                                                                {
-                                                                                                                    tempQuarterYear
-                                                                                                                        .roll(
-                                                                                                                            Calendar.YEAR,
-                                                                                                                            1 );
-
-                                                                                                                    sDateTemp = tempQuarterYear
-                                                                                                                        .getTime();
-
-                                                                                                                }
-
-                                                                                                                if ( !(startMonth
-                                                                                                                    .equalsIgnoreCase( "January" )
-                                                                                                                    || startMonth
-                                                                                                                        .equalsIgnoreCase( "February" ) || startMonth
-                                                                                                                    .equalsIgnoreCase( "March" )) )
-                                                                                                                {
-                                                                                                                    tempQuarterYear
-                                                                                                                        .roll(
-                                                                                                                            Calendar.YEAR,
-                                                                                                                            1 );
-
-                                                                                                                    sDateTemp = tempQuarterYear
-                                                                                                                        .getTime();
-
-                                                                                                                }
-
-                                                                                                                tempStr = yearFormat
-                                                                                                                    .format( sDateTemp );
-                                                                                                            }
-                                                                                                            else
-                                                                                                            {
-                                                                                                                if ( deCodeString
-                                                                                                                    .equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                                                                                                {
-
-                                                                                                                    sDateTemp = sDate;
-
-                                                                                                                    eDateTemp = eDate;
-
-                                                                                                                    Calendar tempQuarterYear = Calendar
-                                                                                                                        .getInstance();
-
-                                                                                                                    String startYear = "";
-
-                                                                                                                    String endYear = "";
-
-                                                                                                                    String startMonth = "";
-
-                                                                                                                    startMonth = monthFormat
-                                                                                                                        .format( sDateTemp );
-
-                                                                                                                    System.out
-                                                                                                                        .println( "The value for periodType is "
-                                                                                                                            + periodTypeId );
-
-                                                                                                                    periodType = periodService
-                                                                                                                        .getPeriodTypeByName( periodTypeId );
-
-                                                                                                                    tempQuarterYear
-                                                                                                                        .setTime( sDateTemp );
-
-                                                                                                                    if ( periodType
-                                                                                                                        .getName()
-                                                                                                                        .equalsIgnoreCase(
-                                                                                                                            "Yearly" ) )
-                                                                                                                    {
-                                                                                                                        sDateTemp = sDate;
-                                                                                                                    }
-                                                                                                                    else
-                                                                                                                    {
-                                                                                                                        if ( (startMonth
-                                                                                                                            .equalsIgnoreCase( "January" )
-                                                                                                                            || startMonth
-                                                                                                                                .equalsIgnoreCase( "February" ) || startMonth
-                                                                                                                            .equalsIgnoreCase( "March" )) )
-                                                                                                                        {
-                                                                                                                            tempQuarterYear
-                                                                                                                                .roll(
-                                                                                                                                    Calendar.YEAR,
-                                                                                                                                    -1 );
-
-                                                                                                                            sDateTemp = tempQuarterYear
-                                                                                                                                .getTime();
-
-                                                                                                                        }
-                                                                                                                    }
-
-                                                                                                                    startYear = yearFormat
-                                                                                                                        .format( sDateTemp );
-
-                                                                                                                    tempQuarterYear
-                                                                                                                        .setTime( eDateTemp );
-
-                                                                                                                    if ( periodType
-                                                                                                                        .getName()
-                                                                                                                        .equalsIgnoreCase(
-                                                                                                                            "Yearly" ) )
-                                                                                                                    {
-                                                                                                                        tempQuarterYear
-                                                                                                                            .roll(
-                                                                                                                                Calendar.YEAR,
-                                                                                                                                1 );
-
-                                                                                                                        eDateTemp = tempQuarterYear
-                                                                                                                            .getTime();
-                                                                                                                    }
-
-                                                                                                                    if ( !(startMonth
-                                                                                                                        .equalsIgnoreCase( "January" )
-                                                                                                                        || startMonth
-                                                                                                                            .equalsIgnoreCase( "February" ) || startMonth
-                                                                                                                        .equalsIgnoreCase( "March" )) )
-                                                                                                                    {
-                                                                                                                        tempQuarterYear
-                                                                                                                            .roll(
-                                                                                                                                Calendar.YEAR,
-                                                                                                                                1 );
-
-                                                                                                                        eDateTemp = tempQuarterYear
-                                                                                                                            .getTime();
-
-                                                                                                                    }
-                                                                                                                    endYear = yearFormat
-                                                                                                                        .format( eDateTemp );
-
-                                                                                                                    tempStr = startYear
-                                                                                                                        + " - "
-                                                                                                                        + endYear;
-
-                                                                                                                }
-                                                                                                                else
-                                                                                                                {
-                                                                                                                    if ( deCodeString
-                                                                                                                        .equalsIgnoreCase( "SLNO" ) )
-                                                                                                                    {
-                                                                                                                        tempStr = ""
-                                                                                                                            + (orgUnitCount + 1);
-                                                                                                                    }
-                                                                                                                    else
-                                                                                                                    {
-                                                                                                                        if ( deCodeString
-                                                                                                                            .equalsIgnoreCase( "NA" ) )
-                                                                                                                        {
-                                                                                                                            tempStr = " ";
-                                                                                                                        }
-                                                                                                                        else
-                                                                                                                        {
-                                                                                                                            rowCounter += 1;
-
-                                                                                                                            if ( sType
-                                                                                                                                .equalsIgnoreCase( "dataelement" ) )
-                                                                                                                            {
-                                                                                                                                if ( aggCB == null )
-                                                                                                                                {
-                                                                                                                                    tempStr = getIndividualResultDataValue(
-                                                                                                                                        deCodeString,
-                                                                                                                                        tempStartDate
-                                                                                                                                            .getTime(),
-                                                                                                                                        tempEndDate
-                                                                                                                                            .getTime(),
-                                                                                                                                        currentOrgUnit );
-                                                                                                                                }
-                                                                                                                                else
-                                                                                                                                {
-                                                                                                                                    tempStr = getResultDataValue(
-                                                                                                                                        deCodeString,
-                                                                                                                                        tempStartDate
-                                                                                                                                            .getTime(),
-                                                                                                                                        tempEndDate
-                                                                                                                                            .getTime(),
-                                                                                                                                        currentOrgUnit );
-                                                                                                                                }
-                                                                                                                                if ( deFlag2 == 1 )
-                                                                                                                                {
-                                                                                                                                    try
-                                                                                                                                    {
-                                                                                                                                        tempNum = Double
-                                                                                                                                            .parseDouble( tempStr );
-                                                                                                                                    }
-                                                                                                                                    catch ( Exception ex )
-                                                                                                                                    {
-                                                                                                                                        tempNum = 0;
-                                                                                                                                    }
-
-                                                                                                                                }
-                                                                                                                            }
-                                                                                                                            else
-                                                                                                                            {
-                                                                                                                                if ( sType
-                                                                                                                                    .equalsIgnoreCase( "indicator-parent" ) )
-                                                                                                                                {
-                                                                                                                                    if ( aggCB == null )
-                                                                                                                                    {
-                                                                                                                                        tempStr = getIndividualResultIndicatorValue(
-                                                                                                                                            deCodeString,
-                                                                                                                                            tempStartDate
-                                                                                                                                                .getTime(),
-                                                                                                                                            tempEndDate
-                                                                                                                                                .getTime(),
-                                                                                                                                            currentOrgUnit
-                                                                                                                                                .getParent() );
-                                                                                                                                    }
-                                                                                                                                    else
-                                                                                                                                    {
-                                                                                                                                        tempStr = getResultIndicatorValue(
-                                                                                                                                            deCodeString,
-                                                                                                                                            tempStartDate
-                                                                                                                                                .getTime(),
-                                                                                                                                            tempEndDate
-                                                                                                                                                .getTime(),
-                                                                                                                                            currentOrgUnit
-                                                                                                                                                .getParent() );
-                                                                                                                                    }
-                                                                                                                                    if ( deFlag2 == 1 )
-                                                                                                                                    {
-                                                                                                                                        try
-                                                                                                                                        {
-                                                                                                                                            tempNum = Double
-                                                                                                                                                .parseDouble( tempStr );
-                                                                                                                                        }
-                                                                                                                                        catch ( Exception ex )
-                                                                                                                                        {
-                                                                                                                                            tempNum = 0;
-                                                                                                                                        }
-
-                                                                                                                                    }
-                                                                                                                                }
-                                                                                                                                else
-                                                                                                                                {
-                                                                                                                                    if ( sType
-                                                                                                                                        .equalsIgnoreCase( "dataelement-boolean" ) )
-                                                                                                                                    {
-                                                                                                                                        if ( aggCB == null )
-                                                                                                                                        {
-                                                                                                                                            tempStr = getBooleanDataValue(
-                                                                                                                                                deCodeString,
-                                                                                                                                                tempStartDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                tempEndDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                currentOrgUnit );
-                                                                                                                                        }
-                                                                                                                                        else
-                                                                                                                                        {
-                                                                                                                                            tempStr = getBooleanDataValue(
-                                                                                                                                                deCodeString,
-                                                                                                                                                tempStartDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                tempEndDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                currentOrgUnit );
-                                                                                                                                        }
-                                                                                                                                    }
-                                                                                                                                    else
-                                                                                                                                    {
-                                                                                                                                        if ( aggCB == null )
-                                                                                                                                        {
-                                                                                                                                            tempStr = getIndividualResultIndicatorValue(
-                                                                                                                                                deCodeString,
-                                                                                                                                                tempStartDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                tempEndDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                currentOrgUnit );
-                                                                                                                                        }
-                                                                                                                                        else
-                                                                                                                                        {
-                                                                                                                                            tempStr = getResultIndicatorValue(
-                                                                                                                                                deCodeString,
-                                                                                                                                                tempStartDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                tempEndDate
-                                                                                                                                                    .getTime(),
-                                                                                                                                                currentOrgUnit );
-                                                                                                                                        }
-                                                                                                                                        if ( deFlag2 == 1 )
-                                                                                                                                        {
-                                                                                                                                            try
-                                                                                                                                            {
-                                                                                                                                                tempNum = Double
-                                                                                                                                                    .parseDouble( tempStr );
-                                                                                                                                            }
-                                                                                                                                            catch ( Exception ex )
-                                                                                                                                            {
-                                                                                                                                                tempNum = 0;
-                                                                                                                                            }
-
-                                                                                                                                        }
-                                                                                                                                    }
-                                                                                                                                }
-                                                                                                                            }
-                                                                                                                        }
-                                                                                                                    }
-                                                                                                                }
-                                                                                                            }
-                                                                                                        }
-                                                                                                    }
-                                                                                                }
-                                                                                            }
-                                                                                        }
-                                                                                    }
-                                                                                }
-                                                                            }
-                                                                        }
-                                                                    }
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-                                                }
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
+                            tempStr = reportService.getResultIndicatorValue( deCodeString, tempStartDate.getTime(), tempEndDate.getTime(), currentOrgUnit );
+                        }                       
                     }
                 }
-                int tempRowNo = rowList.get( count1 );
-                int tempColNo = colList.get( count1 );
-                int sheetNo = sheetList.get( count1 ) + orgUnitGroupCount;
+                
+                int tempRowNo = report_inDesign.getRowno();
+                int tempColNo = report_inDesign.getColno();
+                int sheetNo = report_inDesign.getSheetno();
                 WritableSheet sheet0 = outputReportWorkbook.getSheet( sheetNo );
-                if ( tempStr == null || tempStr.equals( " " ) )
+                
+                if ( tempStr == null || tempStr.trim().equals( "" ) )
                 {
                     tempColNo += orgUnitCount;
 
@@ -1744,88 +675,6 @@
                 }
                 else
                 {
-
-                    if ( reportModelTB.equalsIgnoreCase( "STATIC" ) )
-                    {
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
-                        {
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-                                        }
-                                        else
-                                        {
-                                            // tempColNo +=
-                                            // orgUnitCount;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setWrap( true );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-
                     if ( reportModelTB.equalsIgnoreCase( "DYNAMIC-ORGUNIT" ) )
                     {
                         if ( deCodeString.equalsIgnoreCase( "FACILITYP" )
@@ -1834,406 +683,104 @@
                             || deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
                         {
                         }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                            {
-                            }
-                            else
-                            {
-                                tempColNo += orgUnitCount;
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-                        wCellformat.setWrap( true );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-
-                    if ( reportModelTB.equalsIgnoreCase( "STATIC-DATAELEMENTS" )
-                        || reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" ) )
-                    {
-                        if ( deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                            || deCodeString.equalsIgnoreCase( "FACILITY" ) )
-                        {
-                        }
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
-                        {
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setWrap( true );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-
-                    if ( reportModelTB.equalsIgnoreCase( "INDICATOR-AGAINST-PARENT" ) )
-                    {
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
-                        {
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-                                        }
-                                        else
-                                        {
-                                            // tempColNo +=
-                                            // (orgUnitCount * 2);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-
-                    if ( reportModelTB.equalsIgnoreCase( "INDICATOR-AGAINST-SIBLINGS" )
-                        || reportModelTB.equalsIgnoreCase( "INDICATOR-FOR-FEEDBACK" ) )
-                    {
-
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
-                        {
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-                                        }
-                                        else
-                                        {
-                                            tempColNo += orgUnitCount;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setWrap( true );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-                        wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-                    if ( reportModelTB.equalsIgnoreCase( "dynamicwithrootfacility" ) )
-                    {
-                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" )
-                            || deCodeString.equalsIgnoreCase( "FACILITY-NOREPEAT" ) )
-                        {
-                        }
-                        else
-                        {
-                            if ( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
-                            {
-                            }
-                            else
-                            {
-                                if ( deCodeString.equalsIgnoreCase( "FACILITYPPP" ) )
-                                {
-                                }
-                                else
-                                {
-                                    if ( deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
-                                    {
-                                    }
-                                    else
-                                    {
-                                        if ( deCodeString.equalsIgnoreCase( "PERIOD" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-START" )
-                                            || deCodeString.equalsIgnoreCase( "QUARTER-END" )
-                                            || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-END" )
-                                            || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) )
-                                        {
-                                        }
-                                        else
-                                        {
-                                            tempRowNo += orgUnitCount;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
-
-                        CellFormat cellFormat = cell.getCellFormat();
-                        WritableCellFormat wCellformat = new WritableCellFormat();
-
-                        wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
-                        wCellformat.setWrap( true );
-                        wCellformat.setAlignment( Alignment.CENTRE );
-                        wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
-
-                        if ( cell.getType() == CellType.LABEL )
-                        {
-                            Label l = (Label) cell;
-                            l.setString( tempStr );
-                            l.setCellFormat( cellFormat );
-                        }
-                        else
-                        {
-                            if ( deFlag2 == 1 )
-                            {
-                                sheet0.addCell( new Number( tempColNo, tempRowNo, tempNum, wCellformat ) );
-                            }
-                            else
-                            {
-                                sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
-                            }
-                        }
-                    }
-
-                    // }
+                        else if ( deCodeString.equalsIgnoreCase( "PERIOD" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-START" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-END" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-START" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-END" )
+                                || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
+                                || deCodeString.equalsIgnoreCase( "YEAR-END" )
+                                || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" )
+                                || deCodeString.equalsIgnoreCase( "DATE-START-END" )
+                                )
+                        {
+                        }
+                        else
+                        {
+                            tempColNo += orgUnitCount;
+                        }
+                    }
+                    else if ( reportModelTB.equalsIgnoreCase( "dynamicwithrootfacility" ) )
+                    {
+                        if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) 
+                            || deCodeString.equalsIgnoreCase( "FACILITY-NOREPEAT" )
+                            || deCodeString.equalsIgnoreCase( "FACILITYPP" )
+                            || deCodeString.equalsIgnoreCase( "FACILITYPPP" ) 
+                            || deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) )
+                        {
+                        }
+                        else if ( deCodeString.equalsIgnoreCase( "PERIOD" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-WEEK" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-MONTH" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-QUARTER" )
+                                || deCodeString.equalsIgnoreCase( "PERIOD-YEAR" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-START" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-END" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-START-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "MONTH-END-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "SIMPLE-QUARTER" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-MONTHS" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-START-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-END-SHORT" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-START" )
+                                || deCodeString.equalsIgnoreCase( "QUARTER-END" )
+                                || deCodeString.equalsIgnoreCase( "SIMPLE-YEAR" )
+                                || deCodeString.equalsIgnoreCase( "YEAR-END" )
+                                || deCodeString.equalsIgnoreCase( "YEAR-FROMTO" ) 
+                                || deCodeString.equalsIgnoreCase( "DATE-START-END" ) )
+                        {
+                        }
+                        else
+                        {
+                            tempRowNo += orgUnitCount;
+                        }
+                    }    
+
+                    WritableCell cell = sheet0.getWritableCell( tempColNo, tempRowNo );
+                    
+                    CellFormat cellFormat = cell.getCellFormat();
+                    WritableCellFormat wCellformat = new WritableCellFormat();
+                    wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+                    wCellformat.setWrap( true );
+                    wCellformat.setAlignment( Alignment.CENTRE );
+    
+                    if ( cell.getType() == CellType.LABEL )
+                    {
+                        Label l = (Label) cell;
+                        l.setString( tempStr );
+                        l.setCellFormat( cellFormat );
+                    } 
+                    else
+                    {
+                        try
+                        {
+                            sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) );
+                        }
+                        catch( Exception e )
+                        {
+                            sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
+                        }
+                    }
                 }
                 count1++;
             }// inner while loop end
             orgUnitCount++;
         }// outer while loop end
 
-        /*
-         * ActionContext ctx = ActionContext.getContext(); HttpServletResponse
-         * res = (HttpServletResponse) ctx.get(
-         * ServletActionContext.HTTP_RESPONSE );
-         * 
-         * res.setContentType("application/vnd.ms-excel");
-         */
-
         outputReportWorkbook.write();
         outputReportWorkbook.close();
 
@@ -2244,7 +791,7 @@
         File outputReportFile = new File( outputReportPath );
         inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
-        System.out.println( "Report Generation End Time is : \t" + new Date() );
+        System.out.println( orgUnitList.get( 0 ).getName()+ " : " + selReportObj.getName()+" Report Generation End Time is : " + new Date() );
 
         outputReportFile.deleteOnExit();
 
@@ -2252,987 +799,4 @@
 
         return SUCCESS;
     }
-
-    public List<Calendar> getStartingEndingPeriods( String deType )
-    {
-
-        List<Calendar> calendarList = new ArrayList<Calendar>();
-
-        Calendar tempStartDate = Calendar.getInstance();
-        Calendar tempEndDate = Calendar.getInstance();
-
-        Period previousPeriod = new Period();
-        previousPeriod = getPreviousPeriod();
-
-        if ( deType.equalsIgnoreCase( "ccmcy" ) )
-        {
-            tempStartDate.setTime( sDate );
-            if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-            {
-                tempStartDate.roll( Calendar.YEAR, -1 );
-            }
-            tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-            tempEndDate.setTime( eDate );
-            // System.out.println("CCMCY : "+ String.valueOf(
-            // tempStartDate.getTime()) +" ------ "+String.valueOf(
-            // tempEndDate.getTime()));
-        }
-        else
-        {
-            if ( deType.equalsIgnoreCase( "cpmcy" ) )
-            {
-                tempStartDate.setTime( previousPeriod.getStartDate() );
-                if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-                {
-                    tempStartDate.roll( Calendar.YEAR, -1 );
-                }
-                tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-                tempEndDate.setTime( previousPeriod.getEndDate() );
-            }
-            else
-            {
-                if ( deType.equalsIgnoreCase( "cmpy" ) )
-                {
-                    tempStartDate.setTime( sDate );
-                    tempEndDate.setTime( eDate );
-
-                    tempStartDate.roll( Calendar.YEAR, -1 );
-                    tempEndDate.roll( Calendar.YEAR, -1 );
-                }
-                else
-                {
-                    if ( deType.equalsIgnoreCase( "ccmpy" ) )
-                    {
-                        tempStartDate.setTime( sDate );
-                        tempEndDate.setTime( eDate );
-
-                        tempStartDate.roll( Calendar.YEAR, -1 );
-                        tempEndDate.roll( Calendar.YEAR, -1 );
-
-                        if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-                        {
-                            tempStartDate.roll( Calendar.YEAR, -1 );
-                        }
-                        tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-
-                    }
-                    else
-                    {
-                        if ( deType.equalsIgnoreCase( "pmcy" ) )
-                        {
-                            tempStartDate.setTime( previousPeriod.getStartDate() );
-                            tempEndDate.setTime( previousPeriod.getEndDate() );
-
-                        }
-                        else
-                        {
-
-                            tempStartDate.setTime( sDate );
-                            tempEndDate.setTime( eDate );
-                        }
-                    }
-                }
-            }
-        }
-
-        // System.out.print(deType+" -- ");
-        calendarList.add( tempStartDate );
-        calendarList.add( tempEndDate );
-
-        return calendarList;
-    }
-
-    public Period getPreviousPeriod()
-    {
-        Period period = new Period();
-        Calendar tempDate = Calendar.getInstance();
-        tempDate.setTime( sDate );
-        if ( tempDate.get( Calendar.MONTH ) == Calendar.JANUARY )
-        {
-            tempDate.set( Calendar.MONTH, Calendar.DECEMBER );
-            tempDate.roll( Calendar.YEAR, -1 );
-
-        }
-        else
-        {
-            tempDate.roll( Calendar.MONTH, -1 );
-        }
-        PeriodType periodType = getPeriodTypeObject( "monthly" );
-        period = getPeriodByMonth( tempDate.get( Calendar.MONTH ), tempDate.get( Calendar.YEAR ), periodType );
-
-        return period;
-    }
-
-    public Period getPeriodByMonth( int month, int year, PeriodType periodType )
-    {
-        int monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
-        Calendar cal = Calendar.getInstance();
-        cal.set( year, month, 1, 0, 0, 0 );
-        Date firstDay = new Date( cal.getTimeInMillis() );
-
-        if ( periodType.getName().equals( "Monthly" ) )
-        {
-            cal.set( year, month, 1, 0, 0, 0 );
-            if ( year % 4 == 0 )
-            {
-                cal.set( Calendar.DAY_OF_MONTH, monthDays[month] + 1 );
-            }
-            else
-            {
-                cal.set( Calendar.DAY_OF_MONTH, monthDays[month] );
-            }
-        }
-        else
-        {
-            if ( periodType.getName().equals( "Yearly" ) )
-            {
-                cal.set( year, Calendar.DECEMBER, 31 );
-            }
-        }
-
-        Date lastDay = new Date( cal.getTimeInMillis() );
-
-        Period newPeriod = new Period();
-
-        newPeriod.setStartDate( firstDay );
-        newPeriod.setEndDate( lastDay );
-        newPeriod.setPeriodType( periodType );
-
-        return newPeriod;
-    }
-
-    public PeriodType getPeriodTypeObject( String periodTypeName )
-    {
-        Collection<PeriodType> periodTypes = periodService.getAllPeriodTypes();
-        PeriodType periodType = null;
-        Iterator<PeriodType> iter = periodTypes.iterator();
-        while ( iter.hasNext() )
-        {
-            PeriodType tempPeriodType = (PeriodType) iter.next();
-            if ( tempPeriodType.getName().toLowerCase().trim().equals( periodTypeName ) )
-            {
-                periodType = tempPeriodType;
-
-                break;
-            }
-        }
-        if ( periodType == null )
-        {
-            System.out.println( "No Such PeriodType" );
-            return null;
-        }
-        return periodType;
-    }
-
-    public List<String> getDECodes( String fileName )
-    {
-        List<String> deCodes = new ArrayList<String>();
-        String path = System.getProperty( "user.home" ) + File.separator + "dhis" + File.separator + raFolderName
-            + File.separator + fileName;
-        try
-        {
-            String newpath = System.getenv( "DHIS2_HOME" );
-            if ( newpath != null )
-            {
-                path = newpath + File.separator + raFolderName + File.separator + fileName;
-            }
-        }
-        catch ( NullPointerException npe )
-        {
-            // do nothing, but we might be using this somewhere without
-            // USER_HOME set, which will throw a NPE
-        }
-
-        try
-        {
-            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
-            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
-            Document doc = docBuilder.parse( new File( path ) );
-            if ( doc == null )
-            {
-                // System.out.println( "There is no DECodes related XML file in
-                // the user home" );
-                return null;
-            }
-
-            NodeList listOfDECodes = doc.getElementsByTagName( "de-code" );
-            int totalDEcodes = listOfDECodes.getLength();
-
-            for ( int s = 0; s < totalDEcodes; s++ )
-            {
-                Element deCodeElement = (Element) listOfDECodes.item( s );
-                NodeList textDECodeList = deCodeElement.getChildNodes();
-                deCodes.add( ((Node) textDECodeList.item( 0 )).getNodeValue().trim() );
-                serviceType.add( deCodeElement.getAttribute( "stype" ) );
-                deCodeType.add( deCodeElement.getAttribute( "type" ) );
-                sheetList.add( new Integer( deCodeElement.getAttribute( "sheetno" ) ) );
-                rowList.add( new Integer( deCodeElement.getAttribute( "rowno" ) ) );
-                colList.add( new Integer( deCodeElement.getAttribute( "colno" ) ) );
-
-            }// 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 deCodes;
-    }// getDECodes end
-
-    /*
-     * Returns the PeriodType Object for selected DataElement, If no PeriodType
-     * is found then by default returns Monthly Period type
-     */
-    public PeriodType getDataElementPeriodType( DataElement de )
-    {
-        List<DataSet> dataSetList = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-        Iterator<DataSet> it = dataSetList.iterator();
-        while ( it.hasNext() )
-        {
-            DataSet ds = (DataSet) it.next();
-            List<DataElement> dataElementList = new ArrayList<DataElement>( ds.getDataElements() );
-            if ( dataElementList.contains( de ) )
-            {
-                return ds.getPeriodType();
-            }
-        }
-
-        return null;
-
-    } // getDataElementPeriodType end
-
-    /**
-     * Converts an expression on the form<br>
-     * [34] + [23], where the numbers are IDs of DataElements, to the form<br>
-     * 200 + 450, where the numbers are the values of the DataValues registered
-     * for the Period and source.
-     * 
-     * @return The generated expression
-     */
-    private String getResultDataValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit )
-    {
-        try
-        {
-            // System.out.println( "expression : " + formula + " ***** " +
-            // String.valueOf( startDate ) + " **** "
-            // + String.valueOf( endDate ) );
-
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            String resultValue = "";
-
-            while ( matcher.find() )
-            {
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-                String optionComboIdStr = replaceString.substring( replaceString.indexOf( '.' ) + 1, replaceString
-                    .length() );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int dataElementId = Integer.parseInt( replaceString );
-                int optionComboId = Integer.parseInt( optionComboIdStr );
-
-                DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
-                    .getDataElementCategoryOptionCombo( optionComboId );
-
-                if ( dataElement == null || optionCombo == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-                }
-                if ( dataElement.getType().equalsIgnoreCase( "int" ) )
-                {
-                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
-                        startDate, endDate, organisationUnit );
-                    if ( aggregatedValue == null )
-                    {
-                        replaceString = NULL_REPLACEMENT;
-                        deFlag2 = 1;
-                    }
-                    else
-                    {
-                        replaceString = String.valueOf( aggregatedValue );
-
-                        deFlag2 = 1;
-                    }
-
-                }
-                else
-                {
-                    deFlag1 = 1;
-                    deFlag2 = 0;
-                    PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates(
-                        dePeriodType, startDate, endDate ) );
-                    Period tempPeriod = new Period();
-                    if ( periodList == null || periodList.isEmpty() )
-                    {
-                        replaceString = "";
-                        matcher.appendReplacement( buffer, replaceString );
-                        continue;
-                    }
-                    else
-                    {
-                        tempPeriod = (Period) periodList.get( 0 );
-                    }
-
-                    DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, tempPeriod,
-                        optionCombo );
-
-                    if ( dataValue != null )
-                    {
-                        // Works for both text and boolean data types
-
-                        replaceString = dataValue.getValue();
-                    }
-                    else
-                    {
-                        replaceString = "";
-                    }
-
-                    if ( replaceString == null )
-                    {
-                        replaceString = "";
-                    }
-                }
-                matcher.appendReplacement( buffer, replaceString );
-
-                resultValue = replaceString;
-            }
-
-            matcher.appendTail( buffer );
-
-            if ( deFlag1 == 0 )
-            {
-
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-                    resultValue = "";
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-                    resultValue = "";
-                }
-                else
-                {
-
-                    // This is to display financial data as it is like 2.1476838
-                    resultValue = "" + d;
-
-                    // These lines are to display financial data that do not
-                    // have decimals
-                    d = d * 10;
-
-                    if ( d % 10 == 0 )
-                    {
-                        resultValue = "" + (int) d / 10;
-                    }
-
-                    d = d / 10;
-
-                    // These line are to display non financial data that do not
-                    // require decimals
-                    if ( !(reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" )) )
-                    {
-                        d = Math.round( d * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
-                        // System.out.println(" d value : "+d);
-                        resultValue = "" + d;
-                    }
-
-                    // if ( resultValue.equalsIgnoreCase( "0" ) )
-                    // {
-                    // resultValue = "";
-                    // }
-                }
-
-            }
-            else
-            {
-                resultValue = buffer.toString();
-            }
-
-            if ( resultValue.equalsIgnoreCase( "" ) )
-            {
-                resultValue = " ";
-            }
-
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
-
-    private String getIndividualResultDataValue( String formula, Date startDate, Date endDate,
-        OrganisationUnit organisationUnit )
-    {
-        try
-        {
-
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            String resultValue = "";
-            boolean valueDoesNotExist = true;
-
-            while ( matcher.find() )
-            {
-
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-                String optionComboIdStr = replaceString.substring( replaceString.indexOf( '.' ) + 1, replaceString
-                    .length() );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int dataElementId = Integer.parseInt( replaceString );
-                int optionComboId = Integer.parseInt( optionComboIdStr );
-
-                DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
-                    .getDataElementCategoryOptionCombo( optionComboId );
-
-                if ( dataElement == null || optionCombo == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-                }
-                if ( dataElement.getType().equalsIgnoreCase( "int" ) )
-                {
-
-                    PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-
-                    List<Period> periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates(
-                        dePeriodType, startDate, endDate ) );
-
-                    if ( periodList == null || periodList.isEmpty() )
-                    {
-                        replaceString = "";
-                        matcher.appendReplacement( buffer, replaceString );
-                        continue;
-                    }
-                    else
-                    {
-
-                        double aggregatedValue = 0.0;
-                        for ( Period tempPeriod : periodList )
-                        {
-                            DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement,
-                                tempPeriod, optionCombo );
-
-                            if ( dataValue != null )
-                            {
-                                aggregatedValue += Double.parseDouble( dataValue.getValue() );
-
-                                valueDoesNotExist = false;
-                            }
-                        }
-
-                        replaceString = String.valueOf( aggregatedValue );
-
-                        deFlag2 = 1;
-                    }
-
-                }
-                else
-                {
-                    deFlag1 = 1;
-                    deFlag2 = 0;
-                    PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType(
-                        dePeriodType, startDate, endDate ) );
-                    Period tempPeriod = new Period();
-                    if ( periodList == null || periodList.isEmpty() )
-                    {
-                        replaceString = "";
-                        matcher.appendReplacement( buffer, replaceString );
-                        continue;
-                    }
-                    else
-                    {
-                        tempPeriod = (Period) periodList.get( 0 );
-                    }
-
-                    DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, tempPeriod,
-                        optionCombo );
-
-                    if ( dataValue != null )
-                    {
-                        // Works for both text and boolean data types
-
-                        replaceString = dataValue.getValue();
-                        valueDoesNotExist = false;
-                    }
-                    else
-                    {
-                        replaceString = "";
-                    }
-
-                    if ( replaceString == null )
-                    {
-                        replaceString = "";
-                    }
-                }
-                matcher.appendReplacement( buffer, replaceString );
-
-                resultValue = replaceString;
-            }
-
-            matcher.appendTail( buffer );
-
-            if ( deFlag1 == 0 )
-            {
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-
-                    resultValue = "";
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-
-                    resultValue = "";
-                }
-                else
-                {
-                    // This is to display financial data as it is like 2.1476838
-                    resultValue = "" + d;
-
-                    // These lines are to display financial data that do not
-                    // have decimals
-                    d = d * 10;
-
-                    if ( d % 10 == 0 )
-                    {
-                        resultValue = "" + (int) d / 10;
-                    }
-
-                    d = d / 10;
-
-                    // These line are to display non financial data that do not
-                    // require decimals
-                    if ( !(reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" )) )
-                    {
-                        resultValue = "" + (int) d;
-                    }
-
-                    // if ( resultValue.equalsIgnoreCase( "0" ) )
-                    // {
-                    // resultValue = "";
-                    // }
-                }
-            }
-            else
-            {
-                resultValue = buffer.toString();
-            }
-
-            if ( valueDoesNotExist )
-            {
-                resultValue = " ";
-            }
-
-            if ( resultValue.equalsIgnoreCase( "" ) )
-            {
-                resultValue = " ";
-            }
-
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
-
-    private String getBooleanDataValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit )
-    {
-        try
-        {
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            while ( matcher.find() )
-            {
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-                String optionComboIdStr = replaceString.substring( replaceString.indexOf( '.' ) + 1, replaceString
-                    .length() );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int dataElementId = Integer.parseInt( replaceString );
-                int optionComboId = Integer.parseInt( optionComboIdStr );
-
-                DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
-                    .getDataElementCategoryOptionCombo( optionComboId );
-
-                if ( dataElement == null || optionCombo == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-                }
-
-                if ( dataElement.getType().equalsIgnoreCase( "bool" ) )
-                {
-                    deFlag1 = 1;
-                    deFlag2 = 0;
-                    PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType(
-                        dePeriodType, startDate, endDate ) );
-                    Period tempPeriod = new Period();
-                    if ( periodList == null || periodList.isEmpty() )
-                    {
-                        replaceString = "";
-                        matcher.appendReplacement( buffer, replaceString );
-                        continue;
-                    }
-                    else
-                    {
-                        tempPeriod = (Period) periodList.get( 0 );
-                    }
-
-                    DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, tempPeriod,
-                        optionCombo );
-
-                    if ( dataValue != null )
-                    {
-                        // Works for both text and boolean data types
-
-                        if ( dataValue.getValue().equalsIgnoreCase( "true" ) )
-                        {
-                            replaceString = "Yes";
-                        }
-                        else
-                        {
-                            if ( dataValue.getValue().equalsIgnoreCase( "false" ) )
-                            {
-                                replaceString = "No";
-                            }
-                            else
-                            {
-                                replaceString = dataValue.getValue();
-                            }
-                        }
-                    }
-                    else
-                    {
-                        replaceString = "";
-                    }
-
-                }
-                else
-                {
-                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
-                        startDate, endDate, organisationUnit );
-                    if ( aggregatedValue == null )
-                    {
-                        replaceString = NULL_REPLACEMENT;
-                        deFlag2 = 1;
-                    }
-                    else
-                    {
-                        replaceString = String.valueOf( aggregatedValue );
-
-                        deFlag2 = 1;
-                    }
-                }
-                matcher.appendReplacement( buffer, replaceString );
-            }
-
-            matcher.appendTail( buffer );
-
-            String resultValue = "";
-            if ( deFlag1 == 0 )
-            {
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-                }
-                else
-                {
-                    d = Math.round( d * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
-                    // System.out.println(" d value : "+d);
-                    resultValue = "" + d;
-                }
-
-                if ( deFlag2 == 0 )
-                {
-                    resultValue = " ";
-                }
-            }
-            else
-            {
-                resultValue = buffer.toString();
-                deFlag2 = 0;
-            }
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
-
-    private String getResultIndicatorValue( String formula, Date startDate, Date endDate,
-        OrganisationUnit organisationUnit )
-    {
-        try
-        {
-
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            while ( matcher.find() )
-            {
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int indicatorId = Integer.parseInt( replaceString );
-
-                Indicator indicator = indicatorService.getIndicator( indicatorId );
-
-                if ( indicator == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-
-                }
-
-                Double aggregatedValue = aggregationService.getAggregatedIndicatorValue( indicator, startDate, endDate,
-                    organisationUnit );
-
-                if ( aggregatedValue == null )
-                {
-                    replaceString = NULL_REPLACEMENT;
-                    deFlag2 = 1;
-                }
-                else
-                {
-                    replaceString = String.valueOf( aggregatedValue );
-                    deFlag2 = 1;
-                }
-                matcher.appendReplacement( buffer, replaceString );
-            }
-
-            matcher.appendTail( buffer );
-
-            String resultValue = "";
-            if ( deFlag1 == 0 )
-            {
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-                }
-                else
-                {
-                    d = Math.round( d * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
-                    // System.out.println(" d value : "+d);
-                    resultValue = "" + d;
-                }
-
-                if ( deFlag2 == 0 )
-                {
-                    resultValue = " ";
-                }
-            }
-            else
-            {
-                resultValue = buffer.toString();
-                deFlag2 = 0;
-            }
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
-
-    private String getIndividualResultIndicatorValue( String formula, Date startDate, Date endDate,
-        OrganisationUnit organisationUnit )
-    {
-        try
-        {
-
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            while ( matcher.find() )
-            {
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int indicatorId = Integer.parseInt( replaceString );
-
-                Indicator indicator = indicatorService.getIndicator( indicatorId );
-
-                if ( indicator == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-
-                }
-
-                String numeratorExp = indicator.getNumerator();
-                String denominatorExp = indicator.getDenominator();
-                int indicatorFactor = indicator.getIndicatorType().getFactor();
-                String numeratorVal = getIndividualResultDataValue( numeratorExp, startDate, endDate, organisationUnit );
-                String denominatorVal = getIndividualResultDataValue( denominatorExp, startDate, endDate,
-                    organisationUnit );
-
-                double numeratorValue;
-                try
-                {
-                    numeratorValue = Double.parseDouble( numeratorVal );
-                }
-                catch ( Exception e )
-                {
-                    System.out.println( "Exception while getting Numerator : " + numeratorExp + " for Indicaotr "
-                        + indicator.getName() );
-                    numeratorValue = 0.0;
-                }
-
-                double denominatorValue;
-                try
-                {
-                    denominatorValue = Double.parseDouble( denominatorVal );
-                }
-                catch ( Exception e )
-                {
-                    System.out.println( "Exception while getting Deniminator : " + denominatorExp + " for Indicaotr "
-                        + indicator.getName() );
-                    denominatorValue = 1.0;
-                }
-
-                double aggregatedValue;
-                try
-                {
-                    aggregatedValue = (numeratorValue / denominatorValue) * indicatorFactor;
-                }
-                catch ( Exception e )
-                {
-                    System.out.println( "Exception while calculating Indicator value for Indicaotr "
-                        + indicator.getName() );
-                    aggregatedValue = 0.0;
-                }
-
-                replaceString = String.valueOf( aggregatedValue );
-                deFlag2 = 1;
-
-                matcher.appendReplacement( buffer, replaceString );
-            }
-
-            matcher.appendTail( buffer );
-
-            String resultValue = "";
-            if ( deFlag1 == 0 )
-            {
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-                }
-                else
-                {
-                    d = Math.round( d * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
-                    // System.out.println(" d value : "+d);
-                    resultValue = "" + d;
-                }
-
-                if ( deFlag2 == 0 )
-                {
-                    resultValue = " ";
-                }
-            }
-            else
-            {
-                resultValue = buffer.toString();
-                deFlag2 = 0;
-            }
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/routine/action/GenerateRoutineReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/routine/action/GenerateRoutineReportAnalyserResultAction.java	2010-12-29 04:52:35 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/routine/action/GenerateRoutineReportAnalyserResultAction.java	2010-12-29 12:19:53 +0000
@@ -237,10 +237,20 @@
         }
 
         System.out.println( orgUnitList.get( 0 ).getName()+ " : " + selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
-        
-        OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( organisationUnitGroupId ) );
-        
-        List<OrganisationUnit> orgGroupMembers = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
+
+        OrganisationUnitGroup orgUnitGroup = null;
+        
+        List<OrganisationUnit> orgGroupMembers = null;
+
+        if ( organisationUnitGroupId.equalsIgnoreCase( "ALL" ) || organisationUnitGroupId.equalsIgnoreCase( "Selected_Only" ) )
+        {
+            
+        }
+        else
+        {
+            orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( organisationUnitGroupId ) );
+            orgGroupMembers = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
+        }
 
         
         selectedPeriod = periodService.getPeriod( availablePeriods );
@@ -717,7 +727,6 @@
                         }
                         else
                         {
-                            
                             List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( currentOrgUnit.getId() ) );
                             
                             orgUnitList.retainAll( orgGroupMembers );

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-12-22 07:29:08 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-12-29 12:19:53 +0000
@@ -287,55 +287,24 @@
 		
 	</bean>
 	
-	<!--Aggregation Report 25/08/2010 start-->
+	<!-- Aggregation Report -->
 	<bean
 		id="org.hisp.dhis.reports.aggregation.action.GenerateAggregationReportAnalyserFormAction"
 		class="org.hisp.dhis.reports.aggregation.action.GenerateAggregationReportAnalyserFormAction"
 		scope="prototype">
-		<property name="periodService" ref="org.hisp.dhis.period.PeriodService">
-		</property>
-		<property name="organisationUnitService"
-			ref="org.hisp.dhis.organisationunit.OrganisationUnitService">
-		</property>
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
 	
 	<bean
 		id="org.hisp.dhis.reports.aggregation.action.GenerateAggregationReportAnalyserResultAction"
 		class="org.hisp.dhis.reports.aggregation.action.GenerateAggregationReportAnalyserResultAction"
 		scope="prototype">
-		
-		<property name="reportService" ref="org.hisp.dhis.reports.ReportService">
-		</property>
-		<property name="statementManager" ref="statementManager">
-		</property>
-		<property name="dataSetService"
-			ref="org.hisp.dhis.dataset.DataSetService">
-		</property>
-		<property name="periodService" ref="org.hisp.dhis.period.PeriodService">
-		</property>
-		<property name="dataElementService"
-			ref="org.hisp.dhis.dataelement.DataElementService">
-		</property>
-		<property name="organisationUnitService"
-			ref="org.hisp.dhis.organisationunit.OrganisationUnitService">
-		</property>
-		<property name="aggregationService"
-			ref="org.hisp.dhis.aggregation.AggregationService">
-		</property>
-		<property name="indicatorService"
-			ref="org.hisp.dhis.indicator.IndicatorService">
-		</property>
-		<property name="dataValueService"
-			ref="org.hisp.dhis.datavalue.DataValueService">
-		</property>
-		<property name="dataElementCategoryOptionComboService"
-			ref="org.hisp.dhis.dataelement.DataElementCategoryService">
-		</property>
-		
+		<property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
+		<property name="statementManager" ref="statementManager" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 	
-	<!-- Aggregation Report 25/08/2010 end -->
-	
 	<!-- Feedback Reports -->
 	<bean
 		id="org.hisp.dhis.reports.feedback.action.GenerateFeedbackReportAnalyserFormAction"
@@ -347,11 +316,7 @@
 		</property>
 		<property name="organisationUnitService">
 			<ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
-		</property>
-		<!--    <property name="reportService">
-		<ref bean="org.hisp.dhis.reports.util.ReportService"/>
-		</property>-->
-		
+		</property>		
 	</bean>
 	
 	<bean

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties'
--- local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties	2010-11-09 15:02:39 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties	2010-12-29 12:19:53 +0000
@@ -2,6 +2,7 @@
 routine_ra = Routine Report Analyser
 physical_output_ra = Quarterly Physical Output Report
 periodwise_progress_ra = PeriodWise Progress Report Analyser
+aggregation_ra = Aggregation Reports Analyser
 periodtype = PeriodType
 organisationunit = OrganisationUnit
 select_periodtype = Select PeriodType

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/aggregationReportAnalysisFront.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/aggregationReportAnalysisFront.vm	2010-12-09 10:23:58 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/aggregationReportAnalysisFront.vm	2010-12-29 12:19:53 +0000
@@ -1,51 +1,26 @@
                 
-                <script>
-                    //Global Variables
-                    
-                    var reportModels = new HashTable();
-                    var reportFileNames = new HashTable();
-                    var periodTypeIds = new HashTable();
-
-                    // OrganisationUnit ids and its Names
-                        ##var orgUnits = new HashTable();
-                        ##foreach($orgUnit in $organisationUnits)
-                        ##    var orgUnitId = ""+$orgUnit.getId();
-                        ##    orgUnits.put(orgUnitId,"$orgUnit.getShortName()");
-                        ##end
-                        
-                        // OrganisationUnit ids and its Level
-                        ##var orgUnitLevels = new HashTable();
-                        ##foreach($orgUnit in $organisationUnits)
-                        ##    var orgUnitId = ""+$orgUnit.getId();
-                        ##    orgUnitLevels.put(orgUnitId,"$organisationUnitService.getLevelOfOrganisationUnit( $orgUnit )");
-                        ##end
-                        
-                        function formValidations()
-                        {                                                   
-                            var periodTypeIndex = document.reportForm.periodTypeId.selectedIndex;
-                            var orgunitIdValue = document.reportForm.ouIDTB.value;
-                            var reportListIndex = document.reportForm.reportList.selectedIndex;
-                                                        
-                            var startDateValue = document.reportForm.startDate.value;
-                            var endDateValue = document.reportForm.endDate.value;
-                            
-                            if(document.reportForm.periodTypeId.options[periodTypeIndex].text == null || document.reportForm.periodTypeId.options[periodTypeIndex].text== "" || document.reportForm.periodTypeId.options[periodTypeIndex].text== "[ Select PeriodType ]") {alert("Please Select A Period Type"); return false;}
-                            else if(orgunitIdValue == null || orgunitIdValue=="" || orgunitIdValue==" ") {alert("Please Select OrganisationUnit"); return false;}    
-                            else if(reportListIndex < 0 || document.reportForm.reportList.options[reportListIndex].text == null) {alert("Please Select a Report"); return false;}               
-                            else if(startDateValue == null || startDateValue== "" || endDateValue == null || endDateValue=="") {alert("Please Select Start Date And End Date"); return false;}
-                            else if(startDateValue > endDateValue) {alert("Start Date Is Greater Than End Date"); return false;}        
-                                                        
-                           // document.reportForm.reportModelTB.value = reportModels.get(document.reportForm.reportList.options[reportListIndex].value);
-                            //document.reportForm.reportFileNameTB.value = reportFileNames.get(document.reportForm.reportList.options[reportListIndex].value);
-                            document.reportForm.periodTypeIdTB.value = periodTypeIds.get(document.reportForm.periodTypeId.value);
-                            document.forms['reportForm'].submit();
-                            //return true;
-                        }
-
-//-----------------------------------------------------------------------
-//init jQuery validation for reportForm
-//@added validation for all fields and additional rules alphanumericwithbasicpuncspaces, date and url.
-//-----------------------------------------------------------------------
+<script>
+                        
+	function formValidations()
+	{                                  
+		var orgunitIdValue = document.getElementById("ouIDTB").value;
+		var reportList = document.getElementById("reportList");
+		var periodType = document.getElementById("periodTypeId");
+		var periodTypeIndex = periodType.selectedIndex;
+		var reportListIndex = reportList.selectedIndex;
+											
+		var startDateValue = document.getElementById("startDate").value;
+        var endDateValue = document.getElementById("endDate").value;
+		
+		if( periodType.options[periodTypeIndex].text == null || periodType.options[periodTypeIndex].text== "" || periodType.options[periodTypeIndex].text== "[ Select PeriodType ]") { alert("Please Select A Period Type"); return false; }
+		else if( orgunitIdValue == null || orgunitIdValue=="" || orgunitIdValue==" " ) { alert("Please Select OrganisationUnit"); return false; }    
+		else if( reportListIndex < 0 || document.reportForm.reportList.options[reportListIndex].text == null ) { alert("Please Select a Report"); return false; }               
+		else if( startDateValue == null || startDateValue== "" || endDateValue == null || endDateValue=="" ) { alert("Please Select Start Date And End Date"); return false; }
+		else if( startDateValue > endDateValue ) { alert("Start Date Is Greater Than End Date"); return false; }        
+									
+		document.forms['reportForm'].submit();
+	}
+
     jQuery(document).ready(
             function()
             {
@@ -61,79 +36,76 @@
             }
     );
     
-                    </script>
+</script>
        
-            <h1>Aggregation Reports Analyser</h1>
-            <hr />  
-            <br />
-            <form id="reportForm" name="reportForm" action="generateAggregationReport.action" method="post" target="_blank">
-            <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>                      
-                 <tr>
-                      <td class="NormalB">
-                                    PeriodType : <br />
-                                    <select id="periodTypeId" name="periodTypeId" style="width:200px" onchange="getPeriodsForCumulative()">
-                                            <option value="NA">[ Select PeriodType ]</option>
-                                            #foreach ( $type in $periodTypes )
-                                                    <option value="$type.name">$type.name</option>
-                                            #end
-                                    </select>
-                      </td>
-                      <td class="NormalB">                            
-                        OrganisationUnit : <br />
-                        <input type="text" name="ouNameTB" id="ouNameTB" size="20" disabled>         
-                      </td>
-                  </tr>
-                  <tr>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
-                  </tr>
-                  <tr>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
-                  </tr> 
-                  <tr>
-                        <td class="NormalB">
-                            <label for="startDate">$i18n.getString( 'start_date' ) ($i18n.getString( "format.date.label" ))</label><br/>
-                            <input type="text" id="startDate" name="startDate" onChange="if(!isDate( this.value )) this.value='';" style="width:20em" class="{validate:{required:true,dateISO:true}}">                            
-                        </td>
-                            <td class="NormalB">
-                            <label for="endDate">$i18n.getString( 'end_date' ) ($i18n.getString( "format.date.label" ))</label><br />
-                            <input type="text" id="endDate" name="endDate" onChange="if(!isDate( this.value )) this.value='';" style="width:20em" class="{validate:{required:true,dateISO:true}}">                            
-                        </td>
-                  </tr>
-                  <tr>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
-                  </tr>
-                  <tr>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
-                  </tr> 
-                  <tr>         
-                        <td class="NormalB">
-                                    Reports :<br />
-                                    <select id="reportList" name="reportList" style="width:200px"></select>
-                        </td>
-                        <td>
-                          <input type="checkbox" id="aggCB" name="aggCB" checked> Aggregated Data
-                          <br><br>                              
-                          <input type="submit" name="generate" value="Generate Report" disabled="disabled"/>
-                          <input type="hidden" name="autogen" id="autogen" value="0" >
-                          <input type="hidden" name="periodTypeIdTB" id="periodTypeIdTB">
-                          <input type="hidden" name="ouIDTB" id="ouIDTB">
-                          <input type="hidden" name="ouLevelTB" id="ouLevelTB">
- <!--                     <input type="hidden" name="reportModelTB" id="reportModelTB">
-                          <input type="hidden" name="reportFileNameTB" id="reportFileNameTB">
-                          <input type="hidden" name="reportListFileNameTB" id="reportListFileNameTB" value="goiReportsList.xml">-->
-                          <input type="hidden" name="reportTypeNameTB" id="reportTypeNameTB" value="$reportTypeName">
-                        </td>
-                  </tr>
-            </table>
-        </form>
-        <script type="text/javascript">
-		jQuery( function(){
-			datePickerInRange( "startDate", "endDate", false, false );
-		});		
-	
+<h1>$i18n.getString( "aggregation_ra" )</h1>
+<hr /><br />
+
+<form id="reportForm" name="reportForm" action="generateAggregationReport.action" method="post" target="_blank">
+
+	<table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>                      
+		<tr>
+			<td class="NormalB">
+				1. $i18n.getString( "periodtype" ) :<br />
+				<select id="periodTypeId" name="periodTypeId" style="width:200px" onchange="getPeriodsForCumulative()">
+					<option value="NA">[ $i18n.getString( "select_periodtype" ) ]</option>
+					#foreach ( $type in $periodTypes )
+					<option value="$type.name">$type.name</option>
+					#end
+				</select>
+			</td>
+			<td class="NormalB">                            
+				2. $i18n.getString( "organisationunit" ) :<br />
+				<input type="text" name="ouNameTB" id="ouNameTB" size="20" style="width:200px" disabled>         
+			</td>
+		</tr>
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr>
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr> 
+		<tr>
+			<td class="NormalB">
+				<label for="startDate">3. $i18n.getString( 'start_date' ) ($i18n.getString( "format.date.label" ))</label><br/>
+				<input type="text" id="startDate" name="startDate" onChange="if(!isDate( this.value )) this.value='';" style="width:175px" class="{validate:{required:true,dateISO:true}}">                            
+			</td>
+			<td class="NormalB">
+				<label for="endDate">4. $i18n.getString( 'end_date' ) ($i18n.getString( "format.date.label" ))</label><br />
+				<input type="text" id="endDate" name="endDate" onChange="if(!isDate( this.value )) this.value='';" style="width:180px" class="{validate:{required:true,dateISO:true}}">                            
+			</td>
+		</tr>
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr>
+		<tr>
+			<td>&nbsp;</td>
+			<td>&nbsp;</td>
+		</tr> 
+		<tr>         
+			<td class="NormalB">
+				5. $i18n.getString( "reports" ) :<br />
+				<select id="reportList" name="reportList" style="width:200px"></select>
+			</td>
+			<td>
+				<input type="checkbox" id="aggCB" name="aggCB" checked> $i18n.getString( "aggregated_data" )
+				<br><br>                              
+				<input type="submit" name="generate" value="Generate Report" disabled="disabled" style="width:200px" />
+				<input type="hidden" name="autogen" id="autogen" value="0" >
+				<input type="hidden" name="ouIDTB" id="ouIDTB">
+				<input type="hidden" name="reportTypeNameTB" id="reportTypeNameTB" value="$reportTypeName">
+			</td>
+		</tr>
+	</table>
+</form>
+
+<script type="text/javascript">
+	jQuery( function()
+	{
+		datePickerInRange( "startDate", "endDate", false, false );
+	});		
 </script>
            
\ No newline at end of file