← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2462: Add Prev/Next button for periods in Aggregation Benificiaries funtion into case-entry-form.

 

------------------------------------------------------------
revno: 2462
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-01-05 08:13:23 +0700
message:
  Add Prev/Next button for periods in Aggregation Benificiaries funtion into case-entry-form.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.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/resources/struts.xml
  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/javascript/caseagg.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.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/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java	2010-12-03 06:08:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/LoadPeriodsAction.java	2011-01-05 01:13:23 +0000
@@ -7,6 +7,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.hisp.dhis.caseentry.state.PeriodGenericManager;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
@@ -29,6 +30,13 @@
         this.dataSetService = dataSetService;
     }
 
+    private PeriodGenericManager periodGenericManager;
+
+    public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
+    {
+        this.periodGenericManager = periodGenericManager;
+    }
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -73,6 +81,11 @@
     {
         DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
 
+        periodGenericManager.clearSelectedPeriod();
+        periodGenericManager.clearBasePeriod();
+
+        periodGenericManager.setPeriodType( selectedDataSet.getPeriodType().getName() );
+
         if ( selectedDataSet != null )
         {
             periods = getPeriodList( (CalendarPeriodType) selectedDataSet.getPeriodType() );

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultPeriodGenericManager.java	2011-01-05 01:13:23 +0000
@@ -0,0 +1,205 @@
+package org.hisp.dhis.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+
+import com.opensymphony.xwork2.ActionContext;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id$
+ */
+public class DefaultPeriodGenericManager
+    implements PeriodGenericManager
+{
+
+    private static final Log log = LogFactory.getLog( DefaultPeriodGenericManager.class );
+
+
+    public static final String SESSION_KEY_SELECTED_PERIOD_TYPE = "SESSION_KEY_SELECTED_PERIOD_TYPE";
+    
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+  
+
+    // -------------------------------------------------------------------------
+    // Period
+    // -------------------------------------------------------------------------
+    
+    public void setSelectedPeriodIndex( String key, Integer index )
+    {
+        getSession().put( key, index );
+    }
+
+    public Integer getSelectedPeriodIndex( String key )
+    {
+        return (Integer) getSession().get( key );
+    }
+
+    public Period getSelectedPeriod( String key, String baseKey )
+    {
+        Integer index = getSelectedPeriodIndex( key );
+
+        if ( index == null )
+        {
+            return null;
+        }
+
+        List<Period> periods = getPeriodList( key, baseKey );
+
+        if ( index >= 0 && index < periods.size() )
+        {
+            return periods.get( index );
+        }
+
+        return null;
+    }
+
+    public void clearSelectedPeriod()
+    {
+        getSession().remove( SESSION_KEY_SELECTED_PERIOD_INDEX_START );
+        getSession().remove( SESSION_KEY_SELECTED_PERIOD_INDEX_END );
+    }
+
+    public List<Period> getPeriodList( String key, String baseKey )
+    {
+        Period basePeriod = getBasePeriod( baseKey );
+        
+        CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
+
+        List<Period> periods = periodType.generatePeriods( basePeriod );
+
+        Date now = new Date();
+
+        Iterator<Period> iterator = periods.iterator();
+        
+        while ( iterator.hasNext() )
+        {
+            if ( iterator.next().getStartDate().after( now ) )
+            {
+                iterator.remove();
+            }
+        }
+        
+        return periods;
+    }
+    
+    public void nextPeriodSpan( String key, String baseKey )
+    {
+        List<Period> periods = getPeriodList( key, baseKey );
+        CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
+
+        Period basePeriod = periods.get( periods.size() - 1 );
+        Period newBasePeriod = periodType.getNextPeriod( basePeriod );
+
+        if ( newBasePeriod.getStartDate().before( new Date() ) ) // Future periods not allowed
+        {
+            getSession().put( baseKey, newBasePeriod );
+        }
+    }
+
+    public void previousPeriodSpan( String key, String baseKey )
+    {
+        List<Period> periods = getPeriodList(key, baseKey);
+        CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType();
+
+        Period basePeriod = periods.get( 0 );
+        Period newBasePeriod = periodType.getPreviousPeriod( basePeriod );
+
+        getSession().put( baseKey, newBasePeriod );
+    }
+
+    // -------------------------------------------------------------------------
+    // Support methods
+    // -------------------------------------------------------------------------
+
+    private PeriodType getPeriodType()
+    {
+        return (PeriodType) getSession().get( SESSION_KEY_SELECTED_PERIOD_TYPE );
+    }
+
+    private Period getBasePeriod( String baseKey )
+    {
+        Period basePeriod = (Period) getSession().get( baseKey );
+        
+        PeriodType periodType = getPeriodType();
+
+        if ( basePeriod == null )
+        {
+            log.debug( "Base period is null, creating new" );
+
+            basePeriod = periodType.createPeriod();
+            getSession().put( baseKey, basePeriod );
+        }
+        else if ( !basePeriod.getPeriodType().equals( periodType ) )
+        {
+            log.debug( "Wrong type of base period, transforming" );
+
+            basePeriod = periodType.createPeriod( basePeriod.getStartDate() );
+            getSession().put( baseKey, basePeriod );
+        }
+
+        return basePeriod;
+    }
+
+    private static final Map<String, Object> getSession()
+    {
+        return ActionContext.getContext().getSession();
+    }
+
+    @Override
+    public void setPeriodType( String periodTypeName )
+    {
+        getSession().put( SESSION_KEY_SELECTED_PERIOD_TYPE, periodService.getPeriodTypeByName( periodTypeName ) );
+    }
+    
+    public void clearBasePeriod( )
+    {
+        getSession().remove( SESSION_KEY_BASE_PERIOD_START );
+        getSession().remove( SESSION_KEY_BASE_PERIOD_END );
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/NextPeriodsAction.java	2011-01-05 01:13:23 +0000
@@ -0,0 +1,109 @@
+package org.hisp.dhis.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.List;
+
+import org.hisp.dhis.period.Period;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Torgeir Lorange Ostby
+ * @version $Id: NextPeriodsAction.java 2966 2007-03-03 14:38:20Z torgeilo $ *
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-14
+ */
+public class NextPeriodsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PeriodGenericManager periodGenericManager;
+
+    public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
+    {
+        this.periodGenericManager = periodGenericManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input && Output
+    // -------------------------------------------------------------------------
+
+    private boolean startField;
+
+    public void setStartField( boolean startField )
+    {
+        this.startField = startField;
+    }
+
+    private List<Period> periods;
+
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    private Integer index;
+
+    public void setIndex( Integer index )
+    {
+        this.index = index;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        String selectedPeriodKey = "";
+        String basePeriodKey = "";
+
+        if ( startField )
+        {
+            selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START;
+            basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START;
+        }
+        else
+        {
+            selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END;
+            basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END;
+        }
+        
+        periodGenericManager.setSelectedPeriodIndex( selectedPeriodKey, index );
+        periodGenericManager.nextPeriodSpan(selectedPeriodKey, basePeriodKey);
+
+        periods = periodGenericManager.getPeriodList(selectedPeriodKey, basePeriodKey);
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PeriodGenericManager.java	2011-01-05 01:13:23 +0000
@@ -0,0 +1,66 @@
+package org.hisp.dhis.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.List;
+
+import org.hisp.dhis.period.Period;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id$
+ */
+public interface PeriodGenericManager
+{        
+
+    public static final String SESSION_KEY_BASE_PERIOD_START = "SESSION_KEY_BASE_PERIOD_START";
+    public static final String SESSION_KEY_BASE_PERIOD_END = "SESSION_KEY_BASE_PERIOD_END";
+
+    public static final String SESSION_KEY_SELECTED_PERIOD_INDEX_START = "SESSION_KEY_SELECTED_PERIOD_INDEX_START";
+    public static final String SESSION_KEY_SELECTED_PERIOD_INDEX_END = "SESSION_KEY_SELECTED_PERIOD_INDEX_END";
+    
+
+    public void setSelectedPeriodIndex( String key, Integer index );
+
+    public Integer getSelectedPeriodIndex( String key );
+    
+    public Period getSelectedPeriod( String key, String baseKey  );
+    
+    public void setPeriodType( String periodTypeName );
+
+    public void clearSelectedPeriod( );
+    
+    public void clearBasePeriod( );
+
+    public List<Period> getPeriodList( String key, String baseKey );
+
+    public void nextPeriodSpan( String key, String baseKey );
+
+    public void previousPeriodSpan( String key, String baseKey );
+    
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/PreviousPeriodsAction.java	2011-01-05 01:13:23 +0000
@@ -0,0 +1,111 @@
+package org.hisp.dhis.caseentry.state;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.List;
+
+import org.hisp.dhis.period.Period;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Torgeir Lorange Ostby
+ * @version $Id: PreviousPeriodsAction.java 2966 2007-03-03 14:38:20Z torgeilo $
+ *          *
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-14
+ */
+public class PreviousPeriodsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PeriodGenericManager periodGenericManager;
+
+    public void setPeriodGenericManager( PeriodGenericManager periodGenericManager )
+    {
+        this.periodGenericManager = periodGenericManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private boolean startField;
+
+    public void setStartField( boolean startField )
+    {
+        this.startField = startField;
+    }
+
+    private List<Period> periods;
+
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    private Integer index;
+
+    public void setIndex( Integer index )
+    {
+        this.index = index;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        String selectedPeriodKey = "";
+        String basePeriodKey = "";
+
+        if ( startField )
+        {
+            selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_START;
+            basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_START;
+        }
+        else
+        {
+            selectedPeriodKey = PeriodGenericManager.SESSION_KEY_SELECTED_PERIOD_INDEX_END;
+            basePeriodKey = PeriodGenericManager.SESSION_KEY_BASE_PERIOD_END;
+        }
+
+        periodGenericManager.setSelectedPeriodIndex( selectedPeriodKey, index );
+        periodGenericManager.previousPeriodSpan( selectedPeriodKey, basePeriodKey );
+
+        periods = periodGenericManager.getPeriodList( selectedPeriodKey, basePeriodKey );
+
+        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	2010-12-04 00:17:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-01-05 01:13:23 +0000
@@ -349,6 +349,7 @@
 		class="org.hisp.dhis.caseentry.action.caseaggregation.LoadPeriodsAction"
 		scope="prototype">
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+		<property name="periodGenericManager" ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
 	</bean>
 
 	<bean
@@ -363,4 +364,27 @@
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.caseentry.state.PeriodGenericManager"
+		class="org.hisp.dhis.caseentry.state.DefaultPeriodGenericManager"
+		scope="singleton">
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.caseentry.state.NextPeriodsAction"
+		class="org.hisp.dhis.caseentry.state.NextPeriodsAction"
+		scope="prototype">
+		<property name="periodGenericManager"
+			ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.caseentry.state.PreviousPeriodsAction"
+		class="org.hisp.dhis.caseentry.state.PreviousPeriodsAction"
+		scope="prototype">
+		<property name="periodGenericManager"
+			ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
+	</bean>
+	
 </beans>

=== 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	2010-12-09 03:09:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-01-05 01:13:23 +0000
@@ -237,6 +237,18 @@
       <param name="page">/dhis-web-caseentry/caseAggregationResult.vm</param>
       <param name="menu">/dhis-web-caseentry/menu.vm</param>      
     </action>
+    
+    <action name="nextPeriods"
+			class="org.hisp.dhis.caseentry.state.NextPeriodsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonPeriods.vm</result>
+		</action>
+
+		<action name="previousPeriods"
+			class="org.hisp.dhis.caseentry.state.PreviousPeriodsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonPeriods.vm</result>
+		</action>
 		  
   </package>
 </struts>

=== 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	2010-12-03 06:08:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2011-01-05 01:13:23 +0000
@@ -37,13 +37,15 @@
 				</select>
 			</td>
 		</tr>
-						 
+		
 		<tr>
 			<td>
 				$i18n.getString( "from" )
 			</td>
 			<td>
-				<select id="sDateLB" name="sDateLB" style="width: 30em" class="{validate:{required:true}}"></select>
+				<input type="button" value="<<" onclick="getPreviousPeriodForStart()" id="previousPeriodForStartBtn" disabled />
+				<select id="sDateLB" name="sDateLB" style="width: 23em" class="{validate:{required:true}}"></select>
+				<input type="button" value=">>"  onclick="getNextPeriodForStart()" id="nextPeriodForStartBtn" disabled />
 			</td>
 		</tr>
 		
@@ -52,7 +54,9 @@
 				$i18n.getString( "to" )
 			</td>
 			<td>
-				<select id="eDateLB" name="eDateLB" style="width: 30em" class="{validate:{required:true}}"></select>
+				<input type="button" value="<<" onclick="getPreviousPeriodForEnd()" id="previousPeriodForEndBtn" disabled />
+				<select id="eDateLB" name="eDateLB" style="width: 23em" class="{validate:{required:true}}"></select>
+				<input type="button" value=">>"  onclick="getNextPeriodForEnd()" id="nextPeriodForEndBtn" disabled />
 				<i><span id='warningMessage' style="color:red"></span></i>
 			</td>
 				
@@ -61,7 +65,7 @@
 			<td>
 			   $i18n.getString( "ga_facilityby" )
 			</td>
-			<td>		
+			<td>
 				<select id="facilityLB" name="facilityLB" style="width: 30em">
 					<option value="random" selected>$i18n.getString( "selected" )</option>
 					<option value="immChildren" >$i18n.getString( "immediate_children" )</option>

=== 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	2010-12-03 06:08:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2011-01-05 01:13:23 +0000
@@ -23,7 +23,66 @@
 	    		addOptionToList( listStartPeriod, i, json.periods[i].name );
 				addOptionToList( listEndPeriod, i, json.periods[i].name );
 	    	}
-	    	
+	    
+			enable('previousPeriodForStartBtn');
+			enable('nextPeriodForStartBtn');
+			enable('previousPeriodForEndBtn');
+			enable('nextPeriodForEndBtn');
+	
 	    } );
-	}
-}
\ No newline at end of file
+		
+	}
+	else
+	{
+		disable('previousPeriodForStartBtn');
+		disable('nextPeriodForStartBtn');
+		disable('previousPeriodForEndBtn');
+		disable('nextPeriodForEndBtn');
+	}
+	
+}
+
+function getPreviousPeriodForStart() 
+{
+	var index = byId('sDateLB').options[byId('sDateLB').selectedIndex].value;
+	jQuery.postJSON('previousPeriods.action?startField=true&index=' + index, responseListPeriodForStartReceived );	
+}
+
+function getNextPeriodForStart() 
+{
+	var index = byId('sDateLB').options[byId('sDateLB').selectedIndex].value;
+	jQuery.postJSON('nextPeriods.action?startField=true&index=' + index, responseListPeriodForStartReceived );	
+}
+
+function responseListPeriodForStartReceived( json ) 
+{	
+	clearListById('sDateLB');
+	
+	jQuery.each( json.periods, function(i, item ){
+		addOption('sDateLB', item.name , i );
+	});
+}
+
+function getPreviousPeriodForEnd() 
+{
+	var index = byId('eDateLB').options[byId('eDateLB').selectedIndex].value;
+	jQuery.postJSON('previousPeriods.action?startField=false&index=' + index, responseListPeriodForEndReceived );	
+}
+
+function getNextPeriodForEnd() 
+{
+	var index = byId('eDateLB').options[byId('eDateLB').selectedIndex].value;
+	jQuery.postJSON('nextPeriods.action?startField=false&index=' + index, responseListPeriodForEndReceived );	
+}
+
+function responseListPeriodForEndReceived( json ) 
+{	
+	clearListById('eDateLB');
+	
+	jQuery.each( json.periods, function(i, item ){
+		addOption('eDateLB', item.name , i );
+	});
+}
+
+
+	
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2010-12-09 22:05:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2011-01-05 01:13:23 +0000
@@ -238,13 +238,13 @@
 	if (dataElementType == "bool")
 	{
 		id = boolDataEntryId;
-		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryselect\" id=\""+ boolDataEntryId +"\" style=\"width:4em;text-align:center\"/>";
+		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" id=\""+ boolDataEntryId +"\" style=\"width:4em;text-align:center\"/>";
 		
 		
 	}else 
 	{	
 		id = dataEntryId;
-		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + dataEntryId + "\" style=\"width:4em;text-align:center\"/>" ;			
+		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" id=\"" + dataEntryId + "\" style=\"width:4em;text-align:center\"/>" ;			
 	}	
 	
 	if( checkExisted( id ) )