← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10502: Add option to show/hide totals in Aggregate tabular report.

 

------------------------------------------------------------
revno: 10502
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-04-09 12:48:54 +0700
message:
  Add option to show/hide totals in Aggregate tabular report.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.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-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-03-25 04:56:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-04-09 05:48:54 +0000
@@ -112,7 +112,7 @@
 
     Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
-        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, I18nFormat format,
+        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals, I18nFormat format,
         I18n i18n );
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-03-25 04:56:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-04-09 05:48:54 +0000
@@ -104,13 +104,13 @@
 
     Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
-        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, I18nFormat format,
-        I18n i18n );
+        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents,
+        Boolean displayTotals, I18nFormat format, I18n i18n );
 
     // -------------------------------------------------------------------------
     // Activity plans
     // -------------------------------------------------------------------------
-    
+
     Collection<ProgramStageInstance> get( Program program, Collection<Integer> orgunitIds, Date startDate,
         Date endDate, Boolean completed );
 
@@ -123,7 +123,7 @@
 
     int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         Boolean completed );
-    
+
     Collection<Integer> getOrgunitIds( Date startDate, Date endDate );
-    
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-03-25 04:56:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-04-09 05:48:54 +0000
@@ -481,11 +481,11 @@
     @Override
     public Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
-        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, I18nFormat format,
+        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals, I18nFormat format,
         I18n i18n )
     {
         return programStageInstanceStore.getAggregateReport( position, programStage, orgunitIds, facilityLB, deGroupBy,
-            deSum, deFilters, periods, aggregateType, limit, useCompletedEvents, format, i18n );
+            deSum, deFilters, periods, aggregateType, limit, useCompletedEvents, displayTotals, format, i18n );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-04-04 18:06:19 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-04-09 05:48:54 +0000
@@ -469,8 +469,8 @@
 
     public Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
-        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, I18nFormat format,
-        I18n i18n )
+        List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals,
+        I18nFormat format, I18n i18n )
     {
         String sql = "";
         List<String> deValues = new ArrayList<String>();
@@ -684,11 +684,11 @@
                 || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_ORGUNIT
                 || (position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD && deGroupBy == null) )
             {
-                pivotTable( grid, rowSet, i18n, format );
+                pivotTable( grid, rowSet, displayTotals, i18n, format );
             }
             else
             {
-                fillDataInGrid( grid, rowSet, i18n, format );
+                fillDataInGrid( grid, rowSet, displayTotals, i18n, format );
             }
         }
 
@@ -1954,7 +1954,7 @@
             Projections.property( "orgunit.id" ), "orgunitid" ) ) );
         return criteria.list();
     }
-    
+
     // ---------------------------------------------------------------------
     // Get orgunitIds
     // ---------------------------------------------------------------------
@@ -1980,7 +1980,7 @@
         return orgunitIds;
     }
 
-    private void fillDataInGrid( Grid grid, SqlRowSet rs, I18n i18n, I18nFormat format )
+    private void fillDataInGrid( Grid grid, SqlRowSet rs, Boolean displayTotals, I18n i18n, I18nFormat format )
     {
         int cols = rs.getMetaData().getColumnCount();
         int dataCols = 0;
@@ -1996,7 +1996,7 @@
         }
 
         // Add total column if the number of columns is greater then 1
-        if ( dataCols > 1 )
+        if ( displayTotals && dataCols > 1 )
         {
             grid.addHeader( new GridHeader( i18n.getString( "total" ), false, false ) );
         }
@@ -2025,14 +2025,14 @@
             }
 
             // total
-            if ( dataCols > 1 )
+            if ( displayTotals && dataCols > 1 )
             {
                 grid.addValue( format.formatValue( total ) );
             }
         }
 
         // Add total row if the number of rows is greater then 1
-        if ( grid.getRows().size() > 1 )
+        if ( displayTotals && grid.getRows().size() > 1 )
         {
             grid.addRow();
             grid.addValue( i18n.getString( "total" ) );
@@ -2050,7 +2050,7 @@
         }
     }
 
-    private void pivotTable( Grid grid, SqlRowSet rowSet, I18n i18n, I18nFormat format )
+    private void pivotTable( Grid grid, SqlRowSet rowSet, Boolean displayTotals, I18n i18n, I18nFormat format )
     {
         try
         {
@@ -2074,6 +2074,7 @@
                 for ( int i = 2; i <= cols; i++ )
                 {
                     column.add( rowSet.getObject( i ) );
+                    
                     // Total value of the column
                     if ( rowSet.getMetaData().getColumnType( i ) != Types.VARCHAR )
                     {
@@ -2082,9 +2083,10 @@
                 }
 
                 // Add total value of the column
-                if ( cols > 2 )
+                if ( displayTotals && cols > 2 )
                 {
-                    grid.addValue( format.formatValue( total ) );
+                    //grid.addValue( format.formatValue( total ) );
+                    column.add( format.formatValue( total ) );
                 }
 
                 columnValues.put( index, column );
@@ -2092,7 +2094,7 @@
             }
 
             // Add total header
-            if ( rows > 1 )
+            if ( displayTotals && rows > 1 )
             {
                 grid.addHeader( new GridHeader( i18n.getString( "total" ), false, false ) );
             }
@@ -2105,7 +2107,7 @@
                 column.add( i18n.getString( rowSet.getMetaData().getColumnLabel( i ) ) );
             }
 
-            if ( cols > 2 )
+            if ( displayTotals && cols > 2 )
             {
                 grid.addRow();
                 column.add( i18n.getString( "total" ) );
@@ -2118,7 +2120,7 @@
                 grid.addColumn( columnValues.get( i ) );
             }
 
-            if ( rows > 1 )
+            if ( displayTotals && rows > 1 )
             {
                 // Total column
                 int allTotal = 0;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-03-18 03:57:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-04-09 05:48:54 +0000
@@ -229,6 +229,13 @@
         this.type = type;
     }
 
+    private Boolean displayTotals;
+
+    public void setDisplayTotals( Boolean displayTotals )
+    {
+        this.displayTotals = displayTotals;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -246,6 +253,8 @@
 
     public String execute()
     {
+        displayTotals = ( displayTotals == null )? false : displayTotals;
+        
         // ---------------------------------------------------------------------
         // Get user orgunits
         // ---------------------------------------------------------------------
@@ -296,18 +305,18 @@
         }
 
         // Fixed periods
-        List<Period> fixedPeriodList = new ArrayList<Period>(); 
+        List<Period> fixedPeriodList = new ArrayList<Period>();
         for ( String periodId : fixedPeriods )
         {
             Period p = PeriodType.getPeriodFromIsoString( periodId );
             fixedPeriodList.add( p );
         }
-        Collections.sort( fixedPeriodList, new AscendingPeriodComparator() );      
+        Collections.sort( fixedPeriodList, new AscendingPeriodComparator() );
         periods.addAll( fixedPeriodList );
-        
+
         // Relative periods
         periods.addAll( getRelativePeriod() );
-        
+
         // ---------------------------------------------------------------------
         // Generate report
         // ---------------------------------------------------------------------
@@ -335,9 +344,9 @@
                 }
             }
         }
-        
+
         grid = programStageInstanceService.getAggregateReport( position, programStage, orgunitIds, facilityLB,
-            deGroupBy, deSum, deFilterMap, periods, aggregateType, limitRecords, useCompletedEvents, format, i18n );
+            deGroupBy, deSum, deFilterMap, periods, aggregateType, limitRecords, useCompletedEvents, displayTotals, format, i18n );
 
         return type == null ? SUCCESS : type;
     }
@@ -351,13 +360,13 @@
         List<Period> periods = new ArrayList<Period>();
 
         RelativePeriods rp = new RelativePeriods();
-        
+
         if ( relativePeriods.contains( "lastWeek" ) )
         {
             rp.clear().setLastWeek( true );
             periods.addAll( periodService.reloadPeriods( rp.getRelativePeriods() ) );
         }
-        
+
         if ( relativePeriods.contains( "last4Weeks" ) )
         {
             rp.clear().setLast4Weeks( true );
@@ -417,8 +426,8 @@
             rp.clear().setLast5Years( true );
             periods.addAll( periodService.reloadPeriods( rp.getRelativePeriods() ) );
         }
- 
-        return setNames(periods);
+
+        return setNames( periods );
     }
 
     private List<Period> setNames( List<Period> periods )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-04-08 05:43:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-04-09 05:48:54 +0000
@@ -618,4 +618,6 @@
 confirm_delete_favorite = Are you sure you want to delete favorite ?
 in = IN
 home = Home
-show_all_sections = Show all sections
\ No newline at end of file
+show_all_sections = Show all sections
+aggregate_options = Aggregate options
+display_totals = Display totals
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-04-02 08:24:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-04-09 05:48:54 +0000
@@ -1338,6 +1338,7 @@
 								TR.util.positionFilter.convert( f.position );
 								
 								Ext.getCmp('completedEventsOpt').setValue(f.useCompletedEvents);
+								Ext.getCmp('displayTotalsOpt').setValue(f.displayTotalsOpt);
 								Ext.getCmp('facilityLBCombobox').setValue( f.facilityLB );
 								Ext.getCmp('limitOption').setValue( f.limitRecords );
 								Ext.getCmp('levelCombobox').setValue( f.level );
@@ -2100,8 +2101,15 @@
 					{
 						completedEvent = "&completedEventsOpt=true";
 					}
+					
+					var displayTotals='&displayTotals=false';
+					if( Ext.getCmp('displayTotalsOpt').getValue() == true )
+					{
+						displayTotals = "&displayTotals=true";
+					}
+					
   				    var exportForm = document.getElementById('exportForm');
-					exportForm.action = url + "?type=" + type + completedEvent;
+					exportForm.action = url + "?type=" + type + completedEvent + "&" + displayTotals;
 					exportForm.submit();
 				}
 				// Show report on grid
@@ -2302,6 +2310,15 @@
 					p.useCompletedEvents = Ext.getCmp('completedEventsOpt').getValue();
 				}
 				
+				if( Ext.getCmp('displayTotalsOpt').getValue()== true )
+				{
+					p.displayTotals = Ext.getCmp('displayTotalsOpt').getValue();
+				}
+				else
+				{
+					p.displayTotals = 'false';
+				}
+				
 				return p;
 			},
 			getURLParams: function() {
@@ -5555,14 +5572,31 @@
 													}
 												},
 												{
-													xtype: 'checkbox',
-													cls: 'tr-checkbox',
-													id: 'completedEventsOpt',
-													style:'padding: 0px 0px 0px 3px;',
-													boxLabel: TR.i18n.use_completed_events,
-													boxLabelAlign: 'before',
-													labelWidth: 135
+													xtype: 'panel',
+													layout: 'column',
+													bodyStyle: 'border-style:none; background-color:transparent;',
+													items:[
+														{
+															xtype: 'checkbox',
+															cls: 'tr-checkbox',
+															id: 'completedEventsOpt',
+															style:'padding: 0px 0px 0px 3px;',
+															boxLabel: TR.i18n.use_completed_events,
+															boxLabelAlign: 'before',
+															labelWidth: 135
+														},
+														{
+															xtype: 'checkbox',
+															cls: 'tr-checkbox',
+															id: 'displayTotalsOpt',
+															style:'padding-left: 20px;',
+															boxLabel: TR.i18n.display_totals,
+															boxLabelAlign: 'before',
+															labelWidth: 135
+														},
+													]
 												},
+												
 												{
 													xtype: 'combobox',
 													cls: 'tr-combo',

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-04-02 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-04-09 05:48:54 +0000
@@ -186,4 +186,6 @@
 next: '$encoder.jsEscape($i18n.getString( 'next' ) , "'")',
 confirm_delete_favorite: '$encoder.jsEscape($i18n.getString( 'confirm_delete_favorite' ) , "'")',
 home: '$encoder.jsEscape($i18n.getString( 'home' ) , "'")',
+aggregate_options: '$encoder.jsEscape($i18n.getString( 'aggregate_options' ) , "'")',
+display_totals: '$encoder.jsEscape($i18n.getString( 'display_totals' ) , "'")',
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-03-07 04:29:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-04-09 05:48:54 +0000
@@ -95,6 +95,7 @@
 	"deSumName": #if($!aggregateReport.deSum) "$!encoder.jsonEncode( ${aggregateReport.deSum.displayName})" #else "" #end,
 	"aggregateType": "${aggregateReport.aggregateType}",
 	"useCompletedEvents": "$!aggregateReport.useCompletedEvents",
+	"displayTotals": "$!aggregateReport.displayTotals",
 	"userOrganisationUnit": "$!aggregateReport.userOrganisationUnit",
 	"userOrganisationUnitChildren": "$!aggregateReport.userOrganisationUnitChildren"
 }
\ No newline at end of file