=== modified file 'local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/FormManager.java'
--- local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/FormManager.java	2009-09-01 06:09:20 +0000
+++ local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/FormManager.java	2009-09-10 10:50:06 +0000
@@ -94,4 +94,6 @@
      * @return statistics Result
      */
     public int reportDataStatement( String operator, Period period, FormReport formReport );
+    
+    public String createCode(Form form);
 }

=== modified file 'local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/JDBCFormManager.java'
--- local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/JDBCFormManager.java	2009-09-01 06:09:20 +0000
+++ local/vn/dhis-service-chr/src/main/java/org/hisp/dhis/vn/chr/jdbc/JDBCFormManager.java	2009-09-10 10:50:06 +0000
@@ -22,6 +22,7 @@
 import org.hisp.dhis.vn.chr.jdbc.util.AccessMetaDataService;
 import org.hisp.dhis.vn.chr.statement.AddDataStatement;
 import org.hisp.dhis.vn.chr.statement.AlterColumnStatement;
+import org.hisp.dhis.vn.chr.statement.CreateCodeStatement;
 import org.hisp.dhis.vn.chr.statement.CreateTableStatement;
 import org.hisp.dhis.vn.chr.statement.DeleteDataStatement;
 import org.hisp.dhis.vn.chr.statement.FormStatement;
@@ -115,8 +116,8 @@
                     if ( columns.contains( element.getName().toLowerCase() ) )
                     {
 
-                        statement = new AlterColumnStatement( statementBuilder,
-                            AlterColumnStatement.ALTER_STATUS, element );
+                        statement = new AlterColumnStatement( statementBuilder, AlterColumnStatement.ALTER_STATUS,
+                            element );
 
                         log.debug( "Alter column with SQL statement: '" + statement.getStatement() + "'" );
                     }
@@ -126,8 +127,8 @@
                     else
                     // if(!columns.contains(element.getName()))
                     {
-                        statement = new AlterColumnStatement( statementBuilder,
-                            AlterColumnStatement.ADD_STATUS, element );
+                        statement = new AlterColumnStatement( statementBuilder, AlterColumnStatement.ADD_STATUS,
+                            element );
 
                         log.debug( "Add column with SQL statement: '" + statement.getStatement() + "'" );
                     }
@@ -148,7 +149,8 @@
                     if ( element == null )
                     {
 
-                        statement = new AlterColumnStatement( form, statementBuilder, AlterColumnStatement.DROP_STATUS, column );
+                        statement = new AlterColumnStatement( form, statementBuilder, AlterColumnStatement.DROP_STATUS,
+                            column );
 
                         allStatement += statement.getStatement();
 
@@ -199,8 +201,7 @@
 
         StatementHolder holder = statementManager.getHolder();
 
-        FormStatement statement = new ListDataStatement( form, statementBuilder,
-            pageSize );
+        FormStatement statement = new ListDataStatement( form, statementBuilder, pageSize );
 
         log.debug( "Selecting data form table with SQL statement: '" + statement.getStatement() + "'" );
 
@@ -219,7 +220,7 @@
                 {
                     rowData.add( resultSet.getString( i ) );
                 }
-                
+
                 data.add( rowData );
             }
 
@@ -257,8 +258,7 @@
                 arrData.add( data[i] );
             }
 
-            FormStatement statement = new AddDataStatement( form,
-                statementBuilder, arrData );
+            FormStatement statement = new AddDataStatement( form, statementBuilder, arrData );
 
             log.debug( "Update data form table with SQL statement: '" + statement.getStatement() + "'" );
 
@@ -356,8 +356,7 @@
 
         try
         {
-            FormStatement statement = new GetDataStatement( form,
-                statementBuilder, id );
+            FormStatement statement = new GetDataStatement( form, statementBuilder, id );
 
             log.debug( "Get data form table with SQL statement: '" + statement.getStatement() + "'" );
 
@@ -412,7 +411,7 @@
                 {
                     rowData.add( resultSet.getString( i ) );
                 }
-                
+
                 data.add( rowData );
 
             }
@@ -464,7 +463,7 @@
                 {
                     rowData.add( resultSet.getString( i ) );
                 }
-                
+
                 data.add( rowData );
 
                 rowIndex++;
@@ -500,8 +499,7 @@
         try
         {
 
-            FormStatement statement = new ReportDataStatement( statementBuilder,
-                operator, period, formReport );
+            FormStatement statement = new ReportDataStatement( statementBuilder, operator, period, formReport );
             log.debug( "Data statistics from relative table with SQL statement: '" + statement.getStatement() + "'" );
 
             ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
@@ -525,4 +523,46 @@
         return 0;
     }
 
+    public String createCode( Form form )
+    {
+
+        StatementHolder holder = statementManager.getHolder();
+
+        int count = 0;
+        try
+        {
+
+            FormStatement statement = new CreateCodeStatement( form, statementBuilder );
+
+            log.debug( "Statistics data from table with SQL statement: '" + statement.getStatement() + "'" );
+
+            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
+
+            if ( resultSet.next() )
+            {
+
+                count = resultSet.getInt( 1 ) + 1;
+
+                if ( count < 10 )
+                {
+                    return "00" + count;
+                }
+                else if ( count < 100 )
+                {
+                    return "0" + count;
+                }
+            }
+        }
+        catch ( Exception ex )
+        {
+            throw new RuntimeException( "Failed to query data : ", ex );
+        }
+
+        finally
+        {
+            holder.close();
+        }
+
+        return count + "";
+    }
 }

=== modified file 'local/vn/dhis-web-chr-form/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-web-chr-form/src/main/resources/META-INF/dhis/beans.xml	2009-09-03 03:55:25 +0000
+++ local/vn/dhis-web-chr-form/src/main/resources/META-INF/dhis/beans.xml	2009-09-10 10:50:06 +0000
@@ -340,6 +340,12 @@
 		<property name="formReportService" ref="org.hisp.dhis.vn.chr.FormReportService" />
 	</bean>
 
+    <bean id="org.hisp.dhis.vn.chr.object.action.CreateCodeAction"
+        class="org.hisp.dhis.vn.chr.object.action.CreateCodeAction" scope="prototype">
+        <property name="formService" ref="org.hisp.dhis.vn.chr.FormService" />
+        <property name="formManager" ref="org.hisp.dhis.vn.chr.jdbc.FormManager" />
+    </bean>
+
 </beans>
 
 

=== 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-03 03:55:25 +0000
+++ local/vn/dhis-web-chr-form/src/main/resources/struts.xml	2009-09-10 10:50:06 +0000
@@ -295,7 +295,12 @@
 			<result name="error" type="velocity-xml">/dhis-web-chr-form/responseError.vm</result>
 		</action>
 		
-		
+		<action name="createCode" class="org.hisp.dhis.vn.chr.object.action.CreateCodeAction">
+            <result name="success" type="velocity">/dhis-web-chr-form/responseCode.vm</result>
+            <result name="error" type="velocity-xml">/dhis-web-chr-form/responseError.vm</result>
+        </action>
+        
+        
 	<!--  --><!--  --><!--  -->
 	  <!--  FormReport -->
 	<!--  --><!--  --><!--  -->

=== 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-10 05:59:02 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/addForm.vm	2009-09-10 10:50:06 +0000
@@ -37,7 +37,15 @@
 			 $dt<br>
 		#end
 		</td>
+		<!-- maso -->
+		  #elseif($element.name == "Maso")
+    <td>$element.label#if($element.required == "true") <font color="#FF0000">*</font> #end</td>
+    <td>
+	<div id='code$element.id'>
+		<input type="text" name="data" id="data"><input type="button" onClick="createCode('code$element.id');" value="...">
+	</div></td>
     <!-- textfield -->
+	
     #elseif($element.controlType == "checkbox")
     <td>$element.label</td>
     <td><input type="checkbox" name="data" id="data"></td>

=== 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-01 03:49:33 +0000
+++ local/vn/dhis-web-chr-form/src/main/webapp/dhis-web-chr-form/javascripts/forms.js	2009-09-10 10:50:06 +0000
@@ -951,4 +951,25 @@
 		request.setCallbackSuccess( Completed );			
 		request.send( "deleteFormReport.action?id=" + id );  
 	}		
+}
+
+var inputObject;
+function createCode(inputObjectName){
+	
+	
+	this.inputObject = document.getElementById(inputObjectName).getElementsByTagName('input')[0];
+	
+	var request = new Request();
+	
+	request.setResponseTypeXML( 'xmlObject' );
+	
+	request.setCallbackSuccess( createCodeReceived );
+	
+	var formId = getParamByURL('formId');
+	
+	request.send( "createCode.action?formId=" +  formId);
+}
+
+function createCodeReceived( xmlObject ){
+		this.inputObject.value = xmlObject.getElementsByTagName("code").item[0].firstChild.nodeValue;
 }
\ No newline at end of file

=== modified file 'local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ImportDataAction.java'
--- local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ImportDataAction.java	2009-09-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/java/org/hisp/dhis/vn/imports/action/ImportDataAction.java	2009-09-10 10:50:06 +0000
@@ -192,7 +192,7 @@
                 }// end if
             }
         }
-
+ 
         message = i18n.getString( "success" );
 
         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-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/resources/META-INF/dhis/beans.xml	2009-09-10 10:50:06 +0000
@@ -465,6 +465,12 @@
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 	</bean>
 
+    <bean id="org.hisp.dhis.vn.imports.action.ViewDataAction"
+        class="org.hisp.dhis.vn.imports.action.ViewDataAction" scope="prototype">
+        <property name="reportExcelService"
+            ref="org.hisp.dhis.vn.report.ReportExcelService" />
+    </bean>
+    
 	<bean id="org.hisp.dhis.vn.imports.action.DeleteExcelFileAction"
 		class="org.hisp.dhis.vn.imports.action.DeleteExcelFileAction" scope="prototype">
 		<property name="reportLocationManager"

=== modified file 'local/vn/dhis-web-vn-report/src/main/resources/org/hisp/dhis/vn/i18n_module.properties'
--- local/vn/dhis-web-vn-report/src/main/resources/org/hisp/dhis/vn/i18n_module.properties	2009-09-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/resources/org/hisp/dhis/vn/i18n_module.properties	2009-09-10 10:50:06 +0000
@@ -105,5 +105,4 @@
 unselect_all_at_level		= Un-Select All At Level
 remove_all					= Un-Select All
 define_associations			= Report Associations
-import_excel_file           = Import excel file
-
+import_excel_file           = Import excel file
\ No newline at end of file

=== 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-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/resources/struts.xml	2009-09-10 10:50:06 +0000
@@ -393,7 +393,14 @@
 			<result name="error" type="velocity-xml">
 				/dhis-web-vn-report/responseError.vm</result>
 		</action>
-
+		
+		<action name="previewData" class="org.hisp.dhis.vn.imports.action.ViewDataAction">
+            <result name="success" type="velocity">
+                /dhis-web-vn-report/responseReportItemValues.vm</result>
+            <result name="error" type="velocity-xml">
+                /dhis-web-vn-report/responseError.vm</result>
+        </action>
+		
 		<action name="getExcelFileByOrganisationUnit"
 			class="org.hisp.dhis.vn.imports.action.GetListExcelFileByOrganisationAction">
 			<interceptor-ref name="organisationUnitTreeStack" />

=== modified file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/importData.vm'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/importData.vm	2009-09-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/importData.vm	2009-09-10 10:50:06 +0000
@@ -43,8 +43,14 @@
   
 </table>
 <hr>
+<input type="button" name="preview" id="preview" onClick="javascript: getPreviewImportData();" value="$i18n.getString('preview')">
 <input type="button" name="import" id="import" onClick="javascript: importData();" value="$i18n.getString('import')">
 
 
+<div id='organisationUnitGroup' style="position:fixed;display:block;width:450px;z-index:10001;background-color: white;border: medium solid silver;height:200px;padding:20px;">
+	<div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="javascript:hideById('organisationUnitGroup');deleteDivEffect();">[x]</div>	</div>
+	<div id="showValue">
+	
+	</div>
 </body>
 

=== modified file 'local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js'
--- local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js	2009-09-09 09:19:35 +0000
+++ local/vn/dhis-web-vn-report/src/main/webapp/dhis-web-vn-report/javascript/imports.js	2009-09-10 10:50:06 +0000
@@ -100,3 +100,41 @@
 	//window.location.reload();
 	
 }
+
+function getPreviewImportData(){
+	
+	var request = new Request();
+	
+	request.setResponseTypeXML( 'xmlObject' );
+	
+	request.setCallbackSuccess( getReportItemValuesReceived );
+	
+	var reportId = byId("reportId").value;
+	
+	var uploadFileName = byId("uploadFileName").value;
+
+	request.send( "previewData.action?reportId=" + reportId +"&uploadFileName=" + uploadFileName);
+}
+
+function getReportItemValuesReceived( xmlObject ){
+	
+		var availableDiv = byId('showValue');
+		availableDiv.style.display = 'block';
+		var str_values = "<br><br><table border='1' style='width:100% '> <tr><td>Report</td><td>Value</td></tr>";
+		
+		
+		var availableObjectList = xmlObject.getElementsByTagName('reportItemValue');
+		
+		for(var i=0;i<availableObjectList.length;i++){
+			str_values += "<tr>";
+			var reportItermValue = availableObjectList.item(i);
+			str_values += "<td>" + reportItermValue.getElementsByTagName('name')[0].firstChild.nodeValue + "</td>";
+			str_values += "<td>" + reportItermValue.getElementsByTagName('value')[0].firstChild.nodeValue + "</td>";
+			str_values += "</tr>";
+		}
+		
+		str_values += "</table>";
+	
+
+		availableDiv.innerHTML = str_values;
+}

