dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03463
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1164: Finally fixed ...
------------------------------------------------------------
revno: 1164
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-12-04 16:37:23 +0700
message:
Finally fixed ...
modified:
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm
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/individual.js
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/reportItem.js
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/reportparams.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 '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<Period> periods;
@@ -77,22 +104,23 @@
private Integer reportId;
+ private HSSFWorkbook templateWorkbook;
+
+ private FileInputStream inputStreamExcelTemplate;
+
+ private Map<Integer, String> mapSheets = new HashMap<Integer, String>();
+
private Collection<Integer> collectSheets = new HashSet<Integer>();
- // -------------------------------------------
+ // -------------------------------------------------------------------------
// Getter & Setter
- // -------------------------------------------
+ // -------------------------------------------------------------------------
public List<String> 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<Integer, String> getMapSheets()
{
- this.organisationUnitSelectionManager = organisationUnitSelectionManager;
+ return mapSheets;
}
public List<Period> 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" />
<property name="periodDatabaseService"
ref="org.hisp.dhis.reportexcel.period.db.PeriodDatabaseService" />
+ <property name="reportLocationManager"
+ ref="org.hisp.dhis.reportexcel.ReportLocationManager" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm 2009-12-03 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/individualReportExcel.vm 2009-12-04 09:37:23 +0000
@@ -171,7 +171,7 @@
getPeriodsByPeriodTypeName();
- var choose_period = '$encoder.jsEscape($i18n.getString( 'choose_period' ) , "'")';
- var choose_dataelement = '$encoder.jsEscape($i18n.getString( 'choose_dataelement' ) , "'")';
+ var i18n_choose_period = '$encoder.jsEscape($i18n.getString( 'choose_period' ) , "'")';
+ var i18n_choose_dataelement = '$encoder.jsEscape($i18n.getString( 'choose_dataelement' ) , "'")';
</script>
=== 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 += "<br>"+ choose_report;
- }
-
- if(message.length > 0){
+
+ if ( sheetId < 1 )
+ {
+ message = i18n_input_sheet_no;
+ }
+ if ( byId("targetExcelItemGroup").value == -1 )
+ {
+ message += "<br/>" + 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 + "<br>";
+ warningMessages = " ======= Sheet [" + sheetId + "] =======<br/>";
+
+ // If have ReportItem(s) in Duplicating list
+ // preparing the warning message
+ if ( excelItemsDuplicated.length > 0 ) {
+
+ warningMessages +=
+ "<b>[" + (excelItemsDuplicated.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+ + i18n_copy_items_duplicated
+ + "<br/><br/>";
for (var i in excelItemsDuplicated) {
- excelItemsDuplicatedList += " - " + excelItemsDuplicated[i] + "<br>";
+ warningMessages +=
+ "<b>(*)</b> "
+ + excelItemsDuplicated[i]
+ + "<br/><br/>";
}
-
+
+ warningMessages += "======================<br/><br/>";
}
- 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<reportItemIds.length; i++) {
- url += "&reportItemIds=" + reportItemIds[i];
- }
-
- request.send( url );
-
- }
-
- if(reportItemIds.length == 0){
- setMessage( excelItemsDuplicatedList );
- }else{
- if (excelItemsDuplicated.length > 0)
- excelItemsDuplicatedList += "<br>==========<br>" + 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 +=
+ "<br/><b>[" + (reportItemIds.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+ + i18n_copy_successful
+ + "<br/>======================<br/><br/>";
+
+
+ }
+
+ 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 + '<br>';
+ message = i18n_choose_dataelement + '<br/>';
}
// Check periods
selectedDataElements = byId('selectedPeriods').options;
if(selectedDataElements.length==0)
{
- message += choose_period + '<br>';
+ message += i18n_choose_period + '<br/>';
}
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 += "<br>"+ choose_report;
- }
-
- if(message.length > 0){
+
+ if ( sheetId < 1 )
+ {
+ message = i18n_input_sheet_no;
+ }
+ if ( byId("targetReport").value == -1 )
+ {
+ message += "<br/>" + 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 + "] =======<br/>";
@@ -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 +=
- "<br/><b>[" + (reportItems.length) + "/" + (iReportItemsChecked) + "]</b>:: "
- + i18n_copy_successful
- + "<br/>======================<br/><br/>";
- }
-
- 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 +=
+ "<br/><b>[" + (reportItems.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+ + i18n_copy_successful
+ + "<br/>======================<br/><br/>";
+ }
+
+ 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" ) , "'")';
</script>
=== 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 @@
</p>
<!-- Preview Report Excel -->
-<div id="tabs" style="display:none">
+<div id="tabs" style="display:true">
- #if( $!collectSheets )
+ #if( $!collectSheets && $!mapSheets )
<ul>
- #foreach( $i in $!collectSheets )
- <li><a href="#fragment-$i">Sheet $i</a></li>
+ #foreach( $i in $!collectSheets )
+ <li><a href="#fragment-$i">$!mapSheets.get($i)</a></li>
#end
</ul>