← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13509: local/in PBF Dataentry work in progress

 

------------------------------------------------------------
revno: 13509
committer: Mithilesh Kumar Thakur <mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-12-31 07:59:05 +0000
message:
  local/in PBF Dataentry work in progress
added:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/GetOrganisationUnitAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadDataEntryFormAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadNextPrePeriodsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadPeriodsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/PageInitAction.java
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/css/dataentry.css
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/dataEntrySelection.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pbfDataEntry.js
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataEntryForm.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/menuDataEntry.vm
modified:
  local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties
  local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml


--
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
=== added directory 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry'
=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/GetOrganisationUnitAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/GetOrganisationUnitAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/GetOrganisationUnitAction.java	2013-12-31 07:59:05 +0000
@@ -0,0 +1,124 @@
+package org.hisp.dhis.pbf.dataentry;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.pbf.api.Lookup;
+import org.hisp.dhis.pbf.api.LookupService;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetOrganisationUnitAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+    
+    private LookupService lookupService;
+    
+    public void setLookupService( LookupService lookupService )
+    {
+        this.lookupService = lookupService;
+    }
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+    
+    
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+    private String message;
+    
+    public String getMessage()
+    {
+        return message;
+    }
+    
+    private String orgUnitId;
+    
+    public String getOrgUnitId()
+    {
+        return orgUnitId;
+    }
+
+    public void setOrgUnitId( String orgUnitId )
+    {
+        this.orgUnitId = orgUnitId;
+    }
+
+    private List<DataSet> dataSets = new ArrayList<DataSet>();
+    
+    public List<DataSet> getDataSets()
+    {
+        return dataSets;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception
+    {
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+        
+        dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
+        
+        List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PBF_TYPE ) );
+        
+        List<DataSet> pbfDataSets = new ArrayList<DataSet>();
+        
+        for( Lookup lookup : lookups )
+        {
+            Integer dataSetId = Integer.parseInt( lookup.getValue() );
+            
+            DataSet dataSet = dataSetService.getDataSet( dataSetId );
+            if( dataSet != null )
+            {
+                pbfDataSets.add(dataSet);
+           
+            }
+        }
+        
+        dataSets.retainAll( pbfDataSets );
+        Collections.sort(dataSets);
+        
+        /*
+        for( DataSet dataSet : dataSets )
+        {
+            System.out.println(" dataSet ---" + dataSet.getId() +" -- " + dataSet.getName() );
+        }
+        */
+        
+        if ( dataSets.size() > 0 )
+        {
+            message = organisationUnit.getName();
+            return SUCCESS;
+            
+        }
+        else
+        {
+            message = organisationUnit.getName();
+            
+            return INPUT;
+        }
+
+    }
+
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadDataEntryFormAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadDataEntryFormAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadDataEntryFormAction.java	2013-12-31 07:59:05 +0000
@@ -0,0 +1,190 @@
+package org.hisp.dhis.pbf.dataentry;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ */
+public class LoadDataEntryFormAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private OrganisationUnitService organisationUnitService;
+    
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+    
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    private DataValueService dataValueService;
+
+    public void setDataValueService( DataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Comparator
+    // -------------------------------------------------------------------------
+/*
+    private Comparator<DataElement> dataElementComparator;
+
+    public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
+    {
+        this.dataElementComparator = dataElementComparator;
+    }
+*/    
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+    
+    private String orgUnitId;
+  
+    public void setOrgUnitId( String orgUnitId )
+    {
+        this.orgUnitId = orgUnitId;
+    }
+    
+    private int dataSetId;
+    
+    public void setDataSetId( int dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+
+    private String selectedPeriodId;
+    
+    public void setSelectedPeriodId( String selectedPeriodId )
+    {
+        this.selectedPeriodId = selectedPeriodId;
+    }
+
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
+    
+    public List<DataElement> getDataElements()
+    {
+        return dataElements;
+    }
+    
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+    
+    public Map<String, String> dataValueMap;
+    
+    public Map<String, String> getDataValueMap()
+    {
+        return dataValueMap;
+    }
+    
+    private DataSet dataSet;
+    
+    public DataSet getDataSet()
+    {
+        return dataSet;
+    }
+    
+    private Period period;
+    
+    public Period getPeriod()
+    {
+        return period;
+    }
+    
+    private List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+    
+    public List<DataElementCategoryOptionCombo> getOptionCombos()
+    {
+        return optionCombos;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+ 
+    public String execute()
+    {
+        
+        dataValueMap = new HashMap<String, String>();
+        
+        organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+        
+        dataSet = dataSetService.getDataSet( dataSetId );
+        
+        period = PeriodType.getPeriodFromIsoString( selectedPeriodId );
+        
+        dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+        
+        optionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+       
+        for( DataElement dataElement : dataElements )
+        {
+            //DataElementCategoryOptionCombo decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
+            
+            DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+            
+            optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+            
+            for( DataElementCategoryOptionCombo decombo : optionCombos )
+            {
+                DataValue dataValue = new DataValue();
+                
+                dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, decombo );
+                
+                String value = "";
+                
+                if ( dataValue != null )
+                {
+                    value = dataValue.getValue();
+                }
+                
+                String key = dataElement.getId()+ ":" +  decombo.getId();
+                
+                dataValueMap.put( key, value );
+            }
+            
+        }
+        
+        /*
+        for( DataElementCategoryOptionCombo decombo : optionCombos )
+        {
+            System.out.println(" decombo ---" + decombo.getId() +" -- " + decombo.getName() );
+        }
+        */
+        
+        
+        return SUCCESS;
+    }
+
+}
+

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadNextPrePeriodsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadNextPrePeriodsAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadNextPrePeriodsAction.java	2013-12-31 07:59:05 +0000
@@ -0,0 +1,121 @@
+package org.hisp.dhis.pbf.dataentry;
+
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
+import org.hisp.dhis.util.SessionUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ */
+
+public class LoadNextPrePeriodsAction implements Action
+{
+   
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private int dataSetId;
+    
+    public void setDataSetId( int dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+
+    private int year;
+
+    public void setYear( int year )
+    {
+        this.year = year;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<Period> periods;
+
+    public List<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()  throws Exception
+    {
+        
+        DataSet dataset = dataSetService.getDataSet( dataSetId );
+        
+        String periodType = dataset.getPeriodType().getName();
+        
+        
+        //periodType = periodType != null && !periodType.isEmpty() ? periodType : MonthlyPeriodType.NAME;
+
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+
+        int thisYear = Calendar.getInstance().get( Calendar.YEAR );
+
+        int currentYear = (Integer) SessionUtils.getSessionVar( SessionUtils.KEY_CURRENT_YEAR, thisYear );
+
+        Calendar cal = PeriodType.createCalendarInstance();
+
+        // Cannot go to next year if current year equals this year
+        
+        if ( !( currentYear == thisYear && year > 0 ) )
+        {
+            cal.set( Calendar.YEAR, currentYear );
+            cal.add( Calendar.YEAR, year );
+
+            SessionUtils.setSessionVar( SessionUtils.KEY_CURRENT_YEAR, cal.get( Calendar.YEAR ) );
+        }
+
+        periods = _periodType.generatePeriods( cal.getTime() );
+
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+
+
+        for ( Period period : periods )
+        {
+            period.setName( format.formatPeriod( period ) );
+        }
+
+        return SUCCESS;
+    }
+
+
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadPeriodsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadPeriodsAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/LoadPeriodsAction.java	2013-12-31 07:59:05 +0000
@@ -0,0 +1,100 @@
+package org.hisp.dhis.pbf.dataentry;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.CalendarPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ */
+
+public class LoadPeriodsAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+    
+    private int dataSetId;
+    
+    public void setDataSetId( int dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+ 
+    private List<Period> periods = new ArrayList<Period>();
+
+    public Collection<Period> getPeriods()
+    {
+        return periods;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception
+    { 
+        
+        DataSet dataset = dataSetService.getDataSet( dataSetId );
+        
+        String periodType = dataset.getPeriodType().getName();
+        
+        CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodType );
+        
+        Calendar cal = PeriodType.createCalendarInstance();
+        
+        periods = _periodType.generatePeriods( cal.getTime() );
+        
+        //periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
+        
+        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+
+        Collections.reverse( periods );
+        //Collections.sort( periods );
+        for ( Period period : periods )
+        {
+            //System.out.println("ISO Date : " + period.getIsoDate() );
+            
+            period.setName( format.formatPeriod( period ) );
+        }
+        
+        return SUCCESS;
+    }
+}
+

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/PageInitAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/PageInitAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/PageInitAction.java	2013-12-31 07:59:05 +0000
@@ -0,0 +1,136 @@
+package org.hisp.dhis.pbf.dataentry;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.pbf.api.Lookup;
+import org.hisp.dhis.pbf.api.LookupService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ */
+public class PageInitAction implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitSelectionManager selectionManager;
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+    
+    private OrganisationUnitService organisationUnitService;
+    
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+    
+    private LookupService lookupService;
+    
+    public void setLookupService( LookupService lookupService )
+    {
+        this.lookupService = lookupService;
+    }
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+    
+    
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }    
+    
+    private String orgUnitId;
+    
+    public void setOrgUnitId( String orgUnitId )
+    {
+        this.orgUnitId = orgUnitId;
+    }
+    
+    private List<DataSet> dataSets = new ArrayList<DataSet>();
+    
+    public List<DataSet> getDataSets()
+    {
+        return dataSets;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception
+    {
+        //selectionManager.clearSelectedOrganisationUnits();
+        
+        organisationUnit = selectionManager.getSelectedOrganisationUnit();
+        
+        if( organisationUnit == null )
+        {
+            System.out.println("Organisationunit is null");
+        }
+        else
+        {
+            System.out.println("Organisationunit is not null ---" + organisationUnit.getId() );
+        }
+        
+        if( organisationUnit == null && orgUnitId != null )
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+           
+        }
+        
+        dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
+        
+        List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PBF_TYPE ) );
+        
+        List<DataSet> pbfDataSets = new ArrayList<DataSet>();
+        
+        for( Lookup lookup : lookups )
+        {
+            Integer dataSetId = Integer.parseInt( lookup.getValue() );
+            
+            DataSet dataSet = dataSetService.getDataSet( dataSetId );
+            if( dataSet != null )
+            {
+                pbfDataSets.add(dataSet);
+           
+            }
+        }
+        
+        dataSets.retainAll( pbfDataSets );
+        Collections.sort(dataSets);
+        /*
+        for( DataSet dataSet : dataSets )
+        {
+            System.out.println(" dataSet ---" + dataSet.getId() +" -- " + dataSet.getName() );
+        }
+        */
+        
+        return SUCCESS;
+    }
+}
+
+

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2013-12-24 12:23:11 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2013-12-31 07:59:05 +0000
@@ -99,4 +99,44 @@
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />		
     </bean>
+    
+    
+    
+<!--  PBF Data Entry -->
+
+	<bean id="org.hisp.dhis.pbf.dataentry.PageInitAction" class="org.hisp.dhis.pbf.dataentry.PageInitAction" scope="prototype">
+		<property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />	
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="lookupService" ref="org.hisp.dhis.pbf.api.LookupService" />
+        <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+    </bean>    
+    
+  	<!-- Get OrganisationUnit Unit name -->
+    <bean id="org.hisp.dhis.pbf.dataentry.GetOrganisationUnitAction" class="org.hisp.dhis.pbf.dataentry.GetOrganisationUnitAction" scope="prototype">
+        <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="lookupService" ref="org.hisp.dhis.pbf.api.LookupService" />
+        <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+    </bean> 
+ 
+	<!-- Get Periods -->
+	 <bean id="org.hisp.dhis.pbf.dataentry.LoadPeriodsAction" class="org.hisp.dhis.pbf.dataentry.LoadPeriodsAction" scope="prototype">   
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService"/>
+	 </bean>		
+	
+	<!-- Get Next and Previous Periods -->
+	 <bean id="org.hisp.dhis.pbf.dataentry.LoadNextPrePeriodsAction" class="org.hisp.dhis.pbf.dataentry.LoadNextPrePeriodsAction" scope="prototype">   
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService"/>
+	 </bean>	 
+    
+    
+	<!-- Load DataEntry Form -->
+	 <bean id="org.hisp.dhis.pbf.dataentry.LoadDataEntryFormAction" class="org.hisp.dhis.pbf.dataentry.LoadDataEntryFormAction" scope="prototype">   
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService"/>
+		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService"/>  
+	 </bean>    
+    
+    
+    
+    
 </beans>
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties	2013-12-31 07:59:05 +0000
@@ -1,3 +1,20 @@
 pbf_setup = PBF Setup
 dataelement_tariff_management = Tariff Management Dataelement
-pbf_management = PBF Management
\ No newline at end of file
+pbf_management = PBF Management
+
+dataentry = Data Entry
+bank_details_management = Bank Details Management
+
+pbf_dataentry = PBF Data Entry
+
+dataset = Dataset
+select_dataSet = Select Dataset
+prev_year = Prev year
+next_year = Next year
+entry = Entry
+earlier_periods = Earlier periods
+later_periods = Later periods
+select = Select
+period = Period
+
+dataelement = Data Element
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml	2013-12-24 12:23:11 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml	2013-12-31 07:59:05 +0000
@@ -2,6 +2,7 @@
 <!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd";>
+
 <struts>
 	
 	<include file="dhis-web-commons.xml"/>
@@ -62,6 +63,44 @@
 			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_BANKDATA_UPDATE</param>					
 		</action>
+	
+	
+	
+<!--  PBF Data Entry -->	
+	
+	
+    <action name="pbfDataEntry" class="org.hisp.dhis.pbf.dataentry.PageInitAction">
+      <interceptor-ref name="organisationUnitTreeStack" />
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-maintenance-pbf/dataEntrySelection.vm</param>
+      <param name="menu">/dhis-web-maintenance-pbf/menuDataEntry.vm</param>
+      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/pbfDataEntry.js</param>
+      <param name="stylesheets">style/dataentry.css</param>
+    </action>	
+	
+    <!-- Get OrganisationUnit Unit name -->
+    <action name="getOrganisationUnit" class="org.hisp.dhis.pbf.dataentry.GetOrganisationUnitAction">
+        <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+        <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+    </action>	
+	
+	<!-- Get Periods -->
+    <action name="loadPeriods" class="org.hisp.dhis.pbf.dataentry.LoadPeriodsAction">
+        <result name="success" type="velocity-json">/dhis-web-maintenance-pbf/jsonPeriods.vm</result>
+    </action>	
+	
+	<!-- Get Next and Previous Periods -->
+    <action name="getAvailableNextPrePeriods" class="org.hisp.dhis.pbf.dataentry.LoadNextPrePeriodsAction">
+        <result name="success" type="velocity-json">/dhis-web-maintenance-pbf/jsonPeriods.vm</result>
+    </action>		
+	
+	<!-- Load DataEntry Form -->
+	<action name="loadDataEntryForm" class="org.hisp.dhis.pbf.dataentry.LoadDataEntryFormAction">
+		<result name="success" type="velocity">/content.vm</result>
+		<param name="page">/dhis-web-maintenance-pbf/loadDataEntryForm.vm</param>
+	</action>	
+	
 	</package>
 	
+	
 </struts>
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/css/dataentry.css'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/css/dataentry.css	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/css/dataentry.css	2013-12-31 07:59:05 +0000
@@ -0,0 +1,102 @@
+
+#currentSelection
+{
+  padding: 6px;
+  background-color: #eee;
+  border: 1px solid #bbb;
+  font-size: 14px;
+  text-align: right;
+  position: fixed;
+  top: 55px;
+  right: 10px;
+  filter: alpha(opacity=85);
+  opacity: 0.85;
+  border-radius: 3px;
+}
+
+#actions
+{
+  float: right;
+  width: 160px;
+  text-align: right;
+}
+
+#closeCurrentSelection
+{
+  float:left;
+  cursor:pointer;
+  margin-right:5px;
+}
+
+#contentDiv
+{
+  margin-bottom: 8px;
+}
+
+#completenessDiv
+{
+  display: none;
+  width: 386px;
+  height: 29px;
+}
+
+#infoDiv
+{
+  display: none;
+  width: 386px;
+  height: 20px;
+}
+
+#completedByDiv
+{
+  display: none;
+}
+
+.currentRow
+{
+  background-color: #d5ffc5;
+  padding-right: 50px;
+}
+
+.hidden 
+{
+  display: none;
+}
+
+input[type=text],textarea
+{
+  padding-left: 0;
+  padding-right: 0;
+  margin-top: 1px;
+  margin-bottom: 1px;
+}
+
+.formSection td
+{
+  padding-right: 2px;
+  padding-left: 2px;
+  height: 28px;
+  white-space: nowrap;
+}
+
+.formSection th
+{
+  text-align: center;
+  min-width: 46px;
+}
+
+.sectionFilter
+{
+  padding: 5px;
+  border: solid 1px #f0f0f0; 
+  outline: 0;
+  color: #333;
+  height: 14px;
+}
+
+.historyHeader
+{
+  color: #606060;
+  font-size: 17px;
+  padding: 5px 0;
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/dataEntrySelection.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/dataEntrySelection.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/dataEntrySelection.vm	2013-12-31 07:59:05 +0000
@@ -0,0 +1,85 @@
+<script>
+    
+	jQuery(document).ready( function(){
+	currentDiv = 'pbfDataEntryForm';
+	isSubmit = true;
+    jQuery("#pbfDataEntryForm").validate({
+		meta:"validate"
+		,errorElement:"span"
+		,submitHandler: function(form)
+		{
+        	if( isSubmit ) 
+            {
+            	savePBFDataEntryForm();
+            }
+		}
+    	});
+    }); 
+    
+</script>
+
+<h3>$i18n.getString( "pbf_dataentry" )</h3>
+
+<form id="pbfDataEntryForm" name="pbfDataEntryForm" method="post" >	
+<div>
+	<input type="hidden" id='selectedOrgunitID' name = 'selectedOrgunitID' value="$!organisationUnit.id" />
+	<input type="hidden" id='selectedOrgunitName' name = 'selectedOrgunitName' value="$!organisationUnit.name" />
+	
+</div>
+
+<div class="inputCriteria" style="width:480px;height:90px;">
+<table>
+	<tr>
+		<td><label for="orgUnitName">$i18n.getString( "organisation_unit" )</label></td>
+		<td><input type="text" id="orgUnitName" name = "orgUnitName" readonly="readonly" value="$!organisationUnit.name" style="width:352px"></td>
+	</tr>
+	
+	<tr>
+		<td><label>$i18n.getString( "dataset" )</label></td>
+		<td>
+			<select id="dataSetId" name = "dataSetId" style="width:354px" onchange="loadPeriods();" #if( $dataSets.size() == 0 ) disabled="disabled" #end>
+				<option value="-1">$i18n.getString( "select_dataSet" )</option>
+				#foreach( $dataSet in $dataSets )
+					<option value="$dataSet.id">$dataSet.name</option>
+				#end
+			</select>
+		</td>
+    </tr>	
+
+	<tr>
+		<td><label for="selectedPeriodId">$i18n.getString( "period" )</label></td>
+		<td><select id="selectedPeriodId" name="selectedPeriodId" style="width:200px" disabled="disabled" onchange="loadDataEntryForm()">
+				<option value="-1">[$i18n.getString( "select" )]</option>
+				#foreach( $period in $periods )
+					<option value="$period.iso">$encoder.htmlEncode( $period.name )</option>
+    			#end
+			</select>
+			<input type="button" id="prevButton" disabled="disabled" style="width:75px" value="$i18n.getString( 'prev_year' )" title="$i18n.getString('earlier_periods')" onclick="getAvailablePeriodsTemp( 'selectedPeriodId', 'selectedPeriodId', '-1' )" >
+			<input type="button" id="nextButton" disabled="disabled" style="width:75px" value="$i18n.getString( 'next_year' )" title="$i18n.getString('later_periods')" onclick="getAvailablePeriodsTemp( 'selectedPeriodId', 'selectedPeriodId', '1' )" >
+		</td>
+	</tr>		
+
+</table>
+</div>
+
+
+#parse( "/dhis-web-commons/loader/loader.vm" )
+<div id='dataEntryFormDiv'></div> <!-- DataEntry Form -->  	
+
+<p>
+	<input type="button"  value="$i18n.getString( 'Cancel' )" style="width:100px" onclick="window.location.href='index.action'"/>&nbsp;&nbsp;
+	&nbsp;&nbsp;<input type="submit"  id="saveButton" name="saveButton" value="$i18n.getString( 'save' )" disabled="disabled" style="width:100px"/>
+</p>
+
+
+</form>
+
+<script type="text/javascript">
+
+var i18n_select_dataset = '$encoder.jsEscape( $i18n.getString( "select_dataSet" ) , "'")';
+
+
+jQuery( document ).ready( function()
+{
+});
+</script>
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pbfDataEntry.js'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pbfDataEntry.js	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pbfDataEntry.js	2013-12-31 07:59:05 +0000
@@ -0,0 +1,193 @@
+
+function orgUnitHasBeenSelected( orgUnitIds )
+{    
+	$( '#dataEntryFormDiv' ).html( '' );
+	
+	document.getElementById('selectedOrgunitID').value = orgUnitIds;
+	
+	//alert( orgUnitIds );
+	
+	if( orgUnitIds != null && orgUnitIds != "" )
+	{
+		 $.getJSON( 'getOrganisationUnit.action', {orgUnitId:orgUnitIds[0]}
+	        , function( json ) 
+	        {
+	            var type = json.response;
+	            setFieldValue('orgUnitName', json.message );
+	            setFieldValue('selectedOrgunitName', json.message );
+	                
+	            if( type == 'success' )
+	            {
+					enable('dataSetId');
+	                setFieldValue('orgUnitName', json.message );
+	                setFieldValue('selectedOrgunitName', json.message );
+	            }
+	            else if( type == 'input' )
+	            {
+	                disable('dataSetId');
+	                disable('selectedPeriodId');
+	                disable('prevButton');
+	                disable('nextButton');
+	                
+	                setFieldValue('orgUnitName', json.message );
+	                setFieldValue('selectedOrgunitName', json.message );
+	            }
+	        } );		
+	}
+}
+
+selection.setListenerFunction( orgUnitHasBeenSelected );
+
+
+function loadDataEntryForm()
+{
+	var orgUnitId = $( '#selectedOrgunitID' ).val();
+	
+	
+	
+	
+	var dataSetId = $( '#dataSetId' ).val();
+	
+	
+	
+	$( '#dataEntryFormDiv' ).html('');
+	
+	$( '#saveButton' ).removeAttr( 'disabled' );
+	
+
+	var selectedPeriodId = $( '#selectedPeriodId' ).val();
+	
+	if ( selectedPeriodId == "-1" && dataSetId == "-1" )
+	{
+		$( '#dataEntryFormDiv' ).html('');
+		document.getElementById( "saveButton" ).disabled = true;
+		return false;
+	}
+	
+	else
+	{
+	    jQuery('#loaderDiv').show();
+	    
+		jQuery('#dataEntryFormDiv').load('loadDataEntryForm.action',
+			{
+				orgUnitId:orgUnitId,
+				dataSetId:dataSetId,
+				selectedPeriodId:selectedPeriodId
+			}, function()
+			{
+				showById('dataEntryFormDiv');
+				jQuery('#loaderDiv').hide();
+			});
+		hideLoader();
+	}
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// load periods
+function loadPeriods()
+{
+	$( '#dataEntryFormDiv' ).html( '' );
+	
+    var orgUnitId = $( '#selectedOrgunitID' ).val();
+
+    var dataSetId = $( '#dataSetId' ).val();
+	
+	
+	if ( dataSetId == "-1" )
+	{
+		showWarningMessage( i18n_select_dataset );
+		
+		document.getElementById( "selectedPeriodId" ).disabled = true;
+		document.getElementById( "prevButton" ).disabled = true;
+		document.getElementById( "nextButton" ).disabled = true;
+		return false;
+	}
+	
+	else
+	{
+		
+		enable('selectedPeriodId');
+		
+		enable('prevButton');
+		enable('nextButton');
+				
+		var url = 'loadPeriods.action?dataSetId=' + dataSetId;
+		
+		var list = document.getElementById( 'selectedPeriodId' );
+			
+		clearList( list );
+		
+		addOptionToList( list, '-1', '[ Select ]' );
+		
+	    $.getJSON( url, function( json ) {
+	    	for ( i in json.periods ) {
+	    		addOptionToList( list, json.periods[i].isoDate, json.periods[i].name );
+	    	}
+	    } );
+		
+	}
+}
+
+
+//next and pre periods
+function getAvailablePeriodsTemp( availablePeriodsId, selectedPeriodsId, year )
+{	
+	$( '#dataEntryFormDiv' ).html( '' );
+	
+	var dataSetId = $( '#dataSetId' ).val();
+	
+	var availableList = document.getElementById( availablePeriodsId );
+	var selectedList = document.getElementById( selectedPeriodsId );
+	
+	clearList( selectedList );
+	
+	addOptionToList( selectedList, '-1', '[ Select ]' );
+	
+	$.getJSON( "getAvailableNextPrePeriods.action", {
+		"dataSetId": dataSetId ,
+		"year": year },
+		function( json ) {
+			
+			for ( i in json.periods ) {
+	    		addOptionToList( selectedList, json.periods[i].isoDate, json.periods[i].name );
+	    	}
+			
+		} );
+}
+
+
+
+
+
+
+
+
+
+
+
+
+

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/jsonPeriods.vm	2013-12-31 07:59:05 +0000
@@ -0,0 +1,13 @@
+#set( $size = $periods.size() )
+{ "periods": [
+#foreach( $period in $periods )
+  {
+    "id": $!{period.id},
+    "startDate": "$!format.formatDate( ${period.startDate} )",
+    "endDate": "$!format.formatDate( ${period.endDate} )",
+    "name": "$!format.formatPeriod( ${period} )",
+    "externalId": "$!{period.externalId}",
+	"isoDate": "$!{period.isoDate}"
+  }#if( $velocityCount < $size ),#end    
+#end
+] }

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataEntryForm.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataEntryForm.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataEntryForm.vm	2013-12-31 07:59:05 +0000
@@ -0,0 +1,53 @@
+## Macro for generating the jQuery validation rules 
+#macro( validate $type $require )
+  #if( $type == "NUMBER" || $type == "number" )
+    {validate:{ number:true #if($require), required:true #end }}
+  
+	#elseif( $type == "int" )
+  	{validate:{ integer:true #if($require), required:true #end }}
+  	
+  	#elseif( $type == "positiveNumber" )
+  	{validate:{ positive_integer:true #if($require), required:true #end }}
+  	
+	#elseif( $type == "negativeNumber" )
+  	{validate:{ negative_integer:true #if($require), required:true #end }}
+  
+  
+	#elseif( $require )
+    {validate:{required:true}}
+  #end
+#end
+
+
+#set( $tabIndex = 1 )
+#if ( $dataElements.size() > 0)
+
+<table class="formSection">
+	<tr bgcolor="#CBDDEB">
+		<th>$i18n.getString( "dataelement" )</th>
+		
+		#foreach($optionCombo in $optionCombos )
+			<th style="text-align: center;">$encoder.htmlEncode( $optionCombo.name )</th>
+		#end	
+		
+	</tr>
+	
+	#set( $mark = false )
+	#foreach($dataElement in $dataElements )
+		<tr #alternate($mark)>
+			<td><label>$dataElement.getFormNameFallback()</label></td>
+		
+			#foreach($optionCombo in $optionCombos )
+				#set( $valueMapId =  $dataElement.id + ':' + $optionCombo.id )
+				#set( $dataValue = "" )
+				#set( $dataValue = $!dataValueMap.get( $valueMapId ) )
+				<td><input type="text" name="dataelement$valueMapId" id="dataelement$valueMapId" value="$!dataValue" tabindex="$tabIndex" style="text-align: center;" #if($dataElement.type =='number') class="{validate:{number:true}}" #elseif($dataElement.type =='int') class="{validate:{integer:true}}" #elseif($dataElement.type =='positiveNumber') class="{validate:{positive_integer:true}}" #elseif($dataElement.type =='negativeNumber') class="{validate:{negative_integer:true}}" #end/></td>
+			#end
+		</tr>
+		#set( $tabIndex = $tabIndex + 1 )
+		#set( $mark = !$mark)	
+	#end
+	
+</table
+	
+#end
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/menuDataEntry.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/menuDataEntry.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/menuDataEntry.vm	2013-12-31 07:59:05 +0000
@@ -0,0 +1,9 @@
+
+<a href="index.action"><h2>$i18n.getString( "pbf_dataentry" )&nbsp;</h2></a>
+<ul>
+    <!--<li></li>-->
+    <!--<li></li>-->
+</ul>
+<br>
+
+#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
\ No newline at end of file