← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8389: Hide data entry form if it not be assinged for the selected orgunit.

 

------------------------------------------------------------
revno: 8389
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-05 15:56:56 +0700
message:
  Hide data entry form if it not be assinged for the selected orgunit.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.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/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-05 08:12:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-05 08:56:56 +0000
@@ -1461,6 +1461,8 @@
 
 function loadActiveProgramStageRecords(programInstanceId, activeProgramStageInstanceId)
 {
+	if( programInstanceId == "") return;
+	
 	jQuery('#loaderDiv').show();
 	jQuery('#programEnrollmentDiv').load('enrollmentform.action',
 		{
@@ -1468,17 +1470,21 @@
 		}, function()
 		{
 			showById('programEnrollmentDiv');
+			var hasDataEntry = getFieldValue('hasDataEntry');
 			var type = jQuery('#tb_'+programInstanceId).attr('programType');
 			if(type=='2'){
 				hideById('colorHelpLink');
 				hideById('programInstanceDiv');
-				var programStageInstanceId = jQuery('.stage-object').attr('id').split('_')[1];
-				loadDataEntry( programStageInstanceId );
+				if( hasDataEntry=='true' || hasDataEntry==undefined ){
+					var programStageInstanceId = jQuery('.stage-object').attr('id').split('_')[1];
+					loadDataEntry( programStageInstanceId );
+				}
 			}
 			else{
 				showById('programInstanceDiv');
 				activeProgramInstanceDiv( programInstanceId );
-				if( activeProgramStageInstanceId != undefined )
+				if( activeProgramStageInstanceId != undefined 
+					&& ( hasDataEntry=='true' || hasDataEntry==undefined ))
 				{
 					loadDataEntry( activeProgramStageInstanceId );
 				}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-09-25 02:08:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-10-05 08:56:56 +0000
@@ -3,6 +3,7 @@
 {	
 	showById('selectDiv');
 	showById('searchDiv');
+	showById('mainLinkLbl');
 	hideById('listPatientDiv');
 	hideById('editPatientDiv');
 	hideById('enrollmentDiv');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-10-05 08:12:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2012-10-05 08:56:56 +0000
@@ -3,6 +3,7 @@
 #if( $programInstance || $hasDataEntry=='true')
 <input type='hidden' id='programInstanceId' name='programInstanceId' value='$programInstance.id' />
 <input type='hidden' id='patientId' name='patientId' value='$programInstance.patient.id' />
+<input type='hidden' id='hasDataEntry' name='hasDataEntry' value='$hasDataEntry' />
 <div id="tabs">
 	<ul>
 		<li><a href="#tab-1">$i18n.getString("data_entry_screen")</a></li>
@@ -144,10 +145,15 @@
 		$('#tabs').tabs();
 		
 		#if( $programInstance.program.type!='1' )
-			$("#tabs").tabs("remove", 4);
 			$("#tabs").tabs("remove", 3);
 			$("#tabs").tabs("remove", 2);
 			$("#tabs").tabs("remove", 1);
+			#if( $hasDataEntry == 'true' )
+				$( "#tabs" ).tabs( "option", "selected", 0 );
+			#else
+				$( "#tabs" ).tabs( "option", "disabled", [0] );
+				$( "#tabs" ).tabs("remove", 0);
+			#end
 		#else
 			#if( ( $noIden && $noIden > 0) || ( $noOtherGroup && $noOtherGroup > 0) || ( $noGroup && $noGroup > 0 ))
 				$( "#tabs" ).tabs( "option", "selected", 1 );
@@ -176,5 +182,9 @@
 			getEventMessages(getFieldValue('programInstanceId'));
 		}
 	});
+	
+	if( jQuery('#tabs li').length == 1){
+		programReports(getFieldValue('programInstanceId'));
+	}
 	resize();
 </script>