=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-01-25 17:11:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-02-23 08:38:50 +0000 @@ -31,9 +31,12 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import org.apache.struts.taglib.html.FormTag; import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.caseaggregation.CaseAggregationConditionService; import org.hisp.dhis.caseentry.state.PeriodGenericManager; @@ -135,20 +138,41 @@ this.dataSetId = dataSetId; } - private Map mapDataValues; - - public Map getMapDataValues() + private Map mapStatusValues = new HashMap(); + + public Map getMapStatusValues() + { + return mapStatusValues; + } + + private Map> mapDataValues = new HashMap>(); + + public Map> getMapDataValues() { return mapDataValues; } - private Map mapCaseAggCondition; + private Map mapCaseAggCondition = new HashMap(); public Map getMapCaseAggCondition() { return mapCaseAggCondition; } + private List orgunits = new ArrayList(); + + public List getOrgunits() + { + return orgunits; + } + + private List periods = new ArrayList(); + + public List getPeriods() + { + return periods; + } + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- @@ -156,9 +180,6 @@ public String execute() throws Exception { - mapDataValues = new HashMap(); - mapCaseAggCondition = new HashMap(); - String storedBy = currentUserService.getCurrentUsername() + "_CAE"; // --------------------------------------------------------------------- @@ -172,21 +193,21 @@ return SUCCESS; } - List orgUnitList = new ArrayList(); - if ( facilityLB.equals( "children" ) ) + if ( facilityLB.equals( "random" ) ) { - orgUnitList = getChildOrgUnitTree( selectedOrgunit ); + orgunits.add( selectedOrgunit ); } else if ( facilityLB.equals( "immChildren" ) ) { - orgUnitList.add( selectedOrgunit ); + orgunits.addAll( getChildOrgUnitTree( selectedOrgunit ) ); + } + else + { List organisationUnits = new ArrayList( selectedOrgunit.getChildren() ); Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE ); - orgUnitList.addAll( organisationUnits ); - } - else - { - orgUnitList.add( selectedOrgunit ); + + orgunits.addAll( organisationUnits ); + orgunits.add( selectedOrgunit ); } // --------------------------------------------------------------------- @@ -201,8 +222,6 @@ // Get selected periods list // --------------------------------------------------------------------- - List periodList = new ArrayList(); - Period startPeriod = periodGenericManager.getSelectedPeriod( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START, PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START ); @@ -211,13 +230,13 @@ PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END, PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END ); - periodList = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType(), startPeriod, endPeriod ); + periods = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType(), startPeriod, endPeriod ); // --------------------------------------------------------------------- // Aggregation // --------------------------------------------------------------------- - for ( OrganisationUnit orgUnit : orgUnitList ) + for ( OrganisationUnit orgUnit : orgunits ) { for ( DataElement dElement : dataElementList ) { @@ -231,16 +250,17 @@ if ( condition != null ) { - for ( Period period : periodList ) + for ( Period period : periods ) { - String message = i18n.getString( "in" ) + " " + format.formatPeriod( period ); - Double resultValue = aggregationConditionService.parseConditition( condition, orgUnit, period ); DataValue dataValue = dataValueService .getDataValue( orgUnit, dElement, period, optionCombo ); + String key = orgUnit.getId() + "-" + format.formatPeriod( period ); + String keyStatus = key + "-" + dElement.getId(); + if ( resultValue != null && resultValue != 0.0 ) { if ( dataValue == null ) @@ -249,7 +269,7 @@ new Date(), null, optionCombo ); dataValueService.addDataValue( dataValue ); - mapDataValues.put( dataValue, i18n.getString( "added" ) + " " + message ); + mapStatusValues.put( keyStatus, i18n.getString( "added" ) ); } else { @@ -259,7 +279,7 @@ dataValueService.updateDataValue( dataValue ); - mapDataValues.put( dataValue, i18n.getString( "updated" ) + " " + message ); + mapStatusValues.put( keyStatus, i18n.getString( "updated" ) ); } mapCaseAggCondition.put( dataValue, condition ); @@ -267,18 +287,32 @@ } else if ( dataValue != null ) { - DataValue dvalue = new DataValue( dElement, period, orgUnit, "", storedBy, new Date(), + String value = dataValue.getValue(); + + dataValueService.deleteDataValue( dataValue ); + + dataValue = new DataValue( dElement, period, orgUnit, value, storedBy, new Date(), null, optionCombo ); - - dvalue.setValue( dataValue.getValue() + " " + i18n.getString( "old_value" ) ); - - dataValueService.deleteDataValue( dataValue ); - - mapDataValues.put( dvalue, i18n.getString( "deleted" ) + " " + message ); - } - + + mapStatusValues.put( keyStatus, i18n.getString( "deleted" ) ); + } + + if ( dataValue != null ) + { + Set dataValues = null; + if ( mapDataValues.containsKey( key ) ) + { + dataValues = mapDataValues.get( key ); + } + else + { + dataValues = new HashSet(); + } + + dataValues.add( dataValue ); + mapDataValues.put( key, dataValues ); + } } - } } } @@ -320,7 +354,7 @@ period = periodType.getNextPeriod( period ); periods.add( period ); } - + return 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 2012-02-21 19:40:27 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-02-23 08:38:50 +0000 @@ -83,7 +83,7 @@ in=in value=Value status=Status -no_value_added_or_update=No values added or updated. +no_value_added_or_update=No values added or updated date_less_incident_date=This date is less then the incident date. deleted=Deleted old_value=Old Value @@ -251,4 +251,5 @@ show_all_items=Show all items see_history_plan=See history / plan name_based_data_entry=Name-based data entry -multiple_name_based_data_entry=Multiple name-based data entry \ No newline at end of file +multiple_name_based_data_entry=Multiple name-based data entry +ga_facilityby=Organisation Unit By \ 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 2012-02-13 19:27:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-02-23 08:38:50 +0000 @@ -261,6 +261,7 @@ /dhis-web-caseentry/caseAggregationForm.vm /dhis-web-caseentry/caseAggregationMenu.vm javascript/caseagg.js,javascript/date.js,javascript/caseAggregationForm.js + style/dataEntry.css $i18n.getString( "case_aggregation_result" ) - +

-
-#if( $mapDataValues.keySet().size() > 0 ) - - - - - - - - - - - - - - - #set ( $keys = $mapDataValues.keySet() ) - #set ($index = 1) - - #set( $mark = false ) - #foreach( $key in $keys) - - - - - - - #set( $mark = !$mark ) - #set ($index = $index + 1) + +#set( $index = 0 ) +#foreach( $orgunit in $orgunits) +

$orgunit.name

+ #foreach( $period in $periods) + #set( $index = $index + 1 ) + #set( $periodInfo = $orgunit.id + '-' + $index ) + #set( $periodButton = $periodInfo + "-button") + #set( $periodDiv = $periodInfo + "-div") + #set( $key = $orgunit.id + '-' + $format.formatPeriod($period) ) + +

$format.formatPeriod( $period ) + #if( $!mapDataValues.get( $key ) ) +

+ + #set( $dataValues = $mapDataValues.get( $key ) ) +
#$i18n.getString('name')$i18n.getString('value')$i18n.getString('status')
$index$key.dataElement.getName()$key.getValue()$mapDataValues.get($key)
+ + + + + + #set( $mark = false ) + #set($no = 1) + + + + + + + #foreach( $dataValue in $dataValues) + #set( $statusKey = $key + '-' + $dataValue.dataElement.id ) + + + + + + + #set( $mark = !$mark ) + #set ($no = $no + 1) + #end + + + #else + ($i18n.getString('no_value_added_or_update')) #end - - -#else - $i18n.getString('no_value_added_or_update') + #end #end -
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2012-02-14 03:37:23 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2012-02-23 08:38:50 +0000 @@ -144,3 +144,7 @@ showById('caseAggregationForm'); } +function toggleResult( id ) +{ + $( "#" + id + "-div" ).slideToggle( "fast" ); +}