← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1187: fixed some javascript bugs in excel reporting

 

------------------------------------------------------------
revno: 1187
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Wed 2009-12-09 15:57:51 +0700
message:
  fixed some javascript bugs in excel reporting
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/advancedReport.vm
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2009-12-09 05:08:26 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2009-12-09 08:57:51 +0000
@@ -51,118 +51,130 @@
  * @author Margrethe Store
  * @version $Id: ValidationAction.java 5426 2008-06-16 04:33:05Z larshelg $
  */
-public class ValidationAction implements Action {
-	private static final Log log = LogFactory.getLog(ValidationAction.class);
-
-	// -------------------------------------------------------------------------
-	// Dependencies
-	// -------------------------------------------------------------------------
-
-	private ValidationRuleService validationRuleService;
-
-	public void setValidationRuleService(
-			ValidationRuleService validationRuleService) {
-		this.validationRuleService = validationRuleService;
-	}
-
-	private SelectedStateManager selectedStateManager;
-
-	public void setSelectedStateManager(
-			SelectedStateManager selectedStateManager) {
-		this.selectedStateManager = selectedStateManager;
-	}
-
-	private ExpressionService expressionService;
-
-	public void setExpressionService(ExpressionService expressionService) {
-		this.expressionService = expressionService;
-	}
-
-	private PeriodService periodService;
-
-	public void setPeriodService(PeriodService periodService) {
-		this.periodService = periodService;
-	}
-
-	// -------------------------------------------------------------------------
-	// Output
-	// -------------------------------------------------------------------------
-
-	private List<ValidationResult> results;
-
-	public List<ValidationResult> getResults() {
-		return results;
-	}
-
-	private Map<Integer, Expression> leftsideMap;
-
-	public Map<Integer, Expression> getLeftsideMap() {
-		return leftsideMap;
-	}
-
-	private Map<Integer, Expression> rightsideMap;
-
-	public Map<Integer, Expression> getRightsideMap() {
-		return rightsideMap;
-	}
-
-	private Map<Integer, String> leftsideFormulaMap;
-
-	public Map<Integer, String> getLeftsideFormulaMap() {
-		return leftsideFormulaMap;
-	}
-
-	private Map<Integer, String> rightsideFormulaMap;
-
-	public Map<Integer, String> getRightsideFormulaMap() {
-		return rightsideFormulaMap;
-	}
-
-	// -------------------------------------------------------------------------
-	// Action implementation
-	// -------------------------------------------------------------------------
-
-	public String execute() throws Exception {
-		OrganisationUnit orgUnit = selectedStateManager
-				.getSelectedOrganisationUnit();
-
-		Period selectedPeriod = selectedStateManager.getSelectedPeriod();
-		
-		Period period = periodService.getPeriod(selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedPeriod.getPeriodType());
-
-		DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
-		results = new ArrayList<ValidationResult>(validationRuleService
-				.validate(dataSet, period, orgUnit));
-
-		log.info("Numer of validation violations: " + results.size());
-
-		if (results.size() == 0) {
-			return NONE;
-		} else {
-			leftsideMap = new HashMap<Integer, Expression>(results.size());
-			rightsideMap = new HashMap<Integer, Expression>(results.size());
-
-			leftsideFormulaMap = new HashMap<Integer, String>(results.size());
-			rightsideFormulaMap = new HashMap<Integer, String>(results.size());
-
-			for (ValidationResult result : results) {
-				ValidationRule rule = result.getValidationRule();
-				int id = rule.getId();
-
-				Expression leftside = rule.getLeftSide();
-				Expression rightside = rule.getRightSide();
-
-				leftsideMap.put(id, leftside);
-				rightsideMap.put(id, rightside);
-
-				leftsideFormulaMap.put(id, expressionService
-						.getExpressionDescription(leftside.getExpression()));
-				rightsideFormulaMap.put(id, expressionService
-						.getExpressionDescription(rightside.getExpression()));
-			}
-		}
-
-		return SUCCESS;
-	}
+public class ValidationAction
+    implements Action
+{
+    private static final Log log = LogFactory.getLog( ValidationAction.class );
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ValidationRuleService validationRuleService;
+
+    public void setValidationRuleService( ValidationRuleService validationRuleService )
+    {
+        this.validationRuleService = validationRuleService;
+    }
+
+    private SelectedStateManager selectedStateManager;
+
+    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    {
+        this.selectedStateManager = selectedStateManager;
+    }
+
+    private ExpressionService expressionService;
+
+    public void setExpressionService( ExpressionService expressionService )
+    {
+        this.expressionService = expressionService;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<ValidationResult> results;
+
+    public List<ValidationResult> getResults()
+    {
+        return results;
+    }
+
+    private Map<Integer, Expression> leftsideMap;
+
+    public Map<Integer, Expression> getLeftsideMap()
+    {
+        return leftsideMap;
+    }
+
+    private Map<Integer, Expression> rightsideMap;
+
+    public Map<Integer, Expression> getRightsideMap()
+    {
+        return rightsideMap;
+    }
+
+    private Map<Integer, String> leftsideFormulaMap;
+
+    public Map<Integer, String> getLeftsideFormulaMap()
+    {
+        return leftsideFormulaMap;
+    }
+
+    private Map<Integer, String> rightsideFormulaMap;
+
+    public Map<Integer, String> getRightsideFormulaMap()
+    {
+        return rightsideFormulaMap;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        OrganisationUnit orgUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+        Period selectedPeriod = selectedStateManager.getSelectedPeriod();
+
+        Period period = periodService.getPeriod( selectedPeriod.getStartDate(), selectedPeriod.getEndDate(),
+            selectedPeriod.getPeriodType() );
+
+        DataSet dataSet = selectedStateManager.getSelectedDataSet();
+
+        results = new ArrayList<ValidationResult>( validationRuleService.validate( dataSet, period, orgUnit ) );
+
+        log.info( "Numer of validation violations: " + results.size() );
+
+        if ( results.size() == 0 )
+        {
+            return NONE;
+        }
+        else
+        {
+            leftsideMap = new HashMap<Integer, Expression>( results.size() );
+            rightsideMap = new HashMap<Integer, Expression>( results.size() );
+
+            leftsideFormulaMap = new HashMap<Integer, String>( results.size() );
+            rightsideFormulaMap = new HashMap<Integer, String>( results.size() );
+
+            for ( ValidationResult result : results )
+            {
+                ValidationRule rule = result.getValidationRule();
+                int id = rule.getId();
+
+                Expression leftside = rule.getLeftSide();
+                Expression rightside = rule.getRightSide();
+
+                leftsideMap.put( id, leftside );
+                rightsideMap.put( id, rightside );
+
+                leftsideFormulaMap.put( id, expressionService.getExpressionDescription( leftside.getExpression() ) );
+                rightsideFormulaMap.put( id, expressionService.getExpressionDescription( rightside.getExpression() ) );
+            }
+        }
+
+        return SUCCESS;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java	2009-12-07 03:47:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java	2009-12-09 08:57:51 +0000
@@ -27,24 +27,16 @@
 package org.hisp.dhis.reportexcel.export.action;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.reportexcel.ReportExcelService;
-import org.hisp.dhis.reportexcel.ReportLocationManager;
 import org.hisp.dhis.reportexcel.period.db.PeriodDatabaseService;
-import org.hisp.dhis.system.util.CodecUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -67,14 +59,7 @@
     public void setReportService( ReportExcelService reportService )
     {
         this.reportService = reportService;
-    }
-
-    private ReportLocationManager reportLocationManager;
-
-    public void setReportLocationManager( ReportLocationManager reportLocationManager )
-    {
-        this.reportLocationManager = reportLocationManager;
-    }
+    } 
 
     private PeriodDatabaseService periodDatabaseService;
 
@@ -100,18 +85,6 @@
 
     private List<String> groups;
 
-    private String reportGroup;
-
-    private Integer reportId;
-
-    private HSSFWorkbook templateWorkbook;
-
-    private FileInputStream inputStreamExcelTemplate;
-
-    private Map<Integer, String> mapSheets = new HashMap<Integer, String>();
-
-    private Collection<Integer> collectSheets = new HashSet<Integer>();
-
     // -------------------------------------------------------------------------
     // Getter & Setter
     // -------------------------------------------------------------------------
@@ -124,38 +97,8 @@
     public OrganisationUnit getOrganisationUnit()
     {
         return organisationUnit;
-    }
-
-    public Integer getReportId()
-    {
-        return reportId;
-    }
-
-    public void setReportId( Integer reportId )
-    {
-        this.reportId = reportId;
-    }
-
-    public String getReportGroup()
-    {
-        return reportGroup;
-    }
-
-    public void setReportGroup( String reportGroup )
-    {
-        this.reportGroup = reportGroup;
-    }
-
-    public Collection<Integer> getCollectSheets()
-    {
-        return collectSheets;
-    }
-
-    public Map<Integer, String> getMapSheets()
-    {
-        return mapSheets;
-    }
-
+    } 
+    
     public List<Period> getPeriods()
     {
         return periods;
@@ -190,36 +133,7 @@
         groups = new ArrayList<String>( reportService.getReportExcelGroups() );
 
         Collections.sort( groups );
-
-        // ---------------------------------------------------------------------
-        // Processing Tabs for Previewing excel report
-        // ---------------------------------------------------------------------
-
-        if ( reportGroup != null )
-        {
-            reportGroup = CodecUtils.unescape( reportGroup );
-        }
-
-        if ( reportId != null )
-        {
-            inputStreamExcelTemplate = new FileInputStream( reportLocationManager.getReportExcelTemplateDirectory()
-                + File.separator + reportService.getReportExcel( reportId ).getExcelTemplateFile() );
-
-            templateWorkbook = new HSSFWorkbook( inputStreamExcelTemplate );
-
-            collectSheets = reportService.getSheets( reportId );
-
-            for ( Integer sheetId : collectSheets )
-            {
-                mapSheets.put( sheetId, CodecUtils.unescape( templateWorkbook.getSheetName( sheetId.intValue() - 1 ) ) );
-            }
-        }
-        else
-        {
-            collectSheets.add( 0 );
-            mapSheets.put( 0, "" );
-        }
-
+       
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java	2009-12-09 05:55:32 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java	2009-12-09 08:57:51 +0000
@@ -39,8 +39,8 @@
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.reportexcel.ReportExcel;
-import org.hisp.dhis.reportexcel.ReportExcelCategory;
 import org.hisp.dhis.reportexcel.ReportExcelItem;
+import org.hisp.dhis.reportexcel.ReportExcelOganiztionGroupListing;
 import org.hisp.dhis.reportexcel.export.action.GenerateReportSupport;
 import org.hisp.dhis.reportexcel.utils.ExcelUtils;
 
@@ -94,7 +94,7 @@
         Period period = periodDatabaseService.getSelectedPeriod();
         this.installPeriod( period );
 
-        ReportExcelCategory reportExcel = (ReportExcelCategory) reportService.getReportExcel( selectionManager
+        ReportExcelOganiztionGroupListing reportExcel = (ReportExcelOganiztionGroupListing) reportService.getReportExcel( selectionManager
             .getSelectedReportId() );
 
         this.installReadTemplateFile( reportExcel, period, organisationUnitGroup );

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml	2009-12-04 09:37:23 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml	2009-12-09 08:57:51 +0000
@@ -375,9 +375,7 @@
 		<property name="organisationUnitSelectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="periodDatabaseService"
-			ref="org.hisp.dhis.reportexcel.period.db.PeriodDatabaseService" />
-		<property name="reportLocationManager"
-			ref="org.hisp.dhis.reportexcel.ReportLocationManager" />	
+			ref="org.hisp.dhis.reportexcel.period.db.PeriodDatabaseService" />		
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2009-12-03 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2009-12-09 08:57:51 +0000
@@ -419,8 +419,14 @@
 			<param name="page">/dhis-web-excel-reporting/reportparams.vm</param>
 			<param name="menu">/dhis-web-excel-reporting/menuWithTree.vm</param>
 			<param name="menuTreeHeight">250</param>
-			<param name="stylesheets">style/previewStyle.css</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/export.js,javascript/commons.js,javascript/preview.js</param>
+			<param name="stylesheets">style/previewStyle.css, style/ui.all.css</param>
+			<param name="javascripts">
+					../dhis-web-commons/ouwt/ouwt.js,
+					javascript/export.js,
+					javascript/commons.js,
+					javascript/preview.js,
+					javascript/jquery-ui-1.7.2.custom.min.js
+			</param>
 		</action>
 
 		<action name="getReportExcelsByGroup"
@@ -470,51 +476,8 @@
 			<result name="success" type="velocity-xml">
 				/dhis-web-excel-reporting/responseSuccess.vm</result>
 		</action>
+
 		
-
-		<!-- Generate Report By Ajax -->
-		<!-- 
-		<action name="generateReportExcel"
-			class="org.hisp.dhis.reportexcel.export.action.GenerateReportExcelFlowAction">
-			<result name="CATEGORY" type="chain">
-				generateReportExcelCategoryAjax
-			</result>
-			<result name="NORMAL" type="chain">
-				generateReportExcelNormalAjax
-			</result>
-			<result name="ORGANIZATION_GROUP_LISTING" type="chain">
-				generateReportExcelOrganizationGroupListingAjax
-			</result>
-			<result name="PERIOD_COLUMN_LISTING" type="chain">
-				generateReportExcelPeriodColumnListingAjax
-			</result>
-		</action>
-
-		<action name="generateReportExcelCategoryAjax"
-			class="org.hisp.dhis.reportexcel.export.action.GenerateReportExcelCategoryAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-excel-reporting/responseSuccess.vm</result>
-		</action>
-
-		<action name="generateReportExcelNormalAjax"
-			class="org.hisp.dhis.reportexcel.export.action.GenerateReportExcelNormalAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-excel-reporting/responseSuccess.vm</result>
-		</action>
-
-		<action name="generateReportExcelOrganizationGroupListingAjax"
-			class="org.hisp.dhis.reportexcel.export.action.GenerateReportExcelOrganizationGroupListingAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-excel-reporting/responseSuccess.vm</result>
-		</action>
-
-		<action name="generateReportExcelPeriodColumnListingAjax"
-			class="org.hisp.dhis.reportexcel.export.action.GenerateReportExcelPeriodColumnListingAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-excel-reporting/responseSuccess.vm</result>
-		</action>
-
-		-->
 		<!-- DATA ENTRY STATUS ACTION -->
 
 		<action name="viewDataEntryStatus"
@@ -676,7 +639,14 @@
 			<param name="page">/dhis-web-excel-reporting/advancedReport.vm</param>
 			<param name="menu">/dhis-web-excel-reporting/menu.vm</param>
 			<param name="menuTreeHeight">250</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/export.js,javascript/commons.js,javascript/preview.js</param>
+			<param name="stylesheets">style/previewStyle.css, style/ui.all.css</param>
+			<param name="javascripts">
+				../dhis-web-commons/ouwt/ouwt.js,
+				javascript/export.js,
+				javascript/commons.js,
+				javascript/preview.js,
+				javascript/jquery-ui-1.7.2.custom.min.js
+			</param>
 		</action>
 
 		<action name="getALLReportExcelByGroup"

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/advancedReport.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/advancedReport.vm	2009-11-30 04:26:38 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/advancedReport.vm	2009-12-09 08:57:51 +0000
@@ -1,14 +1,4 @@
-<link type="text/css" href="style/ui.all.css" rel="stylesheet" />
-
-<script type="text/javascript" src="javascript/jquery-ui-1.7.2.custom.min.js"></script>
-
-<script type="text/javascript">
-	$(document).ready(function() {
-		$("#tabs").tabs({collapsible : true});
-	});
-</script>
-
-<h2>$i18n.getString( "generate_advanced_report" )</h2>
+<h2>$i18n.getString( "generate_advanced_report" )</h2>
 <table >	
 	<tr>
 		<td ><label>$i18n.getString('group')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
@@ -23,7 +13,7 @@
 	<tr>
 		<td><label>$i18n.getString('reports')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
-			<select type="text" id="report" name="report" style="width:20em" onchange="javascript: reportChanged();" >
+			<select type="text" id="report" name="report" style="width:20em">
 			
 			</select>
 		</td>
@@ -66,48 +56,27 @@
 <br>
 <hr>
 <p>
-<input type="button" value='$i18n.getString( "preview_report" )' onclick="javascript: generic_type= 'preview'; validateExportReport();" />
+<input type="button" value='$i18n.getString( "preview_report" )' onclick="previewAdvandReport();" />
 
-<input name="generate_report" id="generate_report"  type="button" onClick="javascript: generic_type= 'advance'; validateExportReport()" value='$i18n.getString( "generate_report" )' />
+<input name="generate_report" id="generate_report"  type="button" onClick="generateAdvancedReportExcel();" value='$i18n.getString( "generate_report" )' />
 </p>
 
-<!-- Preview Report Excel -->
-<div id="tabs" style="display:none">
-
-	#if( $!collectSheets )
-		<ul>
-		#foreach( $i in $!collectSheets  )
-			<li><a href="#fragment-$i">Sheet $i</a></li>
-		#end
-		</ul>
-		
-		#foreach( $i in $!collectSheets  )
-		<div id="fragment-$i"></div>
-		#end
-	#end
-	
+<div id="preview">
 </div>
 
 <span id="info" style="display:none;top:70px;right:5px;position:fixed;" onclick="hideById(this.id)">
 	
 </span>
-<span id="loading" style="display:none;position:fixed;"><img src="../images/ajax-loader.gif" /></span>
-
-<span id="loadingPreview" style="display:none;position:fixed;"><img src="../images/ajax-loader-preview.gif" /></span>
+
+
+<span id="processing" style="display:none;position:fixed;"><img src="../images/ajax-loader-preview.gif" /></span>
 
 <script>
 
-var selectedReport = '$reportId';
-var i18n_select_report = '$encoder.jsEscape( $i18n.getString( "report_is_null" ) , "'")';
-
-#if ( $organisationUnit )
-	
-	$(document).ready(function() {
-	
-		getReportExcelsByGroup();
-		getPeriodsByPeriodTypeName();
-	});
-	
-#end
+	
+$(document).ready(function() {	
+	getReportExcelsByGroup();		
+});
+	
 
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js	2009-12-04 06:39:28 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js	2009-12-09 08:57:51 +0000
@@ -22,23 +22,10 @@
 		var item = list[i];
 		var id = item.getElementsByTagName('id')[0].firstChild.nodeValue;
 		var name = item.getElementsByTagName('name')[0].firstChild.nodeValue;
-		addOption('report',name,id);
-		
-		// selectedReport is a global variable
-		if ( id == selectedReport) {
-			byId('report').options[i].selected = true;
-		}
+		addOption('report',name,id);	
 	}
 }
 
-function getPeriodsByPeriodTypeName() {
-	
-	var request = new Request();
-	request.setResponseTypeXML( 'xmlObject' );
-	request.setCallbackSuccess( responseListPeriodReceived );
-	request.send( 'getPeriodsByPeriodTypeDB.action');
-}
-
 function lastPeriod() {
 
 	var request = new Request();
@@ -70,7 +57,7 @@
 
 function generateReportExcel() {
 	
-	$("#loading").showAtCenter( true );
+	$("#processing").showAtCenter( true );
 	
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
@@ -83,9 +70,12 @@
 }
 
 function generateReportExcelReceived(xmlObject){
-	window.location = "downloadFile.action";
-	deleteDivEffect();
-	$("#loading").hide();
+	var type = xmlObject.getAttribute("type");
+	if(type=="success"){
+		window.location = "downloadFile.action";
+		deleteDivEffect();
+		$("#processing").hide();
+	}
 }
 
 function getALLReportExcelByGroup(){
@@ -93,7 +83,8 @@
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
 	request.setCallbackSuccess( getALLReportExcelByGroupReceived );
-	request.send( 'getALLReportExcelByGroup.action?group=' + byId("group").value);
+	request.sendAsPost( "group=" + byId("group").value );
+	request.send( 'getALLReportExcelByGroup.action');
 	
 }
 
@@ -110,37 +101,14 @@
 
 function generateAdvancedReportExcel() {	
 
-	$("#loading").showAtCenter( true );	
+	$("#processing").showAtCenter( true );	
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
 	request.setCallbackSuccess( generateReportExcelReceived );
 	var params = "reportId=" + byId('report').value;
 	params += "&periodId=" + byId('period').value;
+	params += "&organisationGroupId=" + byId("availableOrgunitGroups").value;
 	request.sendAsPost(params);
 	request.send( 'generateAdvancedReportExcel.action');
 	
 }
-
-generic_type = '';
-
-function validateExportReport() {
-
-	if ( byId("report").value == -1 ) {
-	
-		setMessage(i18n_select_report);
-		return;
-	}
-	
-	if ( generic_type == 'preview' ) {
-	
-		previewReport();
-	}
-	else if ( generic_type == 'normal' ) {
-	
-		generateReportExcel();
-	}
-	else {
-	
-		generateAdvancedReportExcel();
-	}
-}

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js	2009-12-07 09:03:49 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js	2009-12-09 08:57:51 +0000
@@ -1,12 +1,29 @@
 
-aKey	= null;
-aMerged = null;
+var aKey	= null;
+var aMerged = null;
 
 function reportChanged() {
 	
 	window.location.href="selectExportReportParam.action?reportGroup=" + getListValue("group") + "&reportId=" + getListValue("report");
 }
 
+function previewAdvandReport()
+{	
+	aKey	= null;
+	aMerged = null;
+	
+	var params = "reportId=" + byId('report').value + "&periodId=" + byId('period').value + "&organisationGroupId=" + byId("availableOrgunitGroups").value;
+
+	
+	$("#processing").showAtCenter(true);
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'reportXML' );
+	request.setCallbackSuccess( previewReportReceived );
+	request.sendAsPost( params );
+	request.send( "previewAdvancedReportExcel.action" );	
+}
+
 function previewReport() {
 	
 	aKey	= null;
@@ -22,24 +39,60 @@
 		url = "previewReportExcel.action?" + url;
 	}
 	
-	$("#loadingPreview").showAtCenter(true);
+	$("#processing").showAtCenter(true);
 	
 	var request = new Request();
 	request.setResponseTypeXML( 'reportXML' );
 	request.setCallbackSuccess( previewReportReceived );
-	request.send( url );
+	request.send( url );	
 	
 }
 
 function previewReportReceived( reportXML ) {
-
+	
+	createTabs( reportXML );	
 	setMergedNumberForEachCell( reportXML );
 	exportFromXMLtoHTML( reportXML );
 	
 	deleteDivEffect();
-	$("#loadingPreview").hide();
-	
-}
+	$("#processing").hide();
+	
+}
+
+function createTabs( reportXML )
+{
+	var tabs = document.getElementById( 'tabs' );
+	
+	if(tabs!=null){	
+		byId("preview").removeChild(tabs);
+	}
+
+	tabs = document.createElement("div");
+	tabs.id = "tabs";
+	tabs.style.display = "none";
+	byId("preview").appendChild(tabs);
+	
+	var _sheets		= reportXML.getElementsByTagName( 'sheet' );	
+	
+	var divHTML = "";
+	var html = "<ul>";
+		
+	for(var i=0;i<_sheets.length;i++){
+		var sheet = _sheets.item(i) ;
+		var id = sheet.getAttribute("id");
+		
+		html += "<li><a href='#fragment-" + id + "'>" + id + "</a></li>";
+		divHTML += "<div id='fragment-" + id + "'></div>";
+	}
+	
+	html += "</ul>";	
+	
+	byId("tabs").innerHTML = html + divHTML;	
+	
+	
+	$("#tabs").tabs({collapsible : true});
+}
+
 
 function setMergedNumberForEachCell( parentElement ) {
 		
@@ -143,4 +196,4 @@
 	window.status = "DATAWARE HOUSE";
 	window.stop();
 }
-// END OF Previewed Report Excel //
+

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm	2009-12-07 09:03:49 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm	2009-12-09 08:57:51 +0000
@@ -1,14 +1,4 @@
-<link type="text/css" href="style/ui.all.css" rel="stylesheet" />
-
-<script type="text/javascript" src="javascript/jquery-ui-1.7.2.custom.min.js"></script>
-
-<script type="text/javascript">
-	$(document).ready(function() {
-		$("#tabs").tabs({collapsible : true});
-	});
-</script>
-
-<h2>$i18n.getString( "generate_report" )</h2>
+<h2>$i18n.getString( "generate_report" )</h2>
 <table>	
 	<tr>
 		<td><label>$i18n.getString('group')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
@@ -23,7 +13,7 @@
 	<tr>
 		<td><label>$i18n.getString('reports')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
-			<select type="text" id="report" name="report" style="min-width:20em" onchange="javascript: reportChanged()" #if(!$organisationUnit) disabled #end>
+			<select type="text" id="report" name="report" style="min-width:20em" #if(!$organisationUnit) disabled #end>
 
 			</select>
 		</td>
@@ -56,46 +46,33 @@
 <br/>
 <hr/>
 <p>
-<input type="button" value='$i18n.getString( "preview_report" )' onclick="javascript: generic_type= 'preview'; validateExportReport();" #if(!$organisationUnit) disabled #end/>
-<input name="generate_report" id="generate_report"  type="button" onClick="javascript: generic_type= 'normal'; validateExportReport()" value='$i18n.getString( "generate_report" )' #if(!$organisationUnit) disabled #end/>
+<input type="button" value='$i18n.getString( "preview_report" )' onclick="previewReport();" #if(!$organisationUnit) disabled #end/>
+<input name="generate_report" id="generate_report"  type="button" onClick="generateReportExcel();" value='$i18n.getString( "generate_report" )' #if(!$organisationUnit) disabled #end/>
 </p>
 
-<!-- Preview Report Excel -->
-<div id="tabs" style="display:none">
-
-	#if( $!collectSheets && $!mapSheets )
-		<ul>
-		#foreach( $i in $!collectSheets )
-			<li><a href="#fragment-$i">$!mapSheets.get($i)</a></li>
-		#end
-		</ul>
-		
-		#foreach( $i in $!collectSheets  )
-		<div id="fragment-$i"></div>
-		#end
-	#end
-	
+
+
+<div id="preview">
 </div>
 
 <span id="info" style="display:none;top:70px;right:5px;position:fixed;" onclick="hideById(this.id)">
 	
 </span>
 
-<span id="loading" style="display:none;position:fixed;"><img src="../images/ajax-loader.gif" /></span>
-
-<span id="loadingPreview" style="display:none;position:fixed;"><img src="../images/ajax-loader-preview.gif" /></span>
+<span id="processing" style="display:none;position:fixed;"><img src="../images/ajax-loader-preview.gif" /></span>
 
 <script>
 
-var selectedReport = '$reportId';
+
 var i18n_select_report = '$encoder.jsEscape( $i18n.getString( "report_is_null" ) , "'")';
 
+
 #if ( $organisationUnit )
 	
 	$(document).ready(function() {
 	
 		getReportExcelsByGroup();
-		getPeriodsByPeriodTypeName();
+		
 	});
 	
 #end