<?php
/**
 * Export module
 * 
 * Main report generation page
 * 
 * @package linea21\utils\export
 * @author $Author$ - linea21 <info@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 * Define, compose and generate a SDI (Sustainable Development Indicators) PDF report
 */

ob_start();
session_start();

set_time_limit(0);

include_once('../config/define.php');
include_once('../languages/'.U_L.'/lang_common.' . CHARSET . '.php');


if($_POST['what'] === 'dashboard') {
	//////////// Check Droits utilisateur ////////////
	if (!$l21auth->hasRight('dashboard')) ReloadIndex('admin');
	////////////
	include_once('../languages/'.U_L.'/lang_sdi.' . CHARSET . '.php');
	include_once('../languages/'.U_L.'/lang_dashboard.' . CHARSET . '.php');
	include_once('phpsql.process.dashboard.php');
	include_once('../dashboard/common.php');
} else {
	//////////// Check Droits utilisateur ////////////
	if (!$l21auth->hasRight('project')) ReloadIndex('admin');
	////////////
	include_once('../languages/'.U_L.'/lang_project.' . CHARSET . '.php');
	include_once('phpsql.process.project.php');
}
include_once('../level/display.php');
require_once('../lib/vendor/class.html2text.php');
$converter = new Html2Text();

isset($_POST['quick_export']) ? $report_settings['quick_export'] = true : false ;
isset($_POST['format_report']) ? $report_settings['export_format'] = $_POST['format_report'] : $report_settings['export_format'] = 'pdf';

// DO NOT REMOVE - usefull for debug !
// error_reporting(E_ALL);
// ini_set('display_errors', '1');

// we remove all old images files in case there are still there
SureRemoveDir('../tmp/report', 1);

if($report_settings['export_format'] == 'pdf') {
	
	require_once(override('../export/pdf/main.php', THEME_ADMIN_PATH));
	
} else {
	
	require_once(override('../export/word/main.php', THEME_ADMIN_PATH));
	
}

SureRemoveDir('../tmp/report', 1);
?>