← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1308: Improved copy function in Excel Reporting module:

 

------------------------------------------------------------
revno: 1308
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-01-18 10:21:24 +0700
message:
  Improved copy function in Excel Reporting module:
  + Do not allow to copy the duplicated item(s) in ExcelItems
  + Refined some of GUI files
modified:
  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/struts.xml
  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/javascript/excelitems.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


--
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/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	2010-01-12 06:00:44 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties	2010-01-18 03:21:24 +0000
@@ -163,12 +163,12 @@
 choose_excelItem			= Xin ch\u1ecdn c\u00e1c gi\u00e1 tr\u1ecb c\u1ea7n import
 please_enter_sheet_no		= Vui l\u00f2ng nh\u1eadp 'Sheet No'
 please_enter_group_name		= Vui l\u00f2ng nh\u1eadp t\u00ean nh\u00f3m
-copy_items_duplicated       = ReportItem b\u1ecb tr\u00f9ng l\u1eb7p, kh\u00f4ng th\u1ec3 sao ch\u00e9p !
+copy_items_duplicated       = Item b\u1ecb tr\u00f9ng l\u1eb7p, kh\u00f4ng th\u1ec3 sao ch\u00e9p !
 copy_successful             = Sao ch\u00e9p th\u00e0nh c\u00f4ng !
 filter_by_name				= T\u00ecm theo t\u00ean
 copy_selected_item_to_excel_item = Sao ch\u00e9p report item cho excel item
 excelitem_group				= Nh\u00f3m excel item
-edit						= HI\u1ec7u ch\u1ec9nh
+edit						= Hi\u1ec7u ch\u1ec9nh
 copy_items					= Sao ch\u00e9p item
 period_type					= Lo\u1ea1i th\u1eddi \u0111i\u1ec3m
 import_data					= Import d\u1eef li\u1ec7u
@@ -178,4 +178,7 @@
 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_item						= Kh\u00f4ng c\u00f3 ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn
\ No newline at end of file
+no_item						= Kh\u00f4ng c\u00f3 ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn
+input_sheet_no				= Ch\u01b0a nh\u1eadp sheet
+choose_excel_group          = Ch\u01b0a ch\u1ecdn nh\u00f3m
+choose_report               = Ch\u01b0a ch\u1ecdn b\u00e1o c\u00e1o
\ 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	2010-01-12 06:00:44 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2010-01-18 03:21:24 +0000
@@ -343,7 +343,6 @@
 			<param name="menu">/dhis-web-excel-reporting/menu.vm</param>
 			<param name="javascripts">
 				javascript/reportItem.js,
-				javascript/excelitems.js,
 				javascript/dataelement.js,
 				javascript/jquery.autocomplete.js,
 				javascript/commons.js

=== 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	2010-01-12 06:16:58 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm	2010-01-18 03:21:24 +0000
@@ -26,7 +26,7 @@
 	#set( $mark = false )
 	#foreach($excelItem in $excelItems)
 		<tr #alternate( $mark )>
-		  	<td><input type="checkbox" id="excelItemChecked" name="excelItemChecked" value='$excelItem.id'></td>
+		  	<td><input type="checkbox" excelItemID="$excelItem.id" excelItemName="$excelItem.name" id="excelItemChecked" name="excelItemChecked" value='$excelItem.id'></td>
 			<td>$encoder.htmlEncode( $excelItem.name )</td>
 			<td>$excelItem.sheetNo</td>
 			<td>$excelItem.row</td>
@@ -156,7 +156,16 @@
 	</tr>	
 </table>
 <p align="center">
-<input type="button" value="$i18n.getString('ok')" onclick="saveCopyExcelItemsToGroup();"/>
+<input type="button" value="$i18n.getString('ok')" onclick="validateCopyExcelItemsToExcelItemGroup();"/>
 <input type="button" value="$i18n.getString('cancel')" onclick="hideById('copyTo'); deleteDivEffect();"/>
 </p>
-</div>
\ No newline at end of file
+</div>
+
+<script type="text/javascript">
+    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 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>
\ 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	2010-01-12 06:16:58 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js	2010-01-18 03:21:24 +0000
@@ -270,48 +270,46 @@
 	byId( target ).value += value;
 }
 
-// ===============================================================================
-// Copy selected items Form
-// ===============================================================================
-
-function copySelectedExcelItemForm() {
-	
-	var request = new Request();
-    request.setResponseTypeXML( 'xmlObject' );
-    request.setCallbackSuccess( copySelectedExcelItemFormReceived);
-	request.send( "getAllExcelItemGroup.action" );
-}
-
-function copySelectedExcelItemFormReceived( xmlObject ) {
-	
-	var groups = xmlObject.getElementsByTagName("excelitemgroup");
-	var selectList = document.getElementById("targetExcelItemGroup");
-	var options = selectList.options;
-	
-	options.length = 0;
-	
-	for( var i = 0 ; i < groups.length ; i++ ) {
-	
-		var id = groups[i].getElementsByTagName("id")[0].firstChild.nodeValue;
-		var name = groups[i].getElementsByTagName("name")[0].firstChild.nodeValue;
-		options.add(new Option(name,id), null);
-	}
-	
-	$("#copyToExcelItem").showAtCenter( true );
-}
-
-// ===============================================================================
-// Validate copy Excel Items
-// ===============================================================================
+// -----------------------------------------------------------------------
+// SAVE COPY EXCEL ITEM(s) TO EXCEL_ITEM_GROUP
+// -----------------------------------------------------------------------
 
 sheetId = 0;
-reportItemIds = null;
+noItemsChecked = 0;
+ExcelItemsSaved = null;
 excelItemsCurTarget = null;
 excelItemsDuplicated = null;
 
-function validateCopyExcelItems() {
-
-	sheetId	= byId("targetExcelItemGroupSheetNo").value;
+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 );
+}
+
+function validateCopyExcelItemsToExcelItemGroup() {
+
+	sheetId	= byId("targetSheetNo").value;
 	
 	var message = '';
 	
@@ -320,7 +318,7 @@
 		message = i18n_input_sheet_no;
 	}
 	
-	if ( byId("targetExcelItemGroup").value == -1 )
+	if ( byId("targetGroup").value == -1 )
 	{
 		message += "<br/>" + i18n_choose_report;
 	}
@@ -339,12 +337,12 @@
 	
 	var request = new Request();
     request.setResponseTypeXML( 'xmlObject' );
-    request.setCallbackSuccess( validateCopyExcelItemsReceived );
-	request.send( "getExcelItemsByGroup.action?excelItemGroupId=" + byId("targetExcelItemGroup").value + "&sheetNo=" + sheetId);
+    request.setCallbackSuccess( validateCopyExcelItemsToExcelItemGroupReceived );
+	request.send( "getExcelItemsByGroup.action?excelItemGroupId=" + byId("targetGroup").value );
 	
 }
 
-function validateCopyExcelItemsReceived(xmlObject){
+function validateCopyExcelItemsToExcelItemGroupReceived( xmlObject ) {
 	
 	var items = xmlObject.getElementsByTagName('excelitem');
 	
@@ -353,61 +351,60 @@
 		excelItemsCurTarget.push(items[i].getElementsByTagName('name')[0].firstChild.nodeValue);
 	}
 	
-	splitDuplicatedItems();
+	splitDuplicatedExcelItems( 'excelItemChecked', 'excelItemID', 'excelItemName' );
 	
-	saveCopyExcelItems();
+	saveCopiedExcelItemsToExcelItemGroup();
 }
 
-function splitDuplicatedItems() {
+function splitDuplicatedExcelItems( itemCheckID, itemIDAttribute, itemNameAttribute ) {
 
 	var flag = -1;
-	var reportItemsChecked = new Array();
-	var listRadio = document.getElementsByName('reportItemCheck');
-	
-	reportItemIds = null;
-	reportItemIds = new Array();
+	var itemsChecked = new Array();
+	var listRadio = document.getElementsByName( itemCheckID );
+
+	ExcelItemsSaved = null;
+	ExcelItemsSaved = 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"));
+			itemsChecked.push( listRadio.item(i).getAttribute(itemIDAttribute) + "#" + listRadio.item(i).getAttribute(itemNameAttribute));
 		}
 	}
 	
-	iReportItemsChecked = reportItemsChecked.length;
+	noItemsChecked = itemsChecked.length;
 	
-	for (var i in reportItemsChecked)
+	for (var i in itemsChecked)
 	{
 		flag = i;
 		
 		for (var j in excelItemsCurTarget)
 		{
-			if ( reportItemsChecked[i].split("#")[1] == excelItemsCurTarget[j] )
+			if ( itemsChecked[i].split("#")[1] == excelItemsCurTarget[j] )
 			{
 				flag = -1;
-				excelItemsDuplicated.push( reportItemsChecked[i].split("#")[1] );
+				excelItemsDuplicated.push( itemsChecked[i].split("#")[1] );
 				break;
 			}
 		}
-		
 		if ( flag >= 0 )
 		{
-			reportItemIds.push( reportItemsChecked[i].split("#")[0] );
+			ExcelItemsSaved.push( itemsChecked[i].split("#")[0] );
 		}
 	}
 }
 
 warningMessages = "";
 
-function saveCopyExcelItems() {
-	
-	warningMessages = " ======= Sheet [" + sheetId + "] =======<br/>";
-	
+function saveCopiedExcelItemsToExcelItemGroup() {
+	
+	warningMessages = "";
 	// If have ReportItem(s) in Duplicating list
 	// preparing the warning message
 	if ( excelItemsDuplicated.length > 0 ) {
 
 		warningMessages += 
-		"<b>[" + (excelItemsDuplicated.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+		"<b>[" + (excelItemsDuplicated.length) + "/" + (noItemsChecked) + "]</b>:: "
 		+ i18n_copy_items_duplicated
 		+ "<br/><br/>";
 		
@@ -419,27 +416,27 @@
 			+ "<br/><br/>";
 		}
 		
-		warningMessages += "======================<br/><br/>";
+		warningMessages += "<br/>";
 	}
 	
 	// If have also ReportItem(s) in Copying list
 	// do copy and prepare the message notes
-	if ( reportItemIds.length > 0 ) {
+	if ( ExcelItemsSaved.length > 0 ) {
 	
 		var request = new Request();
 		request.setResponseTypeXML( 'xmlObject' );
-		request.setCallbackSuccess( saveCopyExcelItemsReceived );	
+		request.setCallbackSuccess( saveCopiedExcelItemsToExcelItemGroupReceived );	
 		
-		var params = "excelItemGroupId=" + byId("targetExcelItemGroup").value;
+		var params = "excelItemGroupDestId=" + byId("targetGroup").value;
 			params += "&sheetNo=" + sheetId;
 			
-		for (var i in reportItemIds)
+		for (var i in ExcelItemsSaved)
 		{
-			params += "&reportItemIds=" + reportItemIds[i];
+			params += "&itemIds=" + ExcelItemsSaved[i];
 		}
 			
 		request.sendAsPost(params);
-		request.send( "copyExcelItems.action");
+		request.send( "copyExcelItemsToGroup.action");
 	}
 	// If have no any ReportItem(s) will be copied
 	// and also have ReportItem(s) in Duplicating list
@@ -448,110 +445,32 @@
 		setMessage( warningMessages );
 	}
 		
-	hideById("copyToExcelItem");
+	hideById("copyTo");
 	deleteDivEffect();
 }
 
-function saveCopyExcelItemsReceived( data ) {
+function saveCopiedExcelItemsToExcelItemGroupReceived( data ) {
 	
 	var type = data.getAttribute("type");
 	
 	if ( type == "success" ) {
-		//alert(warningMessages);
+	
 		warningMessages +=
-		"<br/><b>[" + (reportItemIds.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+		" ======= Sheet [" + sheetId + "] ========"
+		+ "<br/><b>[" + (ExcelItemsSaved.length) + "/" + (noItemsChecked) + "]</b>:: "
 		+ i18n_copy_successful
 		+ "<br/>======================<br/><br/>";
-		
-		
+
 	}
 	
 	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<list.length; i++)
-		{
-			if(list.item(i).checked){
-				params += "&itemIds=" + list.item(i).value;
-			}
-		}
-			
-		request.sendAsPost(params);
-		request.send( "copyExcelItemsToGroup.action");
-	}
-	// If have no any ReportItem(s) will be copied
-	// and also have ReportItem(s) in Duplicating list
-	else {
-
-		setMessage( no_item );
-	}
-	
-}
-
-function saveCopyExcelItemsToGroupReceived( data ) {
-	
-	setMessage( data.firstChild.nodeValue );
-	
-	hideById("copyTo");
-	deleteDivEffect();
-	
-}
-
 // ----------------------------------------------------
 // Select Items ALL
 // ----------------------------------------------------
 
-function selectedItemsAll(){
+function selectedItemsAll() {
     
 	var checked = byId('checkAll').checked;
 	

=== 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-16 03:37:57 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js	2010-01-18 03:21:24 +0000
@@ -216,19 +216,20 @@
 	}
 }
 
-/*
-*	COPY REPORT ITEM 
+/**
+*	COPY REPORT ITEM(s) TO ANOTHER REPORTEXCEL
 */
-function copySelectedItem() {
+//function copySelectedItem() {
+function copySelectedReportItemToReport() {
 	
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
-	request.setCallbackSuccess( copySelectedItemReceived );
+	request.setCallbackSuccess( copySelectedReportItemToReportReceived );
 	request.send( "getAllReportExcels.action" );
 
 }
 
-function copySelectedItemReceived( xmlObject ) {
+function copySelectedReportItemToReportReceived( xmlObject ) {
 
 	var reports = xmlObject.getElementsByTagName("report");
 	var selectList = document.getElementById("targetReport");
@@ -248,16 +249,16 @@
 
 
 /*
-*	Validate Copy Report Items
+*	Validate Copy Report Items to another ReportExcel
 */
 
 sheetId = 0;
-iReportItemsChecked = 0;
-reportItems = null;
-reportItemsCurTarget = null;
-reportItemsDuplicated = null;
+NoItemsChecked = 0;
+ItemsSaved = null;
+itemsCurTarget = null;
+itemsDuplicated = null;
 
-function validateCopyReportItems() {
+function validateCopyReportItemsToReportExcel() {
 
 	sheetId	= byId( "targetSheetNo" ).value;
 	
@@ -265,12 +266,12 @@
 	
 	if ( sheetId < 1 ) {
 	
-		message = input_sheet_no;
+		message = i18n_input_sheet_no;
 	}
 	
 	if ( byId("targetReport").value == -1 )
 	{
-		message += "<br/>"+ choose_report;
+		message += "<br/>"+ i18n_choose_report;
 	}
 	
 	if ( message.length > 0 )
@@ -279,15 +280,15 @@
 		return;
 	}
 	
-	reportItemsCurTarget = null;
-	reportItemsDuplicated = null;
+	itemsCurTarget = null;
+	itemsDuplicated = null;
 	
-	reportItemsCurTarget = new Array();
-	reportItemsDuplicated = new Array();
+	itemsCurTarget = new Array();
+	itemsDuplicated = new Array();
 
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
-	request.setCallbackSuccess( validateCopyReportItemsReceived );
+	request.setCallbackSuccess( validateCopyReportItemsToReportExcelReceived );
 	
 	var param = "reportId=" + byId("targetReport").value;
 		param += "&sheetNo=" + sheetId;
@@ -297,76 +298,77 @@
 	
 }
 
-function validateCopyReportItemsReceived( data ) {
+function validateCopyReportItemsToReportExcelReceived( data ) {
 
 	var items = data.getElementsByTagName('reportItem');
 		
 	for (var i = 0 ; i < items.length ; i ++) 
 	{
-		reportItemsCurTarget.push(items[i].getElementsByTagName('name')[0].firstChild.nodeValue);
+		itemsCurTarget.push(items[i].getElementsByTagName('name')[0].firstChild.nodeValue);
 	}
 	
-	splitDuplicatedReportItems();
-	saveCopyItems();
+	splitDuplicatedItems( 'reportItemCheck', 'reportItemID', 'reportItemName' );
+	saveCopyReportItemsToReportExcel();
 }
 
-
-function splitDuplicatedReportItems() {
+function splitDuplicatedItems( itemCheckID, itemIDAttribute, itemNameAttribute ) {
 
 	var flag = -1;
-	var reportItemsChecked = new Array();
-	var listRadio = document.getElementsByName( 'reportItemCheck' );
+	var itemsChecked = new Array();
+	//var listRadio = document.getElementsByName( 'reportItemCheck' );
+	var listRadio = document.getElementsByName( itemCheckID );
 
-	reportItems = null;
-	reportItems = new Array();
+	ItemsSaved = null;
+	ItemsSaved = 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"));
+			//itemsChecked.push( listRadio.item(i).getAttribute("reportItemID") + "#" + listRadio.item(i).getAttribute("reportItemName"));
+			itemsChecked.push( listRadio.item(i).getAttribute(itemIDAttribute) + "#" + listRadio.item(i).getAttribute(itemNameAttribute));
 		}
 	}
 	
-	iReportItemsChecked = reportItemsChecked.length;
+	NoItemsChecked = itemsChecked.length;
 	
-	for (var i in reportItemsChecked)
+	for (var i in itemsChecked)
 	{
 		flag = i;
 		
-		for (var j in reportItemsCurTarget)
+		for (var j in itemsCurTarget)
 		{
-			if ( reportItemsChecked[i].split("#")[1] == reportItemsCurTarget[j] )
+			if ( itemsChecked[i].split("#")[1] == itemsCurTarget[j] )
 			{
 				flag = -1;
-				reportItemsDuplicated.push( reportItemsChecked[i].split("#")[1] );
+				itemsDuplicated.push( itemsChecked[i].split("#")[1] );
 				break;
 			}
 		}
 		if ( flag >= 0 )
 		{
-			reportItems.push( reportItemsChecked[i].split("#")[0] );
+			ItemsSaved.push( itemsChecked[i].split("#")[0] );
 		}
 	}
 }
 
-function saveCopyItems() {
+function saveCopyReportItemsToReportExcel() {
 	
 	var warningMessage = " ======= Sheet [" + sheetId + "] =======<br/>";
 	
 	// If have ReportItem(s) in Duplicating list
 	// preparing the warning message
-	if ( reportItemsDuplicated.length > 0 ) {
+	if ( itemsDuplicated.length > 0 ) {
 
 		warningMessage += 
-		"<b>[" + (reportItemsDuplicated.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+		"<b>[" + (itemsDuplicated.length) + "/" + (NoItemsChecked) + "]</b>:: "
 		+ i18n_copy_items_duplicated
 		+ "<br/><br/>";
 		
-		for (var i in reportItemsDuplicated) {
+		for (var i in itemsDuplicated) {
 		
 			warningMessage +=
 			"<b>(*)</b> "
-			+ reportItemsDuplicated[i] 
+			+ itemsDuplicated[i] 
 			+ "<br/><br/>";
 		}
 		
@@ -375,13 +377,13 @@
 	
 	// If have also ReportItem(s) in Copying list
 	// do copy and prepare the message notes
-	if ( reportItems.length > 0 ) {
+	if ( ItemsSaved.length > 0 ) {
 	
 		$.post("copyReportExcelItems.action",
 		{
 			reportId:$("#targetReport").val(),
 			sheetNo:sheetId,
-			reportItems:reportItems
+			reportItems:ItemsSaved
 		},
 		function (data)
 		{
@@ -391,7 +393,7 @@
 			if ( type == "success" ) {
 				
 				warningMessage +=
-				"<br/><b>[" + (reportItems.length) + "/" + (iReportItemsChecked) + "]</b>:: "
+				"<br/><b>[" + (ItemsSaved.length) + "/" + (NoItemsChecked) + "]</b>:: "
 				+ i18n_copy_successful
 				+ "<br/>======================<br/><br/>";
 			}
@@ -402,7 +404,7 @@
 	}
 	// If have no any ReportItem(s) will be copied
 	// and also have ReportItem(s) in Duplicating list
-	else if ( reportItemsDuplicated.length > 0 ) {
+	else if ( itemsDuplicated.length > 0 ) {
 
 		setMessage( warningMessage );
 	}
@@ -412,6 +414,165 @@
 }
 
 
+/** 
+*	COPY SELECTED REPORTITEM(s) TO EXCEL_ITEM_GROUP
+*/
+
+//function copySelectedExcelItemForm() {
+function copySelectedReportItemToExcelItemGroup() {
+	
+	var request = new Request();
+    request.setResponseTypeXML( 'xmlObject' );
+    request.setCallbackSuccess( copySelectedReportItemToExcelItemGroupReceived );
+	request.send( "getAllExcelItemGroup.action" );
+}
+
+function copySelectedReportItemToExcelItemGroupReceived( xmlObject ) {
+	
+	var groups = xmlObject.getElementsByTagName("excelitemgroup");
+	var selectList = document.getElementById("targetExcelItemGroup");
+	var options = selectList.options;
+	
+	options.length = 0;
+	
+	for( var i = 0 ; i < groups.length ; i++ ) {
+	
+		var id = groups[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+		var name = groups[i].getElementsByTagName("name")[0].firstChild.nodeValue;
+		options.add(new Option(name,id), null);
+	}
+	
+	$("#copyToExcelItem").showAtCenter( true );
+}
+
+/*
+*	Validate copy Report Items to Excel Item Group
+*/
+
+//function validateCopyExcelItems() {
+function validateCopyReportItemsToExcelItemGroup() {
+
+	sheetId	= byId("targetExcelItemGroupSheetNo").value;
+	
+	var message = '';
+	
+	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;
+	}
+	
+	itemsCurTarget = null;
+	itemsDuplicated = null;
+	
+	itemsCurTarget = new Array();
+	itemsDuplicated = new Array();
+	
+	var request = new Request();
+    request.setResponseTypeXML( 'xmlObject' );
+    request.setCallbackSuccess( validateCopyReportItemsToExcelItemGroupReceived );
+	request.send( "getExcelItemsByGroup.action?excelItemGroupId=" + byId("targetExcelItemGroup").value );
+	
+}
+
+function validateCopyReportItemsToExcelItemGroupReceived( xmlObject ) {
+	
+	var items = xmlObject.getElementsByTagName('excelitem');
+	
+	for (var i = 0 ;  i < items.length ; i ++) {
+	
+		itemsCurTarget.push(items[i].getElementsByTagName('name')[0].firstChild.nodeValue);
+	}
+	
+	splitDuplicatedItems( 'reportItemCheck', 'reportItemID', 'reportItemName' );
+	
+	saveCopiedReportItemsToExcelItemGroup();
+}
+
+warningMessages = "";
+
+function saveCopiedReportItemsToExcelItemGroup() {
+	
+	warningMessages = "";
+	
+	// If have ReportItem(s) in Duplicating list
+	// preparing the warning message
+	if ( itemsDuplicated.length > 0 ) {
+
+		warningMessages += 
+		"<b>[" + (itemsDuplicated.length) + "/" + (NoItemsChecked) + "]</b>:: "
+		+ i18n_copy_items_duplicated
+		+ "<br/><br/>";
+		
+		for (var i in itemsDuplicated) {
+		
+			warningMessages +=
+			"<b>(*)</b> "
+			+ itemsDuplicated[i] 
+			+ "<br/><br/>";
+		}
+		
+		warningMessages += "<br/>";
+	}
+	
+	// If have also ReportItem(s) in Copying list
+	// do copy and prepare the message notes
+	if ( ItemsSaved.length > 0 ) {
+	
+		var request = new Request();
+		request.setResponseTypeXML( 'xmlObject' );
+		request.setCallbackSuccess( saveCopyExcelItemsReceived );	
+		
+		var params = "excelItemGroupId=" + byId("targetExcelItemGroup").value;
+			params += "&sheetNo=" + sheetId;
+			
+		for (var i in ItemsSaved)
+		{
+			params += "&reportItemIds=" + ItemsSaved[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 ( itemsDuplicated.length > 0 ) {
+
+		setMessage( warningMessages );
+	}
+		
+	hideById("copyToExcelItem");
+	deleteDivEffect();
+}
+
+function saveCopyExcelItemsReceived( data ) {
+	
+	var type = data.getAttribute("type");
+	
+	if ( type == "success" ) {
+	
+		warningMessages +=
+		" ======= Sheet [" + sheetId + "] ========"
+		+ "<br/><b>[" + (ItemsSaved.length) + "/" + (NoItemsChecked) + "]</b>:: "
+		+ i18n_copy_successful
+		+ "<br/>======================<br/><br/>";
+		
+	}
+	
+	setMessage( warningMessages );
+}
+
+
 /**
 * 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-16 05:19:41 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm	2010-01-18 03:21:24 +0000
@@ -15,8 +15,8 @@
 <td align="right">		
 	<input type="button" onclick="openAddReportItemForm()" value="$i18n.getString('add')" style="width:150px"/><br>
 	<input type="button" onclick="window.location='listReportExcel.action'" value="$i18n.getString('cancel')" style="width:150px"/><br>
-	<input type="button" onclick="copySelectedItem()" value="$i18n.getString('copy_selected_item_to')" style="width:150px"/><br>
-	<input type="button" onclick="copySelectedExcelItemForm()" value="$i18n.getString('copy_selected_item_to_excel_item')" style="width:150px"/>
+	<input type="button" onclick="copySelectedReportItemToReport()" value="$i18n.getString('copy_selected_item_to')" style="width:150px"/><br>
+	<input type="button" onclick="copySelectedReportItemToExcelItemGroup()" value="$i18n.getString('copy_selected_item_to_excel_item')" style="width:150px"/>
 </td>
 </tr>
 </table>
@@ -319,7 +319,7 @@
 	</tr>	
 </table>
 <p align="center">
-<input type="button" value="$i18n.getString('ok')" onclick="javascript: validateCopyReportItems(); " style="width:100px"/>
+<input type="button" value="$i18n.getString('ok')" onclick="javascript: validateCopyReportItemsToReportExcel(); " style="width:100px"/>
 <input type="button" value="$i18n.getString('cancel')" onclick="hideById('copyTo');deleteDivEffect();" style="width:100px"/>
 </p>
 </div>
@@ -340,7 +340,7 @@
 	</tr>	
 </table>
 <p align="center">
-<input type="button" value="$i18n.getString('ok')" onclick="validateCopyExcelItems();" style="width:100px"/>
+<input type="button" value="$i18n.getString('ok')" onclick="validateCopyReportItemsToExcelItemGroup();" style="width:100px"/>
 <input type="button" value="$i18n.getString('cancel')" onclick="hideById('copyToExcelItem'); deleteDivEffect();" style="width:100px"/>
 </p>
 </div>
@@ -349,7 +349,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>