← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2078: Minor fix.

 

------------------------------------------------------------
revno: 2078
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-09-07 18:43:00 +0700
message:
  Minor fix.
modified:
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/datasetcompleted/action/ViewCompletedReportByPeriodsAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseCompletedReportByPeriod.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-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/datasetcompleted/action/ViewCompletedReportByPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/datasetcompleted/action/ViewCompletedReportByPeriodsAction.java	2010-07-13 15:50:08 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/datasetcompleted/action/ViewCompletedReportByPeriodsAction.java	2010-09-07 11:43:00 +0000
@@ -28,23 +28,27 @@
  */
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.comparator.PeriodComparator;
+import org.hisp.dhis.reportexcel.status.DataEntryStatus;
 
 import com.opensymphony.xwork2.Action;
 
@@ -90,20 +94,13 @@
         this.completeDataSetRegistrationService = completeDataSetRegistrationService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
+    public DataValueService dataValueService;
+
+    public void setDataValueService( DataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+    
     // -------------------------------------------
     // Input
     // -------------------------------------------
@@ -147,9 +144,9 @@
         return dataSet;
     }
 
-    private Map<String, String> completedValues;
+    private Map<String, Integer> completedValues;
 
-    public Map<String, String> getCompletedValues()
+    public Map<String, Integer> getCompletedValues()
     {
         return completedValues;
     }
@@ -169,7 +166,7 @@
 
         CompleteDataSetRegistration completeDataSetRegistration = null;
 
-        completedValues = new HashMap<String, String>();
+        completedValues = new HashMap<String, Integer>();
 
         for ( Integer id : columns )
         {
@@ -177,18 +174,35 @@
 
             for ( OrganisationUnit o : organisationUnits )
             {
-                if ( o.getDataSets().contains( dataSet ) )
+                 if ( o.getDataSets().contains( dataSet ) )
                 {
+                    Collection<DataElement> dataElements = dataSet.getDataElements();
+                    Collection<DataValue> values = dataValueService.getDataValues( o, period, dataElements );
+                    int count = 0;
+                    for(DataElement de : dataElements)
+                    {
+                        int opCount = 1;
+                        for ( DataElementCategory ca : de.getCategoryCombo().getCategories()){
+                            opCount *= ca.getCategoryOptions().size();
+                        }
+                        count += opCount;
+                    }
+                    int percent = (values.size() * 100 ) / count ;
+                    
                     completeDataSetRegistration = completeDataSetRegistrationService.getCompleteDataSetRegistration(
                         dataSet, period, o );
 
                     if ( completeDataSetRegistration != null )
                     {
-                        completedValues.put( o.getId() + ":" + id, format.formatDate( completeDataSetRegistration
-                            .getDate() ) );
+                        completedValues.put( o.getId() + ":" + id, percent );
+                    }else{
+                        percent = (percent == 0 ) ? 900 : ( 1000 * percent ) ;
+                        completedValues.put( o.getId() + ":" + id, percent );
                     }
-                }else{
-                    completedValues.put( o.getId() + ":" + id, "" );
+                }
+                else
+                {
+                    completedValues.put( o.getId() + ":" + id, null );
                 }
             }
 

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-09-06 09:12:16 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-09-07 11:43:00 +0000
@@ -627,10 +627,10 @@
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="organisationUnitSelectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="organisationUnitService"
-			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="completeDataSetRegistrationService"
 			ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
+		<property name="dataValueService"
+			ref="org.hisp.dhis.datavalue.DataValueService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseCompletedReportByPeriod.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseCompletedReportByPeriod.vm	2010-07-13 15:50:08 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseCompletedReportByPeriod.vm	2010-09-07 11:43:00 +0000
@@ -13,21 +13,27 @@
 			<td>$o.name</td>
 		#foreach( $p in $periods )
 			<td >
-			#if($!completedValues.get( "$o.id:$p.id" ))
-				#if($completedValues.get( "$o.id:$p.id" )!="")
+				#if($!completedValues.get( "$o.id:$p.id" ))
+					#if($completedValues.get( "$o.id:$p.id" ) != "null" )
+						<a href='javascript:viewDataSetReport($dataSet.id,$p.id,$o.id, "$dataSet.name")'>
+							<img src="../images/view_report.png" title="View Data" align="absmiddle">
+						</a>
+						#set ($percent = $completedValues.get( "$o.id:$p.id" ))
+						#if( $percent <= 100) 
+							<img src="../images/check.png" alt="$i18n.getString( 'yes' )" align="absmiddle">
+							<div style="text-align: center; color: white; width: $percent%; background-color: green;">$percent%</div>
+						#else
+							<img src="../images/warning.png" alt="$i18n.getString( 'no' )" align="absmiddle">
+							#set ($percent = $percent/1000 )
+							<div style="text-align: center; color: white; width: $percent%; background-color: green;">$percent%</div>
+						#end 
+					#end
+				#else
 					<a href='javascript:viewDataSetReport($dataSet.id,$p.id,$o.id, "$dataSet.name")'>
 						<img src="../images/view_report.png" title="View Data" align="absmiddle">
 					</a>
-					<img src="../images/check.png" alt="$i18n.getString( 'yes' )" align="absmiddle">				
-					[$completedValues.get( "$o.id:$p.id" )]
+					<img src="../images/warning.png" alt="$i18n.getString( 'no' )" align="absmiddle">
 				#end
-			#else
-				<a href='javascript:viewDataSetReport($dataSet.id,$p.id,$o.id, "$dataSet.name")'>
-						<img src="../images/view_report.png" title="View Data" align="absmiddle">
-				</a>
-				<img src="../images/warning.png" alt="$i18n.getString( 'no' )" align="absmiddle">
-			#end
-			
 			</td>
 		#end
 		</tr>