=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2010-08-28 10:44:15 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-01-13 15:44:09 +0000 @@ -81,6 +81,8 @@ private List organisationUnits = new ArrayList(); private RelativePeriods relatives; + + private Boolean userOrganisationUnit; // ------------------------------------------------------------------------- // Transient properties @@ -92,6 +94,10 @@ private List allPeriods = new ArrayList(); + private OrganisationUnit organisationUnit; + + private List allOrganisationUnits = new ArrayList(); + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -108,7 +114,9 @@ public void init() { allPeriods.addAll( periods ); - allPeriods.addAll( relativePeriods ); + allPeriods.addAll( relativePeriods ); + allOrganisationUnits.addAll( organisationUnits ); + allOrganisationUnits.add( organisationUnit ); } // ------------------------------------------------------------------------- @@ -198,6 +206,11 @@ { return isSize( SIZE_TALL ) ? 800 : 500; } + + public boolean isUserOrganisationUnit() + { + return userOrganisationUnit != null && userOrganisationUnit; + } // ------------------------------------------------------------------------- // Importable object @@ -357,6 +370,16 @@ this.relatives = relatives; } + public Boolean getUserOrganisationUnit() + { + return userOrganisationUnit; + } + + public void setUserOrganisationUnit( Boolean userOrganisationUnit ) + { + this.userOrganisationUnit = userOrganisationUnit; + } + public List getRelativePeriods() { return relativePeriods; @@ -376,4 +399,24 @@ { this.allPeriods = allPeriods; } + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + public void setOrganisationUnit( OrganisationUnit organisationUnit ) + { + this.organisationUnit = organisationUnit; + } + + public List getAllOrganisationUnits() + { + return allOrganisationUnits; + } + + public void setAllOrganisationUnits( List allOrganisationUnits ) + { + this.allOrganisationUnits = allOrganisationUnits; + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-01-11 19:13:34 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-01-13 15:44:09 +0000 @@ -128,6 +128,11 @@ return CollectionUtils.isEmpty( organisationUnits ) ? null : organisationUnits.iterator().next(); } + public boolean hasOrganisationUnit() + { + return !CollectionUtils.isEmpty( organisationUnits ); + } + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-01-07 11:37:47 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-01-13 15:44:09 +0000 @@ -68,6 +68,8 @@ import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.MathUtils; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; @@ -160,6 +162,13 @@ { this.systemSettingManager = systemSettingManager; } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } // ------------------------------------------------------------------------- // ChartService implementation @@ -175,8 +184,15 @@ if ( chart.getRelatives() != null ) { - chart.setRelativePeriods( periodService.reloadPeriods( chart.getRelatives().getRelativePeriods( 1, null, - false ) ) ); + chart.setRelativePeriods( periodService.reloadPeriods( + chart.getRelatives().getRelativePeriods( 1, null, false ) ) ); + } + + User user = currentUserService.getCurrentUser(); + + if ( chart.isUserOrganisationUnit() && user != null && user.getOrganisationUnit() != null ) + { + chart.setOrganisationUnit( user.getOrganisationUnit() ); } chart.setFormat( format ); @@ -465,7 +481,7 @@ if ( chart != null ) { Period selectedPeriod = chart.getAllPeriods().get( 0 ); - OrganisationUnit selectedOrganisationUnit = chart.getOrganisationUnits().get( 0 ); + OrganisationUnit selectedOrganisationUnit = chart.getAllOrganisationUnits().get( 0 ); for ( Indicator indicator : chart.getIndicators() ) { @@ -535,7 +551,7 @@ // Regular dataset // --------------------------------------------------------- - for ( OrganisationUnit unit : chart.getOrganisationUnits() ) + for ( OrganisationUnit unit : chart.getAllOrganisationUnits() ) { final Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService.getAggregatedIndicatorValue( indicator, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), unit ) : @@ -601,9 +617,9 @@ subTitle.setFont( subTitleFont ); - if ( chart.isDimension( DIMENSION_PERIOD ) && chart.getOrganisationUnits().size() > 0 ) + if ( chart.isDimension( DIMENSION_PERIOD ) && chart.getAllOrganisationUnits().size() > 0 ) { - subTitle.setText( chart.getOrganisationUnits().get( 0 ).getName() ); + subTitle.setText( chart.getAllOrganisationUnits().get( 0 ).getName() ); } else if ( chart.isDimension( DIMENSION_ORGANISATIONUNIT ) && chart.getAllPeriods().size() > 0 ) { === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-01-07 11:37:47 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-01-13 15:44:09 +0000 @@ -112,6 +112,8 @@ ref="org.hisp.dhis.options.SystemSettingManager"/> + === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2011-01-13 15:44:09 +0000 @@ -57,5 +57,7 @@ + + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java 2010-07-18 15:17:23 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java 2011-01-13 15:44:09 +0000 @@ -112,7 +112,7 @@ { this.organisationUnitComparator = organisationUnitComparator; } - + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-01-13 15:44:09 +0000 @@ -152,6 +152,13 @@ this.regression = regression; } + private boolean userOrganisationUnit; + + public void setUserOrganisationUnit( boolean userOrganisationUnit ) + { + this.userOrganisationUnit = userOrganisationUnit; + } + private List selectedIndicators = new ArrayList(); public void setSelectedIndicators( List selectedIndicators ) @@ -254,6 +261,7 @@ chart.setVerticalLabels( verticalLabels ); chart.setHorizontalPlotOrientation( horizontalPlotOrientation ); chart.setRegression( regression ); + chart.setUserOrganisationUnit( userOrganisationUnit ); chart.setIndicators( indicators ); chart.setPeriods( periods ); chart.setOrganisationUnits( organisationUnits ); === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-13 15:44:09 +0000 @@ -243,8 +243,10 @@ select_none = Clear all tally_sheet = Tally Sheet edit_tally_rows = (Optional) Edit tally row numbers manually +clear = Clear next = Next prev = Prev +none = None facility = Facility month = Month year = Year @@ -303,4 +305,5 @@ get_report = Get report get_report_as_xls = Download as Excel get_report_as_csv = Download as CSV -get_report_as_pdf = Download as PDF \ No newline at end of file +get_report_as_pdf = Download as PDF +user_organisation_unit = Include current user organisation unit \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2010-08-28 10:44:15 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-01-13 15:44:09 +0000 @@ -59,6 +59,12 @@ + #if ( $currentUser && $currentUser.hasOrganisationUnit() ) + + + + + #end === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm 2011-01-13 15:44:09 +0000 @@ -133,7 +133,7 @@ - $i18n.getString( "filter_available_organisationunits" ) + $i18n.getString( "filter_available_organisationunits" ) - $i18n.getString( 'clear' ) === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm 2011-01-13 15:44:09 +0000 @@ -81,7 +81,7 @@ - $i18n.getString( "filter_available_organisationunits" ) + $i18n.getString( "filter_available_organisationunits" ) - $i18n.getString( 'clear' ) === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js 2011-01-13 15:44:09 +0000 @@ -95,7 +95,7 @@ return false; } - if ( !hasElements( "selectedOrganisationUnits" ) ) + if ( !hasElements( "selectedOrganisationUnits" ) && !isChecked( "userOrganisationUnit" ) ) { setMessage( i18n_must_select_at_least_one_unit );