=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/GenerateExcelReportFlowAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/GenerateExcelReportFlowAction.java 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/GenerateExcelReportFlowAction.java 2011-06-07 10:07:02 +0000 @@ -29,7 +29,6 @@ import org.hisp.dhis.reportexcel.ExportReportService; import org.hisp.dhis.reportexcel.ReportExcel; -import org.hisp.dhis.reportexcel.period.generic.PeriodGenericManager; import org.hisp.dhis.reportexcel.state.SelectionManager; import com.opensymphony.xwork2.Action; @@ -48,45 +47,32 @@ private ExportReportService exportReportService; + public void setExportReportService( ExportReportService exportReportService ) + { + this.exportReportService = exportReportService; + } + private SelectionManager selectionManager; - private PeriodGenericManager periodGenericManager; - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private Integer exportReportId; - - private Integer periodIndex; - - // ------------------------------------------------------------------------- - // Getter & Setter - // ------------------------------------------------------------------------- - - public void setExportReportId( Integer exportReportId ) - { - this.exportReportId = exportReportId; - } - public void setSelectionManager( SelectionManager selectionManager ) { this.selectionManager = selectionManager; } - public void setPeriodGenericManager( PeriodGenericManager periodGenericManager ) - { - this.periodGenericManager = periodGenericManager; - } - - public void setPeriodIndex( Integer periodIndex ) - { - this.periodIndex = periodIndex; - } - - public void setExportReportService( ExportReportService exportReportService ) - { - this.exportReportService = exportReportService; + // ------------------------------------------------------------------------- + // Input && Output + // ------------------------------------------------------------------------- + + private Integer organisationGroupId; + + public void setOrganisationGroupId( Integer organisationGroupId ) + { + this.organisationGroupId = organisationGroupId; + } + + public Integer getOrganisationGroupId() + { + return organisationGroupId; } // ------------------------------------------------------------------------- @@ -96,11 +82,7 @@ public String execute() throws Exception { - ReportExcel exportReport = exportReportService.getExportReport( exportReportId ); - - periodGenericManager.setSelectedPeriodIndex( periodIndex ); - - selectionManager.setSelectedReportId( exportReportId ); + ReportExcel exportReport = exportReportService.getExportReport( selectionManager.getSelectedReportId() ); return exportReport.getReportType(); } === added file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/ValidateGenerateExportReportAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/ValidateGenerateExportReportAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/action/ValidateGenerateExportReportAction.java 2011-06-07 10:07:02 +0000 @@ -0,0 +1,137 @@ +package org.hisp.dhis.reportexcel.exporting.action; + +/* + * Copyright (c) 2004-2010, 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.io.File; + +import org.hisp.dhis.reportexcel.ExportReportService; +import org.hisp.dhis.reportexcel.ReportExcel; +import org.hisp.dhis.reportexcel.ReportLocationManager; +import org.hisp.dhis.reportexcel.action.ActionSupport; +import org.hisp.dhis.reportexcel.period.generic.PeriodGenericManager; +import org.hisp.dhis.reportexcel.state.SelectionManager; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class ValidateGenerateExportReportAction + extends ActionSupport +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private ExportReportService exportReportService; + + public void setExportReportService( ExportReportService exportReportService ) + { + this.exportReportService = exportReportService; + } + + private PeriodGenericManager periodGenericManager; + + public void setPeriodGenericManager( PeriodGenericManager periodGenericManager ) + { + this.periodGenericManager = periodGenericManager; + } + + private SelectionManager selectionManager; + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + private ReportLocationManager reportLocationManager; + + public void setReportLocationManager( ReportLocationManager reportLocationManager ) + { + this.reportLocationManager = reportLocationManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer exportReportId; + + public void setExportReportId( Integer exportReportId ) + { + this.exportReportId = exportReportId; + } + + private Integer periodIndex; + + public void setPeriodIndex( Integer periodIndex ) + { + this.periodIndex = periodIndex; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ReportExcel exportReport = exportReportService.getExportReport( exportReportId ); + + if ( exportReport == null ) + { + message = i18n.getString( "the_specified_report_is_not_exist" ); + + return ERROR; + } + + File templateDirectory = reportLocationManager.getReportExcelTemplateDirectory(); + + if ( templateDirectory == null || !templateDirectory.exists() ) + { + message = i18n.getString( "template_folder_is_null" ); + + return ERROR; + } + + File templateFile = new File( templateDirectory, exportReport.getExcelTemplateFile() ); + + if ( templateFile == null || !templateFile.exists() ) + { + message = i18n.getString( "template_file_is_not_exist" ); + + return ERROR; + } + + periodGenericManager.setSelectedPeriodIndex( periodIndex ); + + selectionManager.setSelectedReportId( exportReportId ); + + return SUCCESS; + } + +} === modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportNormalAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportNormalAction.java 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportNormalAction.java 2011-06-07 10:07:02 +0000 @@ -49,9 +49,9 @@ public class GenerateAdvancedReportNormalAction extends AbstractGenerateExcelReportSupport { - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Dependency - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- private OrganisationUnitGroupService organisationUnitGroupService; @@ -60,9 +60,9 @@ this.organisationUnitGroupService = organisationUnitGroupService; } - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Input && Output - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- private Integer organisationGroupId; @@ -71,9 +71,9 @@ this.organisationGroupId = organisationGroupId; } - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Override - // --------------------------------------------------------------------- + // ------------------------------------------------------------------------- @Override protected void executeGenerateOutputFile( ReportExcel exportReport, Period period ) === modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java 2011-06-07 10:07:02 +0000 @@ -59,26 +59,22 @@ private OrganisationUnitGroupService organisationUnitGroupService; + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- private Integer organisationGroupId; - // ------------------------------------------------------------------------- - // Getters && Setters - // ------------------------------------------------------------------------- - public void setOrganisationGroupId( Integer organisationGroupId ) { this.organisationGroupId = organisationGroupId; } - public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) - { - this.organisationUnitGroupService = organisationUnitGroupService; - } - // ------------------------------------------------------------------------- // Override // ------------------------------------------------------------------------- @@ -102,7 +98,6 @@ this.generateOutPutFile( exportReportInstance.getPeriodColumns(), exportReportItems, organisationUnitGroup .getMembers(), sheet ); - } for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) @@ -110,12 +105,11 @@ Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 ); this.recalculatingFormula( sheet ); - } } - private void generateOutPutFile( Collection periodColumns, - Collection exportItems, Set organisationUnits, Sheet sheet ) + private void generateOutPutFile( Collection periodColumns, Collection exportItems, + Set organisationUnits, Sheet sheet ) { for ( ReportExcelItem exportItem : exportItems ) { === modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportreport/action/ListExportReportAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportreport/action/ListExportReportAction.java 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/exportreport/action/ListExportReportAction.java 2011-06-07 10:07:02 +0000 @@ -27,13 +27,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.io.File; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.hisp.dhis.reportexcel.ExportReportService; import org.hisp.dhis.reportexcel.ReportExcel; +import org.hisp.dhis.reportexcel.ReportLocationManager; import org.hisp.dhis.reportexcel.comparator.ExportReportNameComparator; +import org.hisp.dhis.reportexcel.utils.ExcelFilenameFilter; +import org.hisp.dhis.reportexcel.utils.FileUtils; import com.opensymphony.xwork2.Action; @@ -55,9 +61,23 @@ this.exportReportService = exportReportService; } - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- + private ReportLocationManager reportLocationManager; + + public void setReportLocationManager( ReportLocationManager reportLocationManager ) + { + this.reportLocationManager = reportLocationManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private boolean valid; + + public void setValid( boolean valid ) + { + this.valid = valid; + } private List exportReports; @@ -66,13 +86,50 @@ return exportReports; } + private Map templateMap = new HashMap(); + + public Map getTemplateMap() + { + return templateMap; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + public String execute() throws Exception { + valid = true; + exportReports = new ArrayList( exportReportService.getAllExportReport() ); + if ( valid ) + { + File templateDirectory = reportLocationManager.getReportExcelTemplateDirectory(); + + if ( templateDirectory == null || !templateDirectory.exists() ) + { + return SUCCESS; + } + + List templateNames = FileUtils.getListFileName( templateDirectory, new ExcelFilenameFilter() ); + + if ( templateNames == null || templateNames.isEmpty() ) + { + return SUCCESS; + } + + for ( ReportExcel exportReport : exportReports ) + { + templateMap.put( exportReport.getExcelTemplateFile(), templateNames.contains( exportReport + .getExcelTemplateFile() ) ); + } + } + Collections.sort( exportReports, new ExportReportNameComparator() ); return SUCCESS; } + } === modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java 2011-06-07 05:41:55 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java 2011-06-07 10:07:02 +0000 @@ -173,7 +173,7 @@ { return ERROR; } - + File templateDirectory = reportLocationManager.getReportExcelTemplateDirectory(); if ( templateDirectory == null || !templateDirectory.exists() ) @@ -216,14 +216,7 @@ for ( File file : templateFiles ) { - if ( exportReportTemplates.contains( file.getName() ) ) - { - mapTemplateFiles.put( file.getName(), true ); - } - else - { - mapTemplateFiles.put( file.getName(), false ); - } + mapTemplateFiles.put( file.getName(), exportReportTemplates.contains( file.getName() ) ); } return SUCCESS; === added file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelFilenameFilter.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelFilenameFilter.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelFilenameFilter.java 2011-06-07 10:07:02 +0000 @@ -0,0 +1,56 @@ +package org.hisp.dhis.reportexcel.utils; + +/* + * Copyright (c) 2004-2010, 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.io.File; +import java.io.FilenameFilter; + +/** + * @author Dang Duy Hieu + * @version $Id + */ +public class ExcelFilenameFilter + implements FilenameFilter +{ + @Override + public boolean accept( File file, String extension ) + { + if ( file.isDirectory() ) + return false; + else + { + String name = file.getName().toLowerCase(); + + if ( extension == null ) + { + return name.endsWith( ".xls" ) || name.endsWith( ".xlsx" ); + } + + return name.endsWith( "." + extension ); + } + } +} === modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java' --- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java 2011-06-07 05:41:55 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java 2011-06-07 10:07:02 +0000 @@ -32,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; +import java.io.FilenameFilter; import java.io.IOException; import java.util.*; @@ -41,7 +42,7 @@ */ public class FileUtils { - public static List getListFileName( File directory, String extentions ) + public static List getListFileName( File directory, String extention ) { List result = new ArrayList(); @@ -56,6 +57,16 @@ return result; } + public static List getListFileName( File directory, FilenameFilter filenameFilter ) + { + if ( directory != null ) + { + return Arrays.asList( directory.list( filenameFilter ) ); + } + + return new ArrayList(); + } + public static List getListFile( File directory, FileFilter fileFilter ) { if ( directory != null ) === modified file 'local/vn/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-06-07 05:41:55 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-06-07 10:07:02 +0000 @@ -141,13 +141,17 @@ - + - + + + + + + + + + - + - - + - + - - - + + + - + - - + + - + - - - + + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + /dhis-web-commons/ajax/jsonResponseError.vm + + @@ -649,13 +657,17 @@ - generateAdvancedReportCategory.action + generateAdvancedReportCategory.action?organisationGroupId=${organisationGroupId} + - generateAdvancedReportNormal.action + generateAdvancedReportNormal.action?organisationGroupId=${organisationGroupId} + - generateAdvancedReportOrganizationGroupListing.action + generateAdvancedReportOrganizationGroupListing.action?organisationGroupId=${organisationGroupId} + - generateAdvancedReportPeriodColumnListing.action + generateAdvancedReportPeriodColumnListing.action?organisationGroupId=${organisationGroupId} + - generatePreviewAdvancedCategory.action + generatePreviewAdvancedCategory.action?organisationGroupId=${organisationGroupId} + - generatePreviewAdvancedNormal.action + generatePreviewAdvancedNormal.action?organisationGroupId=${organisationGroupId} + - generatePreviewAdvancedOrgGroupListing.action + generatePreviewAdvancedOrgGroupListing.action?organisationGroupId=${organisationGroupId} + - generatePreviewAdvancedPeriodColumnListing.action + generatePreviewAdvancedPeriodColumnListing.action?organisationGroupId=${organisationGroupId} + $i18n.getString( "generate_advanced_report" ) #openHelp( "excelReportingAdvancedReport" ) - +
- + @@ -44,9 +44,13 @@
@@ -11,9 +11,9 @@
-
-
- -
+
+ +
+ +
+ +

@@ -54,7 +58,7 @@

- +

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2011-06-07 10:07:02 +0000 @@ -58,7 +58,7 @@ $i18n.getString( 'edit' ) $i18n.getString( 'download' ) - #if( !$value ) + #if( !$value ) $i18n.getString( 'remove' ) #end === modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/generateReportForm.vm' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/generateReportForm.vm 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/generateReportForm.vm 2011-06-07 10:07:02 +0000 @@ -45,8 +45,8 @@

- - + +

@@ -58,8 +58,8 @@ #if ( $organisationUnit ) - $(document).ready(function() { - + $(document).ready(function() + { getExportReportsByGroup(); }); === modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2011-06-07 10:07:02 +0000 @@ -71,28 +71,46 @@ jQuery.each( json.periods, function(i, item ){ addOption('period', item.name , i ); }); - } -function generateExportReport() { - +function validateGenerateReport( isAdvanced ) +{ var exportReport = getFieldValue('exportReport'); - if(exportReport.length == 0){ + + if ( exportReport.length == 0 ) + { showErrorMessage( i18n_specify_export_report ); return; } lockScreen(); - + + jQuery.postJSON( 'validateGenerateReport.action', + { + 'exportReportId': byId('exportReport').value, + 'periodIndex': byId('period').value + }, + function( json ) + { + if ( json.response == "success" ) { + if ( isAdvanced ) { + generateAdvancedExportReport(); + } + else generateExportReport(); + } + else { + unLockScreen(); + showWarningMessage( json.message ); + } + }); +} + +function generateExportReport() { + var request = new Request(); request.setResponseTypeXML( 'xmlObject' ); request.setCallbackSuccess( generateExportReportReceived ); - - var params = "exportReportId=" + byId('exportReport').value; - params += "&periodIndex=" + byId('period').value; - request.sendAsPost(params); request.send( 'generateExportReport.action'); - } function generateExportReportReceived( xmlObject ) { @@ -129,18 +147,10 @@ } } -function generateAdvancedExportReport() { - - lockScreen(); - +function generateAdvancedExportReport() +{ var request = new Request(); request.setResponseTypeXML( 'xmlObject' ); request.setCallbackSuccess( generateExportReportReceived ); - - var params = "exportReportId=" + byId('exportReport').value; - params += "&periodId=" + byId('period').value; - params += "&organisationGroupId=" + byId("availableOrgunitGroups").value; - request.sendAsPost(params); - request.send( 'generateAdvancedExportReport.action'); - + request.send( 'generateAdvancedExportReport.action?organisationGroupId='+ byId("availableOrgunitGroups").value ); } === modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2011-05-27 04:45:31 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2011-06-07 10:07:02 +0000 @@ -1,33 +1,50 @@ +function validatePreviewReport( isAdvanced ) +{ + var exportReport = getFieldValue('exportReport'); + + if ( exportReport.length == 0 ) + { + showErrorMessage( i18n_specify_export_report ); + return; + } + + lockScreen(); + + jQuery.postJSON( 'validateGenerateReport.action', + { + 'exportReportId': byId('exportReport').value, + 'periodIndex': byId('period').value + }, + function( json ) + { + if ( json.response == "success" ) { + if ( isAdvanced ) { + previewAdvandReport(); + } + else previewExportReport(); + } + else { + unLockScreen(); + showWarningMessage( json.message ); + } + }); +} + +function previewExportReport() { + + var request = new Request(); + request.setResponseTypeXML( 'reportXML' ); + request.setCallbackSuccess( previewExportReportReceived ); + request.send( 'previewExportReport.action' ); +} + function previewAdvandReport() -{ - var params = "exportReportId=" + byId('exportReport').value + "&periodId=" + byId('period').value + "&organisationGroupId=" + byId("availableOrgunitGroups").value; - - lockScreen(); - +{ var request = new Request(); request.setResponseTypeXML( 'reportXML' ); request.setCallbackSuccess( previewExportReportReceived ); request.sendAsPost( params ); - request.send( "previewAdvancedExportReport.action" ); -} - -function previewExportReport() { - - var exportReport = getFieldValue('exportReport'); - if(exportReport.length == 0){ - showErrorMessage(i18n_specify_export_report); - return; - } - - lockScreen(); - - var url = "previewExportReport.action?exportReportId=" + getListValue('exportReport') + "&periodIndex=" + getListValue('period'); - - var request = new Request(); - request.setResponseTypeXML( 'reportXML' ); - request.setCallbackSuccess( previewExportReportReceived ); - request.send( url ); - + request.send( "previewAdvancedExportReport.action?organisationGroupId=" + byId("availableOrgunitGroups").value ); } function previewExportReportReceived( parentElement ) === removed file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/advancedReport.vm' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/advancedReport.vm 2011-05-24 07:48:23 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/advancedReport.vm 1970-01-01 00:00:00 +0000 @@ -1,77 +0,0 @@ -

$i18n.getString( "generate_advanced_report" ) #openHelp( "excelReportingAdvancedReport" )

- - - - - - - - - - - - - - - - - - - - - -
- -
- -
- - -
- -
$i18n.getString('choose_orgunit_group')*
- -
- -
- -
- -
- - -
-
-

- - - -

- -
- - - - - - \ No newline at end of file === modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/exportReports.vm' --- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/exportReports.vm 2011-05-27 04:45:31 +0000 +++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/exportReports.vm 2011-06-07 10:07:02 +0000 @@ -1,5 +1,5 @@

$i18n.getString('export_reports') #openHelp( "excelReportingListOfExportReports" )

- +
- #foreach($exportReport in $exportReports) + #foreach( $exportReport in $exportReports ) + #set( $exist = $templateMap.get( $exportReport.excelTemplateFile ) ) - +
$i18n.getString( "filter_by_name" ): @@ -21,12 +21,17 @@
$encoder.htmlEncode( $exportReport.name )$i18n.getString($exportReport.reportType)$i18n.getString( $exportReport.reportType ) - $encoder.htmlEncode( $exportReport.excelTemplateFile ) + #if( $exist ) + $encoder.htmlEncode( $exportReport.excelTemplateFile ) + #else + $encoder.htmlEncode( $exportReport.excelTemplateFile ) $i18n.getString( 'missing_template' ) + #end $i18n.getString( 'define_associations' )