← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13604: PBF Modifications

 

------------------------------------------------------------
revno: 13604
committer: Samta Bajpayee<samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-07 10:10:48 +0000
message:
  PBF Modifications
added:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/SaveValueAction.java
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/TransformGrid.js
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pagingmemory.js
modified:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadBankDetailsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml
  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/getBankDetails.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/loadBankData.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataElementsforTariff.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/loadTariffData.vm
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/status.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadBankDetailsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadBankDetailsAction.java	2013-12-27 05:24:32 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadBankDetailsAction.java	2014-01-07 10:10:48 +0000
@@ -68,10 +68,6 @@
         return dataSets;
     }    
 
-    public void setDataSets(List<DataSet> dataSets) {
-		this.dataSets = dataSets;
-	}
-
 	private List<String> banks = new ArrayList<String>();
 
     public List<String> getBanks()
@@ -96,30 +92,19 @@
         bankDetailsList.addAll( bankDetailsService.getBankDetails( organisationUnit ) );
         dataSets.clear();
         List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PBF_TYPE ) );
+        List<DataSet> bankDetailDataSets = new ArrayList<DataSet>();
         for( Lookup lookup : lookups )
         {
             Integer dataSetId = Integer.parseInt( lookup.getValue() );
             
             DataSet dataSet = dataSetService.getDataSet( dataSetId );
-            if(bankDetailsList.size() > 0)
-            {
-	            for(BankDetails bd : bankDetailsList)
-	            {
-	            	if(bd.getDataSet().getId() == dataSet.getId() && !dataSets.contains(bd.getDataSet()))
-	            	{}
-	            	else
-	            	{
-	            		dataSets.add(dataSet);
-	            		break;
-	            	}
-	            }
-            }
-            else
-            {
-            	dataSets.add( dataSet );
-            }
-            
-        }
+            dataSets.add(dataSet);
+        }
+        for(BankDetails bd : bankDetailsList)
+        {
+        	bankDetailDataSets.add( bd.getDataSet() );
+        }
+        //dataSets.removeAll(bankDetailDataSets);
         
         lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.BANK ) );
         for( Lookup lookup : lookups )
@@ -128,7 +113,12 @@
         }
         
         Collections.sort(dataSets);
+        /*for(DataSet ds : dataSets)
+        {
+        	System.out.println(ds.getName());
+        }
         System.out.println(dataSets.size());
+        */
         return SUCCESS;
     }
 }

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/SaveValueAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/SaveValueAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/dataentry/SaveValueAction.java	2014-01-07 10:10:48 +0000
@@ -0,0 +1,286 @@
+package org.hisp.dhis.pbf.dataentry;
+
+/*
+ * Copyright (c) 2004-2012, 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 com.opensymphony.xwork2.Action;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+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 org.hisp.dhis.system.util.ValidationUtils;
+import org.hisp.dhis.user.CurrentUserService;
+
+import java.util.Date;
+
+/**
+ * @author Abyot Asalefew
+ */
+public class SaveValueAction
+    implements Action
+{
+    private static final Log log = LogFactory.getLog( SaveValueAction.class );
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private DataValueService dataValueService;
+
+    public void setDataValueService( DataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+
+    private DataElementCategoryService categoryService;
+
+    public void setCategoryService( DataElementCategoryService categoryService )
+    {
+        this.categoryService = categoryService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String value;
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+    private String dataElementId;
+
+    public void setDataElementId( String dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    private String organisationUnitId;
+
+    public void setOrganisationUnitId( String organisationUnitId )
+    {
+        this.organisationUnitId = organisationUnitId;
+    }
+
+    private String optionComboId;
+
+    public void setOptionComboId( String optionComboId )
+    {
+        this.optionComboId = optionComboId;
+    }
+
+    private String periodId;
+
+    public void setPeriodId( String periodId )
+    {
+        this.periodId = periodId;
+    }
+    
+    private String periodIso;
+    
+    public void setPeriodIso(String periodIso) {
+		this.periodIso = periodIso;
+	}
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+	private int statusCode = 0;
+
+    public int getStatusCode()
+    {
+        return statusCode;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+    	Period period = PeriodType.getPeriodFromIsoString(periodIso);
+       // Period period = PeriodType.createPeriodExternalId( periodId );
+
+        if ( period == null )
+        {
+            return logError( "Illegal period identifier: " + periodIso );
+        }
+        
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+        if ( organisationUnit == null )
+        {
+            return logError( "Invalid organisation unit identifier: " + organisationUnitId );
+        }
+        
+        DataElement dataElement = dataElementService.getDataElement( Integer.parseInt(dataElementId) );
+
+        if ( dataElement == null )
+        {
+            return logError( "Invalid data element identifier: " + dataElementId );
+        }
+        
+        DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( Integer.parseInt(optionComboId) );
+
+        if ( optionCombo == null )
+        {
+            return logError( "Invalid category option combo identifier: " + optionComboId );
+        }
+        
+        String storedBy = currentUserService.getCurrentUsername();
+
+        Date now = new Date();
+
+        if ( storedBy == null )
+        {
+            storedBy = "[unknown]";
+        }
+
+        if ( value != null && value.trim().length() == 0 )
+        {
+            value = null;
+        }
+
+        if ( value != null )
+        {
+            value = value.trim();
+        }
+
+        // ---------------------------------------------------------------------
+        // Validate value according to type from data element
+        // ---------------------------------------------------------------------
+
+        String valid = ValidationUtils.dataValueIsValid( value, dataElement );
+        
+        if ( valid != null )
+        {
+            return logError( valid, 3 );
+        }
+
+        // ---------------------------------------------------------------------
+        // Check locked status
+        // ---------------------------------------------------------------------
+
+        if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) )
+        {
+            return logError( "Entry locked for combination: " + dataElement + ", " + period + ", " + organisationUnit, 2 );
+        }
+
+        // ---------------------------------------------------------------------
+        // Update data
+        // ---------------------------------------------------------------------
+
+        DataValue dataValue = dataValueService.getDataValue(  dataElement, period,organisationUnit,optionCombo );
+
+        if ( dataValue == null )
+        {
+            if ( value != null )
+            {
+                dataValue = new DataValue( );
+                dataValue.setDataElement(dataElement);
+                dataValue.setPeriod(period);
+                dataValue.setSource(organisationUnit);
+                dataValue.setValue(value);
+                dataValue.setStoredBy(storedBy);
+                dataValue.setTimestamp(now);
+                dataValue.setCategoryOptionCombo(optionCombo);
+                dataValueService.addDataValue( dataValue );
+                
+                System.out.println("Value Added");
+            }
+        }
+        else
+        {
+            dataValue.setValue( value );
+            dataValue.setTimestamp( now );
+            dataValue.setStoredBy( storedBy );
+
+            dataValueService.updateDataValue( dataValue );
+            System.out.println("Value Updated");
+        }
+
+        return SUCCESS;
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private String logError( String message )
+    {
+        return logError( message, 1 );
+    }
+
+    private String logError( String message, int statusCode )
+    {
+        log.info( message );
+
+        this.statusCode = statusCode;
+
+        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-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2014-01-07 10:10:48 +0000
@@ -136,7 +136,15 @@
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService"/>  
 	 </bean>    
     
-    
-    
+    <!-- Save Value -->
+    
+    <bean id="org.hisp.dhis.pbf.dataentry.SaveValueAction"  class="org.hisp.dhis.pbf.dataentry.SaveValueAction" scope="prototype">
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />			
+	</bean>
     
 </beans>
\ 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-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml	2014-01-07 10:10:48 +0000
@@ -19,12 +19,12 @@
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-pbf/loadDataElementsforTariff.vm</param>
 			<param name="menu">/dhis-web-maintenance-pbf/tariffMenu.vm</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/javascripts/ext/ext-all.js,javascript/dataElement_combo.js</param>
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/javascripts/ext/ext-all.js,javascript/TransformGrid.js,javascript/dataElement_combo.js</param>
 			<param name="stylesheets">../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css</param>
 		</action>
 		<action name="loadTariffDetails" class="org.hisp.dhis.pbf.action.LoadTariffDetailsAction">
 			<result name="success" type="velocity">/content.vm</result>
-			<param name="page">/dhis-web-maintenance-pbf/loadTariffData.vm</param>			
+			<param name="page">/dhis-web-maintenance-pbf/loadTariffData.vm</param>
 		</action>
 		 <action name="addTariffData" class="org.hisp.dhis.pbf.action.AddTariffDataAction">
 			<result name="success" type="velocity-json">/dhis-web-maintenance-pbf/status.vm</result>
@@ -46,7 +46,8 @@
             <result name="success" type="velocity">/main.vm</result>
             <param name="page">/dhis-web-maintenance-pbf/loadBankData.vm</param>
             <param name="menu">/dhis-web-maintenance-pbf/tariffMenu.vm</param>
-            <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js</param>
+            <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/javascripts/ext/ext-all.js,javascript/TransformGrid.js</param>
+        	<param name="stylesheets">../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css</param>
         </action>
         
         <action name="loadbankDetails" class="org.hisp.dhis.pbf.action.LoadBankDetailsAction">
@@ -75,7 +76,7 @@
       <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>
+      <param name="stylesheets">css/dataentry.css</param>
     </action>	
 	
     <!-- Get OrganisationUnit Unit name -->
@@ -100,6 +101,14 @@
 		<param name="page">/dhis-web-maintenance-pbf/loadDataEntryForm.vm</param>
 	</action>	
 	
+	<!-- Save Value -->
+	<action name="saveValue"
+		class="org.hisp.dhis.pbf.dataentry.SaveValueAction">
+		<result name="success" type="velocity-json">
+			/dhis-web-maintenance-pbf/status.vm</result>
+		<param name="onExceptionReturn">plainTextError</param>					
+	</action>
+	
 	</package>
 	
 	

=== modified 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	2013-12-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/dataEntrySelection.vm	2014-01-07 10:10:48 +0000
@@ -22,7 +22,7 @@
 
 <form id="pbfDataEntryForm" name="pbfDataEntryForm" method="post" >	
 <div>
-	<input type="hidden" id='selectedOrgunitID' name = 'selectedOrgunitID' value="$!organisationUnit.id" />
+	<input type="hidden" id='selectedOrgunitID' name = 'selectedOrgunitID' value="$!organisationUnit.uid" />
 	<input type="hidden" id='selectedOrgunitName' name = 'selectedOrgunitName' value="$!organisationUnit.name" />
 	
 </div>
@@ -56,6 +56,7 @@
 			</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>		
 
@@ -65,12 +66,13 @@
 
 #parse( "/dhis-web-commons/loader/loader.vm" )
 <div id='dataEntryFormDiv'></div> <!-- DataEntry Form -->  	
+<!--
 
 <p>
+	<input type="submit"  id="saveButton" name="saveButton" value="$i18n.getString( 'save' )" disabled="disabled" style="width:100px"/>&nbsp;&nbsp;
 	<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>
 

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getBankDetails.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getBankDetails.vm	2013-12-27 05:24:32 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/getBankDetails.vm	2014-01-07 10:10:48 +0000
@@ -5,12 +5,39 @@
 		font-size: 1.5em;
 	}
 </style>
+<script type="text/javascript" >
+	
+	Ext.Loader.setConfig({
+		enabled: true
+	});
+	Ext.Loader.setPath('Ext.ux.grid', 'javascript');
+	Ext.require([
+		'Ext.data.*',
+		'Ext.grid.*',
+		'Ext.toolbar.Paging',
+		'Ext.ux.grid.TransformGrid'
+	]);
+	
+</script>
 <script >
 $(function() {
-$("#bankDetails").tablesorter(); 
+
+Ext.QuickTips.init();
+			
+			var grid = Ext.create('Ext.ux.grid.TransformGrid', "bankDetails", {				
+			sortableColumns: true,
+            enableColumnMove: true,
+            enableColumnResize: true,
+            sortOnLoad: true,
+			minWidth: 300,
+        	minHeight: 360,			
+            sorters: {direction: 'ASC'}
+			});
+			
+			grid.render();
+
 $("#openAddBankDetail").button()
 			.click(function() {	
-			
 			validateAddBank();
 			$( "#addBankDetail" ).dialog('option', 'title', 'Add Bank Detail');
            	$('#dataSetId option[value=-1]').attr('selected','selected');
@@ -150,7 +177,10 @@
         }
 	}
 </script>
-
+<div style="width:100%">
+<input type="button" value="Add New Bank Detail" style="float:right;" id="openAddBankDetail" />
+</div>
+<br/><br/>
 <table style="width:100%" id="bankDetails">
 	<thead >
 		<tr >
@@ -201,7 +231,7 @@
 				<select id="dataSetId" style="width:100%;" onchange="validateAddBank()">
 					<option value="-1">Select PBF Type</option>
 					#foreach( $dataSet in $dataSets )
-						<option value="$dataSet.id">$dataSet.name</option>
+						<option value="$!dataSet.id">$!dataSet.name</option>
 					#end
                 </select>
 			</td>

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/TransformGrid.js'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/TransformGrid.js	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/TransformGrid.js	2014-01-07 10:10:48 +0000
@@ -0,0 +1,99 @@
+/**
+ * @class Ext.ux.grid.TransformGrid
+ * @extends Ext.grid.Panel
+ * A Grid which creates itself from an existing HTML table element.
+ * @history
+ * 2007-03-01 Original version by Nige "Animal" White
+ * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
+ * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
+ * The table MUST have some type of size defined for the grid to fill. The container will be
+ * automatically set to position relative if it isn't already.
+ * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
+ * properties: fields and columns which allow for customizing data fields and columns for this grid.
+ */
+Ext.define('Ext.ux.grid.TransformGrid', {
+    extend: 'Ext.grid.Panel',    
+    constructor: function(table, config) {
+        config = Ext.apply({}, config);
+        table = this.table = Ext.get(table);
+    
+        var configFields = config.fields || [], 
+            configColumns = config.columns || [],
+            fields = [],
+            cols = [],
+            ct = table.insertSibling(),
+            headers = table.query("thead th"),
+            i = 0,
+            len = headers.length,
+            data = table.dom,
+            width,
+            height,
+            store,
+            col,
+            text,
+            name;
+    
+        for (; i < len; ++i) {
+            col = headers[i];
+        
+            text = col.innerHTML;
+            name = 'tcol-' + i;
+        
+            fields.push(Ext.applyIf(configFields[i] || {}, {
+                name: name,
+                mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
+            }));
+        
+            cols.push(Ext.applyIf(configColumns[i] || {}, {
+                text: text,
+                dataIndex: name,
+                width: col.offsetWidth,
+                tooltip: col.title,
+                sortable: true
+            }));
+        }
+        
+        if (config.width) {
+            width = config.width;   
+        } else {
+            width = table.getWidth();
+        }
+        
+        if (config.height) {
+            height = config.height;
+        }
+    
+        if (config.remove !== false) {
+            // Don't use table.remove() as that destroys the row/cell data in the table in
+            // IE6-7 so it cannot be read by the data reader.
+            data.parentNode.removeChild(data);
+        }
+        
+    
+        Ext.applyIf(config, {
+            store: {
+                data: data,
+                fields: fields,
+                proxy: {
+                    type: 'memory',
+                    reader: {
+                        record: 'tbody tr',
+                        type: 'xml'
+                    }
+                }    
+            },
+            columns: cols,
+            width: width,
+            autoHeight: height ? false : true,
+            height: height,
+            el: ct
+        });
+        this.callParent([config]);    
+    },
+
+    onDestroy: function() {
+        this.callParent();
+        this.table.remove();
+        delete this.table;
+    }
+});
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pagingmemory.js'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pagingmemory.js	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pagingmemory.js	2014-01-07 10:10:48 +0000
@@ -0,0 +1,165 @@
+/**
+ * Paging memory proxy, allows using in-memory dataset with paging grid.
+ * Similar to Ext.ux.data.PagingMemoryProxy except that it's optimized for large
+ * datasets.
+ *  
+ * Version 0.9.
+ *  
+ * Copyright (c) 2012 Alexander Tokarev.
+ *
+ * This code is licensed under the terms of the Open Source LGPL 3.0 license.
+ * Commercial use is permitted to the extent that the code/component(s) do NOT
+ * become part of another Open Source or Commercially licensed development library
+ * or toolkit without explicit permission.
+ * 
+ * License details: http://www.gnu.org/licenses/lgpl.html
+ */
+
+Ext.define('Ext.ux.data.proxy.PagingMemory', {
+    extend: 'Ext.data.proxy.Memory',
+    alias:  'proxy.memorypaging',
+    
+    alternateClassName: 'Ext.data.proxy.PagingMemory',
+    
+    requires: [
+        'Ext.data.ResultSet'
+    ],
+
+    /**
+     * @cfg {Object} data
+     * Optional data to pass to configured Reader.
+     */
+
+    constructor: function(config) {
+        var me = this;
+        
+        me.callParent(arguments);
+
+        //ensures that the reader has been instantiated properly
+        me.setReader(me.reader);
+        
+        /*
+         * Since we're operating on in-memory dataset, it's safe to assume
+         * that the data is immutable. It's awfully inefficient to pull
+         * the whole dataset through Reader *each time* a new page is
+         * requested (that's what Ext.ux.data.PagingMemoryProxy does).
+         * So we do that only once. If dataset is refreshing, it goes
+         * through Reader again, of course.
+         */
+        me.setData(config.data);
+    },
+    
+    read: function(operation, callback, scope) {
+        var me = this,
+            reader = me.reader,
+            result, sorters, filters, filterFn, sorterFn, records, start, limit;
+        
+        result = me.getData();
+        scope  = scope || me;
+        
+        /*
+         * Filtering and sorting is necessary to be done
+         * on the whole dataset, simulating remote sort.
+         */
+        filters = operation.filters;
+        
+        if ( filters.length > 0 ) {
+            
+            /*
+             * Here we have an array of Ext.util.Filter objects to do filtering with,
+             * so we construct a function that combines all filters by ANDing them together
+             */
+            records = [];
+            
+            filterFn = function(record) {
+                var doesMatch = true;
+                
+                for ( var i = 0, l = filters.length; i < l; i++ ) {
+                    var fn    = filters[i].filterFn,
+                        scope = filters[i].scope;
+                    
+                    doesMatch = doesMatch && fn.call(scope, record);
+                };
+                
+                if ( doesMatch ) {
+                    records.push(record);
+                };
+            };
+            
+            for ( var i = 0, l = result.records.length; i < l; i++ ) {
+                filterFn( result.records[i] );
+            };
+            
+            result.records      = records;
+            result.totalRecords = result.total = records.length;
+        };
+        
+        // Sorting now
+        sorters = operation.sorters;
+        
+        if ( sorters.length > 0 ) {
+            
+            // Same as with filters, one function to sort them all
+            sorterFn = function(a, b) {
+                var result, length;
+                
+                result = sorters[0].sort.call(sorters[0], a, b);
+                
+                // If there is more than one sorter, OR them together
+                for ( var i = 1, l = sorters.length; i < l; i++ ) {
+                    result = result || sorters[i].sort.call(sorters[i], a, b);
+                };
+                
+                return result;
+            };
+            
+            result.records.sort(sorterFn);
+        };
+        
+        // Time to do paging
+        start = operation.start;
+        limit = operation.limit;
+        
+        if ( start !== undefined && limit !== undefined ) {
+            result.records = result.records.slice(start, start + limit);
+            result.count   = result.records.length;
+        };
+        
+        Ext.apply(operation, {
+            resultSet: result
+        });
+        
+        operation.setCompleted();
+        operation.setSuccessful();
+        
+        Ext.callback(callback, scope, [operation], 10);
+    },
+    
+    // @private Return shallow copy of preprocessed dataset
+    getData: function() {
+        var me = this,
+            data = me.data,
+            records, result;
+        
+        records = data.records ? data.records.slice(0) : [];
+        
+        result = new Ext.data.ResultSet({
+            count:        data.count,
+            message:      data.message,
+            records:      records,
+            sucess:       data.success,
+            total:        data.total,
+            totalRecords: data.totalRecords
+        });
+        
+        return result;
+    },
+    
+    setData: function(data) {
+        var me = this;
+        
+        if ( data && Ext.isArray(data) && data.length > 0 ) {
+            me.data = me.reader.read(data);
+        };
+    }
+});

=== modified 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	2013-12-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/javascript/pbfDataEntry.js	2014-01-07 10:10:48 +0000
@@ -1,9 +1,17 @@
 
+	var COLOR_GREEN = '#b9ffb9';
+	var COLOR_YELLOW = '#fffe8c';
+	var COLOR_RED = '#ff8a8a';
+	var COLOR_ORANGE = '#ff6600';
+	var COLOR_WHITE = '#ffffff';
+	var COLOR_GREY = '#cccccc';
+	var LocaleColor = 'black';
+	
 function orgUnitHasBeenSelected( orgUnitIds )
 {    
 	$( '#dataEntryFormDiv' ).html( '' );
 	
-	document.getElementById('selectedOrgunitID').value = orgUnitIds;
+	//document.getElementById('selectedOrgunitID').value = orgUnitIds;
 	
 	//alert( orgUnitIds );
 	
@@ -18,9 +26,11 @@
 	                
 	            if( type == 'success' )
 	            {
+	            	window.location.href = "pbfDataEntry.action";
 					enable('dataSetId');
+					setFieldValue('selectedOrgunitID',orgUnitIds[0])
 	                setFieldValue('orgUnitName', json.message );
-	                setFieldValue('selectedOrgunitName', json.message );
+	                setFieldValue('selectedOrgunitName', json.message );	                
 	            }
 	            else if( type == 'input' )
 	            {
@@ -42,14 +52,7 @@
 function loadDataEntryForm()
 {
 	var orgUnitId = $( '#selectedOrgunitID' ).val();
-	
-	
-	
-	
 	var dataSetId = $( '#dataSetId' ).val();
-	
-	
-	
 	$( '#dataEntryFormDiv' ).html('');
 	
 	$( '#saveButton' ).removeAttr( 'disabled' );
@@ -83,28 +86,64 @@
 
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+function saveValue(dataElementId,optionComboId)
+{
+	var period = document.getElementById("selectedPeriodId").value;
+	var valueId = "dataelement"+dataElementId+":"+optionComboId;
+	
+	var fieldId = "#"+valueId;
+	var defaultValue = document.getElementById(valueId).defaultValue;
+	var value = document.getElementById(valueId).value;
+	
+	if(defaultValue != value)
+	{
+	var dataValue = {
+        'dataElementId' : dataElementId,
+        'optionComboId' : optionComboId,
+        'organisationUnitId' : $("#selectedOrgunitID").val(),
+        'periodIso' : period,
+        'value' : value
+    };
+    jQuery.ajax( {
+            url: 'saveValue.action',
+            data: dataValue,
+            dataType: 'json',
+            success: handleSuccess,
+            error: handleError
+        } );
+	}
+	
+	function handleSuccess( json )
+	{
+	    var code = json.c;
+
+	    alert(code)
+	    if ( code == '0' || code == 0) // Value successfully saved on server
+	    {
+	    	 markValue( fieldId, COLOR_GREEN );
+	    }
+	    else if ( code == 2 )
+	    {
+	        markValue( fieldId, COLOR_RED );
+	        window.alert( i18n_saving_value_failed_dataset_is_locked );
+	    }
+	    else // Server error during save
+	    {
+	        markValue( fieldId, COLOR_RED );
+	        window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+	    }            
+	}
+
+	function handleError( jqXHR, textStatus, errorThrown )
+	{       
+	    markValue( fieldId, COLOR_GREEN );
+	}
+
+	function markValue( fieldId, color )
+	{
+	    document.getElementById(valueId).style.backgroundColor = color;	   
+	}
+}
 
 
 // load periods

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadBankData.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadBankData.vm	2013-12-27 05:24:32 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadBankData.vm	2014-01-07 10:10:48 +0000
@@ -1,14 +1,23 @@
+<style>
+		.x-column-header-inner .x-column-header-text {
+		white-space: normal;
+		z-index:0;
+	}
+
+	.x-column-header-inner {
+		line-height: normal;
+	}	
+	.x-grid-row .x-grid-cell-inner {
+		white-space: normal;		
+	}
+    .x-grid-row-over .x-grid-cell-inner {
+        font-weight: bold;
+		white-space: normal;		
+    }	
+	
+</style>
 <script >
-$(function() {
-	if($dataSets.size() <= 0)
-        {
-        	$("#openAddBankDetail").removeAttr( "disabled" );
-        }
-        else
-        {
-			$("#openAddBankDetail").attr( "disabled", true ).addClass("ui-state-disabled");       	
-        }
-});
+
 function organisationUnitSelected( orgUnits, orgUnitNames )
 {
 		setFieldValue("orgUnit", orgUnitNames[0]);
@@ -32,8 +41,7 @@
 <h3>Bank Detail Management</h3>
 <div style="width:100%">
 	Orgainsation Unit: &nbsp; <input type="text" id="orgUnit" name="orgUnit" readonly size="40"/>
-	<input type="button" value="Add New Bank Detail" style="float:right;" id="openAddBankDetail" />
 </div>
 <br/><br/>
-<div id="loadBankDetails">
+<div id="loadBankDetails" style="width:92%;margin:auto;">
 </div>
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataElementsforTariff.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataElementsforTariff.vm	2013-12-24 12:23:11 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataElementsforTariff.vm	2014-01-07 10:10:48 +0000
@@ -1,14 +1,34 @@
+<style>
+		.x-column-header-inner .x-column-header-text {
+		white-space: normal;
+		z-index:0;
+	}
 
+	.x-column-header-inner {
+		line-height: normal;
+	}	
+	.x-grid-row .x-grid-cell-inner {
+		white-space: normal;		
+	}
+    .x-grid-row-over .x-grid-cell-inner {
+        font-weight: bold;
+		white-space: normal;		
+    }	
+	
+</style>
 <script >
 $(function() {
 	$("#addDataElement").button();
 });
 Ext.require([
     'Ext.form.field.ComboBox',    
-    'Ext.form.FieldSet',    
+    'Ext.form.FieldSet', 	
     'Ext.data.*'
 ]);
-
+Ext.Loader.setConfig({
+		enabled: true
+	});
+	
 // Define the model for a State
 Ext.define('State', {
     extend: 'Ext.data.Model',
@@ -63,7 +83,8 @@
             					dataElementName : $('#dataElementName').val(),
 								orgUnitUid : $("#orgUnitUid").val()
             				}
-            				, function( ){            										
+            				, function( ){  
+							loadExtTariff();
         				});  	
 }
 function organisationUnitSelected( orgUnits, orgUnitNames )
@@ -93,7 +114,13 @@
 	
 }
 
-selection.setListenerFunction( organisationUnitSelected );
+selection.setListenerFunction( organisationUnitSelected );
+
+function loadExtTariff()
+{
+			
+}
+
 </script>
 <style >
 	#tariffSetting {
@@ -136,5 +163,5 @@
 	</tr>
 </table>
 <br/><br/><br/>
-<div id="loadTariffDetails" style="width:80%"></div>
+<div id="loadTariffDetails" style="width:90%"></div>
 	
\ No newline at end of file

=== modified 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	2013-12-31 07:59:05 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataEntryForm.vm	2014-01-07 10:10:48 +0000
@@ -41,7 +41,15 @@
 				#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>
+				<td>
+					<input  onblur="saveValue('$dataElement.id','$optionCombo.id')" 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 )

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm	2013-12-27 05:24:32 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm	2014-01-07 10:10:48 +0000
@@ -1,7 +1,35 @@
+<script type="text/javascript" >
+	
+	Ext.Loader.setConfig({
+		enabled: true
+	});
+	Ext.Loader.setPath('Ext.ux.grid', 'javascript');
+	Ext.require([
+		'Ext.data.*',
+		'Ext.grid.*',
+		'Ext.toolbar.Paging',
+		'Ext.ux.grid.TransformGrid'
+	]);
+	
+</script>
+
 <script >
-
+	
 $(function() {
-$("#tariffDetails").tablesorter(); 
+			Ext.QuickTips.init();
+			
+			var grid = Ext.create('Ext.ux.grid.TransformGrid', "tariffDetails", {				
+			sortableColumns: true,
+            enableColumnMove: true,
+            enableColumnResize: true,
+            sortOnLoad: true,
+			minWidth: 100,
+        	minHeight: 100,			
+            sorters: {direction: 'ASC'}
+			});
+			
+			grid.render();
+			
 datePicker( 'startDate');
 datePicker( 'endDate');
 $("#openAddTariff").button()
@@ -198,8 +226,8 @@
 </div>
 <br/><br/>
 <input type="hidden" id="dataElementId" name="dataElementId" value="$!selecteddataElement.id"/>
-
-<table style="width:100%" id="tariffDetails">
+<div style="width:100%;margin:auto;">
+<table style="width:100%" id="tariffDetails" name="tariffDetails">
 	<thead >
 		<tr >
 			<th >PBF Type</th>
@@ -211,7 +239,7 @@
 			##end
         </tr>
 	</thead>
-	<tbody id="list">
+	<tbody>
 		#set( $mark = false )
 		#foreach( $tariff in $tariffList )
 			#if( $mark )
@@ -219,7 +247,7 @@
 			#else
 				#set( $mark = true )
 			#end
-            <tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8"  #end>
+            <tr >
 				<td >$!tariff.dataSet.name</td>
 				<td >$!tariff.value</td>
 				<td data-sorter="shortDate" data-date-format="yyyymmdd">$simpleDateFormat.format($!tariff.startDate)</td>
@@ -256,13 +284,6 @@
 			<td colspan="2">&nbsp;</td>
         </tr>
 		<tr >
-			<td style="width:40%;">Tariff <b class="mandatory">*</b> </td>
-			<td style="width:60%;"><input type="text" id="tariff" style="width:100%;" value="" onblur="validateAddTariff()" /></td>
-        </tr>
-		<tr >
-			<td colspan="2">&nbsp;</td>
-        </tr>
-		<tr >
 			<td style="width:40%;">Start Date <b class="mandatory">*</b> </td>
 			<td style="width:60%;"><input type="text" id="startDate" style="width:100%;" value="" onblur="validateAddTariff()" /></td>
         </tr>
@@ -273,6 +294,15 @@
 			<td style="width:40%;">End Date <b class="mandatory">*</b> </td>
 			<td style="width:60%;"><input type="text" id="endDate" style="width:100%;" value="" onblur="validateAddTariff()" /></td>
         </tr>
+		<tr >
+			<td colspan="2">&nbsp;</td>
+        </tr>
+		<tr >
+			<td style="width:40%;">Tariff <b class="mandatory">*</b> </td>
+			<td style="width:60%;"><input type="text" id="tariff" style="width:100%;" value="" onblur="validateAddTariff()" /></td>
+        </tr>
+		
+		
 		
     </table>
 </div>
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/status.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/status.vm	2013-12-24 12:23:11 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/status.vm	2014-01-07 10:10:48 +0000
@@ -1,3 +1,5 @@
 {
-"message":"${message}"
+"message":"${message}",
+"dataSets":${dataSets},
+"c":"${statusCode}"
 }
\ No newline at end of file