=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java 2010-01-12 06:00:44 +0000 @@ -0,0 +1,132 @@ +package org.hisp.dhis.reportexcel.excelitem.action; + +/* + * Copyright (c) 2004-2007, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; + +import org.amplecode.quick.StatementManager; +import org.hisp.dhis.reportexcel.action.ActionSupport; +import org.hisp.dhis.reportexcel.excelitem.ExcelItem; +import org.hisp.dhis.reportexcel.excelitem.ExcelItemGroup; +import org.hisp.dhis.reportexcel.excelitem.ExcelItemService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $Id$ + */ + +public class CopyExcelItemToGroupAction extends ActionSupport { + // ------------------------------------------- + // Dependency + // ------------------------------------------- + + private ExcelItemService excelItemService; + + private StatementManager statementManager; + + // ------------------------------------------- + // Input + // ------------------------------------------- + + private Integer sheetNo; + + private Collection itemIds; + + private Integer excelItemGroupDestId; + + // ------------------------------------------- + // Getter & Setter + // ------------------------------------------- + + public void setStatementManager(StatementManager statementManager) { + this.statementManager = statementManager; + } + + public void setItemIds(Collection itemIds) { + this.itemIds = itemIds; + } + + public Integer getSheetNo() { + return sheetNo; + } + + public void setExcelItemGroupDestId(Integer excelItemGroupDestId) { + this.excelItemGroupDestId = excelItemGroupDestId; + } + + public void setExcelItemService(ExcelItemService excelItemService) { + this.excelItemService = excelItemService; + } + + public void setSheetNo(Integer sheetNo) { + this.sheetNo = sheetNo; + } + + // ------------------------------------------- + // Action implementation + // ------------------------------------------- + + public String execute() throws Exception { + + statementManager.initialise(); + + ExcelItemGroup dest = excelItemService.getExcelItemGroup(excelItemGroupDestId); + + for (String itemId : itemIds) { + + ExcelItem item = excelItemService + .getExcelItem(Integer.parseInt(itemId)); + + ExcelItem excelItem = new ExcelItem(); + + excelItem.setName(item.getName()); + + excelItem.setRow(item.getRow()); + + excelItem.setColumn(item.getColumn()); + + excelItem.setExpression(item.getExpression()); + + excelItem.setSheetNo(sheetNo); + + excelItem.setExcelItemGroup(dest); + + excelItemService.addExcelItem(excelItem); + + } + + message = i18n.getString("success"); + + statementManager.destroy(); + + 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-12-18 09:27:51 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-01-12 06:00:44 +0000 @@ -1233,6 +1233,12 @@ scope="prototype"> - + + + + + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2009-12-18 09:27:51 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-01-12 06:00:44 +0000 @@ -179,4 +179,5 @@ available_dataelements = Available Data Elements value_rounded = This value maybe have been rounded level_and_orgunit_group = Level and Organisation Unit Group -levels = Level \ No newline at end of file +levels = Level +no_item = Don't have any items chosen \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2009-12-17 02:15:50 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-01-12 06:00:44 +0000 @@ -177,4 +177,5 @@ list_of_excel_items = Danh s\u00e1ch c\u00e1c excel item selected_dataelements = Ph\u1ea7n t\u1eed c\u00f3 s\u1eb5n available_dataelements = Ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn -value_rounded = Gi\u00e1 tr\u1ecb n\u00e0y c\u00f3 th\u1ec3 \u0111\u00e3 \u0111\u01b0\u1ee3c l\u00e0m tr\u00f2n \ No newline at end of file +value_rounded = Gi\u00e1 tr\u1ecb n\u00e0y c\u00f3 th\u1ec3 \u0111\u00e3 \u0111\u01b0\u1ee3c l\u00e0m tr\u00f2n +no_item = Kh\u00f4ng c\u00f3 ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2009-12-18 09:27:51 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-01-12 06:00:44 +0000 @@ -418,6 +418,13 @@ /dhis-web-excel-reporting/responseSuccess.vm F_EXCEL_REPORT_ADMINISTRATION + + + + /dhis-web-excel-reporting/responseSuccess.vm + F_COPY_EXCEL_ITEM_ADMINISTRATION + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm 2009-12-16 03:37:57 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm 2010-01-12 06:00:44 +0000 @@ -6,25 +6,27 @@ $i18n.getString( "filter_by_name" ): - - +
+
+ + - + - - + #set( $mark = false ) #foreach($excelItem in $excelItems) + @@ -41,7 +43,9 @@ #set( $mark = true ) #end #end - + +
$i18n.getString('name') $i18n.getString('sheetNo')$i18n.getString('row')$i18n.getString('row') $i18n.getString('column')$i18n.getString('expression')$i18n.getString('expression') $i18n.getString('operations')
$encoder.htmlEncode( $excelItem.name ) $excelItem.sheetNo $excelItem.row
+
\ No newline at end of file === 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-16 03:37:57 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js 2010-01-12 06:00:44 +0000 @@ -467,4 +467,86 @@ } setMessage( warningMessages ); +} + +// ----------------------------------------------------------------------- +// SAVE COPY EXCEL ITEM TO GROUP +// ----------------------------------------------------------------------- + +function copySelectedItemToGroup(){ + + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( copySelectedItemToGroupReceived ); + request.send( "getAllExcelItemGroup.action" ); + +} + +function copySelectedItemToGroupReceived( xmlObject ) { + + var reports = xmlObject.getElementsByTagName("excelitemgroup"); + var selectList = document.getElementById("targetGroup"); + var options = selectList.options; + + options.length = 0; + + for( var i = 0 ; i < reports.length ; i++ ) { + + var id = reports[i].getElementsByTagName("id")[0].firstChild.nodeValue; + var name = reports[i].getElementsByTagName("name")[0].firstChild.nodeValue; + options.add(new Option(name,id), null); + } + + $("#copyTo").showAtCenter( true ); +} + +// ----------------------------------------------------------------------- +// SAVE COPY EXCEL ITEM TO GROUP +// ----------------------------------------------------------------------- + +function saveCopyExcelItemsToGroup() { + + var list = document.getElementsByName('excelItemChecked'); + + // If have also ReportItem(s) in Copying list + // do copy and prepare the message notes + if ( list.length > 0 ) { + + var request = new Request(); + request.setResponseTypeXML( 'xmlObject' ); + request.setCallbackSuccess( saveCopyExcelItemsToGroupReceived ); + + var params = "excelItemGroupDestId=" + byId("targetGroup").value; + params += "&sheetNo=" + byId('targetSheetNo').value; + + for (var i=0 ;i