=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/GetPeriodsByPeriodTypeAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/GetPeriodsByPeriodTypeAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/GetPeriodsByPeriodTypeAction.java 2009-10-15 09:50:00 +0000 @@ -0,0 +1,98 @@ +package org.hisp.dhis.reportexcel.export.individual.action; + +/* + * Copyright (c) 2004-2007, 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.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.comparator.PeriodComparator; +import org.hisp.dhis.reportexcel.export.individual.manager.SelectedStateManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Nguyen Tran Do Xuan Thuy + * @version $Id$ + * @since 2009-10-14 + */ + +public class GetPeriodsByPeriodTypeAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependences + // ------------------------------------------------------------------------- + + private SelectedStateManager selectedStateManager; + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List periods; + + public List getPeriods() + { + return periods; + } + + private String periodTypeName; + + public void setPeriodTypeName( String periodTypeName ) + { + this.periodTypeName = periodTypeName; + } + + // ------------------------------------------------------------------------- + // Implement Action method + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + + selectedStateManager.setSelectedPeriodTypeName( periodTypeName ); + + periods = new ArrayList(selectedStateManager.getPeriodList()); + + if ( periods == null ) + { + return ERROR; + } + + Collections.sort( periods, new PeriodComparator() ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/NextPeriodsAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/NextPeriodsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/NextPeriodsAction.java 2009-10-15 09:50:00 +0000 @@ -0,0 +1,91 @@ +package org.hisp.dhis.reportexcel.export.individual.action; + +/* + * Copyright (c) 2004-2007, 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.ArrayList; +import java.util.List; + +import org.hisp.dhis.period.Period; +import org.hisp.dhis.reportexcel.export.action.SelectionManager; +import org.hisp.dhis.reportexcel.export.individual.manager.SelectedStateManager; + +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 SelectionManager selectionManager; + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + private SelectedStateManager selectedStateManager; + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List periods; + + public List getPeriods() + { + return periods; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + selectionManager.setSeletedYear( selectionManager.getSelectedYear() + 1 ); + selectedStateManager.nextPeriodSpan(); + + periods = new ArrayList( selectedStateManager.getPeriodList() ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/PreviousPeriodsAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/PreviousPeriodsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/action/PreviousPeriodsAction.java 2009-10-15 09:50:00 +0000 @@ -0,0 +1,92 @@ +package org.hisp.dhis.reportexcel.export.individual.action; + +/* + * Copyright (c) 2004-2007, 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.ArrayList; +import java.util.List; + +import org.hisp.dhis.period.Period; +import org.hisp.dhis.reportexcel.export.action.SelectionManager; +import org.hisp.dhis.reportexcel.export.individual.manager.SelectedStateManager; + +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 SelectedStateManager selectedStateManager; + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + private SelectionManager selectionManager; + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List periods; + + public List getPeriods() + { + return periods; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + selectionManager.setSeletedYear( selectionManager.getSelectedYear() - 1 ); + selectedStateManager.previousPeriodSpan(); + + periods = new ArrayList( selectedStateManager.getPeriodList() ); + + return SUCCESS; + } + +} === added directory 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager' === added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/DefaultSelectedStateManager.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/DefaultSelectedStateManager.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/DefaultSelectedStateManager.java 2009-10-15 09:50:00 +0000 @@ -0,0 +1,252 @@ +package org.hisp.dhis.reportexcel.export.individual.manager; + +/* + * Copyright (c) 2004-2007, 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.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +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 org.hisp.dhis.period.comparator.PeriodComparator; +import org.hisp.dhis.reportexcel.export.action.SelectionManager; +import org.hisp.dhis.reportexcel.utils.DateUtils; + +import com.opensymphony.xwork2.ActionContext; + +/** + * @author Torgeir Lorange Ostby + * @version $Id: DefaultSelectedStateManager.java 5282 2008-05-28 10:41:06Z + * larshelg $ + * @modifier Dang Duy Hieu + * @since 2009-10-14 + */ +public class DefaultSelectedStateManager + implements SelectedStateManager +{ + private static final Log LOG = LogFactory.getLog( DefaultSelectedStateManager.class ); + + public static final String SESSION_KEY_SELECTED_PERIOD_TYPE_NAME = "_selected_period_type_name"; + + public static final String SESSION_KEY_SELECTED_PERIOD_INDEX = "_selected_period_index"; + + public static final String SESSION_KEY_BASE_PERIOD = "_base_period"; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionManager selectionManager; + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + // ------------------------------------------------------------------------- + // Cache + // ------------------------------------------------------------------------- + + private ThreadLocal> generatedPeriodsCache = new ThreadLocal>(); + + // ------------------------------------------------------------------------- + // SelectedStateManager implementation + // ------------------------------------------------------------------------- + + @SuppressWarnings( "unchecked" ) + public void setSelectedPeriodIndex( Integer index ) + { + getSession().put( SESSION_KEY_SELECTED_PERIOD_INDEX, index ); + } + + public Integer getSelectedPeriodIndex() + { + return (Integer) getSession().get( SESSION_KEY_SELECTED_PERIOD_INDEX ); + } + + @SuppressWarnings( "unchecked" ) + public void setSelectedPeriodTypeName( String periodTypeName ) + { + getSession().put( SESSION_KEY_SELECTED_PERIOD_TYPE_NAME, periodTypeName ); + } + + public String getSelectedPeriodTypeName() + { + return (String) getSession().get( SESSION_KEY_SELECTED_PERIOD_TYPE_NAME ); + } + + public Period getSelectedPeriod() + { + Integer index = getSelectedPeriodIndex(); + + if ( index == null ) + { + return null; + } + + List periods = getPeriodList(); + + if ( index >= 0 && index < periods.size() ) + { + Period selectedPeriod = periods.get( index ); + + Period period = null; + + for ( Period p : periodService.getAllPeriods() ) + { + if ( selectedPeriod.equals( p ) ) + { + period = p; + + return period; + } + } + } + + return null; + } + + public void clearSelectedPeriod() + { + getSession().remove( SESSION_KEY_SELECTED_PERIOD_INDEX ); + } + + public List getPeriodList() + { + List periods = generatedPeriodsCache.get(); + + Period basePeriod = getBasePeriod(); + + if ( periods == null || periods.size() == 0 + || !periods.get( 0 ).getPeriodType().equals( basePeriod.getPeriodType() ) || !periods.contains( basePeriod ) ) + { + CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType(); + + LOG.debug( "Generated periods cache invalid, generating new periods based on " + basePeriod ); + + periods = periodType.generatePeriods( basePeriod ); + + generatedPeriodsCache.set( periods ); + } + + Collection persistedPeriods = periodService.getPeriodsByPeriodType( getPeriodType() ); + + // get the period elements which exist in Collection + persistedPeriods.retainAll( periods ); + Collections.sort( (ArrayList) persistedPeriods, new PeriodComparator() ); + + // return periods; + return (ArrayList) persistedPeriods; + } + + @SuppressWarnings( "unchecked" ) + public void nextPeriodSpan() + { + List periods = getPeriodList(); + CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType(); + + Period basePeriod = periods.get( periods.size() - 1 ); + Period newBasePeriod = periodType.getNextPeriod( basePeriod ); + + // Future periods not allowed + if ( newBasePeriod.getStartDate().before( new Date() ) ) + { + getSession().put( SESSION_KEY_BASE_PERIOD, newBasePeriod ); + } + generatedPeriodsCache.remove(); + + } + + @SuppressWarnings( "unchecked" ) + public void previousPeriodSpan() + { + List periods = getPeriodList(); + CalendarPeriodType periodType = (CalendarPeriodType) getPeriodType(); + + Period basePeriod = periods.get( 0 ); + Period newBasePeriod = periodType.getPreviousPeriod( basePeriod ); + + getSession().put( SESSION_KEY_BASE_PERIOD, newBasePeriod ); + + generatedPeriodsCache.remove(); + } + + // ------------------------------------------------------------------------- + // Support methods + // ------------------------------------------------------------------------- + private PeriodType getPeriodType() + { + return periodService.getPeriodTypeByName( getSelectedPeriodTypeName() ); + } + + @SuppressWarnings( "unchecked" ) + private Period getBasePeriod() + { + Period basePeriod = (Period) getSession().get( SESSION_KEY_BASE_PERIOD ); + PeriodType periodType = getPeriodType(); + + if ( basePeriod == null ) + { + LOG.debug( "getBasePeriod(): Base period is null, creating new." ); + + basePeriod = periodType.createPeriod(); + getSession().put( SESSION_KEY_BASE_PERIOD, basePeriod ); + + selectionManager.setSeletedYear( DateUtils.getCurrentYear() ); + } + else if ( selectionManager.getSelectedYear() > 0 ) + { + Date firstDayOfYear = DateUtils.getFirstDayOfYear( selectionManager.getSelectedYear() ); + + basePeriod = periodType.createPeriod( firstDayOfYear ); + } + + return basePeriod; + } + + @SuppressWarnings( "unchecked" ) + private static final Map getSession() + { + return ActionContext.getContext().getSession(); + } + +} === added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/SelectedStateManager.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/SelectedStateManager.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/individual/manager/SelectedStateManager.java 2009-10-15 09:50:00 +0000 @@ -0,0 +1,59 @@ +package org.hisp.dhis.reportexcel.export.individual.manager; + +/* + * Copyright (c) 2004-2007, 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 Torgeir Lorange Ostby + * @version $Id: SelectedStateManager.java 3311 2007-05-18 14:08:01Z torgeilo $ + * @modifier Dang Duy Hieu + * @since 2009-10-14 + */ +public interface SelectedStateManager +{ + void setSelectedPeriodIndex( Integer index ); + + Integer getSelectedPeriodIndex(); + + void setSelectedPeriodTypeName( String periodTypeName ); + + String getSelectedPeriodTypeName(); + + Period getSelectedPeriod(); + + void clearSelectedPeriod(); + + List getPeriodList(); + + void nextPeriodSpan(); + + void previousPeriodSpan(); +} === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-10-09 08:02:34 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-10-15 09:50:00 +0000 @@ -975,4 +975,42 @@ --> + + + + + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2009-10-14 04:36:29 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2009-10-15 09:50:00 +0000 @@ -744,6 +744,28 @@ --> + + + + + + /dhis-web-excel-reporting/responsePeriods.vm + + /dhis-web-excel-reporting/responseError.vm + + + + + /dhis-web-excel-reporting/responsePeriods.vm + + + + + /dhis-web-excel-reporting/responsePeriods.vm + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm 2009-10-14 02:21:43 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm 2009-10-15 09:50:00 +0000 @@ -108,7 +108,7 @@ - #foreach ( $periodType in $periodTypes ) @@ -122,6 +122,11 @@   + + + +   + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js 2009-10-14 02:39:08 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js 2009-10-15 09:50:00 +0000 @@ -296,4 +296,41 @@ function hideToolTip(){ byId('tooltip').style.display = 'none'; +} + +function getPeriodsByPeriodTypeName() { + + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( responseListPeriodReceived ); + request.send( 'getPeriodsByPeriodType.action?periodTypeName=' + $("#availabelPeriodTypes").val()); +} + +function lastPeriod() { + + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( responseListPeriodReceived ); + request.send( 'previousPeriods.action' ); +} + +function nextPeriod() { + + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( responseListPeriodReceived ); + request.send( 'nextPeriods.action' ); +} + +function responseListPeriodReceived( xmlObject ) { + + clearListById('availablePeriods'); + var list = xmlObject.getElementsByTagName('period'); + for ( var i = 0; i < list.length; i++ ) + { + item = list[i]; + var id = item.getElementsByTagName('id')[0].firstChild.nodeValue; + var name = item.getElementsByTagName('name')[0].firstChild.nodeValue; + addOption('availablePeriods', name, id); + } } \ No newline at end of file