=== 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-07-04 08:55:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-07-23 04:16:21 +0000 @@ -132,7 +132,7 @@ Collection getOrganisationUnitIds( Date startDate, Date endDate ); - Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate, + Grid getCompletenessProgramStageInstance( Collection orgunits, Program program, String startDate, String endDate, 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-07-04 06:19:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-07-23 04:16:21 +0000 @@ -123,6 +123,6 @@ Collection getOrgunitIds( Date startDate, Date endDate ); - Grid getCompleteness( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n ); + Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ); } === 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-07-04 08:55:19 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-07-23 04:16:21 +0000 @@ -523,10 +523,10 @@ } @Override - public Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate, + public Grid getCompletenessProgramStageInstance( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ) { - return programStageInstanceStore.getCompleteness( orgunit, program, startDate, endDate, i18n ); + return programStageInstanceStore.getCompleteness( orgunitIds, program, startDate, endDate, i18n ); } } === 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-07-02 12:24:02 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-07-23 04:16:21 +0000 @@ -732,7 +732,7 @@ return rs != null ? rs.intValue() : 0; } - public Grid getCompleteness( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n ) + public Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ) { String sql = "SELECT ou.name as orgunit, ps.name as events, psi.completeduser as user_name, count(psi.programstageinstanceid) as number_of_events " + " FROM programstageinstance psi INNER JOIN programstage ps " @@ -741,9 +741,9 @@ + " ON ou.organisationunitid=psi.organisationunitid" + " INNER JOIN program pg " + " ON pg.programid = ps.programid " - + " WHERE ou.parentid = " - + orgunit.getId() - + " AND pg.programid = " + + " WHERE ou.organisationunitid in ( " + + TextUtils.getCommaDelimitedString( orgunitIds ) + + " ) AND pg.programid = " + program.getId() + " GROUP BY ou.name, ps.name, psi.completeduser, psi.completeddate, psi.completed " + " HAVING psi.completeddate >= '" === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java 2013-04-16 05:41:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java 2013-07-23 04:16:21 +0000 @@ -27,10 +27,14 @@ package org.hisp.dhis.caseentry.action.caseentry; +import java.util.Collection; +import java.util.HashSet; + import org.hisp.dhis.common.Grid; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStageInstanceService; @@ -49,11 +53,18 @@ // Dependencies // ------------------------------------------------------------------------- - private OrganisationUnitSelectionManager selectionManager; - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; } private ProgramService programService; @@ -109,6 +120,13 @@ this.type = type; } + private String facilityLB; + + public void setFacilityLB( String facilityLB ) + { + this.facilityLB = facilityLB; + } + private Grid grid; public Grid getGrid() @@ -126,10 +144,40 @@ { Program program = programService.getProgram( programId ); - OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit(); - - grid = programStageInstanceService.getCompletenessProgramStageInstance( orgunit, program, startDate, endDate, - i18n ); + Collection orgunits = selectionTreeManager.getRootOrganisationUnits(); + + program = programService.getProgram( programId ); + + // --------------------------------------------------------------------- + // Get orgunitIds + // --------------------------------------------------------------------- + + Collection orgunitIds = new HashSet(); + + for ( OrganisationUnit orgunit : orgunits ) + { + if ( facilityLB.equals( "selected" ) ) + { + orgunitIds.add( orgunit.getId() ); + } + else if ( facilityLB.equals( "childrenOnly" ) ) + { + orgunitIds + .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); + orgunitIds.remove( orgunit.getId() ); + } + else + { + orgunitIds + .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); + } + } + + if ( orgunitIds.size() > 0 ) + { + grid = programStageInstanceService.getCompletenessProgramStageInstance( orgunitIds, program, startDate, + endDate, i18n ); + } return (type == null) ? SUCCESS : type; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-07-23 02:52:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-07-23 04:16:21 +0000 @@ -1162,8 +1162,10 @@ id="org.hisp.dhis.caseentry.action.caseentry.ProgramStageInstanceCompletenessAction" class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageInstanceCompletenessAction" scope="prototype"> - + + === 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-07-09 07:14:55 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-07-23 04:16:21 +0000 @@ -664,4 +664,5 @@ table_layout = Layout is_hidden = Is hidden default_form_name = Default form name -custom_form_name = Custom form name \ No newline at end of file +custom_form_name = Custom form name +use_orgunits_from_level = Use organisation Units from level \ No newline at end of file === 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-06-13 07:36:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-07-23 04:16:21 +0000 @@ -1163,10 +1163,9 @@ /main.vm /dhis-web-caseentry/programStageCompletenessSelect.vm - /dhis-web-caseentry/reportsMenu.vm + /dhis-web-caseentry/reportsMenuWithoutOrgunit.vm style/style.css - ../dhis-web-commons/ouwt/ouwt.js, javascript/commons.js, javascript/programStageCompleteness.js F_PROGRAM_STAGE_COMPLETENESS === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js 2013-05-21 10:08:44 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js 2013-07-23 04:16:21 +0000 @@ -2,6 +2,8 @@ function orgunitSelected( orgUnits, orgUnitNames ) { + showById('selectDiv'); + hideById('showDataBtn'); hideById("listPatientDiv"); setFieldValue('orgunitName', orgUnitNames[0]); setFieldValue('orgunitId', orgUnits[0]); @@ -11,12 +13,15 @@ function generateStageCompleteness() { + hideById('selectDiv'); + showById('showDataBtn'); showLoader(); jQuery('#completenessDiv').load('generateProgramStageCompleteness.action', { programId: getFieldValue('programId'), startDate: getFieldValue('startDate'), - endDate: getFieldValue('endDate') + endDate: getFieldValue('endDate'), + facilityLB: $('input[name=facilityLB]:checked').val() }, function() { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm 2013-06-04 06:13:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm 2013-07-23 04:16:21 +0000 @@ -16,7 +16,7 @@

$i18n.getString( "program_stage_completeness_form" ) #openHelp('program_stage_completeness')

-