← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8063: Improve the activityplan functionality (WIP).

 

------------------------------------------------------------
revno: 8063
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-13 12:37:51 +0700
message:
  Improve the activityplan functionality (WIP).
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js
  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/smsReminder.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-09-12 02:49:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-09-13 05:37:51 +0000
@@ -414,23 +414,23 @@
                 patientWhere += "psi.duedate>='" + keys[3] + "' and psi.duedate<='" + keys[4] + "' and ";
                 if ( keys.length == 6 )
                 {
-                    patientWhere += "psi.organisationunitid = " + keys[5] + " and ";
+                    patientWhere += "psi.organisationunitid = " + keys[5];
                 }
                 
                 int statusEvent = Integer.parseInt( keys[2] );
                 switch ( statusEvent )
                 {
                 case ProgramStageInstance.COMPLETED_STATUS:
-                    patientWhere += "psi.completed=true";
+                    patientWhere += " and psi.completed=true";
                     break;
                 case ProgramStageInstance.VISITED_STATUS:
-                    patientWhere += "psi.executiondate is not null and psi.completed=false";
+                    patientWhere += " and psi.executiondate is not null and psi.completed=false";
                     break;
                 case ProgramStageInstance.FUTURE_VISIT_STATUS:
-                    patientWhere += "psi.executiondate is null and psi.duedate >= now()";
+                    patientWhere += " and psi.executiondate is null and psi.duedate >= now()";
                     break;
                 case ProgramStageInstance.LATE_VISIT_STATUS:
-                    patientWhere += "psi.executiondate is null and psi.duedate < now()";
+                    patientWhere += " and psi.executiondate is null and psi.duedate < now()";
                     break;
                 default:
                     break;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2012-09-12 09:03:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2012-09-13 05:37:51 +0000
@@ -24,13 +24,13 @@
 #if( $patients && $patients.size()>0 )
 	<p>#parse( "/dhis-web-caseentry/colorHelp.vm" )</p>
 	
-	<table class="listTable mainPageTable" id="patientList">
+	<table class="listTable" id="patientList">
 		#set( $mark = false )                 
 		#foreach( $patient in $patients )
 			#set( $programInstance = '')
 			#set( $programInstance = $programInstanceMap.get( $patient ) )
 				<tr #alternate( $mark )>
-					<td>
+					<td width="10px">
 						#set( $value="")
 						#foreach( $identifierType in $programInstance.program.patientIdentifierTypes )
 							#foreach( $pIdentifier in $patient.identifiers )
@@ -44,61 +44,57 @@
 						#end
 						<input type='button' class='patient-object' value='$value' onclick='javascript:showPatientHistory( "$programInstance.id" );' title='$i18n.getString( "patient_dashboard" )'>
 					</td>
-					<td class='bold' style='cursor:pointer;font-size:25px' onclick="eventFlowToggle($programInstance.id)">
+					<td class='bold' name="toggleFlowBtn" style='cursor:pointer;font-size:25px' onclick="eventFlowToggle($programInstance.id)">
 						<a>&raquo;</a>
 					</td>
 					#if($!programStageInstanceMap.get($programInstance))
 						#set($programStageInstances = $programStageInstanceMap.get($programInstance) )
 					<td>
-						<table class="stage-container" id='tb_$programInstance.id'>	
+						<table id='tb_$programInstance.id'>	
 							<tr>
 								<td>
-									<div class="arrow-left" onclick="moveLeft('flow_$programInstance.id')">&nbsp;</div>
+									<div #if($programInstance.programStageInstances.size()<4) class="arrow-left hidden"  #else class="arrow-left" #end onclick="moveLeft('flow_$programInstance.id')">&nbsp;</div>
 								</td>
-								<td class='stage-flow'>
-									<div id='flow_$programInstance.id' class='stage-flow'><table class="stage-flow">
+								<td>
+									<div id='flow_$programInstance.id' class='stage-flow'>
+										<table class="table-flow">
 										<tr>
 										#set( $flag = "false" )
 										#foreach( $programStageInstance in $programStageInstances )
-											<td id="arrow_$programStageInstance.id" width="5px" style='font-size:25px;'>&rarr;</td>
-											<td id="td_$programStageInstance.id">
-												<table class='stage-object'>
-													<tr>
-														<td>
-															#set($title="")
-															#set($index = 0)
-															#foreach( $comment in $programStageInstance.patientComments)
-																#if( $index < 5)
-																	#set( $title= $title + "$format.formatDate( $comment.createdDate ) - $comment.creator - $comment.commentText &#13;&#10;" )
-																	#set( $index = $index + 1 )
-																#end
-															#end
-															#foreach( $sms in $programStageInstance.outboundSms)
-																#if( $index < 5)
-																	#set( $title= $title + "$format.formatDate( $sms.date ) - $sms.message &#13;&#10;")
-																	#set( $index = $index + 1)
-																#end
-															#end
-															
-															<input type="button" name="programStageBtn"
-																id="ps_$!programStageInstance.id"
-																psid="$programStageInstance.programStage.id"
-																psname="$programStageInstance.programStage.name"
-																orgunit="$!programStageInstance.organisationUnit.name"
-																programType='$programInstance.program.type'
-																reportDate="$!format.formatDate( $!programStageInstance.executionDate )"
-																reportDateDes="$programStageInstance.programStage.reportDateDescription"
-																dueDate="$format.formatDate( $programStageInstance.dueDate )"
-																class="stage-object" 
-																title="$title"
-																value="$programStageInstance.programStage.name&#13;&#10;$format.formatDate( $programStageInstance.dueDate )" 
-																onclick="javascript:loadDataEntry( $programStageInstance.id );">
-															<script>	
-																var status = $statusMap.get( $programStageInstance.id ); 
-																setEventColorStatus( 'ps_' + $programStageInstance.id ,status);
-															</script>
-													</tr>
-												</table>
+											<td id="arrow_$programStageInstance.id" name="arrow" width="5px" style='font-size:25px;'>&rarr;</td>
+											<td id="td_$programStageInstance.id" name="td">
+												#set($title="")
+												#set($index = 0)
+												#foreach( $comment in $programStageInstance.patientComments)
+													#if( $index < 5)
+														#set( $title= $title + "$format.formatDate( $comment.createdDate ) - $comment.creator - $comment.commentText &#13;&#10;" )
+														#set( $index = $index + 1 )
+													#end
+												#end
+												#foreach( $sms in $programStageInstance.outboundSms)
+													#if( $index < 5)
+														#set( $title= $title + "$format.formatDate( $sms.date ) - $sms.message &#13;&#10;")
+														#set( $index = $index + 1)
+													#end
+												#end
+												
+												<input type="button" name="programStageBtn"
+													id="ps_$!programStageInstance.id"
+													psid="$programStageInstance.programStage.id"
+													psname="$programStageInstance.programStage.name"
+													orgunit="$!programStageInstance.organisationUnit.name"
+													programType='$programInstance.program.type'
+													reportDate="$!format.formatDate( $!programStageInstance.executionDate )"
+													reportDateDes="$programStageInstance.programStage.reportDateDescription"
+													dueDate="$format.formatDate( $programStageInstance.dueDate )"
+													class="stage-object" 
+													title="$title"
+													value="$programStageInstance.programStage.name&#13;&#10;$format.formatDate( $programStageInstance.dueDate )" 
+													onclick="javascript:loadDataEntry( $programStageInstance.id );">
+												<script>	
+													var status = $statusMap.get( $programStageInstance.id ); 
+													setEventColorStatus( 'ps_' + $programStageInstance.id ,status);
+												</script>
 											</td>
 										#end
 										</tr>
@@ -106,7 +102,7 @@
 								</td>
 								
 								<td>
-									<div class="arrow-right" onclick="moveRight('flow_$programInstance.id')">&nbsp;</div>
+									<div #if($programInstance.programStageInstances.size()<4) class="arrow-right hidden"  #else class="arrow-right" #end onclick="moveRight('flow_$programInstance.id')">&nbsp;</div>
 								</td>
 							</tr>
 						</table>
@@ -129,19 +125,30 @@
 #end
 
 <script>
-	#if( $programStageInstanceIds && $programStageInstanceIds.size() > 0 )
-		jQuery("#patientList .stage-object").each( function(){
-			var programStageInstance = this.id.split('_')[1];
-			hideById('arrow_' + programStageInstance );
-			hideById('td_' + programStageInstance );
-		});
-		
-		jQuery(".arrow-left").css("display", "none");
-		jQuery(".arrow-right").css("display", "none");
-		#foreach( $id in $programStageInstanceIds )
-			showById('arrow_$id');
-			showById('td_$id');
-			jQuery("#box_$id").addClass("stage-object-selected searched");
+	if(getFieldValue('statusEvent')!="0" ){
+		#if( $programStageInstanceIds 
+			&& $programStageInstanceIds.size() > 0 )
+			
+			jQuery("#patientList .stage-object").each( function(){
+				var programStageInstance = this.id.split('_')[1];
+				hideById('arrow_' + programStageInstance );
+				hideById('td_' + programStageInstance );
+			});
+			
+			jQuery(".arrow-left").css("display", "none");
+			jQuery(".arrow-right").css("display", "none");
+			#foreach( $id in $programStageInstanceIds )
+				showById('arrow_$id');
+				showById('td_$id');
+				jQuery("#ps_$id").addClass("stage-object-selected searched");
+			#end
 		#end
-	#end
+	}
+	
+	resize();
+	
+	$(window).bind('resize', function(e){ 
+		resize();
+	});
+	
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2012-09-13 03:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2012-09-13 05:37:51 +0000
@@ -10,7 +10,6 @@
 			}
 		});
 		
-		jQuery('#statusEvent').val('3');
 		jQuery("#searchObjectId [value=prg]").remove();
 		jQuery("#searchObjectId").prepend('<option value="-100">' + i18n_please_select_criteria + '</option>');
 		jQuery("#searchObjectId [value=]").attr("selected","selected");
@@ -56,6 +55,7 @@
 				<td>$i18n.getString('status')</td>
 				<td>
 					<select id="statusEvent" name="statusEvent" onchange="statusEventOnChange()">
+						<option value='0' selected>$i18n.getString("all")</option>
 						<option value='4'>$i18n.getString("overdue")</option>
 						<option value='2'>$i18n.getString("incomplete")</option>
 						<option value='1'>$i18n.getString("completed")</option>
@@ -66,8 +66,7 @@
 			<tr>
 				<td>$i18n.getString('show_events_since')</td>
 				<td>
-					<select id="showEventSince" name="showEventSince" disabled onchange="setDateRangeSince(this.value);">
-						<option value=''>[$i18n.getString("please_select")]</option>
+					<select id="showEventSince" name="showEventSince" onchange="setDateRange();">
 						<option value='-1'>$i18n.getString("one_day")</option>
 						<option value='-3'>$i18n.getString("three_days")</option>
 						<option value='-7' selected>$i18n.getString("one_week")</option>
@@ -79,8 +78,7 @@
 			<tr>
 				<td>$i18n.getString('show_events_up_to')</td>
 				<td>
-					<select id="showEventUpTo" name="showEventUpTo" onchange="setDateRangeUpTo(this.value);">
-						<option value=''>[$i18n.getString("please_select")]</option>
+					<select id="showEventUpTo" name="showEventUpTo" onchange="setDateRange();">
 						<option value='1'>$i18n.getString("one_day")</option>
 						<option value='3'>$i18n.getString("three_days")</option>
 						<option value='7' selected>$i18n.getString("one_week")</option>
@@ -101,6 +99,7 @@
 
 <div id='listPatientDiv'></div>
 <div id='contentDataRecord'></div>
+	
 #parse( "dhis-web-commons/loader/loader.vm" )
 <div class='hidden'>
 	<input type='text' id='startDueDate' name='startDueDate' >
@@ -126,10 +125,5 @@
 	var i18n_please_select_criteria = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_criteria" ) , "'")' + ']';
 	var i18n_program_stage = '$encoder.jsEscape( $i18n.getString( "program_stage" ) , "'")';
 	
-	var date = new Date();
-	var d = date.getDate() + 7;
-	var m = date.getMonth();
-	var y= date.getFullYear();
-	jQuery("#startDueDate").val(jQuery.datepicker.formatDate( dateFormat, new Date() ));
-	jQuery("#endDueDate").val(jQuery.datepicker.formatDate( dateFormat, new Date(y, m, d) ));
+	setDateRange();
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2012-09-13 03:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2012-09-13 05:37:51 +0000
@@ -29,8 +29,9 @@
 	$('#contentDataRecord').html('');
 	
 	var programId = getFieldValue('programIdAddPatient');
-	var searchTexts = "stat_" + programId + "_3_" 
-					+ getFieldValue('startDueDate')
+	var searchTexts = "stat_" + programId
+					+ "_" + getFieldValue("statusEvent")
+					+ "_" + getFieldValue('startDueDate')
 					+ "_" + getFieldValue('endDueDate')
 					+ "_" + getFieldValue('orgunitId');
 	
@@ -59,14 +60,13 @@
 			jQuery(this).removeClass("stage-object-selected");
 		});
 	
-	jQuery("#tb_" + programInstanceId + " .arrow-left").toggle();
-	jQuery("#tb_" + programInstanceId + " .arrow-right").toggle();
 	if( jQuery("#tb_" + programInstanceId + " .searched").length>0)
 	{	
 		var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1];
 		showById("arrow_" + id);
 		showById("td_" + id );
 	}
+	resize();
 }
 
 // --------------------------------------------------------------------
@@ -100,37 +100,75 @@
 {
 	var statusEvent = getFieldValue("statusEvent");
 	
-	if( statusEvent == '3' ){
+	if( statusEvent == '0' ){
+		enable('showEventSince');
+		enable('showEventUpTo');
+		setDateRange();
+	}
+	else if( statusEvent == '3' ){
 		disable('showEventSince');
 		enable('showEventUpTo');
-		setDateRangeUpTo( getFieldValue("showEventUpTo") );
+		setDateRange();
 	}
 	else{
 		enable('showEventSince');
 		disable('showEventUpTo');
-		setDateRangeSince( getFieldValue("showEventSince") );
+		setDateRange();
 	}
 }
 
-function setDateRangeSince( days )
+function setDateRange()
 {
-	if(days == "")
-		return;
+	var statusEvent = getFieldValue("statusEvent");
 	var date = new Date();
 	var d = date.getDate();
 	var m = date.getMonth();
 	var y= date.getFullYear();
-	
+		
+	var startDateSince = "";
+	var endDateSince = "";
+	var startDateUpTo = "";
+	var endDateUpTo = "";
 	var startDate = "";
-	if( days == 'ALL'){
-		startDate = jQuery.datepicker.formatDate( dateFormat, new Date(y-100, m, d) ) ;
-	}
-	else{
-		d = d + eval(days);
-		startDate = jQuery.datepicker.formatDate( dateFormat, new Date(y, m, d) ) ;
-	}
-	
-	var endDate = jQuery.datepicker.formatDate( dateFormat, new Date() );
+	var endDate = "";
+		
+	// Get dateRangeSince
+	var days = getFieldValue('showEventSince');
+	if( days == 'ALL'){
+		startDateSince = jQuery.datepicker.formatDate( dateFormat, new Date(y-100, m, d) ) ;
+	}
+	else{
+		startDateSince = jQuery.datepicker.formatDate( dateFormat, new Date(y, m, d + eval(days)) ) ;
+	}
+	endDateSince = jQuery.datepicker.formatDate( dateFormat, new Date() );
+	
+	// getDateRangeUpTo
+	days = getFieldValue('showEventUpTo');
+	startDateUpTo = jQuery.datepicker.formatDate( dateFormat, new Date() );
+	endDateUpTo = "";
+	if( days == 'ALL'){
+		endDateUpTo = jQuery.datepicker.formatDate( dateFormat, new Date(y+100, m, d) ) ;
+	}
+	else{
+		endDateUpTo = jQuery.datepicker.formatDate( dateFormat, new Date(y, m, d + eval(days)) ) ;
+	}
+
+	// check status to get date-range
+	if( statusEvent == "0")
+	{
+		startDate = startDateSince;
+		endDate = endDateUpTo;
+	
+	}else if (statusEvent=='3'){
+		startDate = startDateUpTo;
+		endDate = endDateUpTo;
+	}
+	else
+	{
+		startDate = startDateSince;
+		endDate = endDateSince;
+	}
+	
 	jQuery("#startDueDate").val(startDate);
 	jQuery("#endDueDate").val(endDate);
 }
@@ -157,4 +195,15 @@
 	
 	jQuery("#startDueDate").val(startDate);
 	jQuery("#endDueDate").val(endDate);
+}
+
+
+function setDateRangeAll()
+{
+	var date = new Date();
+	var d = date.getDate();
+	var m = date.getMonth();
+	var y= date.getFullYear();
+	
+	
 }
\ No newline at end of file

=== 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-09-12 13:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-09-13 05:37:51 +0000
@@ -848,10 +848,22 @@
 		width += 150;
 	}
 	
+	$('.stage-flow').each(function(){
+		var programInstanceId = this.id.split('_')[0];
+		if(jQuery(this).width() < jQuery(this).find(".table-flow").width() ){
+			jQuery('#tb_' + programInstanceId ).find('.arrow-left').show();
+			jQuery('#tb_' + programInstanceId ).find('.arrow-right').show();
+		}
+		else{
+			jQuery('#tb_' + programInstanceId ).find('.arrow-left').hide();
+			jQuery('#tb_' + programInstanceId ).find('.arrow-right').hide();
+		}
+	});
+	
 	$('.stage-flow').css('width', w-width); 
 	$('.table-flow').css('width', w-width); 
 	$('.table-flow tr').each(function(){
 		jQuery(this).find('td').attr("width", "10px");
-		jQuery(this).find('td:last').attr("width", "");
+		jQuery(this).find('td:last').removeAttr("width");
 	});
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-12 13:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-13 05:37:51 +0000
@@ -271,6 +271,9 @@
 			jQuery(this).removeClass("stage-object-selected");
 		});
 	
+	
+	jQuery(".arrow-left").css("display", "block");
+	jQuery(".arrow-right").css("display", "block");
 	if( jQuery("#tb_" + programInstanceId + " .searched").length>0)
 	{	
 		var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1];

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2012-09-12 13:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2012-09-13 05:37:51 +0000
@@ -136,5 +136,10 @@
 			jQuery("#box_$id").addClass("stage-object-selected searched");
 		#end
 	#end
+	
 	resize();
+	
+	$(window).bind('resize', function(e){ 
+		resize();
+	});
 </script>
\ No newline at end of file