dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21977
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10523: wip, offline anonymous reporting
------------------------------------------------------------
revno: 10523
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-04-12 11:20:19 +0700
message:
wip, offline anonymous reporting
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
--
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/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2013-04-04 06:13:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2013-04-12 04:20:19 +0000
@@ -44,7 +44,7 @@
/**
* @author Chau Thu Tran
* @version $ DefaultProgramDataEntryService.java May 26, 2011 3:59:43 PM $
- *
+ *
*/
public class DefaultProgramDataEntryService
implements ProgramDataEntryService
@@ -139,7 +139,7 @@
String inputHTML = dataElementMatcher.group( 1 );
Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( inputHTML );
-
+
if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
{
// -------------------------------------------------------------
@@ -758,7 +758,7 @@
/**
* Replaces i18n string in the custom form code.
- *
+ *
* @param dataEntryFormCode the data entry form html.
* @param i18n the I18n object.
* @return internationalized data entry form html.
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-04-10 03:13:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-04-12 04:20:19 +0000
@@ -50,6 +50,7 @@
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.program.ProgramStageSectionService;
+import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.program.comparator.ProgramStageDataElementSortOrderComparator;
import org.hisp.dhis.program.comparator.ProgramStageSectionSortOrderComparator;
import org.hisp.dhis.system.util.ValidationUtils;
@@ -81,6 +82,13 @@
this.patientDataValueService = patientDataValueService;
}
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
private ProgramStageInstanceService programStageInstanceService;
public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
@@ -113,6 +121,10 @@
// Input && Output
// -------------------------------------------------------------------------
+ private Integer organisationUnitId;
+
+ private Integer programStageId;
+
private Integer programStageInstanceId;
private ProgramStageInstance programStageInstance;
@@ -125,8 +137,6 @@
private Map<Integer, PatientDataValue> patientDataValueMap;
- private Integer organisationUnitId;
-
private OrganisationUnit organisationUnit;
private Program program;
@@ -141,6 +151,16 @@
// Getters && Setters
// -------------------------------------------------------------------------
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ public void setProgramStageId( Integer programStageId )
+ {
+ this.programStageId = programStageId;
+ }
+
public void setProgramStageInstanceId( Integer programStageInstanceId )
{
this.programStageInstanceId = programStageInstanceId;
@@ -234,10 +254,6 @@
organisationUnit = organisationUnitId == null ? selectedStateManager.getSelectedOrganisationUnit() :
organisationUnitService.getOrganisationUnit( organisationUnitId );
- // ---------------------------------------------------------------------
- // Get program-stage-instance
- // ---------------------------------------------------------------------
-
if ( programStageInstanceId != null )
{
programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
@@ -247,7 +263,36 @@
programStage = programStageInstance.getProgramStage();
selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
-
+ }
+ else if ( programStageId != null )
+ {
+ programStage = programStageService.getProgramStage( programStageId );
+
+ program = programStage.getProgram();
+ }
+ else
+ {
+ return INPUT;
+ }
+
+ // ---------------------------------------------------------------------
+ // Get program-stage-instance
+ // ---------------------------------------------------------------------
+
+ programStageDataElements = new ArrayList<ProgramStageDataElement>( programStage.getProgramStageDataElements() );
+
+ Collections.sort( programStageDataElements, new ProgramStageDataElementSortOrderComparator() );
+
+ if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) )
+ {
+ sections = new ArrayList<ProgramStageSection>(
+ programStageSectionService.getProgramStages( programStage ) );
+
+ Collections.sort( sections, new ProgramStageSectionSortOrderComparator() );
+ }
+
+ if ( programStageInstance != null )
+ {
if ( program.isRegistration() )
{
patient = programStageInstance.getProgramInstance().getPatient();
@@ -257,42 +302,21 @@
// Get data values
// ---------------------------------------------------------------------
- programStageDataElements = new ArrayList<ProgramStageDataElement>( programStageInstance.getProgramStage()
- .getProgramStageDataElements() );
-
- Collections.sort( programStageDataElements, new ProgramStageDataElementSortOrderComparator() );
-
- Collection<PatientDataValue> patientDataValues = patientDataValueService
- .getPatientDataValues( programStageInstance );
-
- patientDataValueMap = new HashMap<Integer, PatientDataValue>( patientDataValues.size() );
-
- for ( PatientDataValue patientDataValue : patientDataValues )
- {
- int key = patientDataValue.getDataElement().getId();
- patientDataValueMap.put( key, patientDataValue );
- }
+ Collection<PatientDataValue> patientDataValues = getPatientDataValues();
// ---------------------------------------------------------------------
// Get data-entry-form
// ---------------------------------------------------------------------
- DataEntryForm dataEntryForm = programStageInstance.getProgramStage().getDataEntryForm();
-
if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_CUSTOM ) )
{
+ DataEntryForm dataEntryForm = programStage.getDataEntryForm();
+
Boolean disabled = (program.getDisplayProvidedOtherFacility() == null) ? true : !program
.getDisplayProvidedOtherFacility();
customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry(
dataEntryForm.getHtmlCode(), patientDataValues, disabled.toString(), i18n,
- programStageInstance.getProgramStage(), programStageInstance, organisationUnit );
- }
- else if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) )
- {
- sections = new ArrayList<ProgramStageSection>(
- programStageSectionService.getProgramStages( programStage ) );
-
- Collections.sort( sections, new ProgramStageSectionSortOrderComparator() );
+ programStage, programStageInstance, organisationUnit );
}
// -----------------------------------------------------------------
@@ -306,4 +330,19 @@
return SUCCESS;
}
+ private Collection<PatientDataValue> getPatientDataValues()
+ {
+ Collection<PatientDataValue> patientDataValues = patientDataValueService
+ .getPatientDataValues( programStageInstance );
+
+ patientDataValueMap = new HashMap<Integer, PatientDataValue>( patientDataValues.size() );
+
+ for ( PatientDataValue patientDataValue : patientDataValues )
+ {
+ int key = patientDataValue.getDataElement().getId();
+ patientDataValueMap.put( key, patientDataValue );
+ }
+
+ return patientDataValues;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-04-11 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-04-12 04:20:19 +0000
@@ -87,18 +87,18 @@
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
</bean>
- <bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
- class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction" scope="prototype">
- <property name="programDataEntryService" ref="org.hisp.dhis.program.ProgramDataEntryService" />
- <property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
- <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
- <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- </bean>
+ <bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
+ class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction" scope="prototype">
+ <property name="programDataEntryService" ref="org.hisp.dhis.program.ProgramDataEntryService" />
+ <property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
- <bean
- id="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
+ <bean id="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
scope="prototype">
<property name="programStageInstanceService"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm 2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm 2013-04-12 04:20:19 +0000
@@ -5,4 +5,4 @@
</script>
<div id="customEntryScreenContainer">
$customDataEntryFormCode
-</div>
\ No newline at end of file
+</div>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2013-04-10 04:22:14 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2013-04-12 04:20:19 +0000
@@ -1,18 +1,17 @@
<script>
jQuery("#entryFormContainer").ready(function(){
- #if($!programStageInstance.programStage.program.type!='1')
+ #if($!program.type!='1')
hideById('newEncounterBtn');
#end
- #if($!programStageInstance.programStage.id)
- setFieldValue('programStageId', "$!programStageInstance.programStage.id");
+ #if($!programStage.id)
+ setFieldValue('programStageId', "$!programStage.id");
#end
#if( $programStageInstance )
setFieldValue( 'dueDate', "$!format.formatDate( $programStageInstance.dueDate )" );
setFieldValue( 'executionDate', "$!format.formatDate( $programStageInstance.executionDate )" );
#end
-
+
entryFormContainerOnReady();
-
});
</script>
@@ -21,20 +20,20 @@
<input type='hidden' id='incidentDate' value='$!format.formatDate($programStageInstance.programInstance.dateOfIncident)'>
<input type='hidden' name='programStageInstanceId' id='programStageInstanceId' value='$!programStageInstance.id'>
<input type='hidden' name='programInstanceId' id='programInstanceId' value='$!programStageInstance.programInstance.id'>
-<input type='hidden' name='irregular' id='irregular' value='$!programStageInstance.programStage.irregular'>
-<input type='hidden' name='displayGenerateEventBox' id='displayGenerateEventBox' value='$!programStageInstance.programStage.displayGenerateEventBox'>
+<input type='hidden' name='irregular' id='irregular' value='$!programStage.irregular'>
+<input type='hidden' name='displayGenerateEventBox' id='displayGenerateEventBox' value='$!programStage.displayGenerateEventBox'>
<input type='hidden' name='completed' id='completed' value='$!programStageInstance.completed'>
-<input type='hidden' name='programStageUid' id='programStageUid' value='$!programStageInstance.programStage.uid'>
-<input type='hidden' name='programId' id='programId' value='$!programStageInstance.programInstance.program.id'>
-<input type='hidden' name='validCompleteOnly' id='validCompleteOnly' value='$!programStageInstance.programStage.validCompleteOnly'>
+<input type='hidden' name='programStageUid' id='programStageUid' value='$!programStage.uid'>
+<input type='hidden' name='programId' id='programId' value='$!program.id'>
+<input type='hidden' name='validCompleteOnly' id='validCompleteOnly' value='$!programStage.validCompleteOnly'>
<input type='hidden' name='currentUsername' id='currentUsername' value='$!currentUsername'>
-<input type='hidden' name='blockEntryForm' id='blockEntryForm' value='$!programStageInstance.programInstance.program.blockEntryForm'>
-<input type='hidden' name='remindCompleted' id='remindCompleted' value='$!programStageInstance.programInstance.program.remindCompleted'>
+<input type='hidden' name='blockEntryForm' id='blockEntryForm' value='$!program.blockEntryForm'>
+<input type='hidden' name='remindCompleted' id='remindCompleted' value='$!program.remindCompleted'>
<div id='entryForm' #if($!programStageInstance.executionDate) class='visible' #else class='hidden' #end>
<table style="width:600px;margin-top:-9px" class="listTable">
-
- #if($programStageInstance.programStage.captureCoordinates=='true')
+
+ #if($programStage.captureCoordinates=='true')
<tr>
<th class='coordinates1'><label for="longitude">$i18n.getString( "longitude" )</label></th>
<th class='coordinates2'><input type="text" class='criteria' id="longitude" name="longitude" value="$!{longitude}" class="{validate:{number:true,min:-180,max:180}}" placeholder='$i18n.getString("enter_a_number")' ></th>
@@ -52,8 +51,8 @@
<input type="text" class="{validate:{maxlength:160}} criteria" name="comment_$programStageInstance.id" id="comment_$programStageInstance.id" style="width:430px;#if($programStageInstance.programStage.captureCoordinates=='false') margin-left:10px; #end " onkeypress="keypressOnComent(event,this,$programStageInstance.id);">
</td>
</tr>
-
- #if( $programStageInstance.programStage.getDataEntryType()=='section' )
+
+ #if( $programStage.getDataEntryType()=='section' )
<tr id="filterDataSetSectionTr" class='coordinates1'>
<th class='coordinates1'><label for="filterDataSetSection">$i18n.getString( "filter_on_section" )</label></th>
<th colspan='3'>
@@ -88,7 +87,7 @@
</table>
<br>
-
+
#if( $customDataEntryFormCode )
#parse( "/dhis-web-caseentry/customDataEntryForm.vm" )
#elseif( $sections && $sections.size() > 0 )
@@ -122,7 +121,7 @@
var i18n_enter_values_for_longitude_and_latitude_fields = '$encoder.jsEscape( $i18n.getString( "enter_values_for_longitude_and_latitude_fields" ) , "'" )';
var i18n_enter_a_valid_number = '$encoder.jsEscape( $i18n.getString( "enter_a_valid_number" ) , "'" )';
- #if( $programStageInstance.programInstance.program.type=='1' && $programStageInstance.programInstance.status==1)
+ #if( $program.type == '1' && $programStageInstance.programInstance.status==1)
jQuery("[id=entryFormContainer] :input").prop('disabled', true);
jQuery("[id=entryFormContainer] :input").datepicker("destroy");
jQuery("[id=executionDate]").prop('disabled', true);
@@ -133,4 +132,3 @@
blockEntryForm();
}
</script>
-
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-04-04 05:07:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-04-12 04:20:19 +0000
@@ -3,7 +3,7 @@
<col id="deCol">
<col id="deCol">
<col id="entryCol">
- #if( $!programStageInstance.programStage.program.displayProvidedOtherFacility=='true')
+ #if( $!program.displayProvidedOtherFacility=='true')
<col width="5%" />
#end
</colgroup>
@@ -11,7 +11,7 @@
<tr>
<th>$i18n.getString( "data_element" )</th>
<th>$i18n.getString( "value" )</th>
- #if( $programStage.program.displayProvidedOtherFacility=='true')
+ #if( $program.displayProvidedOtherFacility=='true')
<th>$i18n.getString( "provided_elsewhere" )</th>
#end
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-11 08:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-12 04:20:19 +0000
@@ -539,7 +539,7 @@
setInnerHTML( 'dataEntryFormDiv', '' );
showLoader();
- service.loadDataEntryForm( programStageInstanceId, getFieldValue( 'orgunitId' ) );
+ service.loadDataEntryForm( getFieldValue( 'programStageId' ), programStageInstanceId, getFieldValue( 'orgunitId' ) );
}
function backEventList() {
@@ -650,18 +650,34 @@
// execution date module
var service = (function () {
+ var executionDateStoreInitialized = false;
+ var dataValueStoreInitialized = false;
+ var formStoreInitialized = false;
+
+ var executionDateStore = new dhis2.storage.Store( {name: 'anonymousExecutionDate' }, function ( store ) {
+ executionDateStoreInitialized = true;
+ } );
+
+ var dataValueStore = new dhis2.storage.Store( {name: 'anonymousDataValue' }, function ( store ) {
+ dataValueStoreInitialized = true;
+ } );
+
+ var formStore = new dhis2.storage.Store( {name: 'anonymousForm', adapter: 'dom-ss'}, function ( store ) {
+ formStoreInitialized = true;
+ } );
+
return {
saveExecutionDate: function( programId, programStageInstanceId, executionDate, organisationUnitId ) {
- jQuery.postJSON( "saveExecutionDate.action", {
- programId: programId,
- programStageInstanceId: programStageInstanceId,
- executionDate: executionDate,
- organisationUnitId: organisationUnitId
- },
- function ( json ) {
+ $.ajax( {
+ url: 'saveExecutionDate.action',
+ data: createExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId),
+ type: 'POST',
+ dataType: 'json'
+ } ).done(function ( json ) {
if ( json.response == 'success' ) {
jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
setFieldValue( 'programStageInstanceId', json.message );
+
if ( programStageInstanceId != json.message ) {
showUpdateEvent( json.message );
}
@@ -670,45 +686,99 @@
jQuery( "#executionDate" ).css( 'background-color', ERROR_COLOR );
showWarningMessage( json.message );
}
+ } ).fail( function () {
+ function waitForExecutionDateStore() {
+ if(!executionDateStoreInitialized) {
+ setTimeout(waitForExecutionDateStore, 50);
+ }
+ }
+
+ waitForExecutionDateStore();
+
+ var data = createExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId);
+
+ if(programStageInstanceId == 0) {
+ executionDateStore.keys(function(store, keys) {
+ var i = 100;
+
+ for(; i<10000; i++) {
+ if( keys.indexOf(i) == -1 ) break;
+ }
+
+ console.log("i: ", i);
+
+ setFieldValue( 'programStageInstanceId', "local"+i );
+ jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
+ showUpdateEvent( programStageInstanceId );
+ console.log("programStageInstanceId: ", getFieldValue('programStageInstanceId'));
+ });
+ } else {
+ // if we have a programStageInstanceId, just reuse that one
+ setFieldValue( 'programStageInstanceId', programStageInstanceId );
+ jQuery( "#executionDate" ).css( 'background-color', SUCCESS_COLOR );
+ showUpdateEvent( programStageInstanceId );
+ console.log("programStageInstanceId: ", getFieldValue('programStageInstanceId'));
+ }
} );
},
- loadDataEntryForm: function( programStageInstanceId, organisationUnitId ) {
- $( '#dataEntryFormDiv' ).load( "dataentryform.action", {
- programStageInstanceId: programStageInstanceId,
- organisationUnitId: organisationUnitId
- }, function () {
- jQuery( '#inputCriteriaDiv' ).remove();
- showById( 'programName' );
- showById( 'actionDiv' );
- var programName = jQuery( '#programId option:selected' ).text();
- var programStageId = jQuery( '#programId option:selected' ).attr( 'psid' );
- jQuery( '.stage-object-selected' ).attr( 'psid', programStageId );
- setInnerHTML( 'programName', programName );
- jQuery('#executionDate').css('width',430);
- jQuery('#executionDate').css('margin-right',30);
-
- if ( getFieldValue( 'completed' ) == 'true' ) {
- disable( "completeBtn" );
- enable( "uncompleteBtn" );
- }
- else {
- enable( "completeBtn" );
- disable( "uncompleteBtn" );
- }
+ loadDataEntryForm: function( programStageId, programStageInstanceId, organisationUnitId ) {
+ $.ajax( {
+ url: 'dataentryform.action',
+ data: {
+ programStageId: programStageId,
+ programStageInstanceId: programStageInstanceId,
+ organisationUnitId: organisationUnitId
+ },
+ dataType: 'html'
+ } ).done(function(data) {
+ $( '#dataEntryFormDiv' ).html( data );
+ updateDataForm();
+ } ).fail(function() {
+ $( '#dataEntryFormDiv' ).html( "<div class='message message-info'>Unable to load form.</div>" );
hideById( 'loaderDiv' );
- showById( 'dataEntryInfor' );
- showById( 'entryFormContainer' );
-
- jQuery( "#entryForm :input" ).each( function () {
- if ( ( jQuery( this ).attr( 'options' ) != null && jQuery( this ).attr( 'options' ) == 'true' )
- || ( jQuery( this ).attr( 'username' ) != null && jQuery( this ).attr( 'username' ) == 'true' ) ) {
- var input = jQuery( this );
- input.parent().width( input.width() + 200 );
- }
- } );
- } );
-
+ });
}
}
})();
+
+function updateDataForm() {
+ jQuery( '#inputCriteriaDiv' ).remove();
+ showById( 'programName' );
+ showById( 'actionDiv' );
+ var programName = jQuery( '#programId option:selected' ).text();
+ var programStageId = jQuery( '#programId option:selected' ).attr( 'psid' );
+ jQuery( '.stage-object-selected' ).attr( 'psid', programStageId );
+ setInnerHTML( 'programName', programName );
+ jQuery('#executionDate').css('width',430);
+ jQuery('#executionDate').css('margin-right',30);
+
+ if ( getFieldValue( 'completed' ) == 'true' ) {
+ disable( "completeBtn" );
+ enable( "uncompleteBtn" );
+ }
+ else {
+ enable( "completeBtn" );
+ disable( "uncompleteBtn" );
+ }
+ hideById( 'loaderDiv' );
+ showById( 'dataEntryInfor' );
+ showById( 'entryFormContainer' );
+
+ jQuery( "#entryForm :input" ).each( function () {
+ if ( ( jQuery( this ).attr( 'options' ) != null && jQuery( this ).attr( 'options' ) == 'true' )
+ || ( jQuery( this ).attr( 'username' ) != null && jQuery( this ).attr( 'username' ) == 'true' ) ) {
+ var input = jQuery( this );
+ input.parent().width( input.width() + 200 );
+ }
+ } );
+}
+
+function createExecutionDate( programId, programStageInstanceId, executionDate, organisationUnitId ) {
+ return {
+ programId: programId,
+ programStageInstanceId: programStageInstanceId,
+ executionDate: executionDate,
+ organisationUnitId: organisationUnitId
+ }
+}