<?php
/**
 * Dashboard module - saving indicators selection for further export
 * 
 * 
 * @package linea21\modules\dashboard
 * @author $Author$ - linea21 <info@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

$noplugin = true; // flag for ../config/define.php file
include_once('../config/define.php');

//////////// Check Inclusion de pages ////////////
if (!class_exists('auth')) {
  include_once("../lib/lib_common.php");
  ReloadIndex('admin');
}
////////////

//////////// Check Droits utilisateur ////////////
if (!$l21auth->hasRight('dashboard')) ReloadIndex('admin');
////////////

include_once('../dashboard/'.SQL.'.inc.php');

if(isset($_POST['to_export']) && $_GET['token'] == SECRET_KEY) {

	unset($_SESSION['indicator_export_ids']);
	$_SESSION['indicator_export_ids'] = array_unique($_POST['to_export']);

	// print_r($_SESSION['indicators_export_ids']);
    sleep(2);
}

// we check if values are already stored in DB. If it is, we display a warning !!!!
if(isset($_POST['check_values']) && $_GET['token'] == SECRET_KEY && is_numeric(strip_input($_POST['check_values']))) {

    $r = $sql_object -> DBSelect(SQL_getAllValue("all", 1, strip_input($_POST['check_values'])));
    $msg = _t('sdi', 'warning_switch_type');

    if(is_array($r)) echo '{"returnedValues":' . count($r) . '}';
    else echo '{"returnedValues": 0 }';
}
?>