=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java' --- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java 1970-01-01 00:00:00 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java 2010-11-14 14:20:26 +0000 @@ -0,0 +1,273 @@ +package org.hisp.dhis.ll.action.lldataentry; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +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.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.dbmanager.DataBaseManagerInterface; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.linelisting.LineListGroup; +import org.hisp.dhis.linelisting.LineListOption; +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 GetValidatePostVacantAction + implements Action +{ + // -------------------------------------------------------------------------- + // Dependency + // -------------------------------------------------------------------------- + + private SelectedStateManager selectedStateManager; + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + private DataBaseManagerInterface dataBaseManagerInterface; + + public void setDataBaseManagerInterface( DataBaseManagerInterface dataBaseManagerInterface ) + { + this.dataBaseManagerInterface = dataBaseManagerInterface; + } + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private DataElementCategoryService optionComboService; + + public void setOptionComboService( DataElementCategoryService optionComboService ) + { + this.optionComboService = optionComboService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // -------------------------------------------------------------------------- + // Input/Output + // -------------------------------------------------------------------------- + private String datavalue; + + public void setDatavalue( String datavalue ) + { + this.datavalue = datavalue; + } + + private String dataValueMapKey; + + public void setDataValueMapKey( String dataValueMapKey ) + { + this.dataValueMapKey = dataValueMapKey; + } + + private String message; + + public String getMessage() + { + return message; + } + + public String reportingDate; + + public void setReportingDate( String reportingDate ) + { + this.reportingDate = reportingDate; + } + + private String storedBy; + + private LineListGroup lineListGroup; + + // -------------------------------------------------------------------------- + // Action Implementation + // -------------------------------------------------------------------------- + + public String execute() + { + OrganisationUnit organisationunit = selectedStateManager.getSelectedOrganisationUnit(); + + Period period = selectedStateManager.getSelectedPeriod(); + + lineListGroup = selectedStateManager.getSelectedLineListGroup(); + + LineListOption lineListOption = selectedStateManager.getSelectedLineListOption(); + + String postLineListElementName = lineListGroup.getLineListElements().iterator().next().getShortName(); + String lastWorkingDateLLElementName = "lastworkingdate"; + String departmentLineListName = lineListGroup.getName(); + + // preparing map to filter records from linelist table + Map llElementValueMap = new HashMap(); + llElementValueMap.put( postLineListElementName, lineListOption.getName() ); + llElementValueMap.put( lastWorkingDateLLElementName, "null" ); + + int recordNo = dataBaseManagerInterface.getLLValueCountByLLElements( departmentLineListName, llElementValueMap, organisationunit, period ); + + int dataValue = Integer.parseInt( datavalue ); + + if( dataValue > recordNo ) + { + message = "Number of Sanctioned Position is " + dataValue + "And Number of Filled Position is " + recordNo + "\n Do you want to Add ?"; + saveDataValue(); + return SUCCESS; + } + else + { + message = "Number of Filled Position is equal to Number Sanctioned Post"; + + return INPUT; + } + } + + private void saveDataValue() + { + OrganisationUnit organisationunit = selectedStateManager.getSelectedOrganisationUnit(); + + Period historyPeriod = getHistoryPeriod(); + + storedBy = currentUserService.getCurrentUsername(); + + String[] partsOfDatavalueMap = dataValueMapKey.split( ":" ); + + int dataElementId = Integer.parseInt( partsOfDatavalueMap[1] ); + + int optionComboId = Integer.parseInt( partsOfDatavalueMap[2] ); + + DataElement dataElement = dataElementService.getDataElement( dataElementId ); + + DataElementCategoryOptionCombo optionCombo = optionComboService + .getDataElementCategoryOptionCombo( optionComboId ); + + if ( datavalue != null && datavalue.trim().length() == 0 ) + { + datavalue = null; + } + if ( datavalue != null ) + { + datavalue = datavalue.trim(); + } + + DataValue dataValueObj = dataValueService.getDataValue( organisationunit, dataElement, historyPeriod, optionCombo ); + + if ( storedBy == null ) + { + storedBy = "[unknown]"; + } + + if ( dataValueObj == null ) + { + if ( datavalue != null ) + { + dataValueObj = new DataValue( dataElement, historyPeriod, organisationunit, datavalue, storedBy, new Date(), null, + optionCombo ); + dataValueService.addDataValue( dataValueObj ); + } + } + else + { + dataValueObj.setValue( datavalue ); + dataValueObj.setTimestamp( new Date() ); + dataValueObj.setStoredBy( storedBy ); + + dataValueService.updateDataValue( dataValueObj ); + } + } + + private Period getHistoryPeriod( ) + { + //lineListGroup = selectedStateManager.getSelectedLineListGroup(); + 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; + } + +} === modified 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 2010-11-12 14:18:09 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java 2010-11-14 14:20:26 +0000 @@ -126,8 +126,6 @@ int recordNo = dbManagerInterface.getMaxRecordNumber( department ) + 1; - System.out.println("Record No is :::::" + recordNo ); - Map llElementValuesMap = new HashMap(); LineListDataValue llDataValue = new LineListDataValue(); for ( LineListElement linelistElement : linelistElements ) === 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-11-12 14:18:09 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-11-14 14:20:26 +0000 @@ -457,7 +457,7 @@ class="org.hisp.dhis.ll.action.lldataentry.SaveValueAction" scope="prototype"> - + @@ -474,8 +474,19 @@ - - + + + + + + + + + + + + === 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-11-12 14:18:09 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-11-14 14:20:26 +0000 @@ -425,6 +425,15 @@ /dhis-web-linelisting-mp/responseInput.vm plainTextError + + + + /dhis-web-linelisting-mp/responseSuccess.vm + /dhis-web-linelisting-mp/responseInput.vm + plainTextError + - + === 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-11-12 14:18:09 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm 2010-11-14 14:20:26 +0000 @@ -3,6 +3,12 @@
@@ -22,9 +28,10 @@ $count1 $dataElementName - + + #if( $sactionedPostdataelement == $dataValueMapKey) - + #end @@ -214,7 +221,6 @@ if (element==temparray[k]) { flag=1; - } } @@ -225,21 +231,6 @@ } return true; } - - function addEmployeePostDetail( dataValueMapKey ) - { - var reportingDate = document.getElementById( "reportingDate" ).value; - var url = 'showEmployeePostForm.action?reportingDate=' + reportingDate; - $('#contentDataRecord').dialog('destroy').remove(); - $('
' ).load(url).dialog({ - title: 'Employee Post Detail', - maximize: true, - closable: true, - modal:true, - overlay:{background:'#000000', opacity:0.1}, - width: 420, - height: 380 - }); } \ 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-11-12 14:18:09 +0000 +++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js 2010-11-14 14:20:26 +0000 @@ -1,8 +1,36 @@ var currentPDSCode; + +function validatePostVacant( dataValueMapKey ) +{ + var reportingDate = document.getElementById('reportingDate').value; + + alert( sancPos +" : " + reportingDate ); + var request = new Request(); + request.setResponseTypeXML('element'); + request.setCallbackSuccess( elementReceived ); + request.send( 'getValidatePostVacant.action?datavalue=' + sancPos + '&dataValueMapKey=' + dataValueMapKey + '&reportingDate=' + reportingDate); + //window.location.href = 'getValidatePostVacant.action?datavalue=' + sancPos + '&dataValueMapKey=' + dataValueMapKey + '&reportingDate=' + reportingDate; +} + +function elementReceived( recordNo ) +{ + var type = recordNo.getAttribute( "type" ); + if (type == 'success' ) + { + if( confirm ( recordNo.firstChild.nodeValue ) ) + { + showEmployeePostForm(); + } + } + else if (type == 'input' ) + { + alert( recordNo.firstChild.nodeValue ); + } + +} function getEmployeeName( pdsCodeField, pdsCode ) { - currentPDSCode = pdsCodeField; var request = new Request(); request.setResponseTypeXML( 'employee' ); @@ -14,7 +42,6 @@ { //messageElement = employeeElement.getElementsByTagName( "message" )[0]; var type = employeeElement.getAttribute( "type" ); - if (type == 'success') { if( confirm( employeeElement.firstChild.nodeValue ) ) @@ -132,3 +159,22 @@ } +function showEmployeePostForm() +{ + //alert( dataValueMapKey ); + var reportingDate = document.getElementById( "reportingDate" ).value; + var url = 'showEmployeePostForm.action?reportingDate=' + reportingDate; + $('#contentDataRecord').dialog('destroy').remove(); + $('
' ).load(url).dialog({ + title: 'Employee Post Detail', + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 420, + height: 380 +}); +} + + + === 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-11-12 14:18:09 +0000 +++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/DataBaseManagerInterface.java 2010-11-14 14:20:26 +0000 @@ -35,6 +35,8 @@ public boolean updateLLValue( List llDataValuesList, String tableName ); + public int getLLValueCountByLLElements( String tablename, Map llElementValueMap, Source source, Period period ); + public List getLLValuesFilterByLLElements( String tableName, Map llElementValueMap, Source source, Period period ); public List getLLValuesByLLElementValue( String tableName, String llElementName, String llElementValue, Source source, Period period ); === 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-11-12 14:18:09 +0000 +++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-11-14 14:20:26 +0000 @@ -665,6 +665,62 @@ } + public int getLLValueCountByLLElements( String tableName, Map llElementValueMap, Source source, Period period ) + { + String columnDefinition = ""; + int noOfRows = 0; + if ( source != null ) + { + //columnDefinition += "SELECT COUNT(*) FROM " + tableName + " WHERE periodid = " + period.getId() + " AND sourceid = " + source.getId(); + columnDefinition += "SELECT COUNT(*) FROM " + tableName + " WHERE sourceid = " + source.getId(); + + List llElementNames = new ArrayList( llElementValueMap.keySet() ); + Iterator llENamesIterator = llElementNames.iterator(); + while ( llENamesIterator.hasNext() ) + { + String lleName = llENamesIterator.next(); + + String lleValue = llElementValueMap.get( lleName ); + + if ( lleValue.equalsIgnoreCase( "notnull" ) ) + { + columnDefinition += " AND " + lleName + " IS NOT NULL"; + } else + { + if ( lleValue.equalsIgnoreCase( "null" ) ) + { + columnDefinition += " AND " + lleName + " IS NULL"; + } else + { + columnDefinition += " AND " + lleName + " LIKE '" + lleValue + "'"; + } + } + } + + + columnDefinition += " order by recordnumber"; + System.out.println( columnDefinition ); + + try + { + SqlRowSet rs = jdbcTemplate.queryForRowSet( columnDefinition ); + + if( rs.next() ) + { + noOfRows = rs.getInt( 1 ); + } + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + return noOfRows; + } + + + + public List getLLValuesSortBy( String tableName, String sortBy, Source source, Period period ) { String columnDefinition = "";