<?php
/**
 * @package linea21.modules
 * @subpackage sdi
 * @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');
}
////////////
?><div id="chemin">
	<ul>
		<li>
			<a href="index.php"><?php echo $GLOBALS['lang']['way']['home'] ?></a>
		</li>
		<li>
			<a href="<?php echo $rub_link;
?>"><?php echo $GLOBALS['lang']['menu']['sdi']?></a>
		</li>
		<li>
			<span><?php echo formatnavTitle($GLOBALS['lang']['sdi']['add']) ?></span>
		</li>
	</ul>
</div>
<!--end barre haute -->
<?php
include_once("../lib/input_helpers.php");
$sdi_object= new sdi;

if (isset($_POST['enregistrer'])) {
    $integrity = 1;
    $integrity2 = 1;
    $integrity3 = 1;
    $integrity4 = 1;
    $integrity5 = 1;
    $data_table = unserialize(urldecode($_POST['data_table']));
	$j=0;
	for ($i=0;$i<13;$i++){
		$data_table_sdi[$j]=$data_table[$i];
		$j++;
	}
	$data_table_sdi[14]=$data_table[32];
	$j=0;
	for ($i=13;$i<19;$i++){
		$data_table_e[$j]=$data_table[$i];
		$j++;
	}
	$j=0;
	for ($i=19;$i<27;$i++){
		$data_table_p[$j]=$data_table[$i];
		$j++;
	}
	$j=0;
	for ($i=27;$i<=30;$i++){
		$data_table_r[$j]=$data_table[$i];
		$j++;
	}
	$result=$sdi_object->AddSdi($data_table_sdi, $sql_object);
	$result_e=$sdi_object->ModifyParam($result, $data_table_e, "E", $sql_object);	
	$result_p=$sdi_object->ModifyParam($result, $data_table_p, "P", $sql_object);
	$result_r=$sdi_object->ModifyParam($result, $data_table_r, "R", $sql_object);
	
	$link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
	if(is_numeric($result)) header("Location: ".$link_confirm);
	else  system_error();
} 

$form_name = '';
$form_theme = '';
$form_statut = '';
$mask_statut_P="checked=\"checked\"";
$mask_statut_D='';
//$form_range = '';
$form_description = '';
$form_comment = '';
$form_goal = '';
$form_consulting = '';
$form_unit = '';
$form_max_value = '';
$form_min_value = '';
$form_threshold_value = '';
$form_frequency = '';
$form_threshold_relative='';

$form_e_scale_compare = '';
$form_e_fiability = '';
$form_e_accessibility = '';
$form_e_lisibility = '';
$form_e_relevance = '';
$form_e_global_performance = '';

$form_p_name = '';
$form_p_service = '';
$form_p_description = '';
$form_p_incharge = '';
$form_p_address = '';
$form_p_phone = '';
$form_p_fax = '';
$form_p_email = '';

$form_r_title = '';
$form_r_body = '';
$form_r_referer_uri = '';
$form_r_mask_uri = '';

if (isset($_POST['valider1'])) {

    $table[0] = $_POST['sdi_name'];
    $table[1] = $_POST['description'];
    $table[2] = $_POST['comment'];
    $table[3] = $_POST['sdi_theme'];
    //$table[4] = $_POST['range'];
	$table[4] = 0;
    $table[5] = $_POST['goal'];
    $table[6] = $_POST['consulting'];
    $table[7] = $_POST['unit'];
    $table[8] = $_POST['max_value'];
    $table[9] = $_POST['min_value'];
    $table[10]= $_POST['threshold_value'];
    $table[11]= $_POST['frequency'];
	$table[12]= $_POST['sdi_statut'];
	if (isset($_POST['threshold_relative']))$table[32]="Y"; else $table[32]="N";
    $integrity = $sdi_object -> CheckDataIntegrity_info($table);
	
	
    $form_name = formatText($_POST['sdi_name'], '2FIELD');
    $form_theme = $_POST['sdi_theme'];
    $form_statut= $_POST['sdi_statut'];
    //$form_range = $_POST['range'];
    $form_description = formatText($_POST['description'], '2FIELD');
    $form_comment = formatText($_POST['comment'], '2FIELD');
    $form_goal = formatText($_POST['goal'], '2FIELD');
    $form_consulting = formatText($_POST['consulting'], '2FIELD');
    $form_unit = formatText($_POST['unit'], '2FIELD');
    $form_max_value =$_POST['max_value'];
    $form_min_value = $_POST['min_value'];
    $form_threshold_value = $_POST['threshold_value'];
    $form_frequency = $_POST['frequency'];
	if($form_statut=='D') $mask_statut_D="checked=\"checked\""; else $mask_statut_D='';
	if($form_statut=='P') $mask_statut_P="checked=\"checked\""; else $mask_statut_P='';
    
	$table = urlencode(serialize($table));

}
	
if (isset($_POST['enregistrer2'])) {

   	//intégrité des étapes 2,3,4 OK
	$integrity2 = 1;
   	$integrity3 = 1;
	$integrity4 = 1;
	
    $table[0] = $_POST['sdi_name'];
    $table[1] = $_POST['description'];
    $table[2] = $_POST['comment'];
    $table[3] = $_POST['sdi_theme'];
    //$table[4] = $_POST['range'];
	$table[4] = 0;
    $table[5] = $_POST['goal'];
    $table[6] = $_POST['consulting'];
    $table[7] = $_POST['unit'];
    $table[8] = $_POST['max_value'];
    $table[9] = $_POST['min_value'];
    $table[10]= $_POST['threshold_value'];
    $table[11]= $_POST['frequency'];
	$table[12]= $_POST['sdi_statut'];
	
	if (isset($_POST['threshold_relative'])) $table[32]="Y"; else $table[32]="N";
	for ($z=13;$z<31;$z++){
		$table[$z]="";
	}
    $integrity = $sdi_object -> CheckDataIntegrity_info($table);
	
	$form_name = formatText($_POST['sdi_name'], '2FIELD');
    $form_theme = $_POST['sdi_theme'];
    $form_statut= $_POST['sdi_statut'];
    //$form_range = $_POST['range'];
    $form_description = formatText($_POST['description'], '2FIELD');
    $form_comment = formatText($_POST['comment'], '2FIELD');
    $form_goal = formatText($_POST['goal'], '2FIELD');
    $form_consulting = formatText($_POST['consulting'], '2FIELD');
    $form_unit = formatText($_POST['unit'], '2FIELD');
    $form_max_value =$_POST['max_value'];
    $form_min_value = $_POST['min_value'];
    $form_threshold_value = $_POST['threshold_value'];
    $form_frequency = $_POST['frequency'];
	if($form_statut=='D') $mask_statut_D="checked=\"checked\""; else $mask_statut_D='';
	if($form_statut=='P') $mask_statut_P="checked=\"checked\""; else $mask_statut_P='';
	
	$table = urlencode(serialize($table));
} 

if (isset($_POST['valider2'])) {

    $integrity = 1;
    $table = unserialize(urldecode($_POST['table']));
    $table[13] = $_POST['e_scale_compare'];
    $table[14] = $_POST['e_fiability'];
    $table[15] = $_POST['e_accessibility'];
    $table[16] = $_POST['e_lisibility'];
    $table[17] = $_POST['e_relevance'];
    $table[18] = $_POST['e_global_performance'];
    $integrity2 = $sdi_object -> CheckDataIntegrity_eval($table);
    $form_e_scale_compare = $_POST['e_scale_compare'];
    $form_e_fiability = $_POST['e_fiability'];
    $form_e_accessibility = $_POST['e_accessibility'];
    $form_e_lisibility = $_POST['e_lisibility'];
    $form_e_relevance = $_POST['e_relevance'];
    $form_e_global_performance = $_POST['e_global_performance'];

    $table = urlencode(serialize($table));
} 

if (isset($_POST['valider3'])) {
    $integrity = 1;
    $integrity2 = 1;
    $table = unserialize(urldecode($_POST['table']));
    $table[19] = $_POST['p_name'];
    $table[20] = $_POST['p_service'];
    $table[21] = $_POST['p_description'];
    $table[22] = $_POST['p_incharge'];
    $table[23] = $_POST['p_address'];
    $table[24] = $_POST['p_phone'];
    $table[25] = $_POST['p_fax'];
    $table[26] = $_POST['p_email'];
    $integrity3 = $sdi_object -> CheckDataIntegrity_provider($table);

    $form_p_name = formatText($_POST['p_name'], '2FIELD');
    $form_p_service = formatText($_POST['p_service'], '2FIELD');
    $form_p_description = formatText($_POST['p_description'], '2FIELD');
    $form_p_incharge = formatText($_POST['p_incharge'], '2FIELD');
    $form_p_address = formatText($_POST['p_address'], '2FIELD');
    $form_p_phone = $_POST['p_phone'];
    $form_p_fax = $_POST['p_fax'];
    $form_p_email = $_POST['p_email'];

    $table = urlencode(serialize($table));
} 

if (isset($_POST['valider4'])) {
    
	$integrity = 1;
    $integrity2 = 1;
    $integrity3 = 1;
    $table = unserialize(urldecode($_POST['table']));
    $table[27] = $_POST['r_title'];
    $table[28] = $_POST['r_body'];
    $table[29] = $_POST['r_referer_uri'];
    if ($_POST['r_mask_uri']=="")$table[30] = $table[29];
	else $table[30]=$_POST['r_mask_uri'];
    $integrity4 = $sdi_object -> CheckDataIntegrity_reglementation($table);

    $form_r_title = formatText($_POST['r_title'], '2FIELD');
    $form_r_body = formatText($_POST['r_body'], '2FIELD');
    $form_r_referer_uri = $_POST['r_referer_uri'];
    if ($_POST['r_mask_uri']=="")$form_r_mask_uri = $form_r_referer_uri;
	else $form_r_mask_uri =$_POST['r_mask_uri'];

    $table = urlencode(serialize($table));
} 

include_once("quickicons.php");

$data = $sql_object -> DBSelect($req_list_theme);
$select_theme=ThemeSelectBox($data, "sdi_theme", $form_theme);

?>

<?php
if (!isset($integrity) || is_string($integrity)) {

    ?>
<div class="contentcontainer">
		<?php
    include_once($dir . "/menurub.php");

    ?>
		<div id="content">
			<?php
    if (isset($integrity) && is_string($integrity)) display_errors($integrity);

    ?>
	<div class="stepcontent" >
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step1_act.gif" alt="step1" /><br />
	<span class="stepact"><? echo $GLOBALS['lang']['sdi']['add_step1']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step2_pas.gif" alt="step2" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step2']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step3_pas.gif" alt="step3" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step3']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step4_pas.gif" alt="step4" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step4']; ?></span>
	</div>
	</div><br class="brendstep"/>
			<h2><?php echo $GLOBALS['lang']['sdi']['add_title1'] ?></h2>
			
			<form id="addsdi" action="<?php echo $_SERVER['SCRIPT_NAME'];
    ?>" method="post">
				<p>
				<label for="sdi_name" ><?php echo $GLOBALS['lang']['sdi']['name2'] ?> * :</label>
				<input name="sdi_name" type="text" class="textfield" id="sdi_name" maxlength="255" value="<?php echo $form_name;
    ?>" />
				</p>
				<p>
				<label for="sdi_theme" ><?php echo $GLOBALS['lang']['sdi']['theme'] ?> * : </label>
				<?php echo $select_theme;
    ?>
				</p>
				<p>
				<label for="statut_P"><? echo $GLOBALS['lang']['divers']['statut']; ?> * : </label>
				<input name="sdi_statut" type="radio" id="statut_P" value="P" <?php echo $mask_statut_P; ?> /><span class="radio"><?php echo $GLOBALS['lang']['statut']['public']; ?></span>
				<input name="sdi_statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D; ?> /><span class="radio"><?php echo $GLOBALS['lang']['statut']['draft']; ?></span>
				<br />
				</p>
				<?/* ?><p>
				<label for="range" ><?php echo $GLOBALS['lang']['sdi']['range'] ?> * :</label>
				<input name="range" type="text" size="47" id="range" maxlength="150" value="<?php echo $form_range;
    ?>" />
				</p>
				<? */?>
				<p>
				<label for="description" ><?php echo $GLOBALS['lang']['sdi']['description'] ?> * :</label>
				<textarea id="description" name="description" class="largetextfield"><?php echo $form_description;
    ?></textarea>
				</p>
				<p>
				<label for="comment" ><?php echo $GLOBALS['lang']['sdi']['comment'] ?>  :</label>
				<textarea id="comment" name="comment" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_comment;
    ?></textarea>
				</p>
				<p>
				<label for="goal" ><?php echo $GLOBALS['lang']['sdi']['goal'] ?>  :</label>
				<textarea id="goal" name="goal" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_goal;
    ?></textarea>
				</p>
				<p>
				<label for="consulting" ><?php echo $GLOBALS['lang']['sdi']['consulting'] ?>  :</label>
				<textarea id="consulting" name="consulting" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_consulting;
    ?></textarea>
				</p>

				
                <p>
				<? echo $GLOBALS['lang']['sdi']['info_mesure']; ?>
				</p>

				<p>
				<label for="unit" ><?php echo $GLOBALS['lang']['sdi']['unit'] ?> * :</label>
				<input name="unit" type="text" class="textfield" id="unit" maxlength="100" value="<?php echo $form_unit;
    ?>" />
				</p>
				<p>
				<label for="max_value" ><?php echo $GLOBALS['lang']['sdi']['max_value'] ?> * :</label>
				<input name="max_value" type="text" class="textfield" id="max_value" maxlength="6" value="<?php echo $form_max_value;
    ?>" />
				</p>
				<p>
				<label for="min_value" ><?php echo $GLOBALS['lang']['sdi']['min_value'] ?> * :</label>
				<input name="min_value" type="text" class="textfield" id="min_value" maxlength="100" value="<?php echo $form_min_value;
    ?>" />
				</p>
				<p>
				<label for="threshold_value" ><?php echo $GLOBALS['lang']['sdi']['threshold_value'] ?> * :</label>
				<input name="threshold_value" type="text" class="textfield" id="threshold_value" maxlength="100" value="<?php echo $form_threshold_value;
    ?>" />
				</p>
				<p>
				<label for="frequency" ><?php echo $GLOBALS['lang']['sdi']['frequency'] ?> * :</label>
				<input name="frequency" type="text" class="textfield" id="frequency" maxlength="11" value="<?php echo $form_frequency;
    ?>" />
				</p>
				<p>
				<label for="threshold_relative" ><?php echo $GLOBALS['lang']['sdi']['threshold_relative'] ?> * :</label>
				<input type="checkbox" name="threshold_relative" value="<?php echo $form_threshold_relative; ?>" id="threshold_relative" />
				</p>
				<div class="chekbox"><?php echo $GLOBALS['lang']['sdi']['threshold_relative_comment'] ?></div>
				
				<div>
				
				<input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
				<input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" /><br />
				<? echo cancel_button($rub_link."&amp;todo=list"); ?>
				<input name="enregistrer2" type="submit" value="<?php echo $GLOBALS['lang']['sdi']['btn_fin'] ?>" class="button" id="enregistrer2" />
				<input name="valider1" type="submit" value="<?php echo $GLOBALS['lang']['sdi']['btn_step1'] ?>" class="button" id="valider" />
				</div>
			</form>
		</div>
<?php include_once($dir . "/help.php");
    ?>
</div>
<?php 
    // Récapitulatif
} else {
    if (!isset($integrity2) || is_string($integrity2)) {

        ?>
<div class="contentcontainer">
		<?php
        include_once($dir . "/menurub.php");

        ?>
		<div id="content">
			<?php
        if (isset($integrity2) && is_string($integrity2)) display_errors($integrity2);

        ?>
			<div class="stepcontent" >
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step1_pas.gif" alt="step1" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step1']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step2_act.gif" alt="step2" /><br />
	<span class="stepact"><? echo $GLOBALS['lang']['sdi']['add_step2']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step3_pas.gif" alt="step3" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step3']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step4_pas.gif" alt="step4" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step4']; ?></span>
	</div>
	</div><br class="brendstep"/>
	
			<h2><?php echo $GLOBALS['lang']['sdi']['add_title2'] ?></h2>
			
			<form id="addsdi2" action="<?php echo $_SERVER['SCRIPT_NAME'];
        ?>" method="post">
				<p>
				<label for="e_scale_compare" ><?php echo $GLOBALS['lang']['sdi']['e_scale_compare'] ?> * :</label>
				<input name="e_scale_compare" type="text" class="textfield" id="e_scale_compare" maxlength="3" value="<?php echo $form_e_scale_compare;
        ?>" />
				</p>
				<p>
				<label for="e_fiability" ><?php echo $GLOBALS['lang']['sdi']['e_fiability'] ?> * :</label>
				<input name="e_fiability" type="text" class="textfield" id="e_fiability" maxlength="3" value="<?php echo $form_e_fiability;
        ?>" />
				</p>
				<p>
				<label for="e_accessibility" ><?php echo $GLOBALS['lang']['sdi']['e_accessibility'] ?> * :</label>
				<input name="e_accessibility" type="text" class="textfield" id="e_accessibility" maxlength="3" value="<?php echo $form_e_accessibility;
        ?>" />
				</p>
				<p>
				<label for="e_lisibility" ><?php echo $GLOBALS['lang']['sdi']['e_lisibility'] ?> * :</label>
				<input name="e_lisibility" type="text" class="textfield" id="e_lisibility" maxlength="3" value="<?php echo $form_e_lisibility;
        ?>" />
				</p>
				<p>
				<label for="e_relevance" ><?php echo $GLOBALS['lang']['sdi']['e_relevance'] ?> * :</label>
				<input name="e_relevance" type="text" class="textfield" id="e_relevance" maxlength="3" value="<?php echo $form_e_relevance;
        ?>" />
				</p>
				<p>
				<label for="e_global_performance" ><?php echo $GLOBALS['lang']['sdi']['e_global_performance'] ?> * : </label>
				<input name="e_global_performance" type="text" class="textfield" id="e_global_performance" maxlength="3" value="<?php echo $form_e_global_performance;
        ?>" />
				</p>
				
				<div>
				<input name="table" type="hidden" value="<?php echo $table;
        ?>" id="table" />
				<input name="rub" type="hidden" value="<?php echo $rub;
        ?>" id="rub" />
				<input name="todo" type="hidden" value="<?php echo $todo;
        ?>" id="todo" /><br />
		<? echo cancel_button($rub_link."&amp;todo=list"); ?>
				
				<input name="valider2" type="submit" value="<?php echo $GLOBALS['lang']['sdi']['btn_step2'] ?>" class="button" id="valider" />
				</div>
			</form>
		</div>
<?php include_once($dir . "/help.php");
        ?>
</div>

<?php
    } else {
        if (!isset($integrity3) || is_string($integrity3)) {

            ?>
<div class="contentcontainer">
		<?php
            include_once($dir . "/menurub.php");

            ?>
		<div id="content">
			<?php
            if (isset($integrity3) && is_string($integrity3)) display_errors($integrity3);

            ?>
			
				<div class="stepcontent" >
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step1_pas.gif" alt="step1" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step1']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step2_pas.gif" alt="step2" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step2']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step3_act.gif" alt="step3" /><br />
	<span class="stepact"><? echo $GLOBALS['lang']['sdi']['add_step3']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step4_pas.gif" alt="step4" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step4']; ?></span>
	</div>
	</div><br class="brendstep"/>
			
			<h2><?php echo $GLOBALS['lang']['sdi']['add_title3'] ?></h2>
			
			<form id="addsdi3" action="<?php echo $_SERVER['SCRIPT_NAME'];
            ?>" method="post">
				<p>
				<label for="p_name" ><?php echo $GLOBALS['lang']['sdi']['p_name'] ?> * :</label>
				<input name="p_name" type="text" class="textfield" id="p_name" maxlength="255" value="<?php echo $form_p_name;
            ?>" />
				</p>
				<p>
				<label for="p_service" ><?php echo $GLOBALS['lang']['sdi']['p_service'] ?>  :</label>
				<input name="p_service" type="text" class="textfield" id="p_service" maxlength="255" value="<?php echo $form_p_service;
            ?>" />
				</p>

				<p>
				<label for="p_incharge" ><?php echo $GLOBALS['lang']['sdi']['p_incharge'] ?>  :</label>
				<input name="p_incharge" type="text" class="textfield" id="p_incharge" maxlength="150" value="<?php echo $form_p_incharge;
            ?>" />
				</p>
				<p>
				<label for="p_address" ><?php echo $GLOBALS['lang']['sdi']['p_address'] ?> * :</label>
				<textarea id="p_address" name="p_address" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_p_address;
            ?></textarea>
				</p>
				<p>
				<label for="p_phone" ><?php echo $GLOBALS['lang']['sdi']['p_phone'] ?>  :</label>
				<input name="p_phone" type="text" class="textfield" id="p_phone" maxlength="10" value="<?php echo $form_p_phone;
            ?>" />
				</p>
				<p>
				<label for="p_fax" ><?php echo $GLOBALS['lang']['sdi']['p_fax'] ?>  :</label>
				<input name="p_fax" type="text" class="textfield" id="p_fax" maxlength="10" value="<?php echo $form_p_fax;
            ?>" />
				</p>
				<p>
				<label for="p_email" ><?php echo $GLOBALS['lang']['sdi']['p_email'] ?> * :</label>
				<input name="p_email" type="text" class="textfield" id="p_email" maxlength="200" value="<?php echo $form_p_email;
            ?>" />
				</p>
				<p>
				<label for="p_description" ><?php echo $GLOBALS['lang']['sdi']['p_description'] ?>  :</label>
				<textarea id="p_description" name="p_description" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_p_description;
            ?></textarea>
				</p>
				<div>
				<input name="table" type="hidden" value="<?php echo $table;
            ?>" id="table" />
				<input name="rub" type="hidden" value="<?php echo $rub;
            ?>" id="rub" />
				<input name="todo" type="hidden" value="<?php echo $todo;
            ?>" id="todo" /><br />
			<? echo cancel_button($rub_link."&amp;todo=list"); ?>
				
				<input name="valider3" type="submit" value="<?php echo $GLOBALS['lang']['sdi']['btn_step3'] ?>" class="button" id="valider" />
				</div>
			</form>
		</div>
<?php include_once($dir . "/help.php");
            ?>
</div>

<?php
        } else {
            if (!isset($integrity4) || is_string($integrity4)) {

                ?>
<div class="contentcontainer">
		<?php
                include_once($dir . "/menurub.php");

                ?>
		<div id="content">
			<?php
                if (isset($integrity4) && is_string($integrity4)) display_errors($integrity4);

                ?>
				
					<div class="stepcontent" >
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step1_pas.gif" alt="step1" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step1']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step2_pas.gif" alt="step2" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step2']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step3_pas.gif" alt="step3" /><br />
	<span class="steppas"><? echo $GLOBALS['lang']['sdi']['add_step3']; ?></span>
	</div>
	<div class="step">
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/step4_act.gif" alt="step4" /><br />
	<span class="stepact"><? echo $GLOBALS['lang']['sdi']['add_step4']; ?></span>
	</div>
	</div><br class="brendstep"/>
	
			<h2><?php echo $GLOBALS['lang']['sdi']['add_title4'] ?></h2>
			
			<form id="addsdi4" action="<?php echo $_SERVER['SCRIPT_NAME'];
                ?>" method="post">
				<p>
				<label for="r_title" ><?php echo $GLOBALS['lang']['sdi']['r_title'] ?> * :</label>
				<input name="r_title" type="text" class="textfield" id="r_title" maxlength="255" value="<?php echo $form_r_title;
                ?>" />
				</p>
				<p>
				<label for="r_body" ><?php echo $GLOBALS['lang']['sdi']['r_body'] ?> * :</label>
				<textarea id="r_body" name="r_body" <?php echo AREA_SETTINGS; ?> class="largetextfield" ><?php echo $form_r_body;
                ?></textarea>
				</p>
				<p>
				<label for="r_referer_uri" ><?php echo $GLOBALS['lang']['sdi']['r_referer_uri'] ?>  :</label>
				<input name="r_referer_uri" type="text" class="textfield" id="r_referer_uri" maxlength="255" value="<?php echo $form_r_referer_uri;
                ?>" />
				</p>
				<p>
				<label for="r_mask_uri" ><?php echo $GLOBALS['lang']['sdi']['r_mask_uri'] ?>  :</label>
				<input name="r_mask_uri" type="text" class="textfield" id="r_mask_uri" maxlength="255" value="<?php echo $form_r_mask_uri;
                ?>" />
				</p>
				<div>
				<input name="table" type="hidden" value="<?php

                echo $table;
                ?>" id="table" />
				<input name="rub" type="hidden" value="<?php echo $rub;
                ?>" id="rub" />
				<input name="todo" type="hidden" value="<?php echo $todo;
                ?>" id="todo" />
				<br />
				<? echo cancel_button($rub_link."&amp;todo=list"); ?>
				
				<input name="valider4" type="submit" value="<?php echo $GLOBALS['lang']['btn']['valid'] ?>" class="button" id="valider" />
				</div>
			</form>
		</div>
<?php include_once($dir . "/help.php");
                ?>
</div>

<?php
            } else {
                if (!isset($integrity5) || is_string($integrity5)) {
				
				
                    $table=unserialize(urldecode($table));
					$display_sdi_name = formatText(empty_nc($table[0]), '2HTML');
                    $display_sdi_description =formatText(empty_nc($table[1]), '2HTML');
					$display_sdi_comment =formatText(empty_nc($table[2]), '2HTML');
				    //$display_sdi_range = empty_nc($table[4]);			   
                    $display_sdi_goal = formatText(empty_nc($table[5]), '2HTML');
                    $display_sdi_consulting = formatText(empty_nc($table[6]), '2HTML');
                    $display_sdi_unit = formatText(empty_nc($table[7]), '2HTML');
                    $display_sdi_max_value = empty_nc($table[8]);
                    $display_sdi_min_value = empty_nc($table[9]);
                    $display_sdi_threshold_value = empty_nc($table[10]);
                    $display_sdi_frequency = empty_nc($table[11]);
					$display_sdi_statut = empty_nc($table[12]);
                    $display_e_scale_compare = empty_nc($table[13]);
                    $display_e_fiability = empty_nc($table[14]);
                    $display_e_accessibility = empty_nc($table[15]);
                    $display_e_lisibility = empty_nc($table[16]);
                    $display_e_relevance = empty_nc($table[17]);
                    $display_e_global_performance = empty_nc($table[18]);
                    $display_p_name = formatText(empty_nc($table[19]), '2HTML');
                    $display_p_service = formatText(empty_nc($table[20]), '2HTML');
                    $display_p_description =formatText(empty_nc($table[21]), '2HTML');
                    $display_p_incharge = formatText(empty_nc($table[22]), '2HTML');
                    $display_p_address =formatText(empty_nc($table[23]), '2HTML');
                    $display_p_phone =empty_nc($table[24]);
                    $display_p_fax = empty_nc($table[25]);
                    $display_p_email = empty_nc($table[26]);
                    $display_r_title =formatText(empty_nc($table[27]), '2HTML');
                    $display_r_body = formatText(empty_nc($table[28]), '2HTML');
                    $display_r_referer_uri = empty_nc($table[29]);
                    $display_r_mask_uri = formatText(empty_nc($table[30]), '2HTML');

					if ($table[32]=='Y') $display_sdi_threshold_relative = $GLOBALS['lang']['sdi']['threshold_relative_Y'];
					else $display_sdi_threshold_relative = $GLOBALS['lang']['sdi']['threshold_relative_N'];
					
                    $onetheme = SQL_getOnesditheme($table[3]);
                    $onetheme = $sql_object -> DBSelect($onetheme);
                    $display_sdi_theme = formatText(empty_nc($onetheme[0]['theme_name']), '2HTML');

                    $table = urlencode(serialize($table));

                    ?>
<div class="contentcontainer">
<?php
                    include_once($dir . "/menurub.php");

                    ?>
<div id="content">
			<h2><?php echo $GLOBALS['lang']['recap']['title'] ;
                    ?></h2>
			<dl class="dl3">
				<dt><?php echo $GLOBALS['lang']['sdi']['name2'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_name ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['divers']['statut'] ;
                    ?> :</dt>
				<dd><?php echo display_statut($display_sdi_statut) ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['theme'] ;
                    ?> :</dt>
				<dd><?php echo $display_sdi_theme ;
                    ?><br /></dd>
				<?php /* <dt><?php echo $GLOBALS['lang']['sdi']['range'] ;
                    ?> :</dt>
				<dd><?php echo $display_sdi_range ;
                    ?><br /></dd> */ ?>
				<dt><?php echo $GLOBALS['lang']['sdi']['description'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_description ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['comment'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_comment ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['goal'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_goal ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['consulting'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_consulting ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['unit'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_unit ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['max_value'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_max_value ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['min_value'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_min_value ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['threshold_value'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_threshold_value ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['threshold_relative'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_threshold_relative ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['frequency'] ;
                    ?> : </dt>
				<dd><?php echo $display_sdi_frequency ;
                    ?><br /></dd>
				
				<dt><?php echo $GLOBALS['lang']['sdi']['e_scale_compare'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_scale_compare ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['e_fiability'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_fiability ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['e_accessibility'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_accessibility ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['e_lisibility'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_lisibility ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['e_relevance'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_relevance ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['e_global_performance'] ;
                    ?> : </dt>
				<dd><?php echo $display_e_global_performance ;
                    ?><br /></dd>
				
				<dt><?php echo $GLOBALS['lang']['sdi']['p_name'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_name ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_service'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_service ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_description'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_description ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_incharge'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_incharge ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_address'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_address ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_phone'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_phone ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_fax'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_fax ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['p_email'] ;
                    ?> : </dt>
				<dd><?php echo $display_p_email ;
                    ?><br /></dd>
				
				<dt><?php echo $GLOBALS['lang']['sdi']['r_title'] ;
                    ?> : </dt>
				<dd><?php echo $display_r_title ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['r_body'] ;
                    ?> : </dt>
				<dd><?php echo $display_r_body ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['r_referer_uri'] ;
                    ?> : </dt>
				<dd><?php echo $display_r_referer_uri ;
                    ?><br /></dd>
				<dt><?php echo $GLOBALS['lang']['sdi']['r_mask_uri'] ;
                    ?> : </dt>
				<dd><?php echo $display_r_mask_uri ;
                    ?><br /></dd>
			</dl>
			<form id="addsdi5" action="<?php echo $_SERVER['SCRIPT_NAME'];
                    ?>" method="post">
				<div>
				<input name="rub" type="hidden" value="<?php echo $rub;
                    ?>" id="rub" />
				<input name="todo" type="hidden" value="<?php echo $todo;
                    ?>" id="todo" />
				<input name="data_table" type="hidden" value="<?php echo $table;
                    ?>" id="data_table" />
					<? echo cancel_button($rub_link."&amp;todo=list"); ?>
				<input name="retour" type="button" value="<?php echo $GLOBALS['lang']['btn']['preview'] ?>" class="button" id="retour" onclick="history.go(-1);" />
				<input name="enregistrer" type="submit" value="<?php echo $GLOBALS['lang']['btn']['save'] ?>" class="button" id="valider" />
				</div>
			</form>
		</div>
	<?php include_once($dir . "/help.php");
                    ?>
</div>
<?php
                } 
            } 
        } 
    } 
} 
?>
