/**
 * Axelor Business Solutions
 *
 * Copyright (C) 2014 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.apps;

import com.axelor.app.AppSettings;

public class ReportSettings {
	
	public static String FORMAT_PDF = "pdf";
	public static String FORMAT_XLS = "xls";
	public static String FORMAT_DOC = "doc";
	public static String FORMAT_HTML = "html";
	
	private static String BIRT_PATH = "birt";

	private String url = "";
	
	public ReportSettings(String rptdesign, String format)  {
		
		this.addAxelorReportPath(rptdesign)
		.addDataBaseConnection()
		.addParam("__format", format);
		
	}
	
	public ReportSettings(String rptdesign)  {
		
		this.addAxelorReportPath(rptdesign)
		.addDataBaseConnection()
		.addParam("__format", FORMAT_PDF);
		
	}
	
	public String getUrl()  {
		
		return this.url;
		
	}	
	
	private ReportSettings addAxelorReportPath(String rptdesign)  {
		
		AppSettings appsSettings = AppSettings.get();
		
		String defaultUrl = appsSettings.getBaseURL();
		defaultUrl = defaultUrl.substring(0, defaultUrl.lastIndexOf('/'));
		defaultUrl += "/" + BIRT_PATH ;
		
		String appsUrl = appsSettings.get("axelor.report.engine", defaultUrl);
		
		this.url +=  appsUrl + "/frameset?__report=report/" + rptdesign;
		return this;
		
	}	
	
	private ReportSettings addDataBaseConnection()  {
		
		AppSettings appSettings = AppSettings.get();
		
		return this.addParam("DBName", appSettings.get("db.default.url"))
		.addParam("UserName", appSettings.get("db.default.user"))
		.addParam("Password", appSettings.get("db.default.password"));
		
	}	

	public ReportSettings addParam(String param, String value)  {
		
		this.url +=  "&" + param + "=" + value;
		return this;
		
	}
}


@@ -1760,24 +1760,191 @@
 ultUrl);%0A%09%09%0A
+%09%09String resourcePath = appsSettings.get(%22axelor.report.resource.path%22, %22report%22);%0A%09%09resourcePath = resourcePath.endsWith(%22/%22) ? resourcePath : resourcePath + %22/%22;%0A%09%09%0A
 %09%09this.url +
@@ -1980,16 +1980,24 @@
 ort=
-report/%22
+%22 + resourcePath
  + r

Use axelor.report.resource.path property.