=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java 2009-11-30 04:26:38 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectFormAction.java 2009-12-04 09:37:23 +0000 @@ -27,17 +27,22 @@ package org.hisp.dhis.reportexcel.export.action; import java.io.File; +import java.io.FileInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.period.MonthlyPeriodType; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportexcel.ReportExcelService; +import org.hisp.dhis.reportexcel.ReportLocationManager; import org.hisp.dhis.reportexcel.period.db.PeriodDatabaseService; import org.hisp.dhis.system.util.CodecUtils; @@ -53,19 +58,41 @@ implements Action { - // ------------------------------------------- + // ------------------------------------------------------------------------- // Dependency - // ------------------------------------------- - - private OrganisationUnitSelectionManager organisationUnitSelectionManager; + // ------------------------------------------------------------------------- private ReportExcelService reportService; + public void setReportService( ReportExcelService reportService ) + { + this.reportService = reportService; + } + + private ReportLocationManager reportLocationManager; + + public void setReportLocationManager( ReportLocationManager reportLocationManager ) + { + this.reportLocationManager = reportLocationManager; + } + private PeriodDatabaseService periodDatabaseService; - // ------------------------------------------- + public void setPeriodDatabaseService( PeriodDatabaseService periodDatabaseService ) + { + this.periodDatabaseService = periodDatabaseService; + } + + private OrganisationUnitSelectionManager organisationUnitSelectionManager; + + public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) + { + this.organisationUnitSelectionManager = organisationUnitSelectionManager; + } + + // ------------------------------------------------------------------------- // Input & Output - // ------------------------------------------- + // ------------------------------------------------------------------------- private List periods; @@ -77,22 +104,23 @@ private Integer reportId; + private HSSFWorkbook templateWorkbook; + + private FileInputStream inputStreamExcelTemplate; + + private Map mapSheets = new HashMap(); + private Collection collectSheets = new HashSet(); - // ------------------------------------------- + // ------------------------------------------------------------------------- // Getter & Setter - // ------------------------------------------- + // ------------------------------------------------------------------------- public List getGroups() { return groups; } - public void setPeriodDatabaseService( PeriodDatabaseService periodDatabaseService ) - { - this.periodDatabaseService = periodDatabaseService; - } - public OrganisationUnit getOrganisationUnit() { return organisationUnit; @@ -123,9 +151,9 @@ return collectSheets; } - public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) + public Map getMapSheets() { - this.organisationUnitSelectionManager = organisationUnitSelectionManager; + return mapSheets; } public List getPeriods() @@ -133,11 +161,6 @@ return periods; } - public void setReportService( ReportExcelService reportService ) - { - this.reportService = reportService; - } - private File fileExcel; public File getFileExcel() @@ -168,6 +191,10 @@ Collections.sort( groups ); + // --------------------------------------------------------------------- + // Processing Tabs for Previewing excel report + // --------------------------------------------------------------------- + if ( reportGroup != null ) { reportGroup = CodecUtils.unescape( reportGroup ); @@ -175,13 +202,25 @@ if ( reportId != null ) { + inputStreamExcelTemplate = new FileInputStream( reportLocationManager.getReportExcelTemplateDirectory() + + File.separator + reportService.getReportExcel( reportId ).getExcelTemplateFile() ); + + templateWorkbook = new HSSFWorkbook( inputStreamExcelTemplate ); + collectSheets = reportService.getSheets( reportId ); + + for ( Integer sheetId : collectSheets ) + { + mapSheets.put( sheetId, CodecUtils.unescape( templateWorkbook.getSheetName( sheetId.intValue() ) ) ); + } } else { collectSheets.add( 0 ); + mapSheets.put( 0, "" ); } return SUCCESS; } + } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-11-30 04:26:38 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-12-04 09:37:23 +0000 @@ -376,6 +376,8 @@ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" /> + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js 2009-12-04 06:39:28 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js 2009-12-04 09:37:23 +0000 @@ -293,25 +293,33 @@ function validateCopyExcelItems() { sheetId = byId("targetExcelItemGroupSheetNo").value; + var message = ''; - if(sheetId < 1){ - message = input_sheet_no; - } - if(byId("targetExcelItemGroup").value == -1){ - message += "
"+ choose_report; - } - - if(message.length > 0){ + + if ( sheetId < 1 ) + { + message = i18n_input_sheet_no; + } + if ( byId("targetExcelItemGroup").value == -1 ) + { + message += "
" + i18n_choose_report; + } + + if ( message.length > 0 ) + { setMessage(message); return; } + excelItemsCurTarget = null; + excelItemsDuplicated = null; + excelItemsCurTarget = new Array(); excelItemsDuplicated = new Array(); var request = new Request(); request.setResponseTypeXML( 'xmlObject' ); - request.setCallbackSuccess( validateCopyExcelItemsReceived); + request.setCallbackSuccess( validateCopyExcelItemsReceived ); request.send( "getExcelItemsByGroup.action?excelItemGroupId=" + byId("targetExcelItemGroup").value + "&sheetNo=" + sheetId); } @@ -345,6 +353,8 @@ } } + iReportItemsChecked = reportItemsChecked.length; + for (var i in reportItemsChecked) { flag = i; @@ -359,53 +369,82 @@ } } - if ( flag != -1 ) + if ( flag >= 0 ) { reportItemIds.push( reportItemsChecked[i].split("#")[0] ); } } } +warningMessages = ""; + function saveCopyExcelItems() { - var excelItemsDuplicatedList = ''; - - if (excelItemsDuplicated.length > 0) { - - excelItemsDuplicatedList = "Sheet [" + sheetId + "] - " + i18n_copy_items_duplicated + "
"; + warningMessages = " ======= Sheet [" + sheetId + "] =======
"; + + // If have ReportItem(s) in Duplicating list + // preparing the warning message + if ( excelItemsDuplicated.length > 0 ) { + + warningMessages += + "[" + (excelItemsDuplicated.length) + "/" + (iReportItemsChecked) + "]:: " + + i18n_copy_items_duplicated + + "

"; for (var i in excelItemsDuplicated) { - excelItemsDuplicatedList += "   -  " + excelItemsDuplicated[i] + "
"; + warningMessages += + "(*) " + + excelItemsDuplicated[i] + + "

"; } - + + warningMessages += "======================

"; } - if (reportItemIds.length > 0) { + // If have also ReportItem(s) in Copying list + // do copy and prepare the message notes + if ( reportItemIds.length > 0 ) { var request = new Request(); - request.setResponseTypeXML( 'xmlObject' ); - var url = "copyExcelItems.action?excelItemGroupId=" + byId("targetExcelItemGroup").value; - url += "&sheetNo=" + byId('targetExcelItemGroupSheetNo').value; - - for (var i=0; i 0) - excelItemsDuplicatedList += "
==========
" + i18n_copy_successful; - else - excelItemsDuplicatedList += i18n_copy_successful; - setMessage( excelItemsDuplicatedList); - } - - $("#copyToExcelItem").hide(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( saveCopyExcelItemsReceived ); + + var params = "excelItemGroupId=" + byId("targetExcelItemGroup").value; + params += "&sheetNo=" + sheetId; + + for (var i in reportItemIds) + { + params += "&reportItemIds=" + reportItemIds[i]; + } + + request.sendAsPost(params); + request.send( "copyExcelItems.action"); + } + // If have no any ReportItem(s) will be copied + // and also have ReportItem(s) in Duplicating list + else if ( excelItemsDuplicated.length > 0 ) { + + setMessage( warningMessages ); + } + + hideById("copyToExcelItem"); deleteDivEffect(); +} + +function saveCopyExcelItemsReceived( data ) { + + var type = data.getAttribute("type"); + + if ( type == "success" ) { + //alert(warningMessages); + warningMessages += + "
[" + (reportItemIds.length) + "/" + (iReportItemsChecked) + "]:: " + + i18n_copy_successful + + "
======================

"; + + + } + + setMessage( warningMessages ); } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js 2009-12-04 06:39:28 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/individual.js 2009-12-04 09:37:23 +0000 @@ -240,13 +240,13 @@ var message = ''; if( selectedDataElements.length==0) { - message = choose_dataelement + '
'; + message = i18n_choose_dataelement + '
'; } // Check periods selectedDataElements = byId('selectedPeriods').options; if(selectedDataElements.length==0) { - message += choose_period + '
'; + message += i18n_choose_period + '
'; } if(message.length > 0 ){ === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2009-12-03 07:32:07 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2009-12-04 09:37:23 +0000 @@ -139,7 +139,7 @@ showById("tabs"); - window.status= "DATAWARE HOUSE - "+ _title; + window.status= "DATAWARE HOUSE - " + _title; window.stop(); } // END OF Previewed Report Excel // === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2009-12-04 06:39:28 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2009-12-04 09:37:23 +0000 @@ -234,19 +234,22 @@ sheetId = byId("targetSheetNo").value; var message = ''; - if(sheetId < 1){ - message = input_sheet_no; - } - if(byId("targetReport").value == -1){ - message += "
"+ choose_report; - } - - if(message.length > 0){ + + if ( sheetId < 1 ) + { + message = i18n_input_sheet_no; + } + if ( byId("targetReport").value == -1 ) + { + message += "
" + i18n_choose_report; + } + + if ( message.length > 0 ) + { setMessage(message); return; } - if(byId("targetReport").value) reportItemsCurTarget = null; reportItemsDuplicated = null; @@ -257,14 +260,17 @@ var request = new Request(); request.setResponseTypeXML( 'xmlObject' ); request.setCallbackSuccess( validateCopyReportItemsReceived ); + var param = "reportId=" + byId("targetReport").value; param += "&sheetNo=" + sheetId; + request.sendAsPost(param); request.send("getReportExcelItems.action"); } -function validateCopyReportItemsReceived(data){ +function validateCopyReportItemsReceived( data ) { + var items = data.getElementsByTagName('reportItem'); for (var i = 0 ; i < items.length ; i ++) @@ -273,6 +279,7 @@ } splitDuplicatedReportItems(); + saveCopyItems(); } @@ -287,6 +294,7 @@ reportItems = new Array(); for (var i = 0 ; i < listRadio.length ; i++) { + if ( listRadio.item(i).checked ) { reportItemsChecked.push( listRadio.item(i).getAttribute("reportItemID") + "#" + listRadio.item(i).getAttribute("reportItemName")); } @@ -314,6 +322,8 @@ } } +warningMessage = ""; + function saveCopyItems() { var warningMessage = " ======= Sheet [" + sheetId + "] =======
"; @@ -342,28 +352,21 @@ // do copy and prepare the message notes if ( reportItems.length > 0 ) { - $.post("copyReportExcelItems.action", - { - reportId:$("#targetReport").val(), - sheetNo:sheetId, - reportItems:reportItems - }, - function (data) - { - var data = data.getElementsByTagName("message")[0]; - var type = data.getAttribute("type"); - - if ( type == "success" ) { - - warningMessage += - "
[" + (reportItems.length) + "/" + (iReportItemsChecked) + "]:: " - + i18n_copy_successful - + "
======================

"; - } - - setMessage( warningMessage ); - - },'xml'); + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( saveCopyItemsReceived ); + + var params = "reportId=" + byId("targetReport").value; + params += "&sheetId=" + sheetId; + + for (var i in reportItems) + { + params += "&reportItems=" + reportItems[i]; + } + + request.sendAsPost(params); + request.send( "copyReportExcelItems.action"); + } // If have no any ReportItem(s) will be copied // and also have ReportItem(s) in Duplicating list @@ -372,10 +375,26 @@ setMessage( warningMessage ); } - $("#copyTo").hide(); + hideById("copyTo"); deleteDivEffect(); } +function saveCopyItemsReceived (message) { + + var type = message.getAttribute("type"); + + if ( type == "success" ) { + + warningMessage += + "
[" + (reportItems.length) + "/" + (iReportItemsChecked) + "]:: " + + i18n_copy_successful + + "
======================

"; + } + + setMessage( warningMessage ); + +} + /** * Open dataelement expression === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm 2009-12-04 06:39:28 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm 2009-12-04 09:37:23 +0000 @@ -344,7 +344,7 @@ var i18n_copy_successful = '$encoder.jsEscape( $i18n.getString( "copy_successful" ) , "'")'; var i18n_copy_items_duplicated = '$encoder.jsEscape( $i18n.getString( "copy_items_duplicated" ) , "'")'; var i18n_copy_items = '$encoder.jsEscape( $i18n.getString( "copy_items" ) , "'")'; - var input_sheet_no = '$encoder.jsEscape( $i18n.getString( "input_sheet_no" ) , "'")'; - var choose_report = '$encoder.jsEscape( $i18n.getString( "choose_report" ) , "'")'; - var choose_excel_group = '$encoder.jsEscape( $i18n.getString( "choose_excel_group" ) , "'")'; + var i18n_input_sheet_no = '$encoder.jsEscape( $i18n.getString( "input_sheet_no" ) , "'")'; + var i18n_choose_report = '$encoder.jsEscape( $i18n.getString( "choose_report" ) , "'")'; + var i18n_choose_excel_group = '$encoder.jsEscape( $i18n.getString( "choose_excel_group" ) , "'")'; === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm 2009-11-30 04:26:38 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm 2009-12-04 09:37:23 +0000 @@ -62,12 +62,12 @@

-