← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9832: Allow to export the Statistical program report to excel file.

 

------------------------------------------------------------
revno: 9832
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-19 14:58:54 +0700
message:
  Allow to export the Statistical program report to excel file.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java	2012-12-17 02:42:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java	2013-02-19 07:58:54 +0000
@@ -132,6 +132,13 @@
         this.facilityLB = facilityLB;
     }
 
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
     private Collection<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
 
     public Collection<ProgramInstance> getProgramInstances()
@@ -145,7 +152,7 @@
     {
         return grid;
     }
-    
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -166,7 +173,7 @@
         // ---------------------------------------------------------------------
 
         Collection<Integer> orgunitIds = new HashSet<Integer>();
-        
+
         if ( facilityLB.equals( "selected" ) )
         {
             orgunitIds.add( organisationUnit.getId() );
@@ -188,6 +195,6 @@
             grid = programStageInstanceService.getStatisticalReport( program, orgunitIds, sDate, eDate, i18n, format );
         }
 
-        return SUCCESS;
+        return (type == null) ? SUCCESS : type;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-02-19 04:01:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-02-19 07:58:54 +0000
@@ -354,6 +354,7 @@
       class="org.hisp.dhis.caseentry.action.report.GenerateStatisticalProgramReportAction">
       <result name="success" type="velocity">/content.vm</result>
       <param name="page">/dhis-web-caseentry/statisticalProgramReport.vm</param>
+      <result name="xls" type="gridXlsResult" />
       <param name="requiredAuthorities">F_GENERATE_STATISTICAL_PROGRAM_REPORT</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js	2013-02-19 07:31:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js	2013-02-19 07:58:54 +0000
@@ -8,23 +8,30 @@
 
 function generatedStatisticalProgramReport()
 {
-	hideById('statisticalReportDiv');
-	hideById('detailsDiv');
-	showLoader();
-	jQuery( "#statisticalReportDiv" ).load( "generateStatisticalProgramReport.action",
+	if(  getFieldValue('type') =='' ){
+		hideById('statisticalReportDiv');
+		hideById('detailsDiv');
+		showLoader();
+		jQuery( "#statisticalReportDiv" ).load( "generateStatisticalProgramReport.action",
+		{
+			programId: getFieldValue('programId'),
+			startDate: getFieldValue('startDate'),
+			endDate: getFieldValue( 'endDate' ),
+			facilityLB: $('input[name=facilityLB]:checked').val(),
+		}, function() 
+		{ 
+			setTableStyles();
+			hideById('reportForm');
+			showById('statisticalReportDiv');
+			showById('reportTbl');
+			hideLoader();
+		});
+	}
+	else
 	{
-		programId: getFieldValue('programId'),
-		startDate: getFieldValue('startDate'),
-		endDate: getFieldValue( 'endDate' ),
-		facilityLB: $('input[name=facilityLB]:checked').val()
-	}, function() 
-	{ 
-		setTableStyles();
-		hideById('reportForm');
-		showById('statisticalReportDiv');
-		showById('reportTbl');
-		hideLoader();
-	});
+		byId('reportForm').submit();
+	}
+	
 }
 
 function statisticalProgramDetailsReport( programStageId, status, total )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm	2013-02-19 07:31:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm	2013-02-19 07:58:54 +0000
@@ -9,8 +9,9 @@
 
 <h3>$i18n.getString( "statistical_program_report" )</h3>
 
-<form id="reportForm" name="reportForm" method="post">
+<form id="reportForm" name="reportForm" action="generateStatisticalProgramReport.action" method="post">
 	<input type="hidden" id="status" name="status">
+	<input type="hidden" id="type" name="type">
 	<input type="hidden" id="total" name="total">
 	<div class="inputCriteria" style="width:600px;height:180px;margin-bottom:20px;">
 		<table>	
@@ -51,8 +52,10 @@
 			</tr>
 			<tr>
 				<td></td>
-				<td><input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" style="width:10em" />
-					<input type="button" value="$i18n.getString( 'cancel' )" onclick="hideById('reportForm');" style="width:10em"/>
+				<td>
+					<input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" onclick='setFieldValue("type","")' style="width:7em" />
+					<input type="submit" id='exportBtn' name='exportBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'export_xls' )" onclick='setFieldValue("type","xls")' style="width:7em" />
+					<input type="button" value="$i18n.getString( 'cancel' )" onclick="hideById('reportForm');" style="width:7em"/>
 				</td>
 			</tr>	                		
 		</table>