dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08499
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2049: Work in progress for Bangladesh Manpower Module
------------------------------------------------------------
revno: 2049
committer: Neeraj <neeraj.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-11-12 19:48:09 +0530
message:
Work in progress for Bangladesh Manpower Module
added:
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/AddEmployeeAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/GetEmployeeAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/ShowAddEmployeeFormAction.java
local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml
local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js
local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/DataBaseManagerInterface.java
local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java
--
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 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2010-11-12 14:18:09 +0000
@@ -31,9 +31,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
+import org.apache.struts2.ServletActionContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.struts2.ServletActionContext;
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/AddEmployeeAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/AddEmployeeAction.java 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/AddEmployeeAction.java 2010-11-12 14:18:09 +0000
@@ -8,114 +8,110 @@
import com.opensymphony.xwork2.Action;
-public class AddEmployeeAction
- implements Action
+public class AddEmployeeAction
+ implements Action
{
-
- // -------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
- private EmployeeService employeeService;
-
- public void setEmployeeService (EmployeeService employeeService)
- {
- this.employeeService = employeeService;
- }
-
+
+ private EmployeeService employeeService;
+
+ public void setEmployeeService( EmployeeService employeeService )
+ {
+ this.employeeService = employeeService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
-
- private I18nFormat format;
+
+ private I18nFormat format;
public void setFormat( I18nFormat format )
{
this.format = format;
}
-
- private String pdscode;
-
- public void setPdscode(String pdscode)
- {
- this.pdscode = pdscode;
- }
-
- private String name;
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- private String dob;
-
- public void setDob(String dob)
- {
- this.dob = dob;
- }
-
- private String lprDate;
-
- public void setLprDate(String lprDate)
- {
- this.lprDate = lprDate;
- }
-
- private String govtSerJoinDate;
-
- public void setGovtSerJoinDate(String govtSerJoinDate)
- {
- this.govtSerJoinDate = govtSerJoinDate;
- }
-
- private String sex;
-
- public void setSex(String sex)
- {
- this.sex = sex;
- }
-
- private String resAdd;
-
- public void setResAdd(String resAdd)
- {
- this.resAdd = resAdd;
- }
-
- private String contactNo;
-
- public void setContactNo(String contactNo)
- {
- this.contactNo = contactNo;
- }
-
- private String emerContactNo;
-
- public void setEmerContactNo(String emerContactNo)
- {
- this.emerContactNo = emerContactNo;
- }
-
-
-
- public String execute()
- {
-
- System.out.println("Inside AddEmployee Action");
- Date dateOfBirth = format.parseDate( dob );
-
- Date lpRetirementDate = format.parseDate( lprDate );
-
- Date joinDate = format.parseDate( govtSerJoinDate );
-
-
- Employee employeee = new Employee(pdscode, name, dateOfBirth, lpRetirementDate, sex, joinDate, resAdd, contactNo, emerContactNo );
-
-
- employeeService.addEmployee(employeee);
-
- return SUCCESS;
- }
+
+ private String pdscode;
+
+ public void setPdscode( String pdscode )
+ {
+ this.pdscode = pdscode;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String dob;
+
+ public void setDob( String dob )
+ {
+ this.dob = dob;
+ }
+
+ private String lprDate;
+
+ public void setLprDate( String lprDate )
+ {
+ this.lprDate = lprDate;
+ }
+
+ private String govtSerJoinDate;
+
+ public void setGovtSerJoinDate( String govtSerJoinDate )
+ {
+ this.govtSerJoinDate = govtSerJoinDate;
+ }
+
+ private String sex;
+
+ public void setSex( String sex )
+ {
+ this.sex = sex;
+ }
+
+ private String resAdd;
+
+ public void setResAdd( String resAdd )
+ {
+ this.resAdd = resAdd;
+ }
+
+ private String contactNo;
+
+ public void setContactNo( String contactNo )
+ {
+ this.contactNo = contactNo;
+ }
+
+ private String emerContactNo;
+
+ public void setEmerContactNo( String emerContactNo )
+ {
+ this.emerContactNo = emerContactNo;
+ }
+
+ public String execute()
+ {
+
+ Date dateOfBirth = format.parseDate( dob );
+
+ Date lpRetirementDate = format.parseDate( lprDate );
+
+ Date joinDate = format.parseDate( govtSerJoinDate );
+
+ Employee employeee = new Employee( pdscode, name, dateOfBirth, lpRetirementDate, sex, joinDate, resAdd,
+ contactNo, emerContactNo );
+
+ employeeService.addEmployee( employeee );
+
+ return SUCCESS;
+ }
}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/GetEmployeeAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/GetEmployeeAction.java 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/GetEmployeeAction.java 2010-11-12 14:18:09 +0000
@@ -6,46 +6,59 @@
import com.opensymphony.xwork2.Action;
public class GetEmployeeAction
-implements Action
+ implements Action
{
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
- private EmployeeService employeeService;
-
- public void setEmployeeService(EmployeeService employeeService)
- {
- this.employeeService = employeeService;
- }
-
+
+ private EmployeeService employeeService;
+
+ public void setEmployeeService( EmployeeService employeeService )
+ {
+ this.employeeService = employeeService;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
- private String pdsCode;
-
- public void setPdsCode(String pdsCode)
- {
- this.pdsCode = pdsCode;
- }
-
- private Employee employee;
-
- public Employee getEmployee()
- {
- return employee;
- }
-
+ private String pdsCode;
+
+ public void setPdsCode( String pdsCode )
+ {
+ this.pdsCode = pdsCode;
+ }
+
+ private Employee employee;
+
+ public Employee getEmployee()
+ {
+ return employee;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
- public String execute()
- {
- employee = employeeService.getEmployeeByPDSCode( pdsCode );
-
- return SUCCESS;
- }
+ public String execute()
+ {
+ employee = employeeService.getEmployeeByPDSCode( pdsCode );
+
+ if ( employee == null )
+ {
+ message = "The Employee with this PDSCode does not exist. Do you want to add new Employee?";
+ return INPUT;
+ }
+ message = "Employee name with this PDSCode is : " + employee.getName();
+ return SUCCESS;
+ }
}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/ShowAddEmployeeFormAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/ShowAddEmployeeFormAction.java 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/ShowAddEmployeeFormAction.java 2010-11-12 14:18:09 +0000
@@ -4,25 +4,25 @@
import com.opensymphony.xwork2.Action;
-public class ShowAddEmployeeFormAction
- implements Action
+public class ShowAddEmployeeFormAction
+ implements Action
{
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
- private Integer lprPeriod;
-
- public Integer getLprPeriod()
- {
- return lprPeriod;
- }
-
- public String execute()
- {
- lprPeriod = Employee.LPR_PERIOD;
-
- return SUCCESS;
- }
+ private Integer lprPeriod;
+
+ public Integer getLprPeriod()
+ {
+ return lprPeriod;
+ }
+
+ public String execute()
+ {
+ lprPeriod = Employee.LPR_PERIOD;
+
+ return SUCCESS;
+ }
}
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java 2010-11-12 14:18:09 +0000
@@ -0,0 +1,226 @@
+package org.hisp.dhis.ll.action.lldataentry;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.dbmanager.DataBaseManagerInterface;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.linelisting.LineListDataValue;
+import org.hisp.dhis.linelisting.LineListElement;
+import org.hisp.dhis.linelisting.LineListGroup;
+import org.hisp.dhis.linelisting.LineListService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.DailyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+public class SaveEmplyeePostAction
+ implements Action
+{
+
+ //---------------------------------------------------------------------------
+ // Dependencies
+ //---------------------------------------------------------------------------
+
+ private LineListService lineListService;
+
+ public void setLineListService( LineListService lineListService )
+ {
+ this.lineListService = lineListService;
+ }
+
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private DataBaseManagerInterface dbManagerInterface;
+
+ public void setDbManagerInterface( DataBaseManagerInterface dbManagerInterface )
+ {
+ this.dbManagerInterface = dbManagerInterface;
+ }
+
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ //---------------------------------------------------------------------------
+ //Input/Output
+ //---------------------------------------------------------------------------
+ private String department;
+
+ public void setDepartment( String department )
+ {
+ this.department = department;
+ }
+
+ private Integer groupid;
+
+ public void setGroupid( Integer groupid )
+ {
+ this.groupid = groupid;
+ }
+
+ private String storedBy;
+
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public String reportingDate;
+
+ public void setReportingDate( String reportingDate )
+ {
+ this.reportingDate = reportingDate;
+ }
+
+ private LineListGroup lineListGroup;
+
+ //--------------------------------------------------------------------------
+ //Action Implementation
+ //--------------------------------------------------------------------------
+
+ public String execute()
+ {
+ HttpServletRequest request = ServletActionContext.getRequest();
+
+ System.out.println("GroupId id :::::" + groupid );
+
+ Collection<LineListElement> linelistElements = lineListService.getLineListGroup( groupid ).getLineListElements();
+
+ lineListGroup = selectedStateManager.getSelectedLineListGroup();
+
+ OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ Period historyPeriod = getHistoryPeriod();
+
+ int recordNo = dbManagerInterface.getMaxRecordNumber( department ) + 1;
+
+ System.out.println("Record No is :::::" + recordNo );
+
+ Map<String, String> llElementValuesMap = new HashMap<String, String>();
+ LineListDataValue llDataValue = new LineListDataValue();
+ for ( LineListElement linelistElement : linelistElements )
+ {
+ String linelistElementValue = request.getParameter( linelistElement.getShortName() );
+
+ if ( linelistElementValue != null && linelistElementValue.trim().equals( "" ) )
+ {
+ linelistElementValue = "";
+ }
+ llElementValuesMap.put( linelistElement.getShortName(), linelistElementValue );
+ }
+
+ // add map in linelist data value
+ llDataValue.setLineListValues( llElementValuesMap );
+
+ //add period and source to row
+ llDataValue.setPeriod( historyPeriod );
+ llDataValue.setSource( organisationUnit );
+
+ // add recordNumber to pass to the update query
+ llDataValue.setRecordNumber( recordNo );
+
+ // add stored by, timestamp in linelist data value
+ storedBy = currentUserService.getCurrentUsername();
+
+ if ( storedBy == null )
+ {
+ storedBy = "[unknown]";
+ }
+
+ llDataValue.setStoredBy( storedBy );
+
+ boolean valueInserted = dbManagerInterface.insertSingleLLValueIntoDb( llDataValue, department );
+ if( valueInserted )
+ {
+ System.out.println("Values Successfully Inserted in DB");
+ }
+
+ return SUCCESS;
+ }
+
+ private Period getHistoryPeriod( )
+ {
+ Date historyDate = format.parseDate( reportingDate );
+ System.out.println("Report Date is :::::::" + reportingDate );
+
+ Period period;
+ period = periodService.getPeriod( 0 );
+ Period historyPeriod;
+
+
+ if ( lineListGroup != null && lineListGroup.getPeriodType().getName().equalsIgnoreCase( "OnChange" ) )
+ {
+ PeriodType dailyPeriodType = new DailyPeriodType();
+ historyPeriod = dailyPeriodType.createPeriod( historyDate );
+
+ System.out.println( reportingDate + " : " + historyPeriod );
+ if ( historyPeriod == null )
+ {
+ System.out.println( "historyPeriod is null" );
+ }
+ historyPeriod = reloadPeriodForceAdd( historyPeriod );
+ }
+ else
+ {
+ period = selectedStateManager.getSelectedPeriod();
+
+ period = reloadPeriodForceAdd( period );
+
+ historyPeriod = period;
+ }
+
+ return historyPeriod;
+ }
+
+ private final Period reloadPeriod( Period period )
+ {
+ return periodService.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
+ }
+
+ private final Period reloadPeriodForceAdd( Period period )
+ {
+ Period storedPeriod = reloadPeriod( period );
+
+ if ( storedPeriod == null )
+ {
+ periodService.addPeriod( period );
+
+ return period;
+ }
+
+ return storedPeriod;
+ }
+
+}
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java 2010-11-12 14:18:09 +0000
@@ -0,0 +1,115 @@
+package org.hisp.dhis.ll.action.lldataentry;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.linelisting.LineListElement;
+import org.hisp.dhis.linelisting.LineListGroup;
+import org.hisp.dhis.linelisting.LineListOption;
+
+import com.opensymphony.xwork2.Action;
+
+public class ShowEmployeePostFormAction
+implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ List<LineListElement> lineListElements;
+
+ public Collection<LineListElement> getLineListElements()
+ {
+ return lineListElements;
+ }
+
+ private String linelistGroupName;
+
+ public String getLinelistGroupName()
+ {
+ return linelistGroupName;
+ }
+
+ private String linelistOptionName;
+
+ public String getLinelistOptionName()
+ {
+ return linelistOptionName;
+ }
+
+ private Integer linelistGroupId;
+
+ public Integer getLinelistGroupId()
+ {
+ return linelistGroupId;
+ }
+
+ public String reportingDate;
+
+ public String getReportingDate()
+ {
+ return reportingDate;
+ }
+
+ public void setReportingDate( String reportingDate )
+ {
+ this.reportingDate = reportingDate;
+ }
+
+ private Map<String, Collection<LineListOption>> llElementOptionsMap;
+
+ public Map<String, Collection<LineListOption>> getLlElementOptionsMap()
+ {
+ return llElementOptionsMap;
+ }
+
+ private Collection<LineListOption> lineListOptions;
+
+ public String execute()
+ {
+ LineListGroup lineListGroup = selectedStateManager.getSelectedLineListGroup();
+
+ llElementOptionsMap = new HashMap<String, Collection<LineListOption>>();
+
+ lineListElements = new ArrayList<LineListElement>( lineListGroup.getLineListElements() );
+ if ( lineListElements.size() == 0 )
+ {
+ return SUCCESS;
+ }
+ else
+ {
+ Iterator<LineListElement> it2 = lineListElements.iterator();
+ while ( it2.hasNext() )
+ {
+ LineListElement element = it2.next();
+
+ lineListOptions = element.getLineListElementOptions();
+ llElementOptionsMap.put( element.getShortName(), lineListOptions );
+ }
+ }
+ lineListElements.remove( 0 );
+
+ linelistGroupName = selectedStateManager.getSelectedLineListGroup().getName();
+ linelistOptionName = selectedStateManager.getSelectedLineListOption().getName();
+ linelistGroupId = selectedStateManager.getSelectedLineListGroup().getId();
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-11-12 14:18:09 +0000
@@ -506,6 +506,33 @@
<ref bean="org.hisp.dhis.linelisting.LineListService"/>
</property>
</bean>
+
+ <bean id="org.hisp.dhis.ll.action.lldataentry.ShowEmployeePostFormAction"
+ class="org.hisp.dhis.ll.action.lldataentry.ShowEmployeePostFormAction" scope="prototype">
+ <property name="selectedStateManager">
+ <ref bean="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager"/>
+ </property>
+ </bean>
+
+ <bean id="org.hisp.dhis.ll.action.lldataentry.SaveEmplyeePostAction"
+ class="org.hisp.dhis.ll.action.lldataentry.SaveEmplyeePostAction" scope="prototype">
+ <property name="selectedStateManager">
+ <ref bean="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager"/>
+ </property>
+ <property name="lineListService">
+ <ref bean="org.hisp.dhis.linelisting.LineListService"/>
+ </property>
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService"/>
+ </property>
+ <property name="dbManagerInterface">
+ <ref bean="org.hisp.dhis.dbmanager.DataBaseManagerInterface"/>
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService"/>
+ </property>
+ </bean>
+
<!-- 15/10/2010 Start -->
<bean id="org.hisp.dhis.ll.action.llValidation.GetLineListElementsAction"
class="org.hisp.dhis.ll.action.llValidation.GetLineListElementsAction" scope="prototype">
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-11-12 14:18:09 +0000
@@ -398,9 +398,19 @@
<param name="javascripts">../dhis-web-commons/calendar/calendar.js,../dhis-web-commons/calendar/calendar-lang.js,../dhis-web-commons/calendar/calendar-setup.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js</param>
<param name="stylesheets">css/dhis-web-dataentry-national.css</param>
</action>
+
+ <action name="showEmployeePostForm" class="org.hisp.dhis.ll.action.lldataentry.ShowEmployeePostFormAction">
+ <result name="success" type="velocity">/dhis-web-linelisting-mp/employeePost.vm</result>
+ </action>
<action name="saveValueAction" class="org.hisp.dhis.ll.action.lldataentry.SaveValueAction">
- <result name="success" type="redirect">select.action</result>
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-linelisting-mp/select.vm</param>
+ </action>
+
+ <action name="saveEmployeePost" class="org.hisp.dhis.ll.action.lldataentry.SaveEmplyeePostAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-linelisting-mp/select.vm</param>
</action>
<action name="updateLineListEntry"
@@ -408,6 +418,14 @@
<result name="success" type="redirect">select.action</result>
<param name="requiredAuthorities">F_LINELISTEntry_UPDATE</param>
</action>
+
+ <action name="getEmployeeName"
+ class="org.hisp.dhis.ll.action.employee.GetEmployeeAction">
+ <result name="success" type="velocity-xml">/dhis-web-linelisting-mp/responseSuccess.vm</result>
+ <result name="input" type="velocity-xml">/dhis-web-linelisting-mp/responseInput.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<!-- Org unit -->
<action name="getOrgUnitDetails"
class="org.hisp.dhis.ll.action.lldataentry.GetOrgUnitsAction">
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm 2010-11-12 14:18:09 +0000
@@ -0,0 +1,68 @@
+
+<script type="text/javascript" src="../"></script>
+
+<form id="employeePostForm" action="saveEmployeePost.action" method="post" >
+
+ <table align="centre">
+ <tr>
+ <td><label for="department"><Strong>Department</Strong> </label></td>
+ <td>
+ <input id="department" name="department" type="text" readonly="readonly" value="$linelistGroupName" style="min-width:200px">
+ </td>
+ </tr>
+
+ <tr>
+ <td><label for="post"><Strong>Post</Strong> </label></td>
+ <td>
+ <input id="post" name="post" type="text" readonly="readonly" value="$linelistOptionName" style="min-width:200px">
+ </td>
+ <td>
+ <input type="hidden" name="groupid" id="groupid" value="$linelistGroupId">
+ <input type="text" name="reportingDate" id="reportingDate" value="$reportingDate">
+ </td>
+ </tr>
+
+ <tr><td></td></tr><tr><td></td></tr>
+ #set( $count = 0 )
+ #foreach( $lineListElement in $lineListElements )
+ <tr>
+ <td><label>$lineListElement.name</label></td>
+ #if($lineListElement.PresentationType == 'text')
+ <td>
+ <input type="text" name="$lineListElement.shortName" id = "$lineListElement.shortName" style="width:10em" #if($count==0) onchange="getEmployeeName( '$lineListElement.shortName', this.value )" #end onkeypress="return keyPress(event, this)" value=$!llElementValuesMap.get($element)>
+ </td>
+ #elseif($lineListElement.PresentationType == 'combobox')
+ <td>
+ <select name="$element" id="$element" onkeypress="return keyPress(event, this)">
+ <option name="SelectOption" value="" selected>--Select--</option>
+ #set($lineListOptions = $llElementOptionsMap.get($lineListElement.shortName))
+ #foreach( $lineListOption in $lineListOptions )
+ <option name="$lineListOption.name" value="$lineListOption.name" #if($lineListOption.name == $llElementValuesMap.get($element)) selected #end>$lineListOption.name</option>
+ #end
+ </select>
+ </td>
+ #elseif($lineListElement.PresentationType == 'calender')
+ #set($fordate = $lineListElement.shortName)
+
+ <td>
+ <input type="text" id="$fordate" name="$fordate" style="width:10em" onkeypress="return keyPress(event, this)">
+ <script>datePickerValid( '$fordate', false );</script>
+ </td>
+ #end
+ </tr>
+ #set ($count=$count+1)
+ #end
+
+ <tr>
+
+ <td colspan="2" align="centre">
+ <input type="submit" value="Save">
+ <input type="hidden" id="reportedDate" name="reportedDate">
+ </td>
+ <td>
+ <input type="button" value="Reset">
+ </td>
+ </tr>
+ </table>
+
+</form>
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm 2010-10-31 08:01:14 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm 2010-11-12 14:18:09 +0000
@@ -13,6 +13,7 @@
<th width="10%">Sr.No.</th>
<th width="40%">DataElement</th>
<th width="20%">Entry</th>
+
</tr>
#set( $dataValueMapKeys = $dataelementMap.keySet() )
#foreach( $dataValueMapKey in $dataValueMapKeys )
@@ -23,14 +24,15 @@
<td>$dataElementName</td>
<td align="center"><input type="text" id="$dataValueMapKey" name="$dataValueMapKey" value="$!dataValue.value" />
#if( $sactionedPostdataelement == $dataValueMapKey)
- <input type="button" value="Add" onclick="return addLLNewRow( '$dataValueMapKey' )">
+ <input type="button" value="Add" onclick="return addEmployeePostDetail( '$dataValueMapKey' )">
#end
</td>
<tr>
#set( $count1 = $count1 + 1 )
#end
+
</table>
-
+<!--
<table id="tblGrid" width="100%">
<tr>
@@ -124,7 +126,7 @@
</td>
</tr>
</table>
-
+-->
<script type="text/javascript">
$calInfo
@@ -223,5 +225,21 @@
}
return true;
}
+
+ function addEmployeePostDetail( dataValueMapKey )
+ {
+ var reportingDate = document.getElementById( "reportingDate" ).value;
+ var url = 'showEmployeePostForm.action?reportingDate=' + reportingDate;
+ $('#contentDataRecord').dialog('destroy').remove();
+ $('<div id="contentDataRecord" style="z-index: 1;">' ).load(url).dialog({
+ title: 'Employee Post Detail',
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 420,
+ height: 380
+ });
+}
</script>
\ No newline at end of file
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js 2010-10-20 06:14:25 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js 2010-11-12 14:18:09 +0000
@@ -1,6 +1,52 @@
-
-
+var currentPDSCode;
+function getEmployeeName( pdsCodeField, pdsCode )
+ {
+
+ currentPDSCode = pdsCodeField;
+ var request = new Request();
+ request.setResponseTypeXML( 'employee' );
+ request.setCallbackSuccess( employeeReceived );
+ request.send( 'getEmployeeName.action?pdsCode=' + pdsCode );
+ }
+
+function employeeReceived( employeeElement )
+{
+ //messageElement = employeeElement.getElementsByTagName( "message" )[0];
+ var type = employeeElement.getAttribute( "type" );
+
+ if (type == 'success')
+ {
+ if( confirm( employeeElement.firstChild.nodeValue ) )
+ {
+ }
+ else
+ {
+ var field = document.getElementById( currentPDSCode );
+ field.value = "";
+ setTimeout(function(){
+ field.focus();field.select();
+ },2);
+ }
+ }
+ else if(type == 'input')
+ {
+ if( confirm( employeeElement.firstChild.nodeValue ) )
+ {
+ var url = 'showAddEmployeeForm.action';
+ document.location.href = url;
+ }
+ else
+ {
+ var field = document.getElementById( currentPDSCode );
+ field.value = "";
+ setTimeout(function(){
+ field.focus();field.select();
+ },2);
+ }
+ }
+
+}
function addLLBNewRow()
{
=== modified file 'local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/DataBaseManagerInterface.java'
--- local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/DataBaseManagerInterface.java 2010-08-19 10:40:50 +0000
+++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/DataBaseManagerInterface.java 2010-11-12 14:18:09 +0000
@@ -21,6 +21,8 @@
public boolean updateTable( String tableName, List<LineListElement> removeList, List<LineListElement> addList );
public boolean insertLLValueIntoDb( List<LineListDataValue> llDataValuesList, String tableName );
+
+ public boolean insertSingleLLValueIntoDb( LineListDataValue llDataValue, String tableName );
//public List<Map<String, String>> getFromLLTable( String tableName, int source, int period );
public List<LineListDataValue> getFromLLTable( String tableName, Source source, Period period );
@@ -40,7 +42,9 @@
public Period getRecentPeriodForOnChangeData( String tableName, String llElementName, String llElementValue, Source source );
public List<LineListDataValue> getLLValuesSortBy( String tableName, String sortBy, Source source, Period period );
+
public int rowCount( String tableName );
+ public int getMaxRecordNumber( String tableName );
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java'
--- local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-08-19 10:40:50 +0000
+++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-11-12 14:18:09 +0000
@@ -207,6 +207,28 @@
return doNotDelete;
}
+
+ // function to get max row number
+ public int getMaxRecordNumber( String tableName )
+ {
+ int maxRecordNumber = 0;
+ try
+ {
+ String query = "SELECT MAX(recordNumber) FROM " + tableName;
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+
+ if( rs.next() )
+ {
+ maxRecordNumber = rs.getInt( 1 );
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ return maxRecordNumber;
+ }
+
// function for row count
public int rowCount( String tableName )
{
@@ -741,6 +763,86 @@
return llDataValues;
}
+
+ public boolean insertSingleLLValueIntoDb( LineListDataValue llDataValue, String tableName )
+ {
+ boolean updateLLValue = false;
+
+ String columnDefinition = "";
+
+ columnDefinition = "INSERT INTO " + tableName + " (periodid,sourceid,storedby,lastupdated,";
+
+ Period period = llDataValue.getPeriod();
+
+ Source source = llDataValue.getSource();
+
+ Map<String, String> elementValues = llDataValue.getLineListValues();
+ Set<String> elements = elementValues.keySet();
+
+ int size = elements.size();
+ int i = 1;
+ java.util.Date today = llDataValue.getTimestamp();
+ long t;
+ if ( today == null )
+ {
+ Date d = new Date();
+ t = d.getTime();
+ }
+ else
+ {
+ t = today.getTime();
+ }
+
+ java.sql.Date date = new java.sql.Date( t );
+ String values = " values (" + period.getId() + "," + source.getId() + ",'" + llDataValue.getStoredBy() + "','" + date + "',";
+ for ( String elementName : elements )
+ {
+ LineListElement lineListElement = lineListService.getLineListElementByShortName( elementName );
+ if ( i == size )
+ {
+ columnDefinition += elementName + ")";
+
+ if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
+ {
+ values += Integer.parseInt( elementValues.get( elementName ) );
+ }
+ else
+ {
+ values += "'" + elementValues.get( elementName ) + "'";
+ }
+ }
+ else
+ {
+ columnDefinition += elementName + ",";
+ if( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
+ {
+ values += Integer.parseInt( elementValues.get( elementName ) ) + ",";
+ }
+ else
+ {
+ values += "'" + elementValues.get( elementName ) + "'" + ",";
+ }
+ i++;
+ }
+
+ }
+ columnDefinition += values + ")";
+
+ try
+ {
+ int sqlResult = jdbcTemplate.update( columnDefinition );
+ updateLLValue = true;
+ columnDefinition = "";
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ updateLLValue = false;
+ }
+ return updateLLValue;
+ }
+
+
public boolean insertLLValueIntoDb( List<LineListDataValue> llDataValuesList, String tableName )
{
boolean updateLLValue = false;