<?php
/**
 * @package linea21.utils
 * @subpackage report_sdi
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 * Define, compose and generate a SDI (Sustainable Development Indicators) PDF report
 */

/////////////////////////////////////////
//	TRAITEMENT DES DONNEES PHP - RAPPORT
/////////////////////////////////////////


if (!isset($_POST['generer']) && !isset($_POST['sauver'])) exit;

include_once('../dashboard/'.SQL.'.inc.php');
include_once("../class/system/class." . SQL . ".php");

$sql_entity = SQL;
$sql_object = new $sql_entity;
$sql_object->DBInitialise();
$sql_object->DBConnexion();
// paramètres utilisateurs.

$report_settings = array();

$report_settings['file'] = isset($_POST['sauver']) ? 'D': 'I';
$report_settings['title'] = $_POST['title_report'];
$report_settings['author'] = $_POST['author'];
$report_settings['mail_author'] = $_POST['mail_author'];
$report_settings['service_author'] = $_POST['service_author'];
$report_settings['adress_author'] = str_replace("\r\n", " ", $_POST['adress_author']);


$report_settings['graphic_values'] = isset($_POST['graphic']) ? true : false;

$report_settings['table_values'] = isset($_POST['table_value']) ? true : false;

$report_settings['status'] = isset($_POST['notpublished']) ? 'ALL' : 'PUBLIC';

$report_settings['display_provider'] = isset($_POST['provider']) ? true : false;

$report_settings['display_reglementation'] = isset($_POST['reglementation']) ? true : false;

$report_settings['display_evaluation'] = isset($_POST['evaluation']) ? true : false;

$report_settings['summary'] = isset($_POST['summary']) ? true : false;

$report_settings['publi_infos'] = isset($_POST['publi_info']) ? true : false;

// préparation tableau dénomination des échelles.
$scale_temp = $sql_object->DBSelect(SQL_getAllScale());
//print_r($scale_temp);
$scale_denomination_array = array();
for($i=0; $i<count($scale_temp); $i++) {
	$scale_denomination_array[$scale_temp[$i]['scale_id']] = $scale_temp[$i]['scale_denomination'];
}

if ($_POST['scale'] == 'det') {
    $report_settings['scale'] = 'EACH';
    $scale_array = $_POST['eachscale'];
} else {
	$report_settings['scale'] = 'ALL';
	// initialisation de $scale_array
	$scale_array = array();
	for($i=0; $i<count($scale_temp); $i++) {
		$scale_array[$i] = $scale_temp[$i]['scale_id'];
	}
}




if ($_POST['sdi'] == 'det') {
    $report_settings['sdi'] = 'EACH';
    $sdi_array = $_POST['eachsdi'];
} else  {
	$report_settings['sdi'] = 'ALL';
	$sdi_array = -1;
}


/////////////////////////////////////////
//	TRAITEMENT DES DONNEES PHP
/////////////////////////////////////////
$sdi=$sql_object->DBSelect(GetAllIndicatorsInfo ($report_settings['status'], $report_settings['sdi'], $sdi_array));
?>