dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26705
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13200: PBF Functionality
------------------------------------------------------------
revno: 13200
committer: Samta Bajpayee<samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-12-11 12:08:01 +0000
message:
PBF Functionality
modified:
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java
local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java
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
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/loadTariffData.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/AddTariffDataAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java 2013-12-11 09:01:17 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java 2013-12-11 12:08:01 +0000
@@ -1,7 +1,9 @@
package org.hisp.dhis.pbf.action;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -72,38 +74,28 @@
private String endDate;
private String dataElementId;
- private String orgUnitId;
+ private String orgUnitUid;
public void setDataElementId(String dataElementId) {
this.dataElementId = dataElementId;
}
-
-
- public void setOrgUnitId(String orgUnitId) {
- this.orgUnitId = orgUnitId;
+ public void setOrgUnitUid(String orgUnitUid) {
+ this.orgUnitUid = orgUnitUid;
}
-
-
public void setPbfType(String pbfType) {
this.pbfType = pbfType;
}
-
-
public void setTariff(String tariff) {
this.tariff = tariff;
}
-
-
public void setStartDate(String startDate) {
this.startDate = startDate;
}
-
-
public void setEndDate(String endDate) {
this.endDate = endDate;
}
@@ -122,12 +114,14 @@
DataElement dataElement = dataElementService.getDataElement(Integer.parseInt(dataElementId));
- OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit(Integer.parseInt(orgUnitId));
+ List<String> orgUids = new ArrayList<String>();
+ orgUids.add(orgUnitUid);
+ List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitsByUid(orgUids);
OrganisationUnitGroup orgUnitGrp = organisationUnitGroupService.getOrganisationUnitGroup(Integer.parseInt(pbfType));
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
- TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue(orgUnit, dataElement, optionCombo, orgUnitGrp, sDate, eDate);
+ TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue(organisationUnits.get(0), dataElement, optionCombo, orgUnitGrp, sDate, eDate);
TariffDataValue tariffDataValue1;
@@ -137,7 +131,7 @@
}
else
{
- tariffDataValue1 = tariffDataValueService.getTariffDataValue(orgUnit, dataElement, optionCombo, orgUnitGrp, sDate, eDate);
+ tariffDataValue1 = tariffDataValueService.getTariffDataValue(organisationUnits.get(0), dataElement, optionCombo, orgUnitGrp, sDate, eDate);
}
tariffDataValue1.setValue(Double.parseDouble(tariff));
@@ -148,7 +142,7 @@
tariffDataValue1.setDataElement(dataElement);
tariffDataValue1.setOptionCombo(optionCombo);
tariffDataValue1.setOrganisationUnitGroup(orgUnitGrp);
- tariffDataValue1.setOrganisationUnit(orgUnit);
+ tariffDataValue1.setOrganisationUnit(organisationUnits.get(0));
if(tariffDataValue == null)
{
=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java 2013-12-11 09:01:17 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java 2013-12-11 12:08:01 +0000
@@ -3,6 +3,14 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+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.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.pbf.api.TariffDataValue;
import org.hisp.dhis.pbf.api.TariffDataValueService;
@@ -19,7 +27,31 @@
{
this.tariffDataValueService = tariffDataValueService;
}
-
+ private DataElementService dataElementService;
+
+ public void setDataElementService(DataElementService dataElementService) {
+ this.dataElementService = dataElementService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService(
+ OrganisationUnitService organisationUnitService) {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService(
+ OrganisationUnitGroupService organisationUnitGroupService) {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService(DataElementCategoryService categoryService) {
+ this.categoryService = categoryService;
+ }
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -36,6 +68,36 @@
private String endDate;
+ public void setOrganisationUnitId(String organisationUnitId) {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+
+ public void setDataElementId(String dataElementId) {
+ this.dataElementId = dataElementId;
+ }
+
+
+ public void setCategoryOptionComboId(String categoryOptionComboId) {
+ this.categoryOptionComboId = categoryOptionComboId;
+ }
+
+
+ public void setOrganisationUnitGroupId(String organisationUnitGroupId) {
+ this.organisationUnitGroupId = organisationUnitGroupId;
+ }
+
+
+ public void setStartDate(String startDate) {
+ this.startDate = startDate;
+ }
+
+
+ public void setEndDate(String endDate) {
+ this.endDate = endDate;
+ }
+
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -53,9 +115,13 @@
SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
sDate = dateFormat.parse(startDate);
eDate = dateFormat.parse(endDate);
+ DataElement dataElement = dataElementService.getDataElement(deId);
+ OrganisationUnitGroup orgUnitGrp = organisationUnitGroupService.getOrganisationUnitGroup(orgUnitGrpId);
+ DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo(categoryId);
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(orgUnitId);
TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue
- (orgUnitId, deId, categoryId, orgUnitGrpId, sDate, eDate);
+ (organisationUnit, dataElement, optionCombo, orgUnitGrp, sDate, eDate);
tariffDataValueService.deleteTariffDataValue(tariffDataValue);
=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java 2013-12-11 09:09:47 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java 2013-12-11 12:08:01 +0000
@@ -1,8 +1,11 @@
package org.hisp.dhis.pbf.action;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.dataelement.DataElement;
@@ -16,6 +19,8 @@
{
private final static String TARIFF_SETTING_AUTHORITY = "TARIFF_SETTING_AUTHORITY";
+ private final static String TARIFF_DATAELEMENT = "TARIFF_DATAELEMENT";
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -60,9 +65,9 @@
return tariff_setting_authority;
}
- private List<Integer> levelOrgUnitIds = new ArrayList<Integer>();
+ private List<String> levelOrgUnitIds = new ArrayList<String>();
- public List<Integer> getLevelOrgUnitIds() {
+ public List<String> getLevelOrgUnitIds() {
return levelOrgUnitIds;
}
@@ -72,32 +77,39 @@
public String execute()
{
- if(constantService.getConstantByName( TARIFF_SETTING_AUTHORITY) == null)
+ Constant tariff_authority = constantService.getConstantByName( TARIFF_SETTING_AUTHORITY );
+ Constant tariffDataElement = constantService.getConstantByName( TARIFF_DATAELEMENT );
+ if(tariff_authority == null)
{
tariff_setting_authority = "Level 3";
List<OrganisationUnit> allLevelOrg =new ArrayList<OrganisationUnit>(organisationUnitService.getOrganisationUnitsAtLevel(3)) ;
for(OrganisationUnit org : allLevelOrg)
{
- levelOrgUnitIds.add(org.getId());
+ levelOrgUnitIds.add("\""+org.getUid()+"\"");
}
}
else
{
- Constant tariff_authority = constantService.getConstantByName( TARIFF_SETTING_AUTHORITY );
+
tariff_setting_authority = "Level "+(int)tariff_authority.getValue();
- List<OrganisationUnit> allLevelOrg =new ArrayList<OrganisationUnit>(organisationUnitService.getOrganisationUnitsAtLevel(Integer.parseInt(tariff_authority.getValue()+""))) ;
+ List<OrganisationUnit> allLevelOrg =new ArrayList<OrganisationUnit>(organisationUnitService.getOrganisationUnitsAtLevel((int)tariff_authority.getValue())) ;
for(OrganisationUnit org : allLevelOrg)
{
- levelOrgUnitIds.add(org.getId());
+ levelOrgUnitIds.add("\""+org.getUid()+"\"");
}
}
List<DataElement> dataElements = new ArrayList<DataElement>(dataElementService.getAllDataElements());
+
for(DataElement de : dataElements)
{
- if(!(dataElementList.contains("\""+de.getName()+"\"")))
- {
- dataElementList.add("\""+de.getName()+"\"");
- }
+ Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
+ for ( AttributeValue attValue : attrValueSet )
+ {
+ if (!(dataElementList.contains("\""+de.getName()+"\"")) && attValue.getAttribute().getId() == tariffDataElement.getValue() )
+ {
+ dataElementList.add("\""+de.getName()+"\"");
+ }
+ }
}
return SUCCESS;
=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java 2013-12-11 09:09:47 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java 2013-12-11 12:08:01 +0000
@@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -12,11 +14,16 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.pbf.api.TariffDataValue;
import org.hisp.dhis.pbf.api.TariffDataValueService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserAuthorityGroup;
import com.opensymphony.xwork2.Action;
public class LoadTariffDetailsAction implements Action
{
+ private final static String PBF_ORGUNIT_GROUP_SET = "PBF_ORGUNIT_GROUP_SET";
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -47,7 +54,20 @@
OrganisationUnitGroupService organisationUnitGroupService) {
this.organisationUnitGroupService = organisationUnitGroupService;
}
-
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService(CurrentUserService currentUserService) {
+ this.currentUserService = currentUserService;
+ }
+
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
// -------------------------------------------------------------------------
// Input / Output
// -------------------------------------------------------------------------
@@ -56,18 +76,24 @@
public void setDataElementName(String dataElementName) {
this.dataElementName = dataElementName;
}
- private String orgUnitId;
+ private String orgUnitUid;
- public void setOrgUnitId(String orgUnitId) {
- this.orgUnitId = orgUnitId;
+ public void setOrgUnitUid(String orgUnitUid) {
+ this.orgUnitUid = orgUnitUid;
}
-
+
private List<TariffDataValue> tariffList = new ArrayList<TariffDataValue>();
public List<TariffDataValue> getTariffList() {
return tariffList;
}
+ private String updateAuthority;
+
+ public String getUpdateAuthority() {
+ return updateAuthority;
+ }
+
private DataElement selecteddataElement;
public DataElement getSelecteddataElement() {
@@ -86,12 +112,31 @@
public String execute()
{
- OrganisationUnitGroupSet organisationUnitGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet(3);
+ Constant pbf_orgunitGrpSet = constantService.getConstantByName( PBF_ORGUNIT_GROUP_SET );
+ User curUser = currentUserService.getCurrentUser();
+ List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>( curUser.getUserCredentials()
+ .getUserAuthorityGroups() );
+ for ( UserAuthorityGroup userAuthorityGroup : userAuthorityGroups )
+ {
+ userAuthorityGroup.getUserGroupAccesses();
+ if ( userAuthorityGroup.getAuthorities().contains( "F_TARIFFDATAVALUE_UPDATE" ) )
+ {
+ updateAuthority = "Yes";
+ }
+ else
+ {
+ updateAuthority = "No";
+ }
+ }
+
+ OrganisationUnitGroupSet organisationUnitGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet((int)pbf_orgunitGrpSet.getValue());
orGroupList = new ArrayList<OrganisationUnitGroup>(organisationUnitGroupSet.getOrganisationUnitGroups()) ;
selecteddataElement = dataElementService.getDataElementByName(dataElementName);
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(Integer.parseInt(orgUnitId));
+ List<String> orgUids = new ArrayList<String>();
+ orgUids.add(orgUnitUid);
+ List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitsByUid(orgUids);
- tariffList = new ArrayList<TariffDataValue>(tariffDataValueService.getTariffDataValues(organisationUnit, selecteddataElement)) ;
+ tariffList = new ArrayList<TariffDataValue>(tariffDataValueService.getTariffDataValues(organisationUnits.get(0), selecteddataElement)) ;
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-11 09:01:17 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml 2013-12-11 12:08:01 +0000
@@ -31,7 +31,9 @@
<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+ <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<!-- Add Tariff -->
@@ -46,6 +48,10 @@
<!-- Delete Tariff -->
<bean id="org.hisp.dhis.pbf.action.DeleteTariffDataAction" class="org.hisp.dhis.pbf.action.DeleteTariffDataAction" scope="prototype">
<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</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-07 09:10:04 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/i18n_module.properties 2013-12-11 12:08:01 +0000
@@ -0,0 +1,3 @@
+pbf_setup = PBF Setup
+dataelement_tariff_management = Tariff Management Dataelement
+pbf_management = PBF Management
\ 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-10 12:41:41 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/struts.xml 2013-12-11 12:08:01 +0000
@@ -30,7 +30,8 @@
</action>
<action name="deleteTariffData" class="org.hisp.dhis.pbf.action.DeleteTariffDataAction">
<result name="success" type="velocity-json">/dhis-web-maintenance-pbf/status.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
+ <param name="onExceptionReturn">plainTextError</param>
+ <param name="requiredAuthorities">F_TARIFFDATAVALUE_UPDATE</param>
</action>
</package>
=== 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-11 09:01:17 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadDataElementsforTariff.vm 2013-12-11 12:08:01 +0000
@@ -13,7 +13,7 @@
$('#loadTariffDetails').load("loadTariffDetails.action",
{
dataElementName:dataElementName,
- orgUnitId:$("#orgUnitId").val()
+ orgUnitUid:$("#orgUnitUid").val()
}
, function( ){
});
@@ -34,7 +34,7 @@
$('#loadTariffDetails').load("loadTariffDetails.action",
{
dataElementName:dataElementName,
- orgUnitId:$("#orgUnitId").val()
+ orgUnitUid:$("#orgUnitUid").val()
}
, function( ){
});
@@ -61,7 +61,7 @@
else
{
setFieldValue("orgUnit", orgUnitNames[0]);
- setFieldValue("orgUnitId", orgUnits[0]);
+ setFieldValue("orgUnitUid", orgUnits[0]);
}
}
@@ -69,10 +69,10 @@
selection.setListenerFunction( organisationUnitSelected );
</script>
<h3>Data Element Tariff Management</h3>
-<input type="hidden" name="orgUnitId" id="orgUnitId">
-<table width="100%">
+<input type="hidden" name="orgUnitUid" id="orgUnitUid">
+<table width="60%">
<tr>
- <td >Orgainsation Unit <input type="text" id="orgUnit" name="orgUnit" readonly/></td>
+ <td >Orgainsation Unit <input type="text" id="orgUnit" name="orgUnit" readonly size="40"/></td>
<td >Tariff Setting Authority <input type="text" readonly id="tariff_authority" value="$!tariff_setting_authority"/></td>
</tr>
<tr >
@@ -81,8 +81,9 @@
</tr>
<tr>
<td ><input id="dataElementName" name="dataElementName" onkeyup="getTariffData()" size="55" placeholder="Type the name of dataelement" /> </td>
- <td > </td>
+ <td ><input type="button" id="addDataElement" value="Add DataElement" disabled /></td>
</tr>
</table>
<br/><br/><br/>
-<div id="loadTariffDetails" style="width:80%"></div>
\ No newline at end of file
+<div id="loadTariffDetails" style="width:80%"></div>
+
\ No newline at end of file
=== 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-11 09:01:17 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm 2013-12-11 12:08:01 +0000
@@ -1,13 +1,12 @@
<script >
$(function() {
-
-$( "#startDate" ).datepicker();
-$( "#endDate" ).datepicker();
+datePickerValid( 'startDate', true );
+datePickerValid( 'endDate', true );
$("#openAddTariff").button()
.click(function() {
$( "#addTariff" ).dialog( "open" );
- $("#pbfType option:selected").remove();
+ $('#pbfType option[value=-1]').attr('selected','selected');
$("#pbfType ").removeAttr('disabled');
$("#tariff").val('');
$("#startDate").val('');
@@ -18,17 +17,23 @@
$( "#addTariff" ).dialog({
+ width: 320,
autoOpen: false,
modal: true,
buttons: {
"Save": function() {
-
- var dataValue = {
+ var date1 = Date.parse($("#startDate").val());
+ var date2 = Date.parse($("#endDate").val());
+ if (date1 > date2) {
+ alert ("Please enter correct date");
+ }
+ else{
+ var dataValue = {
'pbfType' : $("#pbfType").val(),
'tariff' : $("#tariff").val(),
'startDate' : $("#startDate").val(),
'endDate' : $("#endDate").val(),
- 'orgUnitId': $("#orgUnitId").val(),
+ 'orgUnitUid': $("#orgUnitUid").val(),
'dataElementId' : $("#dataElementId").val()
};
jQuery.ajax( {
@@ -38,6 +43,8 @@
success: handleSuccess,
error: handleError
} );
+ }
+
},
Cancel: function() {
$( this ).dialog( "close" );
@@ -48,7 +55,7 @@
});
function handleSuccess( json )
{
- $("#pbfType option:selected").remove();
+ $('#pbfType option[value=-1]').attr('selected','selected');
$("#pbfType ").removeAttr('disabled');
$("#tariff").val('');
$("#startDate").val('');
@@ -61,7 +68,7 @@
}
function handleError( json )
{
- $("#pbfType option:selected").remove();
+ $('#pbfType option[value=-1]').attr('selected','selected');
$("#pbfType ").removeAttr('disabled');
$("#tariff").val('');
$("#startDate").val('');
@@ -125,7 +132,9 @@
<th >Tariff</th>
<th >Start Date</th>
<th >End Date</th>
- <th >Operations</th>
+ #if($updateAuthority == 'Yes')
+ <th >Operations</th>
+ #end
</tr>
</thead>
<tbody id="list">
@@ -141,10 +150,17 @@
<td >$!tariff.value</td>
<td >$!tariff.startDate</td>
<td >$!tariff.endDate</td>
+ #if($updateAuthority == 'Yes')
<td>
- <img src="images/delete.png" width="17px" onclick="deleteTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate')"/>
- <img src="../images/edit.png" alt="$i18n.getString( 'edit' )" onclick="editTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate','$tariff.value')">
+ <a href="javascript:deleteTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate')">
+ <img src="images/delete.png" width="17px"/>
+ </a>
+ <a href="javascript:editTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate','$tariff.value')">
+ <img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/>
+ </a>
+
</td>
+ #end
</tr>
#end
</tbody>
@@ -152,10 +168,10 @@
<div id="addTariff" title="Add New Tariff">
<table style="width:100%;table-layout:fixed;">
<tr >
- <td style="width:40%;"> </td>
+ <td style="width:40%;">PBF Type</td>
<td style="width:60%;">
<select id="pbfType" style="width:100%;">
- <option >Select PBF Type</option>
+ <option value="-1">Select PBF Type</option>
#foreach($orGrp in $orGroupList)
<option value="$orGrp.id">$orGrp.name</option>
#end