<?php
/**
 * @package linea21.modules
 * @subpackage dashboard
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

include_once(override('../dashboard/' . SQL . '.inc.php'));
include_once('../dashboard/common.php');
/**
 * DisplayListValuesByThemes()
 * affichage du tableau de bord
 * @param integer $id_filter
 * @param integer $filter
 * @return
 **/

if(!function_exists('DisplayListValuesByThemes')) {

	function DisplayListValuesByThemes($id_filter = -1, $filter = -1)
	{
		$result = $GLOBALS['sql_object'] -> DBSelect(SQL_getListtheme());
		$result_sdi = $GLOBALS['sql_object'] -> DBSelect(SQL_getListSdi("P", $valueparam = 0));
		$listing = "";
		
		$a = array(); // to not display twice an indicator

		$current_sdtheme = '';

		for ($i = 0;$i < count($result);$i++) {
			if ($result[$i]['sdtheme_id'] != $current_sdtheme && $current_sdtheme <> '') {
				$listing .= "</tbody>" . END_LINE;
				$listing .= "</table>" . END_LINE;
			}
			if ($result[$i]['sdtheme_id'] != $current_sdtheme) {

				$current_sdtheme = $result[$i]['sdtheme_id'];
				$listing .= "<h2 class=\"dashboard theme-".$current_sdtheme."\">" . formatText($result[$i]['sdtheme_name'], '2HTML') . "</h2>".END_LINE;
				$listing .= '<table cellspacing="0" cellpadding="5" class="table_dashboard" summary="'.sprintf(_t('dashboard','list_public_summary'), formatText($result[$i]['sdtheme_name'], '2HTML')).'">' . END_LINE;
				$listing .= '<thead>' . END_LINE;
				$listing .= '<tr>' . END_LINE;
				$listing .= '<td style="width:250px">'.mb_ucfirst(_t('dashboard','graphic_value')).'</td>' . END_LINE;
				$listing .= '<td>'.mb_ucfirst(_t('dashboard','label_value')).'</td>' . END_LINE;
				$listing .= '</tr>' . END_LINE;
				$listing .= '</thead>' . END_LINE;
				$listing .= '<tbody>' . END_LINE;
				 
			}
			for ($j = 0;$j < count($result_sdi);$j++) {
				if ($result[$i]['theme_id'] == $result_sdi[$j]['sdii_theme']) {
					
					// we display the value only if attached to dashboard
					// and if not yet displayed
					if ($result_sdi[$j]['sdii_to_dashboard']=='Y' && !in_array($result_sdi[$j]['sdii_id'], $a)) {
						// setting $threshold_value
						// By default initial value
						$threshold_value = $result_sdi[$j]['sdii_threshold_value'];
						// if set, we get the latest for the given scale
						$r = $GLOBALS['sql_object'] -> DBSelect(SQL_getlastInsertByPublicationDate($result_sdi[$j]['sdii_id'], $id_filter));
						if(isset($r[0]['sdiv_value']) && !is_null($r[0]['sdiv_threshold'])) {
							$threshold_value = $r[0]['sdiv_threshold'];
						}
						 
						$link_det_sdi= array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id'=>$result_sdi[$j]['sdii_id'], 'parentid'=> $id_filter, 'name' => $result_sdi[$j]['sdii_name']);
						$listing .= "<tr>" . END_LINE;
						$listing .= "<td>";
						$listing .= getViz($GLOBALS['sql_object'], $id_filter, $result_sdi[$j], $threshold_value);
						$listing .= "</td>";
						$listing .= "<td><a href=\"" . HrefMaker($link_det_sdi) . "\" title=\"" . formatText($result_sdi[$j]['sdii_name'], '2ATT') . "\">" . formatText(cutText($result_sdi[$j]['sdii_name'], 53), '2HTML') . "</a></td>" . END_LINE;
						$listing .= "</tr>" . END_LINE;
						
						array_push($a, $result_sdi[$j]['sdii_id']); // we add the id into array for not displaying it twice
					}
				}
			}
		}
		$listing .= "</tbody>" . END_LINE;
		$listing .= "</table>" . END_LINE;
		
		hoverJsBox();

		echo $listing;
	}
}

/**
 * DisplayListValuesByProjects()
 * affichage du tableau de bord
 * @param integer $id_filter
 * @param integer $filter
 * @return
 **/

if(!function_exists('DisplayListValuesByProjects')) {

	function DisplayListValuesByProjects($id_filter = -1, $filter = -1)
	{
		$result = $GLOBALS['sql_object'] -> DBSelect(SQL_getListProjects());
		$result_sdi = $GLOBALS['sql_object'] -> DBSelect(SQL_getListSdi("P", $valueparam = 0));
		$listing = "";

		$current_project = '';

		for ($i = 0;$i < count($result);$i++) {
			if ($result[$i]['project_id'] != $current_project && $current_project <> '') {
				$listing .= "</tbody>" . END_LINE;
				$listing .= "</table>" . END_LINE;
			}
			if ($result[$i]['project_id'] != $current_project) {

				$current_project = $result[$i]['project_id'];
				$listing .= "<h2 class=\"dashboard project-".$current_project."\">" . formatText($result[$i]['project_name'], '2HTML') . "</h2>".END_LINE;
				$listing .= '<table cellspacing="0" cellpadding="5" class="table_dashboard" summary="'.sprintf(_t('dashboard','list_public_summary'), formatText($result[$i]['project_name'], '2HTML')).'">' . END_LINE;
				$listing .= '<thead>' . END_LINE;
				$listing .= '<tr>' . END_LINE;
				$listing .= '<td style="width:250px">'.mb_ucfirst(_t('dashboard','graphic_value')).'</td>' . END_LINE;
				$listing .= '<td>'.mb_ucfirst(_t('dashboard','label_value')).'</td>' . END_LINE;
				$listing .= '</tr>' . END_LINE;
				$listing .= '</thead>' . END_LINE;
				$listing .= '<tbody>' . END_LINE;
					
			}
			for ($j = 0;$j < count($result_sdi);$j++) {
				if ($result[$i]['project_id'] == $result_sdi[$j]['jps_project_id']) {
						
					// we display the value only if attached to dashboard
					if ($result_sdi[$j]['sdii_to_dashboard']=='Y') {
						// setting $threshold_value
						// By default initial value
						$threshold_value = $result_sdi[$j]['sdii_threshold_value'];
						// if set, we get the latest for the given scale
						$r = $GLOBALS['sql_object'] -> DBSelect(SQL_getlastInsertByPublicationDate($result_sdi[$j]['sdii_id'], $id_filter));
						if(isset($r[0]['sdiv_value']) && !is_null($r[0]['sdiv_threshold'])) {
							$threshold_value = $r[0]['sdiv_threshold'];
						}
							
						$link_det_sdi= array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id'=>$result_sdi[$j]['sdii_id'], 'parentid'=> $id_filter, 'name' => $result_sdi[$j]['sdii_name']);
						$listing .= "<tr>" . END_LINE;
						$listing .= "<td>";
						$listing .= getViz($GLOBALS['sql_object'], $id_filter, $result_sdi[$j], $threshold_value);
						$listing .= "</td>";
						$listing .= "<td><a href=\"" . HrefMaker($link_det_sdi) . "\" title=\"" . formatText($result_sdi[$j]['sdii_name'], '2ATT') . "\">" . formatText(cutText($result_sdi[$j]['sdii_name'], 53), '2HTML') . "</a></td>" . END_LINE;
						$listing .= "</tr>" . END_LINE;
					}
				}
			}
		}
		$listing .= "</tbody>" . END_LINE;
		$listing .= "</table>" . END_LINE;

		hoverJsBox();
		
		echo $listing;
	}
}

function hoverJsBox() {
	
	$js = '<script type="text/javascript">
	$(document).ready(function() {
	$(".dashboard-indicator-gauge .cursor").removeAttr("title");
	$(".infobox").hover(
		function() {
			$(this).next().fadeIn("fast");
		},
		function() {
			$(this).next().hide();
		}
	);
	});
	</script>';
	footerAddInlineJS($js, 'default', false);
}


/**
 * DisplayOneSdi()
 * affichage d'un indicateur et infos résumé
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('DisplayOneSdi')) {

	function DisplayOneSdi($sdi_id, $scale_id)
	{
		echo GetSdiTitle($sdi_id, $scale_id);
		echo getDashboardNavigation($sdi_id,$scale_id);
		echo GetAllValue($sdi_id, $scale_id);
		echo GetOneSdiInfo($sdi_id);
	}
}

/**
 * DisplayOneSdirules()
 * affichage d'un indicateur et toutes ses infos
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('DisplayOneSdirules')) {

	function DisplayOneSdirules($sdi_id, $scale_id)
	{
		echo GetSdiTitle($sdi_id, $scale_id);
		echo getDashboardNavigation($sdi_id,$scale_id);
		echo GetOneSdiRules($sdi_id);
	}
}
/**
 * DisplayOneSdievaluation()
 * affichage d'un indicateur et toutes ses infos
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('DisplayOneSdievaluation')) {

	function DisplayOneSdievaluation($sdi_id, $scale_id)
	{
		echo GetSdiTitle($sdi_id, $scale_id);
		echo getDashboardNavigation($sdi_id,$scale_id);
		echo GetOneSdiEvaluation($sdi_id);
	}
}
/**
 * DisplayOneSdiprovider()
 * affichage d'un indicateur et toutes ses infos
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('DisplayOneSdiprovider')) {

	function DisplayOneSdiprovider($sdi_id, $scale_id)
	{
		echo GetSdiTitle($sdi_id, $scale_id);
		echo getDashboardNavigation($sdi_id,$scale_id);
		echo GetOneSdiProvider($sdi_id);
	}
}
/**
 * GetAllValue()
 * afficahge de l'ensemble des valeurs publiques d'un IDD
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('GetAllValue')) {

	function GetAllValue($sdi_id, $scale_id)
	{
		$result_value = $GLOBALS['sql_object'] -> DBSelect(SQL_getAllValue("SCD", $scale_id, $sdi_id));
		$result_sdi_value = $GLOBALS['sql_object'] -> DBSelect(SQL_getInfoSdiforvalue($sdi_id));

		// setting $default_threshold value
		// By default initial value
		$default_threshold = $result_sdi_value[0]['sdii_threshold_value'];

		$content = '<div id="indicator-value" class="internal-content">' . END_LINE;
		$content .= '<h2>'._t('dashboard','historic').'</h2>' . END_LINE;
		$content .= '<div id="indicator-threshold">'._t('sdi','initial_threshold_value').' : <span>'.$result_sdi_value[0]['sdii_threshold_value'].' '.$result_sdi_value[0]['sdii_unit'].'</span></div>' . END_LINE;

		if ($result_value <> false) {
			if (count($result_value) > 2) {
				$content .= '<h3>'._t('dashboard','rep_graph').' </h3>' . END_LINE;

				$content .= "<img src=\"../dashboard/graph.php?id=" . $sdi_id . "&amp;scale_id=" . $scale_id . "\"  id=\"imggraph\" class=\"graph\" alt=\"".formatText(_t('dashboard','rep_graph'), '2ATT')."\"/>" . END_LINE;
			}
			$content .= '<h3>'._t('dashboard','value').'</h3>' . END_LINE;

			$content .= '<table cellspacing="0" cellpadding="5" class="table_dashboard_det"  summary="'._t('dashboard','all_values_summary').'">' . END_LINE;
			$content .= '<thead>' . END_LINE;
			$content .= '<tr>' . END_LINE;
			$content .= "<td>".mb_ucfirst(_t('dashboard','date'))."</td>" . END_LINE;
			$content .= "<td>".mb_ucfirst(_t('dashboard','value'))." (".$result_sdi_value[0]['sdii_unit'].")</td>" . END_LINE;
			$content .= "<td>".mb_ucfirst(_t('dashboard','threshold_value'))."</td>" . END_LINE;
			$content .= "<td>".mb_ucfirst(_t('dashboard','comment'))."</td>" . END_LINE;
			$content .= "</tr>" . END_LINE;
			$content .= "</thead>" . END_LINE;
			$content .= "<tbody>" . END_LINE;

			for ($i = 0;$i < count($result_value);$i++) {
				$comment = '';
				 
				// if set, we get it from the table
				if(!is_null($result_value[$i]['sdiv_threshold'])) {
					$threshold = $result_value[$i]['sdiv_threshold'];
				} else {
					$threshold = $default_threshold;
				}
				 
		  if(!empty($result_value[$i]['sdiv_comment']) && $result_value[$i]['sdiv_comment_display']=='Y') {
		  	$comment  = '<div class="valuecomment">';
		  	$comment .= '<img src="'.THEME_PUBLIC_PATH.'images/infobull.gif" />';
		  	$comment .= '<div class="cont"><strong>'.ucfirst(_t('dashboard', 'comment')).' :</strong> '.$result_value[$i]['sdiv_comment'].'</div>';
		  	$comment .= '</div>';
		  }
		  $content .= "<tr>" . END_LINE;
		  $content .= "<td>" . formatText($result_value[$i]['date_p'], '2HTML') . "</td>" . END_LINE;
		  $content .= "<td>" . formatText($result_value[$i]['sdiv_value'], '2HTML') . "</td>" . END_LINE;
		  $content .= "<td class=\"threshold\">" . formatText($threshold, '2HTML') . "</td>" . END_LINE;
		  $content .= "<td>". $comment. "</td>\n";
		  $content .= "</tr>" . END_LINE;
			}

			$content .= "</tbody>" . END_LINE;
			$content .= "</table>" . END_LINE;
			$content .= '</div>' . END_LINE;
			return $content;
		}
	}
}

/**
 * GetSdiTitle()
 * affichage nom d'un indicateur
 * @param $sdi_id
 * @param $scale_id
 * @return
 **/
if(!function_exists('GetSdiTitle')) {

	function GetSdiTitle($sdi_id, $scale_id)
	{
		$link_self= array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id' => $sdi_id, 'parentid' => $_REQUEST['parentid']);
		$data_sdi = $GLOBALS['sql_object'] -> DBSelect(SQL_getOnesdiname($sdi_id, array('P')));
		
		if($data_sdi == 0) error_redirect();
		
		$data_scale = $GLOBALS['sql_object'] -> DBSelect(SQL_getonescale($scale_id));
		$sdi_name = formatText($data_sdi[0]['sdii_name'], '2HTML');
		$sdi_description = formatText($data_sdi[0]['sdii_description'], '2HTML');
		$scale_name = formatText(cutText($data_scale[0]['scale_denomination'], 150), '2HTML');
		$content  = '<div id="indicator-main">' . END_LINE;
		$content .= '<h1>' . mb_ucfirst($sdi_name) . '</h1>' . END_LINE;
		$content .='<p class="permalink">'.END_LINE;
		$content .= formatted_permalink($link_self);
		$content .='</p>'.END_LINE;
		$content .= '<div id="indicator-desc" class="body">' . $sdi_description . '</div>' . END_LINE;
		$content .= '<p class="scale"> échelle : <span>' . $scale_name . '</span></p>' . END_LINE;
		$content .= '</div>' . END_LINE;

		return $content;
	}
}

/**
 * GetOneSdiInfo()
 * récupération des infos générales d'un indicateur
 * @param $sdi_id
 * @return
 **/
if(!function_exists('GetOneSdiInfo')) {

	function GetOneSdiInfo($sdi_id)
	{
		$data = $GLOBALS['sql_object'] -> DBSelect(SQL_getInfoSdi($sdi_id));

		$sdi_name = formatText($data[0]['sdii_name'], '2HTML');
		$sdi_theme = formatText(cutText($data[0]['theme_name'], 150), '2HTML');
		$sdi_description = formatText($data[0]['sdii_description'], '2HTML');
		$sdi_comment = formatText($data[0]['sdii_comment'], '2HTML');
		$sdi_goal = formatText($data[0]['sdii_goal'], '2HTML');
		$sdi_consulting = formatText($data[0]['sdii_consulting'], '2HTML');

		$content = '<div id="indicator-info" class="internal-content">' . END_LINE;
		$content .= '<h2>'.mb_ucfirst(_t('dashboard','det_sdi2')).'</h2>' . END_LINE;
		$content .= '<h3> '.mb_ucfirst(_t('sdi','goal_public')).' </h3>' . END_LINE;
		$content .= '<div id="indicator-goal" class="body">' . $sdi_goal . '</div>' . END_LINE;
		$content .= '<h3>'.mb_ucfirst(_t('sdi','consulting_public')).'</h3>' . END_LINE;
		$content .= '<div id="indicator-advices" class="body">' . $sdi_consulting . '</div>' . END_LINE;
		$content .= '</div><br />' . END_LINE;
		return $content;
	}
}

/**
 * GetOneSdiRules()
 * récupération des réglementations d'un indicateur
 * @param $sdi_id
 * @return
 **/
if(!function_exists('GetOneSdiRules')) {

	function GetOneSdiRules($sdi_id)
	{
		$result_r = $GLOBALS['sql_object'] -> DBSelect(SQL_getRules($sdi_id, $GLOBALS['sql_object'], -1));
		$r_title = formatText($result_r[0]['sdir_title'], '2HTML');
		$r_body = formatText($result_r[0]['sdir_body'], '2HTML');
		if(!empty($result_r[0]['sdir_referer_uri'])) {
			$url = "<a href=\"" . formatText($result_r[0]['sdir_referer_uri'], '2HTML') . "\" title=\"" . formatText($result_r[0]['sdir_mask_uri'], '2ATT') . "\">" . formatText($result_r[0]['sdir_mask_uri'], '2HTML') . "</a>";
		}

		$content = '<div id="indicator-rules" class="internal-content">' . END_LINE;
		$content .= '<h2>'.mb_ucfirst(_t('sdi','r_body')).'</h2>' . END_LINE;
		if ($result_r[0]['sdir_title'] == "") {
			$content .= "<p class=\"info\">"._t('divers','nodata')." </p>" . END_LINE;
		} else {
			$content .= "<h3>" . $r_title . "</h3>" . END_LINE;
			$content .= "<div class=\"body\">" . $r_body . "</div>" . END_LINE;
			if(isset($url)) {
				$content .= "<p>" . $url . "</p>" . END_LINE;
			}
		}
		$content .= '</div>' . END_LINE;

		return $content;
	}
}

/**
 * GetOneSdiEvaluation()
 * récupération des critères d'évaluation d'un indicateur
 * @param $sdi_id
 * @return
 **/
if(!function_exists('GetOneSdiEvaluation')) {

	function GetOneSdiEvaluation($sdi_id)
	{
		$result_e = $GLOBALS['sql_object'] -> DBSelect(SQL_getEvaluation($sdi_id, $GLOBALS['sql_object'], -1));

		$content = '<div id="indicator-evaluation" class="internal-content">' . END_LINE;
		$content .= '<h2>'.mb_ucfirst(_t('sdi','e_title')).'</h2>' . END_LINE;
		$content .= '<table cellspacing="0" cellpadding="5" class="table_dashboard_det" summary="'._t('dashboard','evaluation_values_summary').'">' . END_LINE;
		$content .= '<thead>' . END_LINE;
		$content .= '<tr>' . END_LINE;
		$content .= "<td>"._t('sdi','e_scale_compare')."</td>" . END_LINE;
		$content .= "<td>"._t('sdi','e_fiability')."</td>" . END_LINE;
		$content .= "<td>"._t('sdi','e_accessibility')."</td>" . END_LINE;
		$content .= "<td>"._t('sdi','e_lisibility')."</td>" . END_LINE;
		$content .= "<td>"._t('sdi','e_relevance')."</td>" . END_LINE;
		$content .= "<td>"._t('sdi','e_global_performance')."</td>" . END_LINE;
		$content .= "</tr>" . END_LINE;
		$content .= "</thead>" . END_LINE;
		$content .= "<tbody>" . END_LINE;
		$content .= "<tr>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_scale_compare'] . "</td>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_fiability'] . "</td>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_accessibility'] . "</td>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_lisibility'] . "</td>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_relevance'] . "</td>" . END_LINE;
		$content .= "<td>" . $result_e[0]['sdie_global_performance'] . "</td>" . END_LINE;
		$content .= "</tr>" . END_LINE;
		$content .= "</tbody>" . END_LINE;
		$content .= "</table>" . END_LINE;
		$content .= '</div>' . END_LINE;

		return $content;
	}
}

/**
 * GetOneSdiProvider()
 * récupération des infos du fournisseurs d'un indicateur
 * @param $sdi_id
 * @return
 **/
if(!function_exists('GetOneSdiProvider')) {

	function GetOneSdiProvider($sdi_id)
	{
		$result_p = $GLOBALS['sql_object'] -> DBSelect(SQL_getProvider($sdi_id, $GLOBALS['sql_object'], -1));

		$p_name = formatText($result_p[0]['sdip_name'], '2HTML');
		$p_description = formatText($result_p[0]['sdip_description'], '2HTML');

		$content = '<div id="indicator-provider" class="internal-content">' . END_LINE;
		$content .= '<h2>'.mb_ucfirst(_t('sdi','p_title')).'</h2>' . END_LINE;
		if ($result_p[0]['sdip_name'] == "") {
			$content .= "<p class=\"info\">"._t('divers','nodata')." </p>" . END_LINE;
		} else {
			$content .= '<p>' . $p_name . '</p>' . END_LINE;
			$content .= '<div class="body">' . $p_description . '</div>' . END_LINE;
		}
		$content .= '</div>' . END_LINE;
		return $content;
	}
}

/**
 * getDataVizMode()
 * return a link to switch display mode
 * @param $scale_id
 * @return string
 * @todo remove or use to display tabular data
 **/
if(!function_exists('getDataVizSwitcher')) {

	function getDataVizSwitcher($altmode, $scale_id)
	{
		if( $altmode )  {
			$link = array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'], 'id' => $scale_id);
			$msg = _t('dashboard', 'mode_by_finality');
		} else {
			$link = array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'], 'id' => $scale_id, 'altmode' => true);
			$msg = _t('dashboard', 'mode_by_project');
		}
		// adding these vars to url allow to display the right scale into filter box
		// @todo filters should be enhanced
		if(array_key_exists('filter', $_REQUEST) && $_REQUEST['filter'] == $GLOBALS['filters'][U_L]['scale']['linkvalue']) {
			$link = array_merge($link, array('filter' => $GLOBALS['filters'][U_L]['scale']['linkvalue']));
		}
		
		
		$str   = '<div class="switchnav">';
		$str  .= '<a class="button" href="'.HrefMaker($link).'" title="'.$msg.'">'.$msg.'</a>'.END_LINE;
		$str  .= '</div>';
		
		return $str;
	}
}

/**
 * getDashboardNavigation()
 * Return a string with the internal navigation
 * @param int
 * @param int
 * @return string
 **/
if(!function_exists('getDashboardNavigation')) {

	function getDashboardNavigation($sdi_id,$scale_id)
	{
		$data = $GLOBALS['sql_object'] -> DBSelect(SQL_getOnesdiname($sdi_id));
		$link_aff_info = HrefMaker(array('rub' => $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id' => $sdi_id, 'parentid' => $scale_id, 'name' => $data[0]['sdii_name']));
		$link_aff_rules = HrefMaker(array('rub' => $GLOBALS['links'][U_L]['dashboard-rules']['linkvalue'], 'id' => $sdi_id, 'parentid' => $scale_id, 'name' => $data[0]['sdii_name']));
		 
		$link_aff_provider = HrefMaker(array('rub' => $GLOBALS['links'][U_L]['dashboard-provider']['linkvalue'],'id' => $sdi_id, 'parentid' => $scale_id, 'name' => $data[0]['sdii_name']));
		$link_aff_evaluation = HrefMaker(array('rub' => $GLOBALS['links'][U_L]['dashboard-assessment']['linkvalue'], 'id' => $sdi_id, 'parentid' => $scale_id, 'name' => $data[0]['sdii_name']));
		 
		ActiveItemKey($GLOBALS['activeitem'])=='dashboard' ? $info_class='active' : $info_class='';
		ActiveItemKey($GLOBALS['activeitem'])=='dashboard-rules' ? $rules_class='active' : $rules_class='';
		ActiveItemKey($GLOBALS['activeitem'])=='dashboard-assessment' ? $assessment_class='active' : $assessment_class='';
		ActiveItemKey($GLOBALS['activeitem'])=='dashboard-provider' ? $provider_class='active' : $provider_class='';

		$content ="<div class=\"internal-nav\" id=\"indicator-nav\">". END_LINE;
		$content .="<ul>". END_LINE;
		$content .="<li>". END_LINE;
		$content .= '<a href="' . $link_aff_info . '" title="'.formatText(_t('dashboard','mode_aff_info'), '2ATT').'" class="'.$info_class.'">'._t('dashboard','mode_aff_info').'</a> ' . END_LINE;
		$content .="</li>". END_LINE;
		$content .="<li>". END_LINE;
		$content .= '<a href="' . $link_aff_rules . '" title="'.formatText(_t('dashboard','mode_aff_rules'), '2ATT').'" class="'.$rules_class.'">'._t('dashboard','mode_aff_rules').'</a> ' . END_LINE;
		$content .="</li>". END_LINE;
		$content .="<li>". END_LINE;
		$content .= '<a href="' . $link_aff_provider . '" title="'._t('dashboard','mode_aff_provider').'" class="'.$provider_class.'">'._t('dashboard','mode_aff_provider').'</a> ' . END_LINE;
		$content .="</li>". END_LINE;
		$content .="<li>". END_LINE;
		$content .= '<a href="' . $link_aff_evaluation . '" title="'.formatText(_t('dashboard','mode_aff_evaluation'), '2ATT').'" class="'.$assessment_class.'">'._t('dashboard','mode_aff_evaluation').'</a> ' . END_LINE;
		$content .="</li>". END_LINE;
		$content .="</ul>". END_LINE;
		$content .="</div>". END_LINE;

		return $content;
	}
}


?>