=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java 2012-06-14 05:58:42 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java 2012-07-21 10:27:27 +0000 @@ -14,7 +14,9 @@ { final Pattern INPUT_PATTERN = Pattern.compile( "(", Pattern.DOTALL ); - final Pattern IDENTIFIER_PATTERN_FIELD = Pattern.compile( "id=\"(\\d+)-(\\d+)-val\"" ); + //final Pattern IDENTIFIER_PATTERN_FIELD = Pattern.compile( "id=\"(\\d+)-(\\d+)-val\"" ); + + final Pattern IDENTIFIER_PATTERN_FIELD = Pattern.compile( "id=\"attr(\\d+)\"" ); //-------------------------------------------------------------------------- // ProgramDataEntryService === modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java' --- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java 2012-06-14 05:58:42 +0000 +++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java 2012-07-21 10:27:27 +0000 @@ -7,7 +7,9 @@ import java.util.regex.Pattern; import org.apache.commons.lang.BooleanUtils; +import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.ProgramDataEntryService; /** * @author Mithilesh Kumar Thakur @@ -119,15 +121,18 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId ); - if ( catalogTypeAttribute != null && (!CatalogTypeAttribute.TYPE_INT.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) && !CatalogTypeAttribute.TYPE_STRING.equalsIgnoreCase( catalogTypeAttribute.getValueType() )) ) - { - continue; - } - + if ( catalogTypeAttribute != null && !CatalogTypeAttribute.TYPE_INT.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) ) + { + continue; + } + else if ( catalogTypeAttribute != null && !CatalogTypeAttribute.TYPE_STRING.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) ) + { + continue; + } String displayValue = ( catalogTypeAttribute == null ) ? " value=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" " : " value=\"[ " + catalogTypeAttribute.getName() + " ]\""; @@ -191,7 +196,7 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId ); @@ -262,7 +267,7 @@ // ------------------------------------------------------------- // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId ); @@ -334,7 +339,7 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId ); @@ -392,7 +397,9 @@ // --------------------------------------------------------------------- Map catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType ); - + + int catalogTypeId = catalogType.getId(); + while ( CatalogTypeAttributeMatcher.find() ) { // ----------------------------------------------------------------- @@ -412,9 +419,9 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); + //int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = null; @@ -587,8 +594,6 @@ // --------------------------------------------------------------------- // Pattern to match CatalogTypeAttributes in the HTML code // --------------------------------------------------------------------- - - Pattern INPUT_PATTERN = Pattern.compile( "(", Pattern.DOTALL ); @@ -599,7 +604,7 @@ // --------------------------------------------------------------------- Map catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType ); - + int catalogTypeId = catalogType.getId(); // Map dataElementMap = getDataElementMap( programStage ); while ( CatalogTypeAttributeMatcher.find() ) @@ -620,9 +625,9 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); + //int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = null; @@ -794,8 +799,6 @@ // Pattern to match CatalogTypeAttributes in the HTML code // --------------------------------------------------------------------- - - Pattern INPUT_PATTERN = Pattern.compile( "(", Pattern.DOTALL ); Matcher CatalogTypeAttributeMatcher = INPUT_PATTERN.matcher( dataEntryFormCode ); @@ -805,6 +808,7 @@ // --------------------------------------------------------------------- Map catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType ); + int catalogTypeId = catalogType.getId(); // Map dataElementMap = getDataElementMap( programStage ); @@ -826,9 +830,9 @@ // Get catalogType attribute ID of catalogType attribute // ------------------------------------------------------------- - int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); + //int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = null; @@ -905,10 +909,43 @@ } } + + String appendCode = catalogTypeAttributeCode.replaceFirst( "input", "select" ); + appendCode = appendCode.replace( "name=\"entryfield\"", jsCodeForOptions ); + + // ------------------------------------------------------------- + // Add title + // ------------------------------------------------------------- + + if ( catalogTypeAttributeCode.contains( "title=\"\"" ) ) + { + appendCode = appendCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "." + + catalogTypeAttribute.getName() + "-" + catalogTypeAttributeType + "\" " ); + } + else + { + appendCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-" + + catalogTypeAttributeType + "\" "; + } + + appendCode += ">"; + + + appendCode += ""; + + for( CatalogTypeAttributeOption catalogTypeAttributeOption : catalogTypeAttribute.getAttributeOptions() ) + { + appendCode += ""; + } + //appendCode += ""; + //appendCode += ""; + + //-------------------------------------------------------------- // Insert title information - Data element id, name, type, min, // max // ------------------------------------------------------------- + /* if ( catalogTypeAttributeCode.contains( "title=\"\"" ) ) { catalogTypeAttributeCode = catalogTypeAttributeCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "." @@ -919,13 +956,14 @@ catalogTypeAttributeCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + " (" + catalogTypeAttributeType + ")\" "; } - +*/ // ------------------------------------------------------------- // Insert value of catalogType Attribute in output code // ------------------------------------------------------------- - String appendCode = catalogTypeAttributeCode; + //String appendCode = catalogTypeAttributeCode; + /* if ( appendCode.contains( "value=\"\"" ) ) { appendCode = appendCode.replace( "value=\"\"", "value=\"" + catalogTypeAttributeValue + "\"" ); @@ -943,8 +981,8 @@ } appendCode += " />"; - - + */ + appendCode += ""; disabled = ""; if ( catalogTypeId != catalogType.getId() ) @@ -966,7 +1004,7 @@ appendCode = appendCode.replace( "$SAVEMODE", "false" ); appendCode = appendCode.replaceAll( "\\$", "\\\\\\$" ); - System.out.println( "---appendCode---" + appendCode ); + //System.out.println( "---appendCode---" + appendCode ); CatalogTypeAttributeMatcher.appendReplacement( sb, appendCode ); } @@ -1017,7 +1055,7 @@ Map catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType ); - + int catalogTypeId = catalogType.getId(); while ( CatalogTypeAttributeMatcher.find() ) { @@ -1027,7 +1065,6 @@ String mandatory = "null"; - String catalogTypeAttributeCode = CatalogTypeAttributeMatcher.group( 1 ); @@ -1039,9 +1076,9 @@ // Get data element ID of data element // ------------------------------------------------------------- - int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); + //int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) ); - int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) ); + int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 1 ) ); CatalogTypeAttribute catalogTypeAttribute = null; === modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 2012-06-14 05:58:42 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 2012-07-21 10:27:27 +0000 @@ -45,6 +45,14 @@ { this.catalogTypeId = catalogTypeId; } + + private Boolean isCustom; + + public Boolean getIsCustom() + { + return isCustom; + } + /* private Collection catalogTypeAttributes; @@ -54,6 +62,8 @@ } */ + + private List catalogTypeAttributes = new ArrayList(); public List getCatalogTypeAttributes() @@ -92,14 +102,11 @@ // Action implementation // ------------------------------------------------------------------------- - - - - public String execute() { + System.out.println("entering into ShowAddCatalogFormAction action"); catalogType = catalogTypeService.getCatalogType( catalogTypeId ); - + isCustom = false; String disabled = ""; if ( catalogType != null ) { @@ -109,14 +116,20 @@ DataEntryForm dataEntryForm = catalogType.getDataEntryForm(); + System.out.println("dataentryform object retrieved"); + if ( dataEntryForm != null ) { + isCustom = true; + System.out.println("dataentryform object is not null"); Collection catalogDataValues = new ArrayList(); customDataEntryFormCode = catalogDataEntryService.prepareDataEntryFormForCatalog( dataEntryForm.getHtmlCode(), catalogDataValues, disabled, i18n, catalogType ); + //customDataEntryFormCode = "custom dataentry form"; } - catalogTypeAttributes = new ArrayList ( catalogType.getCatalogTypeAttributes()); + catalogTypeAttributes = new ArrayList ( catalogType.getCatalogTypeAttributes() ); + //Collections.sort( catalogTypeAttributes, new CatalogTypeAttributeComparator() ); /* @@ -131,7 +144,7 @@ */ } - + System.out.println("going out from ShowAddCatalogFormAction action"); return SUCCESS; } === modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java 2012-06-27 06:56:57 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java 2012-07-21 10:27:27 +0000 @@ -613,7 +613,6 @@ } else if( ccemReport.getReportType().equals( CCEMReport.VACCINE_STORAGE_CAPACITY ) ) { - ccemReportOutput = new CCEMReportOutput(); List tableHeadings = new ArrayList(); List> tableSubHeadings = new ArrayList>(); @@ -745,18 +744,24 @@ String vsReqCatalogAttribIds = catalogDataParts[5]; Integer vsReqPackedVol = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[0] ); - Integer vsReqDoses = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[1] ); - Integer vsReqTargetPopCat= Integer.parseInt( vsReqCatalogAttribIds.split( "," )[2] ); - Integer vsReqUsage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[3] ); - Integer vsReqWastage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[4] ); + Integer vsReqDiluentVol = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[1] ); + Integer vsReqDoses = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[2] ); + Integer vsReqTargetPopCat= Integer.parseInt( vsReqCatalogAttribIds.split( "," )[3] ); + Integer vsReqUsage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[4] ); + Integer vsReqWastage = Integer.parseInt( vsReqCatalogAttribIds.split( "," )[5] ); List catalogIdsForRequirement = new ArrayList( ccemReportManager.getCatalogIdsForRequirement( vsReqCatalogTypeId, vsReqStorageTempId, vsReqStorageTemp, vsReqNationalSupplyId, vsReqNationalSupply ) ); Map catalogDataForRequirement = new HashMap( ccemReportManager.getCatalogDataForRequirement( vsReqCatalogTypeId, vsReqStorageTempId, vsReqStorageTemp, vsReqNationalSupplyId, vsReqNationalSupply, vsReqCatalogAttribIds ) ); + Integer vsReqStaticDel = Integer.parseInt( partsOfCellContent[3].split( "," )[0] ); + Integer vsReqOutReachDel = Integer.parseInt( partsOfCellContent[3].split( "," )[1] ); + + String catalogOption_DataelementIds = vsReqStaticDel +"," + vsReqOutReachDel; + String[] dataelementDataParts = partsOfCellContent[1].split( "," ); Map catalogOption_DataelementMap = new HashMap(); - String catalogOption_DataelementIds = "-1"; + for( String de_catalogOption : dataelementDataParts ) { @@ -877,6 +882,27 @@ } } + String tempStr1 = dataElementDataForRequirement.get( vsReqStaticDel+":"+periodId+":"+orgUnit.getId() ); + String tempStr2 = dataElementDataForRequirement.get( vsReqOutReachDel+":"+periodId+":"+orgUnit.getId() ); + if( (tempStr1 != null && tempStr1.equalsIgnoreCase( "true" )) || (tempStr2 != null && tempStr2.equalsIgnoreCase( "true" )) ) + { + Double vsReqDiluentVolData = 0.0; + tempStr = catalogDataForRequirement.get( catalogId+":"+vsReqDiluentVol ); + if( tempStr != null ) + { + try + { + vsReqDiluentVolData = Double.parseDouble( tempStr ); + } + catch( Exception e ) + { + vsReqDiluentVolData = 0.0; + } + } + + vsReqPackedVolData += vsReqDiluentVolData; + } + Double vsReqWastageData = 0.0; tempStr = catalogDataForRequirement.get( catalogId+":"+vsReqWastage ); if( tempStr != null ) === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-06-14 05:58:42 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-07-21 10:27:27 +0000 @@ -39,7 +39,7 @@ $i18n.getString( 'upload_image' ) $i18n.getString( 'edit' ) $i18n.getString( - + $i18n.getString( 'design_data_entry_form' ) $i18n.getString( 'show_details' ) === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-06-27 06:56:57 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-07-21 10:27:27 +0000 @@ -445,7 +445,7 @@ $.ajax({ type: "POST", url: 'addCatalog.action', - data: getParamsForDiv('addCatalogFormDiv'), + data: getParamsForDiv('addEditCatalogFormDiv'), success: function(json) { var type = json.response; jQuery('#resultSearchDiv').dialog('close'); === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js 2012-06-14 05:58:42 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js 2012-07-21 10:27:27 +0000 @@ -71,7 +71,8 @@ var catalogTypeAttributevalueType = catalogTypeAttribute.valueType; var htmlCode = ""; - var id = catalogTypeId + "-" + catalogTypeAttributeId + "-val" ; + //var id = catalogTypeId + "-" + catalogTypeAttributeId + "-val" ; + var id = "attr"+catalogTypeAttributeId; if ( catalogTypeAttributevalueType == "YES/NO" ) { @@ -90,9 +91,7 @@ var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName +" (" + catalogTypeAttributevalueType + ") --"; var displayName = catalogTypeAttributeName; htmlCode += ""; - } - - + } else if ( catalogTypeAttributevalueType == "COMBO" ) { var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName +" (" + catalogTypeAttributevalueType + ") --"; === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 2012-06-26 08:38:56 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 2012-07-21 10:27:27 +0000 @@ -43,7 +43,27 @@ $i18n.getString( "catalogType" ) : $catalogType.name - + + + + + + + + + + + + + +
 
+#if( $isCustom ) + + $customDataEntryFormCode + +#else + +
@@ -52,7 +72,7 @@
$i18n.getString( "catalogType_details" )
#if ( $catalogTypeAttributes.size() > 0) - + #foreach($attribute in $catalogTypeAttributes ) @@ -98,15 +118,19 @@
 
  - +
+
+ +#end

+