← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8332: local vn - Improved in generating the org-unit-listing report.

 

------------------------------------------------------------
revno: 8332
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-02 11:32:52 +0700
message:
  local vn - Improved in generating the org-unit-listing report.
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js


--
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/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java	2012-05-03 10:04:29 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java	2012-10-02 04:32:52 +0000
@@ -68,6 +68,18 @@
         return organisationGroupId;
     }
 
+    private boolean showSubItem;
+
+    public boolean isShowSubItem()
+    {
+        return showSubItem;
+    }
+
+    public void setShowSubItem( boolean showSubItem )
+    {
+        this.showSubItem = showSubItem;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -76,15 +88,14 @@
         throws Exception
     {
         Integer reportId = selectionManager.getSelectedReportId();
-        
+
         if ( reportId == null )
         {
             return "MULTI";
         }
-        
+
         ExportReport exportReport = exportReportService.getExportReport( reportId );
 
         return exportReport.getReportType();
     }
-
 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-07-12 10:18:47 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-10-02 04:32:52 +0000
@@ -69,6 +69,17 @@
     private OrganisationUnitService organisationUnitService;
 
     // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private boolean showSubItem;
+
+    public void setShowSubItem( boolean showSubItem )
+    {
+        this.showSubItem = showSubItem;
+    }
+
+    // -------------------------------------------------------------------------
     // Override
     // -------------------------------------------------------------------------
 
@@ -95,7 +106,14 @@
 
             exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo );
 
-            generateOutPutFile( exportReportInstance, exportReportItems, sheet );
+            if ( showSubItem )
+            {
+                generateOutPutFile1( exportReportInstance, exportReportItems, sheet );
+            }
+            else
+            {
+                generateOutPutFile2( exportReportInstance, exportReportItems, sheet );
+            }
         }
 
         /**
@@ -157,7 +175,7 @@
         organisationUnitsAtLevel = null;
     }
 
-    private void generateOutPutFile( ExportReportOrganizationGroupListing exportReport,
+    private void generateOutPutFile1( ExportReportOrganizationGroupListing exportReport,
         Collection<ExportItem> exportReportItems, Sheet sheet )
     {
         List<OrganisationUnit> organisationUnits = null;
@@ -172,20 +190,18 @@
 
             String totalFormula = PREFIX_FORMULA_SUM;
 
-            for ( OrganisationUnitGroup organisationUnitGroup : exportReport.getOrganisationUnitGroups() )
+            for ( OrganisationUnitGroup unitGroup : exportReport.getOrganisationUnitGroups() )
             {
                 int beginChapter = rowBegin;
 
-                organisationUnits = childrenGroupMap.get( organisationUnitGroup.getId() );
+                organisationUnits = childrenGroupMap.get( unitGroup.getId() );
 
-                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION )
-                    && (!organisationUnits.isEmpty()) )
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
                 {
-                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), organisationUnitGroup.getName(),
-                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT,
+                        sheet, this.csText12BoldCenter );
                 }
-                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL )
-                    && (!organisationUnits.isEmpty()) )
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
                 {
                     ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++],
                         ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
@@ -255,6 +271,13 @@
                             this.csFormula );
                     }
                 }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT )
+                    || reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR )
+                    || reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin - 1, reportItem.getColumn(), null, ExcelUtils.NUMBER, sheet,
+                        this.csText10Bold );
+                }
 
                 next = run;
             }
@@ -276,4 +299,73 @@
 
         organisationUnits = null;
     }
+
+    private void generateOutPutFile2( ExportReportOrganizationGroupListing exportReport,
+        Collection<ExportItem> exportReportItems, Sheet sheet )
+    {
+        List<OrganisationUnit> organisationUnits = null;
+
+        for ( ExportItem reportItem : exportReportItems )
+        {
+            int chapperNo = 0;
+            int firstRow = reportItem.getRow();
+            int rowBegin = firstRow + 1;
+            double value = 0;
+            double totalValue = 0;
+
+            for ( OrganisationUnitGroup unitGroup : exportReport.getOrganisationUnitGroups() )
+            {
+                organisationUnits = childrenGroupMap.get( unitGroup.getId() );
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT,
+                        sheet, this.csText12BoldCenter );
+                }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++],
+                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                {
+                    for ( OrganisationUnit o : organisationUnits )
+                    {
+                        value += this.getDataValue( reportItem, o );
+                    }
+
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), value + "", ExcelUtils.NUMBER, sheet,
+                        this.csNumber );
+                }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+                {
+                    for ( OrganisationUnit o : organisationUnits )
+                    {
+                        value += this.getIndicatorValue( reportItem, o );
+                    }
+
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), value + "", ExcelUtils.NUMBER, sheet,
+                        this.csNumber );
+                }
+                else
+                // FORMULA_EXCEL
+                {
+                    ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils.generateExcelFormula(
+                        reportItem.getExpression(), rowBegin, rowBegin ), sheet, this.csFormula );
+                }
+
+                rowBegin++;
+                totalValue += value;
+            }
+
+            if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+            {
+                ExcelUtils.writeValueByPOI( firstRow, reportItem.getColumn(), totalValue + "", ExcelUtils.NUMBER,
+                    sheet, this.csNumber );
+            }
+        }
+
+        organisationUnits = null;
+    }
+
 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties	2012-10-02 04:32:52 +0000
@@ -360,16 +360,17 @@
 into_add_multi_organisation_unit = Allow to create multi-org-unit at the same time based on the selected parent unit and many other params.
 orgunit_prototype_management = Organisation Unit Prototype Management
 create_new_orgunit_prototype = Create new Organisation unit prototype
-edit_org_unit_prototype = Edit Organisation unit prototype
+edit_org_unit_prototype 	 = Edit Organisation unit prototype
 orgunit_prototype_group_management = Organisation Unit Prototype Group Management
 create_new_orgunit_prototype_group = Create new Organisation unit prototype group
 edit_orgunit_prototype_group = Edit Organisation unit prototype group
 available_orgunit_prototypes = Available organisation unit prototypes
-create_multi_org_unit = Create Multi organisation unit
+create_multi_org_unit 		 = Create Multi organisation unit
 confirm_delete_orgunit_prototype_group = Do you want to delete this Organisation unit prototype group ?
-registers_data = Registers data
-available_data_sets = Available data sets
-selected_data_sets = Selected data sets
-select_group = Select group of unit
-add_multi_organisation_unit = Add Multi-org-unit
-filter_on_section=Filter on section
\ No newline at end of file
+registers_data 				 = Registers data
+available_data_sets			 = Available data sets
+selected_data_sets			 = Selected data sets
+select_group				 = Select group of unit
+add_multi_organisation_unit	 = Add Multi-org-unit
+filter_on_section			 = Filter on section
+do_not_show_sub_item 		 = Don't show sub-items in group
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties	2012-10-02 04:32:52 +0000
@@ -401,4 +401,5 @@
 selected_data_sets = Danh s\u00e1ch t\u1eadp d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c ch\u1ecdn
 select_group = Ch\u1ecdn Nh\u00f3m \u0111\u01a1n v\u1ecb
 add_multi_organisation_unit = T\u1ea1o nhi\u1ec1u \u0111\u01a1n v\u1ecb
-filter_on_section=L\u1ecdc theo nh\u00f3m
\ No newline at end of file
+filter_on_section=L\u1ecdc theo nh\u00f3m
+do_not_show_sub_item = Kh\u00f4ng hi\u1ec3n th\u1ecb chi ti\u1ebft trong nh\u00f3m
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml	2012-10-02 04:32:52 +0000
@@ -759,7 +759,7 @@
 			<result name="NORMAL" type="redirect">
 				generateReportNormal.action</result>
 			<result name="ORGANIZATION_GROUP_LISTING" type="redirect">
-				generateReportOrgGroupListing.action</result>
+				generateReportOrgGroupListing.action?showSubItem=${showSubItem}</result>
 			<result name="PERIOD_COLUMN_LISTING" type="redirect">
 				generateReportPeriodColumnListing.action</result>
 			<result name="MULTI" type="redirect">
@@ -926,7 +926,7 @@
 			<result name="NORMAL" type="redirect">
 				generatePreviewNormal.action</result>
 			<result name="ORGANIZATION_GROUP_LISTING" type="redirect">
-				generatePreviewOrgGroupListing.action</result>
+				generatePreviewOrgGroupListing.action?showSubItem=${showSubItem}</result>
 			<result name="PERIOD_COLUMN_LISTING" type="redirect">
 				generatePreviewPeriodColumnListing.action</result>
 			<result name="MULTI" type="redirect">

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm	2012-10-02 04:32:52 +0000
@@ -64,6 +64,11 @@
 			<input type="button" value="&gt;&gt;" onclick="getNextPeriod()" id="nextPeriod"/>
 		</td>
     </tr>
+	<tr id="showSubItemTR" style="display:none">
+		<td><label class='bold'>$i18n.getString( 'do_not_show_sub_item' )</label>
+		<input type="checkbox" id="showSubItem" value="false"/>
+		</td>
+	</tr>
 	<tr id="orderedGroupLabelTR" style="display:none">
 		<td><label class='bold'>$i18n.getString( 'filter_on_section' )</label></td>
 	</tr>

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-10-02 04:32:52 +0000
@@ -88,46 +88,51 @@
 			currentPeriodTypeName = value.split( '_' )[1] == "" ? "Monthly" : value.split( '_' )[1];
 			currentReportTypeName = value.split( '_' )[2];
 
-			if ( currentReportTypeName == "P" ) {
+			if ( currentReportTypeName == "P" )
+			{
 				hideById( "periodCol" );
+			}
+			else if ( currentReportTypeName == "C" )
+			{
+				jQuery.post( "getDataElementGroupOrdersByReport.action",
+				{
+					exportReportId: getFieldValue( 'exportReport' ).split( '_' )[0]
+				},
+				function ( json )
+				{
+					clearListById( 'orderedGroups' );
+
+					jQuery.each( json.dataElementGroupOrders, function( i, item )
+					{
+						addOptionById( 'orderedGroups', item.id, item.name );
+					} );
+					
+					hideById( 'showSubItemTR' );
+					showById( 'orderedGroupLabelTR' );
+					showById( 'orderedGroupSelectTR' );
+					byId( 'exportReportDiv' ).style.height = '410px';
+				} );
+			}
+			else if ( currentReportTypeName == "O" )
+			{
+				showById( "showSubItemTR" );
+				showById( "periodCol" );
+				hideById( 'orderedGroupLabelTR' );
+				hideById( 'orderedGroupSelectTR' );
+				byId( 'exportReportDiv' ).style.height = '320px';
 			} else {
 				showById( "periodCol" );
+				hideById( 'showSubItemTR' );
+				hideById( 'orderedGroupLabelTR' );
+				hideById( 'orderedGroupSelectTR' );
+				byId( 'exportReportDiv' ).style.height = '300px';
 			}
 		}
 	}
-	
-	displayOrderedGroup();
+
 	displayPeriodsInternal();
 }
 
-function displayOrderedGroup()
-{
-	if ( currentReportTypeName == "C" )
-	{
-		jQuery.post( "getDataElementGroupOrdersByReport.action",
-		{
-			exportReportId: getFieldValue( 'exportReport' ).split( '_' )[0]
-		},
-		function ( json )
-		{
-			clearListById( 'orderedGroups' );
-
-			jQuery.each( json.dataElementGroupOrders, function( i, item )
-			{
-				addOptionById( 'orderedGroups', item.id, item.name );
-			} );
-			
-			showById( 'orderedGroupLabelTR' );
-			showById( 'orderedGroupSelectTR' );
-			byId( 'exportReportDiv' ).style.height = '410px';
-		} );
-	} else {		
-		hideById( 'orderedGroupLabelTR' );
-		hideById( 'orderedGroupSelectTR' );
-		byId( 'exportReportDiv' ).style.height = '300px';
-	}
-}
-
 function displayPeriodsInternal()
 {
 	if ( currentPeriodTypeName )
@@ -265,7 +270,11 @@
 
 function generateExportReport() {
 		
-	jQuery.postJSON( 'generateExportReport.action', {}, function ( json ) {
+	jQuery.postJSON( 'generateExportReport.action',
+	{
+		showSubItem: !isChecked( 'showSubItem' )	
+	},
+	function ( json ) {
 		if ( json.response == "success" ) {
 			window.location = "downloadFile.action";		
 			unLockScreen();

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-09-19 02:22:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-10-02 04:32:52 +0000
@@ -78,12 +78,12 @@
 
 function previewExportReport()
 {
-	jQuery.post( "previewExportReport.action", {}, previewExportReportReceived );
+	jQuery.get( "previewExportReport.action", { showSubItem: !isChecked( 'showSubItem' ) }, previewExportReportReceived );
 }
 
 function previewAdvandReport() 
 {	
-	jQuery.post( "previewAdvancedExportReport.action", { organisationGroupId: byId( "availableOrgunitGroups" ).value }, previewExportReportReceived );
+	jQuery.get( "previewAdvancedExportReport.action", { organisationGroupId: getFieldValue( 'availableOrgunitGroups' ) }, previewExportReportReceived );
 }
 
 function previewExportReportReceived( parentElement )