← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15115: local/in RBF work in progress

 

------------------------------------------------------------
revno: 15115
committer: Mithilesh Kumar Thakur <mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-30 06:26:01 +0100
message:
  local/in RBF work in progress
added:
  local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/responseTariffStatusInput.vm
modified:
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/DeleteTariffDataAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/GetDataElementforTariffAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/LoadTariffDetailsAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/ValidateTariffDataAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java
  local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml
  local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataElementsforTariff.vm
  local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm
  local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadTariffData.vm
  local/in/pom.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
=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/DeleteTariffDataAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/DeleteTariffDataAction.java	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/DeleteTariffDataAction.java	2014-04-30 05:26:01 +0000
@@ -8,9 +8,12 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.rbf.api.TariffDataValue;
 import org.hisp.dhis.rbf.api.TariffDataValueService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -48,7 +51,9 @@
     {
         this.dataSetService = dataSetService;
     }
-
+    
+    @Autowired
+    private OrganisationUnitGroupService orgUnitGroupService;
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -88,6 +93,14 @@
         this.endDate = endDate;
     }
 
+    private Integer orgUnitGroupId;
+
+    public void setOrgUnitGroupId( Integer orgUnitGroupId )
+    {
+        this.orgUnitGroupId = orgUnitGroupId;
+    }
+    
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -102,10 +115,15 @@
         
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
-        TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( organisationUnit, dataElement, dataSet, sDate, eDate );
-
+        
+        //OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+        
+        OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+        
+        //TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( organisationUnit, dataElement, dataSet, sDate, eDate );
+        
+        TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( orgUnitGroup, dataElement, dataSet, sDate, eDate );
+        
         tariffDataValueService.deleteTariffDataValue( tariffDataValue );
 
         return SUCCESS;

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/GetDataElementforTariffAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/GetDataElementforTariffAction.java	2014-04-27 08:51:10 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/GetDataElementforTariffAction.java	2014-04-30 05:26:01 +0000
@@ -10,6 +10,7 @@
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -90,6 +91,14 @@
         return orgUnitGroups;
     }
     
+    private Integer orgUnitGroupId;
+
+    public void setOrgUnitGroupId( Integer orgUnitGroupId )
+    {
+        this.orgUnitGroupId = orgUnitGroupId;
+    }
+    
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -121,21 +130,63 @@
         
         orgUnitGroups = new ArrayList<OrganisationUnitGroup>( orgUnitGroupService.getOrganisationUnitGroupSet( (int) tariff_authority.getValue() ).getOrganisationUnitGroups() );
         
-        List<DataElement> dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
-
-        for ( DataElement de : dataElements )
-        {
-            Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
-            for ( AttributeValue attValue : attrValueSet )
-            {
-                if ( dataElementList != null && !( dataElementList.contains( "{\"name\" : \"" + de.getName() + "\"}" ) )
-                    && attValue.getAttribute().getId() == tariffDataElement.getValue() )
-                {
-                    dataElementList.add( "{\"name\" : \"" + de.getName() + "\"}" );
-                }
-            }
-        }
-
+        /*
+        if ( orgUnitGroupId != null )
+        {
+            List<DataElement> dataElements = new ArrayList<DataElement>();
+            
+            OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
+            List<DataSet> dataSets = new ArrayList<DataSet>( orgUnitGroup.getDataSets() );
+            for ( DataSet ds : dataSets )
+            {
+                dataElements.addAll( ds.getDataElements() );
+            }
+            
+            for ( DataElement de : dataElements )
+            {
+                Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
+                for ( AttributeValue attValue : attrValueSet )
+                {
+                    if ( dataElementList != null && !( dataElementList.contains( "{\"name\" : \"" + de.getName() + "\"}" ) )
+                        && attValue.getAttribute().getId() == tariffDataElement.getValue() )
+                    {
+                        dataElementList.add( "{\"name\" : \"" + de.getName() + "\"}" );
+                    }
+                }
+            }
+            
+        }
+        */
+        
+        //else
+        //{
+            List<DataElement> dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
+
+            for ( DataElement de : dataElements )
+            {
+                Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
+                for ( AttributeValue attValue : attrValueSet )
+                {
+                    if ( dataElementList != null && !( dataElementList.contains( "{\"name\" : \"" + de.getName() + "\"}" ) )
+                        && attValue.getAttribute().getId() == tariffDataElement.getValue() )
+                    {
+                        dataElementList.add( "{\"name\" : \"" + de.getName() + "\"}" );
+                    }
+                }
+            }
+        //}
+        
+        /*
+        System.out.println( "dataElementList Size : " + dataElementList.size() );
+        
+        for( String dataElement : dataElementList )
+        {
+            System.out.println("  --- dataElement" + dataElement );
+        }
+        */
+            
+        
+        
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/LoadTariffDetailsAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/LoadTariffDetailsAction.java	2014-04-27 08:51:10 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/LoadTariffDetailsAction.java	2014-04-30 05:26:01 +0000
@@ -60,14 +60,14 @@
     }
 
     private LookupService lookupService;
-    
+
     public void setLookupService( LookupService lookupService )
     {
         this.lookupService = lookupService;
     }
 
     private DataSetService dataSetService;
-    
+
     public void setDataSetService( DataSetService dataSetService )
     {
         this.dataSetService = dataSetService;
@@ -80,11 +80,11 @@
     // Input / Output
     // -------------------------------------------------------------------------
     private Integer orgUnitGroupId;
-    
-    public void setOrgUnitGroupId(Integer orgUnitGroupId) 
+
+    public void setOrgUnitGroupId( Integer orgUnitGroupId )
     {
-		this.orgUnitGroupId = orgUnitGroupId;
-	}
+        this.orgUnitGroupId = orgUnitGroupId;
+    }
 
     private String dataElementName;
 
@@ -122,28 +122,30 @@
     }
 
     private List<DataSet> dataSets = new ArrayList<DataSet>();
-    
+
     public List<DataSet> getDataSets()
     {
         return dataSets;
     }
-    
+
     private SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );;
-    
-    public SimpleDateFormat getSimpleDateFormat() {
-		return simpleDateFormat;
-	}
-    
+
+    public SimpleDateFormat getSimpleDateFormat()
+    {
+        return simpleDateFormat;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-	public String execute()
+    public String execute()
     {
         User curUser = currentUserService.getCurrentUser();
-        
-        List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>( curUser.getUserCredentials().getUserAuthorityGroups() );
-        
+
+        List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>( curUser.getUserCredentials()
+            .getUserAuthorityGroups() );
+
         for ( UserAuthorityGroup userAuthorityGroup : userAuthorityGroups )
         {
             userAuthorityGroup.getUserGroupAccesses();
@@ -159,27 +161,51 @@
 
         selecteddataElement = dataElementService.getDataElementByName( dataElementName );
 
-        //OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
-        
+        // OrganisationUnit organisationUnit =
+        // organisationUnitService.getOrganisationUnit( orgUnitUid );
+
         OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
-        
-        //organisationUnit.getParent()
-        
-        //tariffList = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues( organisationUnit, selecteddataElement ) );
-        
-        tariffList = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues( orgUnitGroup, selecteddataElement ) );
+
+        // organisationUnit.getParent()
+
+        // tariffList = new ArrayList<TariffDataValue>(
+        // tariffDataValueService.getTariffDataValues( organisationUnit,
+        // selecteddataElement ) );
+
+        tariffList = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues( orgUnitGroup,
+            selecteddataElement ) );
 
         List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PBF_TYPE ) );
-        
-        for( Lookup lookup : lookups )
+
+        for ( Lookup lookup : lookups )
         {
             Integer dataSetId = Integer.parseInt( lookup.getValue() );
-            
+
             DataSet dataSet = dataSetService.getDataSet( dataSetId );
-            
+
             dataSets.add( dataSet );
         }
         
+        dataSets.retainAll( orgUnitGroup.getDataSets() );
+        
+        /*
+        System.out.println( "Lookup DataSet Size : " + dataSets.size() );
+        
+        for( DataSet dataSet : dataSets )
+        {
+            System.out.println(" Lookup dataSet ---" + dataSet.getId() +" -- " + dataSet.getName() );
+        }
+        
+        System.out.println( " OrgUnit DataSet Size : " + orgUnitGroup.getDataSets().size() );
+        
+        for( DataSet dataSet : orgUnitGroup.getDataSets() )
+        {
+            System.out.println(" Group dataSet ---" + dataSet.getId() +" -- " + dataSet.getName() );
+        }
+        
+        System.out.println( "Final DataSet Size : " + dataSets.size() );
+        */
+        
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/ValidateTariffDataAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/ValidateTariffDataAction.java	2014-04-27 08:51:10 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/action/ValidateTariffDataAction.java	2014-04-30 05:26:01 +0000
@@ -56,21 +56,21 @@
     }
 
     private DataSetService dataSetService;
-    
+
     public void setDataSetService( DataSetService dataSetService )
     {
         this.dataSetService = dataSetService;
     }
-    
+
     @Autowired
     private OrganisationUnitGroupService orgUnitGroupService;
-    
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
 
     private String pbfType;
-    
+
     private String startDate;
 
     private String endDate;
@@ -80,13 +80,13 @@
     private String orgUnitUid;
 
     private Integer orgUnitGroupId;
-    
-    public void setOrgUnitGroupId(Integer orgUnitGroupId) 
+
+    public void setOrgUnitGroupId( Integer orgUnitGroupId )
     {
-		this.orgUnitGroupId = orgUnitGroupId;
-	}
+        this.orgUnitGroupId = orgUnitGroupId;
+    }
 
-	public void setDataElementId( String dataElementId )
+    public void setDataElementId( String dataElementId )
     {
         this.dataElementId = dataElementId;
     }
@@ -110,62 +110,108 @@
     {
         this.endDate = endDate;
     }
-    public String getPbfType() {
-		return pbfType;
-	}
-
-	public String getStartDate() {
-		return startDate;
-	}
-
-	public String getEndDate() {
-		return endDate;
-	}
-
-	public String getOrgUnitUid() {
-		return orgUnitUid;
-	}
-
-	private String message;
-    
-        public String getMessage() {
-		return message;
-	}
+
+    public String getPbfType()
+    {
+        return pbfType;
+    }
+
+    public String getStartDate()
+    {
+        return startDate;
+    }
+
+    public String getEndDate()
+    {
+        return endDate;
+    }
+
+    public String getOrgUnitUid()
+    {
+        return orgUnitUid;
+    }
+
+    private String message;
+
+    public String getMessage()
+    {
+        return message;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-	public String execute()
+    public String execute()
         throws Exception
-    {	
-		System.out.println(startDate);
+    {
+        System.out.println( startDate );
+        
         SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        
         Date sDate = dateFormat.parse( startDate );
         Date eDate = dateFormat.parse( endDate );
 
         DataElement dataElement = dataElementService.getDataElement( Integer.parseInt( dataElementId ) );
 
-        //OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
+        // OrganisationUnit organisationUnit =
+        // organisationUnitService.getOrganisationUnit( orgUnitUid );
 
         OrganisationUnitGroup orgUnitGroup = orgUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
-        
-        DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( pbfType ) );        
-        
-        List<TariffDataValue> tariffDataValues = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues(orgUnitGroup, dataElement));
-        //boolean status = false;
-        for(TariffDataValue tdv : tariffDataValues)
-        {        	
-        	if(tdv.getDataSet().getId() == dataSet.getId() && tdv.getStartDate().before(sDate) && tdv.getEndDate().after(eDate) )
-        	{
-        		message = "true";
-        		break;
-        	}
-        	else
-        	{
-        		message = "false";
-        	}
-        }
+
+        DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( pbfType ) );
+
+        List<TariffDataValue> tariffDataValues = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues( orgUnitGroup, dataElement ) );
+        // boolean status = false;
+        for ( TariffDataValue tdv : tariffDataValues )
+        {
+            if ( tdv.getDataSet().getId() == dataSet.getId() && tdv.getStartDate().before( sDate )
+                && tdv.getEndDate().after( eDate ) )
+            {
+                message = "true";
+                break;
+            }
+            else
+            {
+                message = "false";
+            }
+        }
+
+        TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( orgUnitGroup, dataElement, dataSet, sDate, eDate );
+        
+        if ( tariffDataValue == null )
+        {
+            String value = tariffDataValueService.getTariffDataValue( orgUnitGroup.getId(), dataSet.getId(), dataElement.getId(), startDate );
+            
+            if ( value == null  )
+            {
+                String enddateValue = tariffDataValueService.getTariffDataValue( orgUnitGroup.getId(), dataSet.getId(), dataElement.getId(), endDate );
+                
+                if ( enddateValue != null  )
+                {
+                    message = "Data Already Exists for the period " + enddateValue + " , Please Specify Another Date";
+
+                    return ERROR;
+                }
+            }
+            
+            else
+            {
+                message = "Data Already Exists for the period " + value + " , Please Specify Another Date";
+
+                return ERROR;
+            }
+        }
+        
+        else
+        {
+            message = "Data Already Exists, Please Specify Another Date";
+            
+            return ERROR;
+        }
+       
+        
+        message = "ok";
         
         return SUCCESS;
     }

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueService.java	2014-04-30 05:26:01 +0000
@@ -37,4 +37,6 @@
     Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataElement dataElement );
     
     Collection<TariffDataValue> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, DataElement dataElement );
+    
+    String getTariffDataValue( Integer orgunitgroupId, Integer dataSetId, Integer dataElementId, String date );
 }

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/TariffDataValueStore.java	2014-04-30 05:26:01 +0000
@@ -36,6 +36,8 @@
     
     Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataElement dataElement );
     
-    Collection<TariffDataValue> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, DataElement dataElement );    
+    Collection<TariffDataValue> getTariffDataValues( OrganisationUnitGroup orgUnitGroup, DataElement dataElement );
+    
+    String getTariffDataValue( Integer orgunitgroupId, Integer dataSetId, Integer dataElementId, String date );
     
 }

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java	2014-04-28 11:42:33 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java	2014-04-30 05:26:01 +0000
@@ -9,6 +9,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.velocity.tools.generic.NumberTool;
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -208,6 +209,13 @@
         return qValOptCombo;
     }
 
+    private NumberTool nullTool;
+    
+    public NumberTool getNullTool()
+    {
+        return nullTool;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -313,6 +321,18 @@
                 pbfDataValueService.addPBFDataValue( pbfDataValue );
                 pbfDataValueMap.put( de, pbfDataValue );
             }
+            else
+            {
+                PBFDataValue pbfDataValue = new PBFDataValue();
+
+                pbfDataValue.setDataSet( dataSet );
+                pbfDataValue.setDataElement( de );
+                pbfDataValue.setPeriod( period );
+                pbfDataValue.setOrganisationUnit( organisationUnit );
+                pbfDataValue.setTariffAmount( null );
+
+                pbfDataValueMap.put( de, pbfDataValue );
+            }
         }
 
         /*

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultTariffDataValueService.java	2014-04-30 05:26:01 +0000
@@ -102,4 +102,10 @@
         return tariffDataValueStore.getTariffDataValues( orgUnitGroup, dataSet, period );
     }
 
+    public String getTariffDataValue( Integer orgunitgroupId, Integer dataSetId, Integer dataElementId, String date )
+    {
+        return tariffDataValueStore.getTariffDataValue( orgunitgroupId, dataSetId, dataElementId, date );
+    }
+    
+    
 }

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/HibernateTariffDataValueStore.java	2014-04-30 05:26:01 +0000
@@ -207,12 +207,14 @@
                                 " startdate <= '" + curPeriod + "' AND "+ 
                                 " enddate >= '" + curPeriod +"'";
             
+            //System.out.println("Query: " + query );
             SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
             while ( rs.next() )
             {
                 Integer dataElementId = rs.getInt( 1 );
                 Double value = rs.getDouble( 2 );
                 tariffDataValueMap.put( dataElementId, value );
+                //System.out.println( dataElementId + " : " + value );
             }
         }
         catch( Exception e )
@@ -222,4 +224,48 @@
         
         return tariffDataValueMap;
     }
+    
+    
+    public String getTariffDataValue( Integer orgunitgroupId, Integer dataSetId, Integer dataElementId, String date )
+    {
+        String value = null;
+        
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        
+        try
+        {
+            String query = "select startdate, enddate from tariffdatavalue " + 
+                " WHERE " +
+                " orgunitgroupid = " + orgunitgroupId + " AND " +
+                " datasetid = " + dataSetId + " AND " +
+                " dataelementid = " + dataElementId + " AND " +
+                " startdate <= '" + date + "' AND "+ 
+                " enddate >= '" + date +"'";
+            
+            //System.out.println( " query is --: " + query );
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+
+            if ( rs.next() )
+            {
+                Date sDate = rs.getDate( 1 );
+                
+                Date eDate = rs.getDate( 2 );
+                
+                if ( sDate != null && eDate != null  )
+                {
+                    value  = simpleDateFormat.format( sDate ) + " To " + simpleDateFormat.format( eDate ) ;
+                }
+            }
+
+        }
+        catch ( Exception e )
+        {
+            System.out.println("In getTariffDataValues Exception :"+ e.getMessage() );
+        }
+        
+        return value; 
+    }
+    
+   
 }

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml	2014-04-28 11:42:33 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml	2014-04-30 05:26:01 +0000
@@ -38,6 +38,7 @@
 		
 		<action name="validateTariffData" class="org.hisp.dhis.rbf.action.ValidateTariffDataAction">
 			<result name="success" type="velocity-json">/dhis-web-maintenance-rbf/tariffStatus.vm</result>
+			<result name="error" type="velocity-json">/dhis-web-maintenance-rbf/responseTariffStatusInput.vm</result>
 			<param name="onExceptionReturn">plainTextError</param>								
 		</action>
 		
@@ -101,6 +102,19 @@
 		<param name="page">/dhis-web-maintenance-rbf/loadDataEntryForm.vm</param>
 	</action>	
 	
+	<!-- for PBF DataEntry Role -->	 
+	<action name="quanitityValidated" class="org.hisp.dhis.rbf.action.NoAction">
+		<result name="success" type="velocity">/content.vm</result>
+		<param name="page">/dhis-web-maintenance-rbf/loadDataEntryForm.vm</param>		
+	 	<param name="requiredAuthorities">F_QUANTITY_VALIDATED</param>		
+	</action>	
+	
+	
+	
+	
+	
+	
+	
 	<!-- Save Value -->
 	<action name="saveValue"
 		class="org.hisp.dhis.rbf.dataentry.SaveValueAction">

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataElementsforTariff.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataElementsforTariff.vm	2014-04-28 11:42:33 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataElementsforTariff.vm	2014-04-30 05:26:01 +0000
@@ -88,6 +88,17 @@
     {
         document.getElementById('simpleCombo').style.display = 'block';
         document.getElementById('loadTariffDetails').style.display = 'block';
+		
+		/*
+		$('#simpleCombo').load("dataElementTariffManagement.action",
+		{
+			orgUnitGroupId : $( "#orgUnitGroupId" ).val()
+        }
+            				, function( ){  
+							
+        				});  	
+		
+		*/
         if( $('#dataElementName').val() != '' )
         {
             getTariffData();
@@ -169,8 +180,8 @@
 <input type="hidden" name="dataElementName" id="dataElementName" value="" />
 <table width="60%">
 	<tr>
-		<td >Orgainsation Unit Group: &nbsp;&nbsp;&nbsp; 
-		    <select id="orgUnitGroupId" name="orgUnitGroupId" onchange="javascript:orgUnitGroupChange()">
+		<td>Orgainsation Unit Group: &nbsp;&nbsp;&nbsp; 
+		    <select id="orgUnitGroupId" name="orgUnitGroupId" onchange="javascript:orgUnitGroupChange()" style="width:52%">
                 <option value="-1">[Please select]</option>		    	
                 #foreach( $orgUnitGroup in $orgUnitGroups )
                 	<option value="$!orgUnitGroup.id">$!orgUnitGroup.name</option>

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm	2014-04-26 11:27:06 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm	2014-04-30 05:26:01 +0000
@@ -28,9 +28,13 @@
 	<tr bgcolor="#CBDDEB">
 		<th style="width:35%;">$i18n.getString( "dataelement" )</th>
 		<th style="text-align: center;width:15%;">$i18n.getString( "qty_reported" )</th>
-		<th style="text-align: center;width:15%;">$i18n.getString( "qty_validated" )</th>
-		<th style="text-align: center;width:15%;">$i18n.getString( "tariff_amount" )</th>
-		<th style="text-align: center;width:15%;">$i18n.getString( "total" )</th>
+		
+		#if( $auth.hasAccess( "dhis-web-maintenance-rbf", "quanitityValidated") )
+			<th style="text-align: center;width:15%;">$i18n.getString( "qty_validated" )</th>
+			<th style="text-align: center;width:15%;">$i18n.getString( "tariff_amount" )</th>
+			<th style="text-align: center;width:15%;">$i18n.getString( "total" )</th>
+		#end
+			
 	</tr>
 	<script>
 		var allTotal = 0.0;
@@ -45,51 +49,53 @@
 		<tr #if( $mark1 ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8" #end>
 			<td><label>$dataElement.getFormNameFallback()</label></td>
 			#set( $count = 0)
-			#set( $pbfDataValue = $!pbfDataValueMap.get( $dataElement ) )
-			<td>
-				<input onblur="savePBFDataValue('$dataElement.id', 1 )" type="text" name="pbfdv_qty_reported_$dataElement.id" id="pbfdv_qty_reported_$dataElement.id" 
-						value="$!pbfDataValue.quantityReported" 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>
+				#set( $pbfDataValue = $!pbfDataValueMap.get( $dataElement ) )
+    			<td>
+    				<input onblur="savePBFDataValue('$dataElement.id', 1 )" type="text" name="pbfdv_qty_reported_$dataElement.id" id="pbfdv_qty_reported_$dataElement.id" 
+    						value="$!pbfDataValue.quantityReported" 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>
+    			#if( $auth.hasAccess( "dhis-web-maintenance-rbf", "quanitityValidated") )
+        			<td>
+        				<input onblur="savePBFDataValue('$dataElement.id', 2 )" onkeyup="calTariffVal('$dataElement.id')" type="text" name="pbfdv_qty_validated_$dataElement.id" id="pbfdv_qty_validated_$dataElement.id" 
+        						value="$!pbfDataValue.quantityValidated" 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 class="quantity$count"  />
+        				</td>
+        				<script>
+        					function changeInt()
+        					{
+        						var tariff = 0.0;
+        					if('$!pbfDataValue.tariffAmount' != '' )
+        					{
+        						tariff = parseFloat($pbfDataValue.tariffAmount);
+        						$('#pbfdv_tariff_amt_'+$dataElement.id).val(tariff);
+        					}					
+        											
+        					}
+        					changeInt();
+        				</script>
+        			<td>
+        				<input type="text" name="pbfdv_tariff_amt_$dataElement.id" id="pbfdv_tariff_amt_$dataElement.id" 
+        						value="$!pbfDataValue.tariffAmount" 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 class="tariff$count" readonly/>
+        			</td>
+        			<td >
+        				<input type="text" id="total_$dataElement.id" style="text-align: center;" readonly/>
+                    </td>
+				#end			
 			
-			<td>
-				<input onblur="savePBFDataValue('$dataElement.id', 2 )" onkeyup="calTariffVal('$dataElement.id')" type="text" name="pbfdv_qty_validated_$dataElement.id" id="pbfdv_qty_validated_$dataElement.id" 
-						value="$!pbfDataValue.quantityValidated" 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 class="quantity$count"  />
-				</td>
-				<script>
-					function changeInt()
-					{
-						var tariff = 0.0;
-					if('$!pbfDataValue.tariffAmount' != '' )
-					{
-						tariff = parseFloat($pbfDataValue.tariffAmount);
-						$('#pbfdv_tariff_amt_'+$dataElement.id).val(tariff);
-					}					
-											
-					}
-					changeInt();
-				</script>
-			<td>
-				<input type="text" name="pbfdv_tariff_amt_$dataElement.id" id="pbfdv_tariff_amt_$dataElement.id" 
-						value="$!pbfDataValue.tariffAmount" 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 class="tariff$count" readonly/>
-			</td>
-			<td >
-				<input type="text" id="total_$dataElement.id" style="text-align: center;" readonly/>
-            </td>
 			<script >				
                 function calVal( ) {
 					var total = 0.0;
@@ -129,14 +135,16 @@
                   calVal();
                 });
             </script>	
-			
-			#end			
+			#end
+					
 			
 			#set( $count = $count + 1)
 		</tr>
 		#set( $tabIndex = $tabIndex + 1 )
 		#set( $mark = !$mark)	
-	#end
+#end
+
+	#if( $auth.hasAccess( "dhis-web-maintenance-rbf", "quanitityValidated") )
 		<tr>
 			<td >&nbsp;</td>
 			<td >&nbsp;</td>
@@ -146,6 +154,7 @@
 				<input type="text" id="all-total" style="text-align: center;" readonly/>
             </td>
 		</tr>
+	#end
 		<script>
 			function calTariffVal( dataElementId ) {
 					var total = 0.0;

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadTariffData.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadTariffData.vm	2014-04-27 08:51:10 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadTariffData.vm	2014-04-30 05:26:01 +0000
@@ -197,13 +197,16 @@
 		return bValue;
 	}	
 		function handleSuccess( json )
-	    {		
+	    {	
+			//alert( json.message );
+		
 			if(json.message == "true")	
 			{
 				alert("Tariff value of this pbf type exist between this range");
 				bValue = true;				
 			}
-			else
+			
+			else if(json.message == "ok")
 			{
 				 var dataValue = {
         		        			'pbfType' : $("#pbfType").val(),
@@ -223,10 +226,18 @@
                                 error: addTariffError
                             } );
 			}
+			
+			else
+			{
+				alert( json.message );
+				bValue = true;
+			}
+	
 	    }
-	    function handleError( json )
+	    
+		function handleError( json )
 	    {	
-			
+			alert( "Inside Error " + json.message );
 	    }
 		
 		 function addTariffSuccess( json )

=== added file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/responseTariffStatusInput.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/responseTariffStatusInput.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/responseTariffStatusInput.vm	2014-04-30 05:26:01 +0000
@@ -0,0 +1,4 @@
+{
+"message":"${message}"
+
+}
\ No newline at end of file

=== modified file 'local/in/pom.xml'
--- local/in/pom.xml	2014-04-26 11:27:06 +0000
+++ local/in/pom.xml	2014-04-30 05:26:01 +0000
@@ -15,8 +15,8 @@
     <module>dhis-in-services</module>
 	
 	<module>dhis-web-maintenance-in</module>
-	<module>dhis-web-maintenance-pbf</module>
-	
+	<!--<module>dhis-web-maintenance-pbf</module>-->
+	<module>dhis-web-maintenance-rbf</module>
 	<!--<module>dhis-web-maintenance-ccem</module>	
 	<module>dhis-web-coldchain</module>
     <module>dhis-web-dataentry-ccem</module> -->