=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-03-12 18:00:07 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-03-13 16:45:17 +0000 @@ -328,8 +328,8 @@ "left join dataapproval da on da.organisationunitid = ous.organisationunitid " + "and da.dataapprovallevelid = " + dal.getId() + " and da.periodid in (" + periodIds + ") " + "and da.datasetid in (" + dataSetIds + ") " + + "where ous.idlevel" + orgUnitLevel + " = o.organisationunitid " + "and da.attributeoptioncomboid = cocco.categoryoptioncomboid " + - "where ous.idlevel" + orgUnitLevel + " = o.organisationunitid " + "and ous.level = " + dal.getOrgUnitLevel() + " " + "and ( da.dataapprovalid is null " + ( acceptanceRequiredForApproval ? "or not da.accepted " : "" ) + ") )"; break; @@ -349,16 +349,16 @@ final String sql = "select cocco.categoryoptioncomboid, o.organisationunitid, " + "(select min(coalesce(dal.level, 0)) from period p " + - "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " + - "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " + + "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " + "left join dataapprovallevel dal on dal.dataapprovallevelid = da.dataapprovallevelid " + "where p.periodid in (" + periodIds + ") " + + "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " + ") as highest_approved_level, " + "(select substring(min(concat(100000 + coalesce(dal.level, 0), coalesce(da.accepted, FALSE))) from 7) from period p " + "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " + - "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " + "left join dataapprovallevel dal on dal.dataapprovallevelid = da.dataapprovallevelid " + "where p.periodid in (" + periodIds + ") " + + "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " + ") as accepted_at_highest_level, " + readyBelowSubquery + " as ready_below, " + approvedAboveSubquery + " as approved_above " +