dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02539
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 848: New function of CHR
------------------------------------------------------------
revno: 848
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2009-10-12 16:28:34 +0700
message:
New function of CHR
modified:
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/AddFormReport.java
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/UpdateFormReport.java
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListObjectAction.java
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListRelativeObjectAction.java
local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/UpdateObjectAction.java
local/vn/dhis-web-chr-form/src/main/resources/struts.xml
local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/addForm.vm
local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/javascripts/forms.js
local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/listForm.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 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/AddFormReport.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/AddFormReport.java 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/AddFormReport.java 2009-10-12 09:28:34 +0000
@@ -115,7 +115,7 @@
// set formula for the element
formula = formula.toLowerCase();
- formReport.setFormula( formula );
+ formReport.setFormula( CodecUtils.unescape(formula ));
// get all forms
Collection<Form> forms = formService.getAllForms();
=== modified file 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/UpdateFormReport.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/UpdateFormReport.java 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/formreport/action/UpdateFormReport.java 2009-10-12 09:28:34 +0000
@@ -43,7 +43,6 @@
* @version $Id$
*/
-
public class UpdateFormReport
extends ActionSupport
{
@@ -121,7 +120,7 @@
// set formula for the element
formula = formula.toLowerCase();
- formReport.setFormula( formula );
+ formReport.setFormula( CodecUtils.unescape( formula ) );
// get all forms
Collection<Form> forms = formService.getAllForms();
=== modified file 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListObjectAction.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListObjectAction.java 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListObjectAction.java 2009-10-12 09:28:34 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import org.hisp.dhis.options.SystemSettingManager;
import org.hisp.dhis.vn.chr.Element;
@@ -123,7 +124,7 @@
form = formService.getForm( formId.intValue() );
formLinks = elementService.getElementsByFormLink( form );
-
+
String number = (String) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_CHR_NUMBER_OF_RECORDS );
int numberOfRecords = 50;
=== modified file 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListRelativeObjectAction.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListRelativeObjectAction.java 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/ListRelativeObjectAction.java 2009-10-12 09:28:34 +0000
@@ -28,7 +28,8 @@
*/
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
import org.hisp.dhis.options.SystemSettingManager;
import org.hisp.dhis.vn.chr.Egroup;
@@ -45,7 +46,6 @@
* @version $Id$
*/
-
public class ListRelativeObjectAction
implements Action
{
@@ -114,9 +114,9 @@
return data;
}
- private Collection<Element> formLinks;
+ private List<Element> formLinks;
- public Collection<Element> getFormLinks()
+ public List<Element> getFormLinks()
{
return formLinks;
}
@@ -145,7 +145,7 @@
form = formService.getForm( formId.intValue() );
- formLinks = elementService.getElementsByFormLink( form );
+ formLinks = new ArrayList<Element>( elementService.getElementsByFormLink( form ) );
int numberOfRecords = Integer.parseInt( (String) systemSettingManager
.getSystemSetting( SystemSettingManager.KEY_CHR_NUMBER_OF_RECORDS ) );
@@ -163,6 +163,20 @@
Form fparent = element.getFormLink();
+ formLinks.addAll( new ArrayList<Element>( elementService.getElementsByFormLink( fparent ) ) );
+
+ Iterator<Element> iter = formLinks.iterator();
+
+ while ( iter.hasNext() )
+ {
+ Element e = iter.next();
+
+ if ( e.getForm().getId() == formId.intValue() )
+ {
+ iter.remove();
+ }
+ }
+
ArrayList<String> data = formManager.getObject( fparent, Integer.parseInt( objectId ) );
parentObject = new ArrayList<String>();
@@ -181,8 +195,10 @@
break;
}// end for element
- if ( k == fparent.getNoColumnLink() )
+ if ( k == fparent.getNoColumnLink() ){
break;
+ }
+
}// end for egroup
}
}
=== modified file 'local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/UpdateObjectAction.java'
--- local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/UpdateObjectAction.java 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/java/org/hisp/dhis/vn/chr/object/action/UpdateObjectAction.java 2009-10-12 09:28:34 +0000
@@ -101,7 +101,7 @@
String value = request.getParameterValues( "dataid" )[0];
- data.add( CodecUtils.unescape( value ) );
+ data.add( value );
for ( Egroup egroup : egroups )
{
=== modified file 'local/vn/dhis-web-chr-form/src/main/resources/struts.xml'
--- local/vn/dhis-web-chr-form/src/main/resources/struts.xml 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/resources/struts.xml 2009-10-12 09:28:34 +0000
@@ -23,6 +23,7 @@
<result name="success" type="velocity">/main.vm</result>
<result name="error" type="velocity-xml">/dhis-web-chr-form/responseError.vm
</result>
+ <param name="stylesheets">styles/intro.css</param>
</action>
<!-- --><!-- --><!-- -->
@@ -256,6 +257,7 @@
<param name="page">/dhis-web-chr-form/addForm.vm</param>
<param name="menu">/dhis-web-chr-form/menu.vm</param>
<param name="javascripts">
+
javascripts/forms.js,
javascripts/dhtmlgoodies_calendar.js,
javascripts/calendar.js</param>
@@ -279,7 +281,7 @@
<!-- Show List relative Object -->
- <action name="listReletiveObject"
+ <action name="listRelativeObject"
class="org.hisp.dhis.vn.chr.object.action.ListRelativeObjectAction">
<result name="success" type="chain">getVisibleForms
</result>
=== modified file 'local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/addForm.vm'
--- local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/addForm.vm 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/addForm.vm 2009-10-12 09:28:34 +0000
@@ -1,4 +1,35 @@
- <body onLoad="javacript: var dataObject = '$!data'; if(dataObject!=''){getData('$!data');} else{ javacript:var d, s; d = new Date(); s = d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate(); document.getElementById('datangaykham').value = s ; s = d.getHours() + ':' + d.getMinutes(); document.getElementById('datagiokham').value = s ;document.getElementById('tittleForm').innerHTML='$i18n.getString("add_object") - $!form.label';}">
+ <script language="javascript" src="javascripts/nutritionTable.js"></script>
+<script language="javascript">
+ function init(){
+
+ var dataObject = '$!data';
+
+ if(dataObject!='')
+ {
+ getData('$!data');
+ }else
+ {
+
+ var d, s;
+ d = new Date();
+ s = d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate();
+
+ if( document.getElementById('datangaylapphieuskte')!=null)
+ {
+ document.getElementById('datangaylapphieuskte').value = s;
+ }
+ if( document.getElementById('datangaykham')!=null)
+ {
+ document.getElementById('datangaykham').value = s ;
+ s = d.getHours() + ':' + d.getMinutes();
+ document.getElementById('datagiokham').value = s ;
+
+ }
+ document.getElementById('tittleForm').innerHTML='$i18n.getString("add_object") - $!form.label';
+ }
+ }
+</script>
+ <body onLoad="javacript:init();">
<span id="message" style="top:70px;right:5px;position:fixed;width:200px;z-index:100009" onclick="hideById(this.id);"></span>
<form name="editForm" id="editForm" method="post" action="">
@@ -62,7 +93,7 @@
<td><!--<select style="width:145px;" name="data" id="data" onBlur="javascript : validateObject($element.required, this.value); ">
</select> -->
<div id='$element.name' >
- <select style=" width:145px;" id="data$element.name" name="data$element.name" onFocus="javascript: var select = '<select style=width:145px id=data name=data >'; fillup(select,'$element.initialValue', '$element.name');" ></select>
+ <select style=" width:145px;" id="data$element.name" name="data$element.name" onFocus="javascript: var name = 'data$element.name' ; fillup(name,'$element.initialValue' );" ></select>
</div>
</td>
<!-- date -->
@@ -128,7 +159,7 @@
</tr>
<tr class="formcontrol">
<td height="25" colspan="6" align="center"><input name="Submit" type="button" value=" $i18n.getString('save') " onClick="javascript: var dataObject = '$!data'; if(dataObject!=''){ mode='UPDATE' ;} else{ mode='ADD';}; validateDataObject();">
- <input name="Submit2" type="button" value=" $i18n.getString('cancel') " onClick=""></td>
+ <input name="Submit2" type="button" value=" $i18n.getString('cancel') " onClick="javascript: history.back(1)"></td>
</tr>
</table>
</form>
=== modified file 'local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/javascripts/forms.js'
--- local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/javascripts/forms.js 2009-09-24 06:18:51 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/javascripts/forms.js 2009-10-12 09:28:34 +0000
@@ -477,6 +477,7 @@
// --------------------------------------------------------------------------------------
// Delete Object
// --------------------------------------------------------------------------------------
+var i18n_confirm_delete;
function deleteObject( id ){
if(window.confirm(i18n_confirm_delete)){
@@ -485,12 +486,53 @@
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( Completed );
+ request.setCallbackSuccess( deleteObjectReceived );
request.send( "deleteObject.action?formId="+ result + "&id=" + id );
}
}
// --------------------------------------------------------------------------------------
+// Delete Objects
+// --------------------------------------------------------------------------------------
+function deleteObjects (i18n_confirm_delete){
+
+ if(window.confirm(i18n_confirm_delete)){
+
+ var result = getParamByURL('formId');
+
+ var url = "deleteObject.action?formId="+ result + "&id=";
+ var deleteElements = document.getElementsByName('delete');
+
+ for(var i=0; i<deleteElements.length; i++){
+ var deleteElement = deleteElements[i];
+ if( deleteElement.checked ){
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( deleteObjectReceived );
+ request.send( url + deleteElement.value );
+ }
+ break;
+ }
+ }
+}
+
+function deleteObjectReceived(xmlObject){
+ var type = xmlObject.getAttribute( 'type' );
+ if(type =='error') {
+ setMessage(xmlObject.firstChild.nodeValue);
+ }
+ if(type == 'success') {
+
+ if(document.getElementById('message') != null){
+ document.getElementById('message').style.display = 'block';
+ document.getElementById('message').innerHTML = xmlObject.firstChild.nodeValue;
+ }
+
+ window.location.reload();
+ }
+}
+
+// --------------------------------------------------------------------------------------
// Add Object
// --------------------------------------------------------------------------------------
@@ -514,7 +556,6 @@
request.send( url );
-
}
function validateObjectCompleted( xmlObject ){
@@ -523,23 +564,14 @@
if(type =='error') {
setMessage(xmlObject.firstChild.nodeValue);
}
- if(type == 'success') {
- if(mode == "ADD")
+ else if(type == 'success') {
+ if(mode == "ADD") {
addObject();
- else
+ } else {
updateObject();
- }
-
- var formId = getParamByURL('formId');
- var objectId = getParamByURL('objectId');
- var url = '';
- if(objectId!=''){
- url = 'listReletiveObject.action?formId=' + formId + '&column='+getParamByURL('column') + '&objectId=' + getParamByURL('objectId');
- }else{
- url = 'listObject.action?formId='+formId ;
- }
-
- window.location = url;
+ }
+ }
+
}
// Validate data inputted into a control
@@ -550,7 +582,6 @@
document.getElementById('info').innerHTML = strerror;
element.focus();
}
-
}
function addObject () {
@@ -578,28 +609,52 @@
}
var request = new Request();
+
request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( Completed );
+ request.setCallbackSuccess( objectCompleted );
var url = 'addObject.action' + dataParam;
request.send( url );
}
+function objectCompleted(){
+ var url = '';
+ var objectId = getParamByURL('objectId');
+
+ if(objectId == ''){
+ url = 'listObject.action?formId=' + getParamByURL('formId');
+ }else{
+ url = 'listReletiveObject.action?formId=' + getParamByURL('formId') +'&column=' + getParamByURL('column') + '&objectId=' + objectId;
+ }
+
+ window.location.replace( url );
+}
// ------------------------------------------------------------
// Fillup Initial values into control
// ------------------------------------------------------------
-function fillup (strSelect, str, div_name){
+function fillup (selectName, str){
+
+ var operandList = byId( selectName );
+
+ operandList.options.length = 0;
+
+
if(str==null && str=='')
return;
var arr = str.split(",");
- var result = strSelect;
+ //var result = strSelect;
for(var i=0; i<arr.length; i++){
- result += "<option value='" + arr[i].replace(/^\s*|\s*$/g, "") + "'>" + arr[i] + "</option>";
+ //result += "<option value='" + arr[i].replace(/^\s*|\s*$/g, "") + "'>" + arr[i] + "</option>";
+
+ var option = document.createElement( "option" );
+ option.value = arr[i].replace(/^\s*|\s*$/g, "") ;
+ option.text = arr[i] ;
+
+ operandList.add( option, null );
}
- result += '</select>';
- document.getElementById(div_name).innerHTML = result;
+
}
// ------------------------------------------------------------
@@ -645,7 +700,7 @@
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( Completed );
+ request.setCallbackSuccess( objectCompleted );
var url = 'updateObject.action' + dataParam;
request.send( url );
}
@@ -853,4 +908,23 @@
function createCodeReceived( xmlObject ){
this.inputObject.value = xmlObject.getElementsByTagName("code")[0].firstChild.nodeValue;
+}
+
+function openLink(formId, objectId, column){
+
+ var currentObjectId = getParamByURL('objectId');
+
+ var currentFormId = getParamByURL('formId');
+
+ if(currentObjectId!='')
+ {
+ window.location='listReletiveObject.action?formId='+formId +'&column=' + column + '&objectId='+currentObjectId;
+ }
+ else
+ {
+ window.location='listReletiveObject.action?formId='+formId +'&column=' + column + '&objectId='+objectId;
+ }
+
+
+
}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/listForm.vm'
--- local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/listForm.vm 2009-09-01 03:49:33 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/listForm.vm 2009-10-12 09:28:34 +0000
@@ -1,3 +1,4 @@
+ <script language="javascript" src="javascripts/nutritionTable.js"></script>
<script language="javascript">
function getData(dataObject){
@@ -6,7 +7,8 @@
return object;
}
</script>
- <form name="form1" method="post" action="" >
+ <form name="listObjectForm" method="post" action="" >
+ #set($birthday='')
<table width="100%">
<tr class="moduleheader">
<td colspan="13" class="moduleheader"><font size="+1">$form.label</font></td>
@@ -17,22 +19,26 @@
<td colspan="13">
<input name="txtCondition" id="txtCondition" value="" type="text" ><!-- onKeyPress="javascript: if(event.keyCode==13){searchObject('txtCondition');}" -->
<input name="Submit" value="$i18n.getString('search')" onClick="javascript: searchObject('txtCondition');" type="button">
- <input name="button3" class="bodytext" onClick="javascript: addObjectForm();" value="$i18n.getString('add')" type="button"></td>
+ <input name="button3" class="bodytext" onClick="javascript: addObjectForm(byId('birthday').value);" value="$i18n.getString('add')" type="button">
+ <input name="button32" class="bodytext" onClick="javascript: i18n_confirm_delete = '$encoder.jsEscape($i18n.getString( "confirm_delete" ) , "'")'; deleteObject(byId('deleteid').value);" title="$i18n.getString('delete')" value="$i18n.getString('delete')" type="button"> </td>
</table>
<table width="100%">
#foreach($egroup in $form.egroups)
#foreach($element in $!egroup.elements)
#if($!element.formLink)
- <tr><td colspan="2" #alternate( 'false' ) >$!element.egroup.name</td></tr>
+ <tr><td colspan="2" #alternate( 'false' ) align="left"><strong>$!element.egroup.name</strong></td></tr>
<tr><td>$!element.label</td>
<td><br>
#foreach($dt in $!parentObject)
- $dt<br>
+ $dt
+ #set($birthday=$dt)
+ <br>
#end
</td> </tr>
#end
#end
#end
+ <input type='hidden' id='birthday' name='birthday' value='$!birthday'>
</table>
<br>
<table width="100%">
@@ -40,11 +46,16 @@
#set($i=0)
#set($noColumn = $form.noColumn)
<th>$i18n.getString('STT')</th>
+
+ #set ($sex=-1)
#foreach($egroup in $form.egroups)
#foreach($element in $!egroup.elements)
#if($!element.formLink)
#elseif($i < $noColumn )
<th>$!element.label</th>
+ #if($!element.name=='PNam')
+ #set ($sex=$i)
+ #end
#set($i = $i+1)
#end
@@ -52,7 +63,7 @@
#end
<!-- <th>Add by</th> -->
-
+ <th> </th>
#if($!formLinks != '[]')
<th>$i18n.getString('functions')</th>
#end
@@ -71,8 +82,10 @@
#set($pos = -1)
#set($addby='')
<tr #alternate( $mark )>
+
#foreach($object in $!dt)
+
#if($i < $noColumn + 3)
#if( $i==1 )
#set($id=$object)
@@ -85,21 +98,24 @@
<!-- <td>$!object</td> -->
#else
<td>$!object</td>
- #end
+ #end
- #set($array = $array + $!object + ";")
+ #set($array = $array + $!object + ";")
#end
#set($i = $i +1)
#end
<input type="hidden" id="data$id" name="data$id" value="$array">
+ <input type="hidden" id="deleteid" name="deleteid">
+ <td><input type="radio" name="delete" id="delete" value="$id" onChange="if(this.checked){byId('deleteid').value=$id}"> </td>
#if($!formLinks != '[]')
<td>
#foreach($!e in $!formLinks)
- <a href="javascript:window.location='listReletiveObject.action?formId=$e.form.id&column=$e.name&objectId=$id'" title="$!e.form.label">
- <img src="../images/$!e.form.icon" alt="$!e.form.label" width="24" height="24">
- #end
+
+ <a href="javascript: openLink('$!e.form.id', '$id', '$!e.name', '$!birthday', '$!sex')" title="$!e.form.label">
+ <img src="../images/$!e.form.icon" alt="$!e.form.label" width="24" height="24"> </a>
+ #end
</td>
#end
@@ -118,6 +134,7 @@
<img src="../images/edit.png" alt="$i18n.getString('edit')">
</a>
+
<a href="javascript: var i18n_confirm_delete = '$encoder.jsEscape($i18n.getString( "confirm_delete" ) , "'")'; deleteObject($id);" title="$i18n.getString('delete')">
<img src="../images/delete.png" alt="$i18n.getString('delete')">
</a>
@@ -151,6 +168,7 @@
#end
</tr>
+ <tr><td colspan="15" align='right'> <input name="button3" class="bodytext" onClick="javascript: addObjectForm();" value="$i18n.getString('add')" type="button"></td></td></tr>
</table>
</form>