=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Coordinate.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Coordinate.java 2013-05-18 06:07:28 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Coordinate.java 2013-05-19 09:15:33 +0000 @@ -47,10 +47,10 @@ { } - public Coordinate( Double latitude, Double longitude ) + public Coordinate( Double longitude, Double latitude ) { + this.longitude = longitude; this.latitude = latitude; - this.longitude = longitude; } @JsonProperty( required = true ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-04-18 15:32:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-05-19 09:15:33 +0000 @@ -32,6 +32,7 @@ import org.apache.struts2.ServletActionContext; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dxf2.event.Coordinate; import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -139,7 +140,25 @@ Boolean completed = (Boolean) executionDate.get( "completed" ); - ProgramStageInstance programStageInstance = saveExecutionDate( programId, organisationUnitId, date, completed ); + Coordinate coordinate = null; + Map coord = (Map) input.get( "coordinate" ); + + if ( coord != null ) + { + try + { + double lng = Double.parseDouble( coord.get( "longitude" ) ); + double lat = Double.parseDouble( coord.get( "latitude" ) ); + + coordinate = new Coordinate( lng, lat ); + } + catch ( NullPointerException ignored ) + { + } + + } + + ProgramStageInstance programStageInstance = saveExecutionDate( programId, organisationUnitId, date, completed, coordinate ); Map values = (Map) input.get( "values" ); @@ -160,7 +179,8 @@ return SUCCESS; } - private ProgramStageInstance saveExecutionDate( Integer programId, Integer organisationUnitId, Date date, Boolean completed ) + private ProgramStageInstance saveExecutionDate( Integer programId, Integer organisationUnitId, Date date, Boolean completed, + Coordinate coordinate ) { OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); Program program = programService.getProgram( programId ); @@ -181,6 +201,18 @@ programStageInstance.setCompletedUser( currentUserService.getCurrentUsername() ); } + if ( programStage.getCaptureCoordinates() ) + { + if ( coordinate != null && coordinate.isValid() ) + { + programStageInstance.setCoordinates( coordinate.getCoordinateString() ); + } + else + { + programStageInstance.setCoordinates( null ); + } + } + programStageInstanceService.addProgramStageInstance( programStageInstance ); message = programStageInstance.getId() + ""; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-05-15 09:14:57 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-05-19 09:15:33 +0000 @@ -131,7 +131,6 @@ ,javascript/commons.js ,javascript/anonymousRegistration.js ,javascript/entry.js - ,javascript/dhis2.storage.anonymous.js ,../dhis-web-commons/javascripts/date.js style/style.css === 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-05-19 05:57:26 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-05-19 09:15:33 +0000 @@ -14,7 +14,8 @@ $.ajax( { url: 'getProgramMetaData.action', - dataType: 'json' + dataType: 'json', + cache: false } ).done(function ( data ) { var programs = _.values( data.metaData.programs ); DAO.store.setAll( 'programs', programs ).then( function () { @@ -44,7 +45,8 @@ return $.ajax( { url: 'dataentryform.action', data: data, - dataType: 'html' + dataType: 'html', + cache: false } ).done( function ( data ) { var obj = {}; obj.id = psid; @@ -76,7 +78,8 @@ promise = promise.then( function () { return $.ajax( { url: 'getOptionSet.action?dataElementUid=' + item, - dataType: 'json' + dataType: 'json', + cache: false } ).done( function ( data ) { var obj = {}; obj.id = item; @@ -90,7 +93,8 @@ promise = promise.then( function () { return $.ajax( { url: 'getUsernames.action', - dataType: 'json' + dataType: 'json', + cache: false } ).done( function ( data ) { var obj = {}; obj.id = 'usernames'; @@ -163,14 +167,15 @@ } ); } -function uploadOfflineData( item ) { +function uploadOfflineData( event ) { $.ajax( { url: 'uploadAnonymousEvent.action', contentType: 'application/json', - data: JSON.stringify( item ) + data: JSON.stringify( event ), + cache: false } ).done( function ( json ) { if ( json.response == 'success' ) { - DAO.store.delete( 'dataValues', item.id ).done( function () { + DAO.store.delete( 'dataValues', event.id ).done( function () { updateOfflineEvents(); searchEvents( eval( getFieldValue( 'listAll' ) ) ); } ); @@ -282,7 +287,7 @@ $( document ).bind( 'dhis2.offline', function () { setHeaderMessage( i18n_offline_notification ); $('#commentInput').attr('disabled', true); - $('#commentButton').attr('disabled', true); + $('#commentInput').attr('disabled', true); $('#validateBtn').attr('disabled', true); disableFiltering(); showOfflineEvents(); @@ -498,6 +503,7 @@ $.ajax( { url: "getOptions.action?id=" + searchObjectId + "&query=" + input.val(), dataType: "json", + cache: false, success: function ( data ) { response( $.map( data.options, function ( item ) { return { @@ -560,7 +566,7 @@ $.ajax( { url: "getUsernameList.action?query=" + input.val(), dataType: "json", - cache: true, + cache: false, success: function ( data ) { response( $.map( data.usernames, function ( item ) { return { @@ -742,6 +748,7 @@ url: 'searchProgramStageInstances.action', data: params, dataType: 'text', + cache: false, success: function ( data ) { if ( data.indexOf( "