← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12231: Fixed bugs in tabular report.

 

------------------------------------------------------------
revno: 12231
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-09-25 14:00:33 +0700
message:
  Fixed bugs in tabular report.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java	2013-08-28 06:43:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java	2013-09-25 07:00:33 +0000
@@ -31,6 +31,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageSection;
 import org.hisp.dhis.program.ProgramStageService;
 
@@ -81,10 +82,13 @@
     public String execute()
         throws Exception
     {
-        sections = new ArrayList<ProgramStageSection>( programStageService.getProgramStage( programStageId )
-            .getProgramStageSections() );
+        ProgramStage programStage = programStageService.getProgramStage( programStageId );
+        
+        if ( programStage.getProgramStageSections() != null )
+        {
+            sections = new ArrayList<ProgramStageSection>( programStage.getProgramStageSections() );
+        }
 
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2013-09-03 15:04:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2013-09-25 07:00:33 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageSection;
 import org.hisp.dhis.program.ProgramStageSectionService;
@@ -95,13 +96,6 @@
     // Input/output
     // -------------------------------------------------------------------------
 
-    private String programId;
-
-    public void setProgramId( String programId )
-    {
-        this.programId = programId;
-    }
-
     private String programStageId;
 
     public void setProgramStageId( String programStageId )
@@ -145,36 +139,36 @@
     public String execute()
         throws Exception
     {
-        if ( programId != null )
-        {
-            Program program = programService.getProgram( programId );
-            if ( program.isRegistration() )
-            {
-                Collection<PatientIdentifierType> identifierTypes = identifierTypeService
-                    .getAllPatientIdentifierTypes();
-                Collection<PatientAttribute> patientAttributes = attributeService.getAllPatientAttributes();
-
-                Collection<Program> programs = programService.getAllPrograms();
-                programs.remove( program );
-
-                for ( Program _program : programs )
-                {
-                    identifierTypes.removeAll( _program.getPatientIdentifierTypes() );
-                    patientAttributes.removeAll( _program.getPatientAttributes() );
-                }
-            }
-        }
+        Program program = null;
 
         if ( programStageId != null )
         {
-            psDataElements = programStageService.getProgramStage( programStageId ).getProgramStageDataElements();
+            ProgramStage programStage = programStageService.getProgramStage( programStageId );
+            psDataElements = programStage.getProgramStageDataElements();
+            program = programStage.getProgram();
         }
         else if ( sectionId != null )
         {
             ProgramStageSection section = programStageSectionService.getProgramStageSection( sectionId );
             psDataElements = section.getProgramStageDataElements();
-        }
-
+            program = section.getProgramStageDataElements().iterator().next().getProgramStage().getProgram();
+        }
+
+        if ( program != null && program.isRegistration() )
+        {
+            Collection<PatientIdentifierType> identifierTypes = identifierTypeService.getAllPatientIdentifierTypes();
+            Collection<PatientAttribute> patientAttributes = attributeService.getAllPatientAttributes();
+
+            Collection<Program> programs = programService.getAllPrograms();
+            programs.remove( program );
+
+            for ( Program _program : programs )
+            {
+                identifierTypes.removeAll( _program.getPatientIdentifierTypes() );
+                patientAttributes.removeAll( _program.getPatientAttributes() );
+            }
+        }
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-09-24 04:30:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-09-25 07:00:33 +0000
@@ -45,12 +45,12 @@
             path_api: '../../api/',
             path_images: 'images/',
 			initialize: 'tabularInitialize.action',
-			programstages_get: '../api/programs/',
+			programstages_get: 'programs/',
 			programstagesections_get: 'loadProgramStageSections.action',
 			dataelements_get: 'loadDataElements.action',
 			organisationunitchildren_get: 'getOrganisationUnitChildren.action',
 			organisationunit_getbygroup: 'getOrganisationUnitPathsByGroup.action',
-			generatetabularreport_get: '../api/analytics/events/query/',
+			generatetabularreport_get: 'analytics/events/query/',
 			casebasedfavorite_getall: 'getTabularReports.action',
 			casebasedfavorite_get: 'getTabularReport.action',
 			casebasedfavorite_rename: 'updateTabularReportName.action',
@@ -512,6 +512,7 @@
 				params.valueField = 'value';
 				params.displayField = 'name';
 				params.editable = false;
+				valueType = valueType.split('_')[0];
 				if( filterOperator != undefined || filterOperator!= '')
 				{
 					params.value = filterOperator;
@@ -574,7 +575,7 @@
 			},
 			createFilterField: function( valueType, id, filterValue ){
 				var params = {};
-				var xtype = TR.value.covertXType(valueType);
+				var xtype = TR.value.covertXType(valueType.split('_')[0]);
 				params.xtype = xtype;
 				params.id = 'filter_' + id;
 				params.cls = 'tr-textfield-alt1';
@@ -588,52 +589,20 @@
 				else if( xtype == 'combobox' )
 				{
 					var deId = id.split('_')[0];
-					var fixedId = id.substring(0, id.lastIndexOf('_') );
 					params.typeAhead = true;
 					params.editable = true;
-					if( valueType == 'bool' || fixedId=='fixedAttr_gender' || fixedId=='fixedAttr_dobType')
-					{
+					if( valueType == 'bool' ){
 						params.queryMode = 'local';
 						params.valueField = 'value';
 						params.displayField = 'name';
 						params.editable = false;
-						if( fixedId=='fixedAttr_gender')
-						{
-							params.multiSelect = true;
-							params.delimiter = ';';
-							params.forceSelection = true;
-							params.store = new Ext.data.ArrayStore({
-								fields: ['value', 'name'],
-								data: [['', TR.i18n.please_select], 
-									['M', TR.i18n.male], 
-									['F', TR.i18n.female],
-									['T', TR.i18n.transgender]]
-							});
-						}
-						else if( fixedId=='fixedAttr_dobType')
-						{
-							params.forceSelection = true;
-							params.multiSelect = true;
-							params.delimiter = ';';
-							params.editable = false;
-							params.store = new Ext.data.ArrayStore({
-								fields: ['value', 'name'],
-								data: [['', TR.i18n.please_select],
-									['V', TR.i18n.verified], 
-									['D', TR.i18n.declared],
-									['A', TR.i18n.approximated]]
-							});
-						}
-						else if (valueType == 'bool')
-						{
-							params.forceSelection = true;
-							params.store = new Ext.data.ArrayStore({
-								fields: ['value', 'name'],
-								data: [['', TR.i18n.please_select], 
-									['true', TR.i18n.yes], 
-									['false', TR.i18n.no]]
-							});
-						}
+						params.forceSelection = true;
+						params.store = new Ext.data.ArrayStore({
+							fields: ['value', 'name'],
+							data: [['', TR.i18n.please_select], 
+								['true', TR.i18n.yes], 
+								['false', TR.i18n.no]]
+						});
 					}
 					else if( valueType == 'trueOnly'){
 						params.queryMode = 'local';
@@ -676,7 +645,7 @@
 							proxy: {
 								type: 'ajax',
 								url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.suggested_dataelement_get,
-								extraParams:{id: deId},
+								extraParams:{id: valueType.split('_')[1]},
 								reader: {
 									type: 'json',
 									root: 'options'
@@ -685,6 +654,7 @@
 						});
 					}					
 				}
+				
 				if( filterValue != undefined )
 				{
 					params.value = filterValue;
@@ -1483,7 +1453,7 @@
 			fields: ['id', 'name'],
 			proxy: {
 				type: 'ajax',
-				url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.programstages_get,
+				url: TR.conf.finals.ajax.path_api + TR.conf.finals.ajax.programstages_get,
 				reader: {
 					type: 'json',
 					root: 'programStages'
@@ -1587,6 +1557,7 @@
                 proxy: {
                     type: 'ajax',
                     url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.dataelements_get,
+					disableCaching: false,
                     reader: {
                         type: 'json',
                         root: 'items'
@@ -1789,8 +1760,8 @@
     
     TR.state = {
         currentPage: 1,
-		total: 1,
-		totalRecords: 0,
+		pageCount: 1,
+		total: 0,
 		asc: "",
 		desc: "",
 		orgunitIds: [],
@@ -1839,7 +1810,7 @@
 				// Get url
 				var programId = Ext.getCmp('programCombobox').getValue(); 
 				var programStageId = TR.cmp.params.programStage.getValue();
-				var url = TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.generatetabularreport_get;
+				var url = TR.conf.finals.ajax.path_api + TR.conf.finals.ajax.generatetabularreport_get;
 				
 				// Export to XLS 
 				
@@ -1852,14 +1823,9 @@
 						completedEvent = "&completedEventsOpt=true";
 					}
 					
-					var displayOrgunitCode='';
-					if ( Ext.getCmp('displayOrgunitCode').getValue() == true )
-					{
-						displayOrgunitCode = "&displayOrgunitCode=true";
-					}
 					
   				    var exportForm = document.getElementById('exportForm');
-					exportForm.action = url + programId + ".xls?stage=" + programStageId + completedEvent + displayOrgunitCode;
+					exportForm.action = url + programId + ".xls?stage=" + programStageId + completedEvent;
 					exportForm.submit();
 				}
 				// Show report on grid
@@ -1882,8 +1848,8 @@
 							else{
 								TR.value.columns = json.headers;
 								TR.value.values = json.rows;
-								TR.state.totalRecords = json.metaData.pager.total;
-								TR.state.total = json.metaData.pager.pageCount;
+								TR.state.total = json.metaData.pager.total;
+								TR.state.pageCount = json.metaData.pager.pageCount;
 								
 								// Get fields
 								
@@ -1914,7 +1880,7 @@
 					p.ouMode = TR.cmp.settings.facilityLB.getValue();
 				}
 				
-				// order-by
+				// Order-by
 				
 				if(TR.state.asc!=""){				
 					p.asc = TR.state.asc;
@@ -1923,7 +1889,9 @@
 					p.desc= TR.state.desc;
 				}
 				
-				p.currentPage = TR.state.currentPage;
+				// Paging
+				
+				p.page = TR.state.currentPage;
 				
 				// organisation unit
 				
@@ -1945,11 +1913,6 @@
 					p.useCompletedEvents = Ext.getCmp('completedEventsOpt').getValue();
 				}
 				
-				if( Ext.getCmp('displayOrgunitCode').getValue()== true )
-				{
-					p.displayOrgunitCode = Ext.getCmp('displayOrgunitCode').getValue();
-				}
-				
 				// Get searching values
 				
 				p.item = [];
@@ -1977,12 +1940,7 @@
 							filter += ';' + filterOpt + ';';
 							if( filterOpt == 'IN' )
 							{
-								var filterValues = filterValue.split(";");
-								for(var i=0;i<filterValues.length;i++)
-								{
-									filter += filterValues[i] +":";
-								}
-								filter = filter.substr(0,filter.length - 1);
+								filter +=filterValue.replace(/;/g,":"); 
 							}
 							else
 							{
@@ -2860,7 +2818,7 @@
 					{
 						xtype: 'label',
 						id:'totalPageLbl',
-						text: ' of ' + TR.state.total + ' | '
+						text: ' of ' + TR.state.pageCount + ' | '
 					},
 					{
 						xtype: 'button',
@@ -2875,7 +2833,7 @@
 						icon: 'images/arrowrightdouble.png',
 						id:'lastPageBtn',
 						handler: function() {
-							TR.exe.paging( TR.state.total );
+							TR.exe.paging( TR.state.pageCount );
 						}
 					},
 					{
@@ -2896,7 +2854,7 @@
 						xtype: 'label',
 						id: 'totalEventLbl',
 						style: 'margin-right:18px;',
-						text: TR.state.totalRecords + ' ' + TR.i18n.events
+						text: TR.state.total + ' ' + TR.i18n.events
 					},
 				], 
 				store: TR.store.datatable
@@ -2996,9 +2954,9 @@
         setPagingToolbarStatus: function() {
 			TR.datatable.showPagingBar();
 			Ext.getCmp('currentPage').enable();
-			Ext.getCmp('totalEventLbl').setText( TR.state.totalRecords + ' ' + TR.i18n.events );
-			Ext.getCmp('totalPageLbl').setText( ' of ' + TR.state.total + ' | ' );
-			if( TR.state.totalRecords== 0 )
+			Ext.getCmp('totalEventLbl').setText( TR.state.total + ' ' + TR.i18n.events );
+			Ext.getCmp('totalPageLbl').setText( ' of ' + TR.state.pageCount + ' | ' );
+			if( TR.state.total== 0 )
 			{
 				Ext.getCmp('currentPage').setValue('');
 				Ext.getCmp('currentPage').setValue('');
@@ -3015,15 +2973,15 @@
 				Ext.getCmp('btnClean').enable();
 				Ext.getCmp('currentPage').setValue(TR.state.currentPage);
 				
-				if( TR.state.currentPage == TR.state.total 
-					&& TR.state.total== 1 )
+				if( TR.state.currentPage == TR.state.pageCount 
+					&& TR.state.pageCount== 1 )
 				{
 					Ext.getCmp('firstPageBtn').disable();
 					Ext.getCmp('previousPageBtn').disable();
 					Ext.getCmp('nextPageBtn').disable();
 					Ext.getCmp('lastPageBtn').disable();
 				}
-				else if( TR.state.currentPage == TR.state.total )
+				else if( TR.state.currentPage == TR.state.pageCount )
 				{
 					Ext.getCmp('firstPageBtn').enable();
 					Ext.getCmp('previousPageBtn').enable();
@@ -4110,16 +4068,6 @@
 			labelWidth: 135
 		});
 		
-		var displayOrgunitCodeField = Ext.create('Ext.form.field.Checkbox', {
-			xtype: 'checkbox',
-			cls: 'tr-checkbox',
-			id: 'displayOrgunitCode',
-			style:'padding-left: 20px;',
-			boxLabel: TR.i18n.display_orgunit_code,
-			boxLabelAlign: 'before',
-			labelWidth: 135
-		});
-		
 		var facilityLBField = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'tr-combo',
 			id: 'facilityLBCombobox',
@@ -4263,8 +4211,7 @@
 							bodyStyle: 'border-style:none; background-color:transparent;',
 							items:[
 								completedEventsField,
-								displayTotalsOptField,
-								displayOrgunitCodeField
+								displayTotalsOptField
 							]
 						},
 						facilityLBField,
@@ -4879,7 +4826,6 @@
 													Ext.getCmp('layoutBtn').setVisible(false);
 													Ext.getCmp('caseBasedFavoriteBtn').setVisible(true);
 													Ext.getCmp('levelCombobox').setVisible(true);
-													Ext.getCmp('displayOrgunitCode').setVisible(true);
 													
 													var level = Ext.getCmp('levelCombobox').getValue();
 													if( level==null || level!='' ){
@@ -4914,7 +4860,6 @@
 													Ext.getCmp('dateRangeDiv').setVisible(false);
 													Ext.getCmp('levelCombobox').setVisible(false);
 													Ext.getCmp('caseBasedFavoriteBtn').setVisible(false);
-													Ext.getCmp('displayOrgunitCode').setVisible(false);
 													
 													Ext.getCmp('datePeriodRangeDiv').setVisible(true);
 													Ext.getCmp('fixedPeriodsDiv').setVisible(true);
@@ -4966,7 +4911,6 @@
 										},
 										select: function(cb) {
 											var pid = cb.getValue();
-											
 											TR.store.programStageSection.loadData([],false);
 										
 											// Program-stage

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2013-09-10 15:46:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2013-09-25 07:00:33 +0000
@@ -24,7 +24,7 @@
 		<select multiple id="startDates" name="startDates" class="hidden"></select>
 		<input type="hidden" id="startDate" name="startDate" >
 		<input type="hidden" id="endDate" name="endDate" >
-		<input type="hidden" id="orderByOrgunitAsc" name="orderByOrgunitAsc" >
+		<input type="hidden" id="asc" name="asc" >
 		<input type="hidden" id="orderByExecutionDateByAsc" name="orderByExecutionDateByAsc" >
 		<select multiple id="filterValues" name="filterValues" class="hidden"></select>
 		

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2013-09-16 09:47:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2013-09-25 07:00:33 +0000
@@ -1,80 +1,38 @@
 { "items": [
+	#foreach( $iden in $identifierTypes )
+	{
+		"id": "$iden.uid",
+		"name": "$encoder.xmlEncode(${iden.displayName} )",
+		"valueType": #if( $iden.optionSet )
+						"list"
+					 #else
+						"${iden.type}"
+					 #end
+	},
+	#end
 	
-  #if( $auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ) )
-  
-  {
-	"id": "fixedAttr_firstName",
-	"name": "$i18n.getString('first_name')",
-	"valueType": "string"
-  },
-  {
-	"id": "fixedAttr_middleName",
-	"name": "$i18n.getString('middle_name')",
-	"valueType": "string"
-  },
-  {
-	"id": "fixedAttr_lastName",
-	"name": "$i18n.getString('last_name')",
-	"valueType": "string"
-  },
-  {
-	"id": "fixedAttr_gender",
-	"name": "$i18n.getString('gender')",
-	"valueType": "list"
-  },
-  {
-	"id": "fixedAttr_birthDate",
-	"name": "$i18n.getString('date_of_birth')",
-	"valueType": "date"
-  },
-  {
-	"id": "fixedAttr_dobType",
-	"name": "$i18n.getString('dob_type')",
-	"valueType": "list"
-  },
-  {
-	"id": "fixedAttr_phoneNumber",
-	"name": "$i18n.getString('phone_number')",
-	"valueType": "string"
-  },
-  {
-	"id": "fixedAttr_deathdate",
-	"name": "$i18n.getString('death_date')",
-	"valueType": "date"
-  }
-  #foreach( ${identifierType} in $!{identifierTypes} )
-  ,{
-	"id": "iden_${identifierType.id}",
-	"name": "$!encoder.jsonEncode( ${identifierType.displayName} )",
-	"valueType": "$identifierType.type"
-  }
-  #end
-  #foreach( $patientAttribute in $!{patientAttributes} )
-  ,{
-    "id": "attr_${patientAttribute.id}",
-	"name": "$!encoder.jsonEncode( ${patientAttribute.displayName} )",
-	"valueType": #if( $patientAttribute.valueType == 'combo')
-					"list"
-				 #else
-					"${patientAttribute.valueType}"
-				 #end
-  }
-  #end
-  
-  #end
-  
-  
-  #foreach( $psDataElement in $psDataElements )
-	,{
+	#foreach( $attr in $patientAttributes )
+	{
+		"id": "$attr.uid",
+		"name": "$encoder.xmlEncode(${attr.displayName} )",
+		"valueType": #if( $attr.optionSet )
+						"list"
+					 #else
+						"${attr.type}"
+					 #end
+	},
+	#end
+    
+	#foreach( $psDataElement in $psDataElements )
+	{
 		"id": "$psDataElement.dataElement.uid",
 		"name": "$encoder.xmlEncode(${psDataElement.dataElement.getFormNameFallback()} )",
 		"valueType": #if( $psDataElement.dataElement.optionSet )
-						"list"
+						"list_$psDataElement.dataElement.optionSet.uid"
 					 #else
 						"${psDataElement.dataElement.type}"
 					 #end
-	}
+	}#if( $velocityCount < $psDataElements.size() ),#end
 	#end
-	
   ]
 }
\ No newline at end of file