dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01938
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 634: update vn report module
------------------------------------------------------------
revno: 634
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Mon 2009-09-07 23:54:40 +0700
message:
update vn report module
removed:
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOperandList.vm
added:
local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/report/formula/action/GetOptionCombosAction.java
local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/reportitem/action/GetListSheetAction.java
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseDataElements.vm
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOptionCombo.vm
modified:
local/vn/dhis-web-vn-report/src/main/resources/META-INF/dhis/beans.xml
local/vn/dhis-web-vn-report/src/main/resources/struts.xml
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/reportItem.js
local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/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.
=== added file 'local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/report/formula/action/GetOptionCombosAction.java'
--- local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/report/formula/action/GetOptionCombosAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/report/formula/action/GetOptionCombosAction.java 2009-09-07 16:54:40 +0000
@@ -0,0 +1,134 @@
+package org.hisp.dhis.vn.report.formula.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.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
+import org.hisp.dhis.dataelement.DataElementService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Bharath Kumar
+ * @version $Id$
+ */
+public class GetOptionCombosAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
+
+ public void setDataElementCategoryOptionComboService( DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
+ {
+ this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters & Setters
+ // -------------------------------------------------------------------------
+
+ private int dataElementId;
+
+ public void setDataElementId( int dataElementId )
+ {
+ this.dataElementId = dataElementId;
+ }
+
+ private List<String> optionComboIds;
+
+ public List<String> getOptionComboIds()
+ {
+ return optionComboIds;
+ }
+
+ private List<String> optionComboNames;
+
+ public List<String> getOptionComboNames()
+ {
+ return optionComboNames;
+ }
+
+ // -------------------------------------------------------------------------
+ // Execute
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ optionComboIds = new ArrayList<String>();
+ optionComboNames = new ArrayList<String>();
+
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+
+ List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>(
+ dataElementCategoryCombo.getOptionCombos() );
+
+ Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+
+ while ( optionComboIterator.hasNext() )
+ {
+ DataElementCategoryOptionCombo optionCombo = optionComboIterator.next();
+
+ String optionComboName = dataElementCategoryOptionComboService.getOptionNames( optionCombo );
+
+ String optionComboId = String.valueOf( optionCombo.getId() );
+
+ if ( optionComboId != null )
+ {
+ if ( optionComboName == null || optionComboName.trim().length() == 0 )
+ {
+ optionComboName = DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
+ }
+ }
+
+ optionComboNames.add( optionComboName );
+
+ optionComboIds.add( String.valueOf( optionCombo.getId() ) );
+ }
+
+ return SUCCESS;
+ }
+}
=== added file 'local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/reportitem/action/GetListSheetAction.java'
--- local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/reportitem/action/GetListSheetAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/reportitem/action/GetListSheetAction.java 2009-09-07 16:54:40 +0000
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.hisp.dhis.vn.reportitem.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.vn.report.ReportExcelService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ * @version $Id$
+ */
+public class GetListSheetAction
+ implements Action
+{
+
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private ReportExcelService reportService;
+
+ // -------------------------------------------
+ // Output & Input
+ // -------------------------------------------
+
+ private List<Integer> sheets;
+
+ private Integer reportId;
+
+ // -------------------------------------------
+ // Getter & Setter
+ // -------------------------------------------
+
+ public List<Integer> getSheets()
+ {
+ return sheets;
+ }
+
+ public void setReportId( Integer reportId )
+ {
+ this.reportId = reportId;
+ }
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ public String execute()
+ throws Exception
+ {
+ sheets = new ArrayList<Integer>( reportService.getSheets( reportId ) );
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'local/vn/dhis-web-vn-report/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-web-vn-report/src/main/resources/META-INF/dhis/beans.xml 2009-09-07 07:34:18 +0000
+++ local/vn/dhis-web-vn-report/src/main/resources/META-INF/dhis/beans.xml 2009-09-07 16:54:40 +0000
@@ -179,6 +179,20 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.vn.report.formula.action.GetOptionCombosAction"
+ class="org.hisp.dhis.vn.report.formula.action.GetOptionCombosAction"
+ scope="prototype">
+ <property name="dataElementService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementService" />
+ </property>
+ <property name="dataElementCategoryOptionComboService">
+ <ref
+ bean="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService" />
+ </property>
+ </bean>
+
+
+
<bean id="org.hisp.dhis.vn.report.formula.action.GetFormulaTextAction"
class="org.hisp.dhis.vn.report.formula.action.GetFormulaTextAction"
scope="prototype">
@@ -201,6 +215,12 @@
scope="prototype">
<property name="reportService" ref="org.hisp.dhis.vn.report.ReportExcelService" />
</bean>
+
+ <bean id="org.hisp.dhis.vn.reportitem.action.GetListSheetAction"
+ class="org.hisp.dhis.vn.reportitem.action.GetListSheetAction"
+ scope="prototype">
+ <property name="reportService" ref="org.hisp.dhis.vn.report.ReportExcelService" />
+ </bean>
<!-- Export Report -->
@@ -235,7 +255,7 @@
class="org.hisp.dhis.vn.report.export.action.GetPeriodAction" scope="prototype">
<property name="selectionManager"
ref="org.hisp.dhis.vn.report.state.SelectionManager" />
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
<bean
=== modified file 'local/vn/dhis-web-vn-report/src/main/resources/struts.xml'
--- local/vn/dhis-web-vn-report/src/main/resources/struts.xml 2009-09-07 07:34:18 +0000
+++ local/vn/dhis-web-vn-report/src/main/resources/struts.xml 2009-09-07 16:54:40 +0000
@@ -167,7 +167,8 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-vn-report/reportItems.vm</param>
<param name="menu">/dhis-web-vn-report/menu.vm</param>
- <param name="javascripts">javascript/reportItem.js,javascript/dataelement.js</param>
+ <param name="javascripts">javascript/reportItem.js,javascript/dataelement.js,javascript/jquery.autocomplete.js</param>
+ <param name="stylesheets">style/jquery.autocomplete.css</param>
</action>
<action name="getReportItems"
@@ -214,10 +215,16 @@
<action name="getFilteredDataElements"
class="org.hisp.dhis.vn.report.formula.action.GetFilteredDataElementsAction">
<result name="success" type="velocity-xml">
- /dhis-web-vn-report/responseOperandList.vm</result>
+ /dhis-web-vn-report/responseDataElements.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="getOptionCombos"
+ class="org.hisp.dhis.vn.report.formula.action.GetOptionCombosAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-vn-report/responseOptionCombo.vm</result>
+ </action>
+
<action name="getFormulaText"
class="org.hisp.dhis.vn.report.formula.action.GetFormulaTextAction">
<result name="success" type="velocity-xml">
@@ -246,6 +253,15 @@
<param name="requiredAuthorities">F_ADMINISTRATIONS</param>
</action>
+ <action name="getListSheet"
+ class="org.hisp.dhis.vn.reportitem.action.GetListSheetAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-vn-report/sheets.vm
+ </result>
+ </action>
+
+
+
<!-- Export Report-->
@@ -465,12 +481,12 @@
<action name="saveReportUserRoles"
class="org.hisp.dhis.vn.admin.action.SaveReportUserRolesAction">
- <result name="success" type="chain">getAdminOptions</result>
+ <result name="success" type="chain">getAdminOptions
+ </result>
<param name="requiredAuthorities">F_ADMINISTRATIONS</param>
</action>
- <action name="openAdministrator"
- class="org.hisp.dhis.vn.admin.action.NoAction">
+ <action name="openAdministrator" class="org.hisp.dhis.vn.admin.action.NoAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-vn-report/viewAdministrator.vm</param>
<param name="menu">/dhis-web-vn-report/menu.vm</param>
=== modified file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/reportItem.js'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/reportItem.js 2009-09-07 07:34:18 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/reportItem.js 2009-09-07 16:54:40 +0000
@@ -42,126 +42,68 @@
window.location = "listReportItem.action?reportId=" + getFieldValue("reportId") + "&sheetNo=" + getFieldValue("sheetNoFilter");
}
function validateAddReportItem(){
-
- var id = getFieldValue("id");
- var name = getFieldValue("name");
- var itemType = getFieldValue("itemType");
- var periodType = getFieldValue("periodType");
- var expression = getFieldValue("expression");
- var row = getFieldValue("row");
- var column = getFieldValue("column");
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( validateAddReportItemCompleted );
- url = "validateReportItem.action";
- url += "?name=" + name;
- url += "&reportItemId=" + id;
- url += "&expression=" + expression;
- url += "&row=" + row;
- url += "&column=" + column;
- url += "&mode=" + mode;
- url += "&reportId=" + reportId;
- request.send( url );
-
-}
-
-function validateAddReportItemCompleted( xmlObject ){
- var type = xmlObject.getAttribute( 'type' );
-
- if(type=='error')
- {
- setMessage(xmlObject.firstChild.nodeValue);
- }
- if(type=='success')
- {
- if(mode=='ADD'){
- addReportItem();
- }else{
- updateReportItem();
- }
- }
-}
+
+ $.post("validateReportItem.action",{
+ name:$("#name").val(),
+ reportItemId:$("#id").val(),
+ expression:$("#expression").val(),
+ row:$("#row").val(),
+ column:$("#column").val(),
+ mode:mode,
+ reportId:reportId
+ }, function (data){
+ var xmlObject = data.getElementsByTagName('message')[0];
+ var type = xmlObject.getAttribute( 'type' );
+ if(type=='error')
+ {
+ setMessage(xmlObject.firstChild.nodeValue);
+ }
+ if(type=='success')
+ {
+ if(mode=='ADD'){
+ addReportItem();
+ }else{
+ updateReportItem();
+ }
+ }
+ },'xml');
+
+
+
+}
+
function addReportItem(){
- var name = getFieldValue("name");
- var itemType = getFieldValue("itemType");
- var periodType = getFieldValue("periodType");
- var expression = getFieldValue("expression");
- var row = getFieldValue("row");
- var column = getFieldValue("column");
- var sheetNo = getFieldValue("sheetNo");
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( addReportItemCompleted );
- url = "addReportItem.action";
- url += "?reportId=" + reportId;
- url += "&name=" + name;
- url += "&itemType=" + itemType;
- url += "&periodType=" + periodType;
- url += "&expression=" + htmlEncode(expression);
- url += "&row=" + row;
- url += "&column=" + column;
- url += "&sheetNo=" + sheetNo;
-
- request.send( url );
+ $.post("addReportItem.action",{
+ name:$("#name").val(),
+ expression:$("#expression").val(),
+ row:$("#row").val(),
+ column:$("#column").val(),
+ reportId:reportId,
+ itemType:$("#itemType").val(),
+ periodType:$("#periodType").val(),
+ sheetNo:$("#sheetNo").val()
+ }, function (data){
+ window.location.reload();
+ },'xml');
}
function updateReportItem(){
- var id = getFieldValue("id");
- var name = getFieldValue("name");
- var itemType = getFieldValue("itemType");
- var periodType = getFieldValue("periodType");
- var expression = getFieldValue("expression");
- var row = getFieldValue("row");
- var column = getFieldValue("column");
- var sheetNo = getFieldValue("sheetNo");
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( addReportItemCompleted );
- url = "updateReportItem.action";
- url += "?id=" + id;
- url += "&name=" + name;
- url += "&itemType=" + itemType;
- url += "&periodType=" + periodType;
- url += "&expression=" + expression;
- url += "&row=" + row;
- url += "&column=" + column;
- url += "&reportId=" + reportId;
- url += "&sheetNo=" + sheetNo;
-
-
- request.send( url );
-}
-
-function addReportItemCompleted( xmlObject ){
- window.location.reload();
-}
-
-
-
-
-
-function getFilteredDataElementsReceived( xmlObject )
-{
- var operandList = byId( "availableDataElements" );
-
- operandList.options.length = 0;
-
- var operands = xmlObject.getElementsByTagName( "operand" );
-
- for ( var i = 0; i < operands.length; i++)
- {
- var id = operands[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
- var elementName = operands[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
-
- var option = document.createElement( "option" );
- option.value = "[" + id + "]";
- option.text = elementName;
- operandList.add( option, null );
- }
-}
+ $.post("updateReportItem.action",{
+ id:$("#id").val(),
+ name:$("#name").val(),
+ expression:$("#expression").val(),
+ row:$("#row").val(),
+ column:$("#column").val(),
+ reportId:reportId,
+ itemType:$("#itemType").val(),
+ periodType:$("#periodType").val(),
+ sheetNo:$("#sheetNo").val()
+ }, function (data){
+ window.location.reload();
+ },'xml');
+}
+
+
function insertFormulaText(sourceId, targetId) {
$("#" + targetId).html($("#"+targetId).html() + $("#"+sourceId).val());
@@ -229,15 +171,14 @@
/**
* Calculation ReportItem type
*/
-function openCalculationExpression( reportId ){
- $("#formula").html($("#expression").val());
+function openCalculationExpression( reportId ){
+ $("#formulaCalculation").html($("#expression").val());
$.get("getReportItems.action",
{reportId:reportId},
function (data){
- var xmlObject = data.getElementsByTagName('reportItems')[0];
- var operandList = document.getElementById( "availableDataElements" );
-
- operandList.options.length = 0;
+ var xmlObject = data.getElementsByTagName('reportItems')[0];
+ var availableReportItemList = byId( "availableReportItems" );
+ availableReportItemList.options.length = 0;
var reportItems = xmlObject.getElementsByTagName( "reportItem" );
@@ -250,17 +191,18 @@
var option = document.createElement( "option" );
option.value = "[" + row + "." + column + "]";
option.text = name;
- operandList.add( option, null );
- }
-
- $("#dataElementGroup").attr("disabled", true);
- $("#availableDataElements").attr("disabled", false);
- setPositionCenter( 'normal' );
- $("#normal").show();
+ availableReportItemList.add( option, null );
+ }
+ setPositionCenter( 'calculation' );
+ $("#calculation").show();
},
'xml');
}
+function insertCalculation(){
+ $("#formulaCalculation").html($("#formulaCalculation").html() + $("#availableReportItems").val());
+}
+
/**
* DataElement Report type
*/
@@ -270,6 +212,7 @@
filterDataElements();
$("#dataElementGroup").attr("disabled", false);
$("#availableDataElements").attr("disabled", false);
+ $("#availableDataElements").change(getOptionCombos);
setPositionCenter( 'normal' );
$("#normal").show();
}
@@ -289,26 +232,54 @@
var dataElementGroupId = $("#dataElementGroup").val();
$.get("getFilteredDataElements.action",{dataElementGroupId:dataElementGroupId},
function(xmlObject){
- var xmlObject = xmlObject.getElementsByTagName('operands')[0];
- var operandList = byId( "availableDataElements" );
+ var xmlObject = xmlObject.getElementsByTagName('dataelements')[0];
+ var dataElementList = byId( "availableDataElements" );
- operandList.options.length = 0;
-
- var operands = xmlObject.getElementsByTagName( "operand" );
-
- for ( var i = 0; i < operands.length; i++)
+ dataElementList.options.length = 0;
+
+ var dataelements = xmlObject.getElementsByTagName( "dataelement" );
+
+ for ( var i = 0; i < dataelements.length; i++)
{
- var id = operands[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
- var elementName = operands[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
+ var id = dataelements[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
+ var elementName = dataelements[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
var option = document.createElement( "option" );
- option.value = "[" + id + "]";
+ option.value = id ;
option.text = elementName;
- operandList.add( option, null );
- }
- }
- ,'xml');
-}
+ dataElementList.add( option, null );
+ }
+ }
+ ,'xml');
+}
+
+function getOptionCombos(){
+ $.get("getOptionCombos.action",{dataElementId:$("#availableDataElements").val()},
+ function(xmlObject){
+ var xmlObject = xmlObject.getElementsByTagName('optionCombo')[0];
+ xmlObject = xmlObject.getElementsByTagName('categoryOptions')[0];
+ var optionComboList = byId( "optionCombos" );
+ optionComboList.options.length = 0;
+ var optionCombos = xmlObject.getElementsByTagName( "categoryOption" );
+ for ( var i = 0; i < optionCombos.length; i++)
+ {
+ var id = optionCombos[ i ].getAttribute('id');
+ var name = optionCombos[ i ].firstChild.nodeValue;
+ var option = document.createElement( "option" );
+ option.value = id ;
+ option.text = name;
+ optionComboList.add( option, null );
+ }
+
+ }
+ ,'xml');
+}
+
+function insertDataElementId(){
+ var dataElementComboId = "[" + $("#availableDataElements").val() + "." + $("#optionCombos").val() + "]";
+ $("#formula").html($("#formula").html() + dataElementComboId);
+}
+
/**
* Indicator Report item type
*/
=== modified file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/reportItems.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/reportItems.vm 2009-09-07 07:34:18 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/reportItems.vm 2009-09-07 16:54:40 +0000
@@ -69,16 +69,20 @@
<td><label>$i18n.getString('item_type')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td>
<select type="text" id="itemType" name="itemType" style="min-width:20em" onchange="selectItiemType(this.value);">
+ #if($!reportExcel.getReportType()=='category')
+ <option value='element_optioncombo'>$i18n.getString('element_optioncombo')</option>
+ <option value='icd_code'>$i18n.getString('icd_code')</option>
+ <option value='jumping_step'>$i18n.getString('jumping_step')</option>
+ <option value='rename'>$i18n.getString('rename')</option>
+ #else
<option value='calculation'>$i18n.getString('calculation')</option>
<option value='dataelement'>$i18n.getString('dataelement')</option>
- <option value='element_optioncombo'>$i18n.getString('element_optioncombo')</option>
- <option value='formulaexcel'>$i18n.getString('formulaexcel')</option>
- <option value='icd_code'>$i18n.getString('icd_code')</option>
+ <option value='formulaexcel'>$i18n.getString('formulaexcel')</option>
<option value='indicator'>$i18n.getString('indicator')</option>
<option value='organisation'>$i18n.getString('organisation')</option>
<option value='serial'>$i18n.getString('serial')</option>
- <option value='jumping_step'>$i18n.getString('jumping_step')</option>
- <option value='rename'>$i18n.getString('rename')</option>
+ #end
+
</select>
</td>
</tr>
@@ -124,13 +128,48 @@
</div>
</form>
-<!-- This form use for calculation & dataelement -->
+<!-- This form use for Calculation -->
+
+<div id="calculation" style="position:fixed;display:none;width:800px;z-index:10002;background-color: white;border: medium solid silver;height:300px;padding:20px;">
+ <div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="$('#calculation').hide();">[x]</div>
+ <table width="100%">
+ <tr>
+ <th>$i18n.getString( "formula" )</th>
+ <th></th>
+ <th>$i18n.getString( "report_items" )</th>
+ <tr>
+ <tr valign="top">
+ <td>
+ <textarea id="formulaCalculation" cols="15" rows="11" style="width:250px; height:180px" wrap="virtual">$encoder.htmlEncode( $formula )</textarea><br>
+ <a href="#" onclick="insertOperation( 'formula','(' )"><img src="images/left_parent.png" alt="$i18n.getString( 'left_brackets' )"></a>
+ <a href="#" onclick="insertOperation( 'formula',')' )"><img src="images/right_parent.png" alt="$i18n.getString( 'right_brackets' )"></a>
+ <a href="#" onclick="insertOperation( 'formula','*' )"><img src="images/multiply.png" alt="$i18n.getString( 'multiply' )"></a>
+ <a href="#" onclick="insertOperation( 'formula','/' )"><img src="images/divide.png" alt="$i18n.getString( 'divide' )"></a>
+ <a href="#" onclick="insertOperation( 'formula','+' )"><img src="images/plus.png" alt="$i18n.getString( 'plus' )"></a>
+ <a href="#" onclick="insertOperation( 'formula','-' )"><img src="images/minus.png" alt="$i18n.getString( 'minus' )"></a>
+ </td>
+ <td valign="middle">
+ <input type="button" value="<" onclick="insertCalculation()"/>
+ </td>
+ <td>
+ <select id="availableReportItems" size="13" style="min-width:500px"></select>
+ </td>
+ </tr>
+ </table>
+ <p>
+ <input type="button" value="$i18n.getString('ok')" onclick="$('#expression').val($('#formulaCalculation').html());$('#calculation').hide();"/>
+ <input type="button" value="$i18n.getString('clean')" onclick="$('#formulaCalculation').html('')"/></p>
+</div>
+
+
+<!-- This form use for dataelement -->
<div id="normal" style="position:fixed;display:none;width:800px;z-index:10002;background-color: white;border: medium solid silver;height:300px;padding:20px;">
<div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="$('#normal').hide();">[x]</div>
<table width="100%">
<tr>
<th>$i18n.getString( "formula" )</th>
+ <th></th>
<th>$i18n.getString( "dataelement" )</th>
<tr>
<tr valign="top">
@@ -143,12 +182,15 @@
<a href="#" onclick="insertOperation( 'formula','+' )"><img src="images/plus.png" alt="$i18n.getString( 'plus' )"></a>
<a href="#" onclick="insertOperation( 'formula','-' )"><img src="images/minus.png" alt="$i18n.getString( 'minus' )"></a>
</td>
+ <td valign="bottom">
+ <input type="button" value="<" onclick="insertDataElementId()"/>
+ </td>
<td>
- <select id="dataElementGroup" style="min-width:450px" onchange="filterDataElements()"></select>
- <select id="availableDataElements" size="11" style="min-width:450px" ondblclick="insertFormulaText(this.id, 'formula');"></select>
+ <select id="dataElementGroup" style="min-width:500px" onchange="filterDataElements()"></select>
+ <select id="availableDataElements" size="11" style="min-width:500px"></select>
+ <select id="optionCombos" size=4 style="min-width:500px"></select>
</td>
- </tr>
-
+ </tr>
</table>
<p>
<input type="button" value="$i18n.getString('ok')" onclick="$('#expression').val($('#formula').html());$('#normal').hide();"/>
=== added file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseDataElements.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseDataElements.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseDataElements.vm 2009-09-07 16:54:40 +0000
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dataelements>
+#foreach ( $dataelement in $dataElements )
+ <dataelement>
+ <id>$dataelement.id</id>
+ <name>$encoder.xmlEncode( $dataelement.name )</name>
+ </dataelement>
+#end
+</dataelements>
=== removed file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOperandList.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOperandList.vm 2009-07-13 00:23:50 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOperandList.vm 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<operands>
-#foreach ( $operand in $operands )
- <operand>
- <id>$operand.id</id>
- <name>$encoder.xmlEncode( $operand.operandName )</name>
- </operand>
-#end
-</operands>
=== added file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOptionCombo.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOptionCombo.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/responseOptionCombo.vm 2009-09-07 16:54:40 +0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set($count = 0)
+<optionCombo>
+ <categoryOptions>
+ #foreach( $optionComboId in $optionComboIds )
+ #set($optionComboName = $optionComboNames.get($count))
+ <categoryOption id="$optionComboId">$encoder.xmlEncode( $optionComboName )</categoryOption>
+ #set($count = $count + 1)
+ #end
+ </categoryOptions>
+</optionCombo>
\ No newline at end of file