<?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
 */

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

	if(!isset($_GET['id']) && !isset($_POST['id'])) {
	$id="1";
} else {
	if(isset($_POST['id']))	$id=$_POST['id'];
	if(isset($_GET['id']))	$id=$_GET['id'];
}
	if(!isset($_GET['scale_id']) && !isset($_POST['scale_id'])) {
	$scale_id=1;
} else {
	if(isset($_POST['scale_id']))	$scale_id=$_POST['scale_id'];
	if(isset($_GET['scale_id']))	$scale_id=$_GET['scale_id'];
}
include_once("../lib/lib_common.php"); 

$sdi_object= new sdi;
//$result_sdii=$sdi_object->GetInfoSdi($id, $sql_object);
//$result_e=$sdi_object->GetEvaluation( $id, $sql_object, $ID=-1);
//$result_p=$sdi_object->GetProvider( $id, $sql_object, $ID=-1);
//$result_r=$sdi_object->GetRules( $id, $sql_object, $ID=-1);
$req_sdii=SQL_getInfoSdi($id);
$result_sdii = $sql_object -> DBSelect($req_sdii);

$req_sdir=SQL_getRules( $id, $sql_object, $ID=-1);
$result_r = $sql_object -> DBSelect($req_sdir);

$req_sdie=SQL_getEvaluation( $id, $sql_object, $ID=-1);
$result_e = $sql_object -> DBSelect($req_sdie);

$req_sdip=SQL_getProvider( $id, $sql_object, $ID=-1);
$result_p = $sql_object -> DBSelect($req_sdip);

$req_sdiav=SQL_getAllValue("SCA", $scale_id, $id);	
$result_value = $sql_object -> DBSelect($req_sdiav);

//$result_value=$sdi_object->GetAllValue("SCA", $scale_id, $id, $sql_object);
$req_scale=SQL_getonescale($scale_id);
$resultscale2 = $sql_object -> DBSelect($req_scale);

$link_det=$rub_link."&amp;todo=det&amp;id="; 
$link_det_theme="index.php?rub=theme&amp;todo=det&amp;id="; 
$link_sup=$rub_link."&amp;todo=sup&amp;value_id=";
$link_mod=$rub_link."&amp;todo=mod&amp;value_id=";
$link_add=$rub_link."&amp;todo=add&amp;id=";
$navtitle=_t('dashboard','det')." : ".$result_sdii[0]['sdii_name'];	
//valeur du graphique
?>
<div id="chemin">
	<ul>
		<li>
			<a href="index.php" class="chemin_home"><? echo _t('way','home') ?></a>
		</li>
		<li>
			   <a href="<?php echo $rub_link; ?>" id="chemin_<? echo $rub; ?>" class="chemin_rub"><? echo _t('menu','dashboard')?></a>
		</li>
		<li>
			<span><? echo formatnavTitle($navtitle);
			?></span>
		</li>
	</ul>
</div>
  <!--end barre haute -->
<?php
include_once(THEME_ADMIN_PATH."quickicons.php");
?>
<div class="contentcontainer">
<?php
include_once($dir."/menurub.php");
?>
<div id="content">
		<h2><? echo formatTitleh2($result_sdii[0]['sdii_name']);
		?></h2>	
<div class="iconetodo2">
		<? echo "<a href=\"".$link_add.$id."&amp;scale_id=".$scale_id."\" title=\""._t('dashboard','add')."\" class=\"ico_add2\">";?></a>
		</div>	
		
		<? if ($result_value<>false) {?>
		 <br class="brendstep" />	      
		  <? if (count($result_value)>2) {?> 
		<img src="../dashboard/graph.php?id=<? echo $id; ?>&amp;scale_id=<? echo $scale_id; ?>"  id="imggraph" class="graph" alt="<? echo _t('dashboard','all_value');?>"/>
		
		<br class="brendstep" />	
		<?}
		?>
		<h2>
		<? echo formatTitleh2(_t('dashboard','all_value')." / ".$resultscale2[0]['scale_denomination']); 
		 ?>
		</h2>
		<br class="brendstep" />	
		<table cellspacing="0" cellpadding="3">
		<thead>
		<tr>
		<?
		echo "<td>"._t('dashboard','date')."</td>\n";
		echo "<td>"._t('dashboard','value')." (".formatText($result_sdii[0]['sdii_unit'], '2HTML').")"."</td>\n";
		echo "<td>&nbsp;</td>\n";
		?>
		</tr>
		</thead>
		<tbody>
		<?
		
		for ($i=0;$i<count($result_value);$i++){
		echo "<tr>\n";
		echo "<td>". formatText($result_value[$i]['date_p'], '2HTML')."</td>\n";
		echo "<td>". formatText($result_value[$i]['sdiv_value'], '2HTML');
		if ($result_value[$i]['sdiv_statut']=='D') {
		    echo "<span class=\"state\">"._t('statut','draft')."</span>";
		}
		echo "</td>\n";
		echo "<td><div class=\"iconetab\"><a href=\"".$link_sup.$result_value[$i]['sdiv_id']."&amp;id=".$id."&amp;scale_id=".$scale_id."\" title=\""._t('dashboard','sup')."\" class=\"ico_sup\"></a>";
		echo "<a href=\"".$link_mod.$result_value[$i]['sdiv_id']."&amp;id=".$id."&amp;scale_id=".$scale_id."\" title=\""._t('dashboard','mod')."\" class=\"ico_mod\"></a></div></td>\n";
		echo "</tr>\n";
		
		}
		?>
		</tbody>
		</table>
		<? }
		else echo "<br class=\"brendstep\" /><div class=\"info\">"._t('dashboard','novalue').": ".formatText($resultscale2[0]['scale_denomination'], '2HTML')."</div>";
		?>
		<br class="brendstep" />
		
		<dl class="dl2">
		<dt><? echo _t('sdi','theme') ?> : </dt>
		<dd><? 
		if (IsSuperAdmin())
		echo "<a href=\"".$link_det_theme.$result_sdii[0]['sdii_theme']."\" title=\"".formatText($result_sdii[0]['theme_name'], '2HTML')."\">".formatText($result_sdii[0]['theme_name'], '2HTML')."</a>"; 
		else echo formatText($result_sdii[0]['theme_name'], '2HTML');
		?></dd>
		<dt><? echo _t('sdi','description') ?> : </dt>
		<dd><? echo formatText($result_sdii[0]['sdii_description'], '2HTML');?></dd>
		<dt><? echo _t('sdi','threshold_relative') ?>  :</dt>
		<dd><? 
		if ($result_sdii[0]['sdii_threshold_relative']=='Y') echo _t('sdi','threshold_relative_Y');
					else echo _t('sdi','threshold_relative_N');
		?></dd>
		</dl>
		
		
		<h2>
		<? echo _t('sdi','info_mesure'); ?>
		</h2>
		
		<br class="brendstep" />
		<table cellspacing="0" cellpadding="3">
		<thead>
		<tr>
		<?
		echo "<td>"._t('sdi','max_value')." (".formatText($result_sdii[0]['sdii_unit'], '2HTML').")"."</td>\n";
		echo "<td>"._t('sdi','min_value')." (".formatText($result_sdii[0]['sdii_unit'], '2HTML').")"."</td>\n";
		echo "<td>"._t('sdi','threshold_value')." (".formatText($result_sdii[0]['sdii_unit'], '2HTML').")"."</td>\n";
		echo "<td>"._t('sdi','frequency')."</td>\n";
		?>
		</tr>
		</thead>
		<tbody>
		<?echo "<tr>\n";
		echo "<td>". formatText($result_sdii[0]['sdii_max_value'], '2HTML')."</td>\n";
		echo "<td>". formatText($result_sdii[0]['sdii_min_value'], '2HTML')."</td>\n";
		echo "<td>". formatText($result_sdii[0]['sdii_threshold_value'], '2HTML')."</td>\n";
		echo "<td>". formatText($result_sdii[0]['sdii_frequency'], '2HTML')."</td>\n";
		echo "</tr>\n";
		?>
		</tbody>
		</table>
		<br class="brendstep" />
		
		<div class="sdi_det">
		<a name="affinfoge" id="affinfoge" style="display:none;" ></a>
		<a href="#affinfoge" onclick="$('#general').slideToggle();"><?echo _t('dashboard','det_sdi');?></a>
		</div>
		<div id="general" style="display:none;" >
		<dl class="dl2">
		
		<?php /*<dt><? echo _t('sdi','range') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_sdii[0]['sdii_range']), '2HTML');?></dd> */ ?>
		<dt><? echo _t('sdi','comment') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_sdii[0]['sdii_comment']), '2HTML');?></dd>
		<dt><? echo _t('sdi','goal') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_sdii[0]['sdii_goal']), '2HTML');?></dd>
		<dt><? echo _t('sdi','consulting') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_sdii[0]['sdii_consulting']), '2HTML');?></dd>
		<dt><? echo _t('divers','statut') ?>  :</dt>
		<dd><? echo display_statut($result_sdii[0]['sdii_statut']);?></dd>
		</dl>
		</div>
		<br class="brendstep" />
		
		<div class="sdi_det">
		<a name="affprovider" id="affprovider" style="display:none;"></a>
		<a href="#affprovider" onclick="$('#provider').slideToggle();"><?echo _t('sdi','aff_sdi_p');?></a>
		</div>
		<div id="provider" style="display:none;" >
		<? if ($result_p[0]['sdip_name']=="") {
		   echo "<h2 class=\"info\">"._t('sdi','noresultp')."</h2>";    
		   }else {?>
		<?php
		if(empty($result_p[0]['sdip_email'])) {
		  $mailto_provider = empty_nc($result_p[0]['sdip_email']);
		} else {
		  $mailto_provider =  "<a href=\"mailto:".formatText(empty_nc($result_p[0]['sdip_email']), '2HTML')."\" title=\"".formatText(empty_nc($result_p[0]['sdip_email']), '2HTML')."\">".formatText(empty_nc($result_p[0]['sdip_email']), '2HTML')."</a>";
		}
		?>
		<h2><? echo formatText(empty_nc($result_p[0]['sdip_name']), '2HTML');?></h2>		
		<dl class="dl2">
		<dt><? echo formatText(empty_nc(_t('sdi','p_service')), '2HTML') ?> :</dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_service']), '2HTML');?></dd>
		<dt><? echo formatText(empty_nc(_t('sdi','p_incharge')), '2HTML') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_incharge']), '2HTML');?></dd>
		<dt><? echo _t('sdi','p_address') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_address']), '2HTML');?></dd>
		<dt><? echo _t('sdi','p_phone') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_phone']), '2HTML');?></dd>
		<dt><? echo _t('sdi','p_fax') ?> : </dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_fax']), '2HTML');?></dd>
		<dt><? echo _t('sdi','p_email') ?> : </dt>
		<dd><? echo $mailto_provider; ?></dd>
		<dt><? echo _t('sdi','p_description') ?>  :</dt>
		<dd><? echo formatText(empty_nc($result_p[0]['sdip_description']), '2HTML');?></dd>
		</dl>
		<? } ?>
		
		</div>
		<br class="brendstep" />
		

		
		<div class="sdi_det">
		<a name="affeval" id="affeval" style="display:none;"></a>
		<a href="#affeval" onclick="$('#evaluation').slideToggle();"><?echo _t('sdi','aff_sdi_e');?></a>
		</div>
		<div id="evaluation" style="display:none;" >
		<br class="brendstep" />
		<table cellspacing="0" cellpadding="3">
		<thead>
		<tr>
		<?
		echo "<td>"._t('sdi','e_scale_compare')."</td>\n";
		echo "<td>"._t('sdi','e_fiability')."</td>\n";
		echo "<td>"._t('sdi','e_accessibility')."</td>\n";
		echo "<td>"._t('sdi','e_lisibility')."</td>\n";
		echo "<td>"._t('sdi','e_relevance')."</td>\n";
		echo "<td>"._t('sdi','e_global_performance')."</td>\n";
		?>
		</tr>
		</thead>
		<tbody>
		<?echo "<tr>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_scale_compare'])."</td>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_fiability'])."</td>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_accessibility'])."</td>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_lisibility'])."</td>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_relevance'])."</td>\n";
		echo "<td>". empty_nc($result_e[0]['sdie_global_performance'])."</td>\n";
		echo "</tr>\n";
		?>
		</tbody>
		</table>
		</div>
		<br class="brendstep" />

		<div  class="sdi_det">
		<a name="affreg" id="affreg" style="display:none;"></a>
		<a href="#affreg" onclick="$('#reglementation').slideToggle();"><?echo _t('sdi','aff_sdi_r');?></a>
		</div>
		<div id="reglementation" style="display:none;" >
		
		<? if ($result_r[0]['sdir_title']=="") {
		   echo "<h2 class=\"info\">"._t('sdi','noresultr')."</h2>";    
		   }else {?>
		
		<?php
		if(empty($result_r[0]['sdir_referer_uri'])) {
		  $rules_link = empty_nc($result_r[0]['sdir_referer_uri']);
		} else {
		  $rules_link = "<a href=\"".formatText(empty_nc($result_r[0]['sdir_referer_uri']), '2HTML')."\" title=\"".formatText(empty_nc($result_r[0]['sdir_mask_uri']), '2HTML')."\" class=\"out\">".formatText(empty_nc($result_r[0]['sdir_mask_uri']), '2HTML')."</a>";
		}
		?>
		<h2><? echo formatText(empty_nc($result_r[0]['sdir_title']), '2HTML');?></h2>	
		<dl class="dl2">
		<dt><? echo _t('sdi','r_referer_uri') ?> :</dt>
		<dd><? echo $rules_link; "</dd>"; ?>
		</dl>
		<br class="brendstep" />
		<p>
		<? echo formatText(empty_nc($result_r[0]['sdir_body']), '2HTML'); ?>
		</p>
		<? } ?>
		<br class="brendstep" />
		</div>
</div>
<?php include_once($dir."/help.php"); ?>
</div>

