=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2011-03-08 03:35:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2011-03-22 02:17:23 +0000 @@ -215,22 +215,15 @@ List periodList = new ArrayList(); - periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START, - sDateLB ); Period startPeriod = periodGenericManager.getSelectedPeriod( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START, PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START ); - - periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END, - eDateLB ); + Period endPeriod = periodGenericManager.getSelectedPeriod( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END, PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END ); - if ( sDateLB != -1 && eDateLB != -1 ) - { - periodList = getPeriodList( (CalendarPeriodType)selectedDataSet.getPeriodType(), startPeriod, endPeriod ); - } + periodList = getPeriodList( (CalendarPeriodType)selectedDataSet.getPeriodType(), startPeriod, endPeriod ); // --------------------------------------------------------------------- // Aggregation @@ -287,7 +280,7 @@ { DataValue dvalue = new DataValue( dElement, period, orgUnit, "", storedBy, new Date(), null, optionCombo ); - dvalue.setValue( dataValue.getValue() + i18n.getString( "old_value" ) ); + dvalue.setValue( dataValue.getValue() + " " + i18n.getString( "old_value" ) ); dataValueService.deleteDataValue( dataValue ); === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/ValidationCaseAggregationAction.java 2011-03-22 02:17:23 +0000 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.caseentry.action.caseaggregation; + +import org.hisp.dhis.caseentry.state.PeriodGenericManager; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.period.Period; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version ValidationCaseAggregationAction.java Mar 21, 2011 8:50:06 PM $ + */ +public class ValidationCaseAggregationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + private PeriodGenericManager periodGenericManager; + + private I18n i18n; + + // ------------------------------------------------------------------------- + // Input / Output + // ------------------------------------------------------------------------- + + private String message; + + private int sDateLB; + + private int eDateLB; + + // ------------------------------------------------------------------------- + // Getters && Setters + // ------------------------------------------------------------------------- + + public void setPeriodGenericManager( PeriodGenericManager periodGenericManager ) + { + this.periodGenericManager = periodGenericManager; + } + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + public void setEDateLB( int dateLB ) + { + eDateLB = dateLB; + } + + public void setSDateLB( int dateLB ) + { + sDateLB = dateLB; + } + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + message = ""; + + // --------------------------------------------------------------------- + // Get selected orgunits + // --------------------------------------------------------------------- + + OrganisationUnit selectedOrgunit = selectionTreeManager.getReloadedSelectedOrganisationUnit(); + + if ( selectedOrgunit == null ) + { + message = i18n.getString("please_specify_an_orgunit"); + return INPUT; + } + + // --------------------------------------------------------------------- + // Check start-date and end-date + // --------------------------------------------------------------------- + + periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START, + sDateLB ); + Period startPeriod = periodGenericManager.getSelectedPeriod( + PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START, + PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START ); + + periodGenericManager.setSelectedPeriodIndex( PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END, + eDateLB ); + Period endPeriod = periodGenericManager.getSelectedPeriod( + PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END, + PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END ); + + if ( startPeriod.getEndDate().after( endPeriod.getEndDate() ) ) + { + message = i18n.getString("please_select_to_date_greater_or_equals_to_from_date"); + return INPUT; + } + + return SUCCESS; + } +} === 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 2011-01-12 02:22:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-03-22 02:17:23 +0000 @@ -335,6 +335,7 @@ + - + + + + + /dhis-web-caseentry/responsePeriods.vm - + + /dhis-web-caseentry/responseSuccess.vm + /dhis-web-caseentry/responseError.vm + /dhis-web-caseentry/responseInput.vm + /main.vm === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2011-03-21 10:55:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2011-03-22 02:17:23 +0000 @@ -62,7 +62,7 @@ - #organisationUnitSelectionTree( false, true, false ) + #organisationUnitSelectionTree( true, false, false ) @@ -73,4 +73,6 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseAggregationForm.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseAggregationForm.js 2011-03-21 10:55:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseAggregationForm.js 2011-03-22 02:17:23 +0000 @@ -12,19 +12,9 @@ }; validation2( 'caseAggregationForm', function(form) { - if(isSubmit) form.submit(); + validationCaseAggregation(); }, { - 'beforeValidateHandler': function() { - var periodFrom = jQuery( '#sDateLB' ).val(); - var periodTo = jQuery( '#eDateLB' ).val(); - - if(periodFrom > periodTo){ - byId('warningMessage').innerHTML = i18n_greater_then_from_date; - isSubmit = false; - } else { - isSubmit = true; - } - }, + 'rules': rules }) }); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2011-01-05 01:13:23 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2011-03-22 02:17:23 +0000 @@ -84,5 +84,30 @@ }); } + +function validationCaseAggregation( ) +{ + var request = new Request(); + request.setResponseTypeXML( 'dataElementGroup' ); + request.setCallbackSuccess( validationCaseAggregationCompleted ); + + var url = "sDateLB=" + byId('sDateLB').value; + url += "&eDateLB=" + byId('eDateLB').value; + + request.sendAsPost(url); + request.send( 'validateCaseAggregation.action' ); +} - \ No newline at end of file +function validationCaseAggregationCompleted( message ) +{ + var type = message.getAttribute("type"); + + if( type == "success" ) + { + document.forms[ 'caseAggregationForm' ].submit(); + } + else + { + setMessage(message.firstChild.nodeValue); + } +}