<?php

	//$largeur_utile = 1250;
	//$largeur= $nbgen>=4 ? ceil($largeur_utile/$nbgen) : "'300px'";
	$largeur= "'200px'";
//var_dump($_SESSION['t_parents'] );
	
/*	

.box1H {
    background-color: #e5ffff;
}
.box1F {
   background-color: #FFE3FF;
}	

*/

	$colorH = isset($_SESSION['s_colorH']) ? $_SESSION['s_colorH'] : 'e3f9fc';// même valeur par défault que dans la css box1H
	$colorF = isset($_SESSION['s_colorF']) ? $_SESSION['s_colorF'] : 'ffeafa';// même valeur par défault que dans la css box1F

	$colorF =  isset($_GET['colorF']) ? $_GET['colorF'] : $colorF; 
	$colorH =  isset($_GET['colorH']) ? $_GET['colorH'] : $colorH;

	$ttprenom = isset($this->request->data->ttprenom) ? $this->request->data->ttprenom : 2 ;
	$affichage =isset($this->request->data->affichage) ? $this->request->data->affichage : 2 ;
	$nbgen = isset($this->request->data->nbgen) ? $this->request->data->nbgen : 4 ;

	echo "<style type='text/css'>
			.box1H { background-color: #".$colorH."; }
			.box1F { background-color: #".$colorF."; }
		  </style>";
		
	echo "<div id=panel>";
	echo "<form action='' method='post' >";

	echo "<input type='hidden' name='colorH' id='colorH' value='$colorH'>";
	echo "<input type='hidden' name='colorF' id='colorF' value='$colorF'>";
	echo "<center>";
	echo "<table border=0><tr>";
	if ($_SESSION['b_connecte'] == true ) {
		echo "<td colspan=2><center>".decode_lng_text('TREE_COL')." ".decode_lng_text('STATS_SEXE_M')."/".decode_lng_text('STATS_SEXE_F')."</br>";
		echo "<input type='hidden' name='colorH' id='colorH' value='$colorH'>";
		echo "<input type='hidden' name='colorF' id='colorF' value='$colorF'>";
		echo "<button style='font-size:10px;' onClick=\"UpdateSaveColorsArbre('".BASE_URL."');\">".decode_lng_text('TREE_SAVE')."</button>&nbsp;";
		echo "<input  style='width:80px; height:20px;' class='jscolor'  data-jscolor=\"{onFineChange:'UpdateArbre(\'H\',this)', mode:'HS', valueElement:null, value:'".$colorH."', closable:true, closeText:'Fermer', width:243, height:150, borderColor:'#FFF', insetColor:'#FFF', backgroundColor:'#ffe5af'}\"  >";  
		echo "&nbsp;&nbsp;&nbsp;";
		echo "<input  style='width:80px; height:20px;' class='jscolor' data-jscolor=\"{ onFineChange:'UpdateArbre(\'F\',this)', mode:'HS', valueElement:null, value:'".$colorF."', closable:true, closeText:'Fermer', width:243, height:150, borderColor:'#FFF', insetColor:'#FFF', backgroundColor:'#ffe5af'}\" >";  
		echo "&nbsp;<button style='font-size:10px;' onClick=\"UpdateArbre('H','e3f9fc');UpdateArbre('H','ffeafa');\">".decode_lng_text('TREE_RESET')."</button>&nbsp;";
		echo "</br>".decode_lng_text('TREE_CHOIX')."";
		echo "</td>";
	}

	echo "<td></br>".decode_lng_text('TREE_NBGEN')." : ";
	echo "<select name='nbgen'>";

	for ($i=3;$i<8;$i++) {
		if ($nbgen == $i) { 
				$selected = "selected=selected";
			} 
			else {
				$selected = '';
			}
		echo "<option value='".$i."'".$selected.">".$i."</option>";
	}
	echo "</select>";

	echo "<td></br>".decode_lng_text('TREE_AFI')." : ";
	
	echo "<select name='affichage' value>";
	for ($i=1;$i<4;$i++) {
		if ($affichage == $i) { 
				$selected = "selected=selected";
			} 
			else {
				$selected = '';
			}
		echo "<option value='".$i."'".$selected.">".decode_lng_text('TREE_AFF'.$i)."</option>";
	}
	echo "</select>";
	echo "&nbsp;";
	
	//echo "Affichage prénoms : ";
	echo "<select name='ttprenom'>";
	for ($i=1;$i<3;$i++) {
		if ($ttprenom == $i) { 
				$selected = "selected=selected";
			} 
			else {
				$selected = '';
			}

		echo "<option value='".$i."'".$selected.">".decode_lng_text('TREE_AFF'.($i+3))."</option>";
	}
	
	echo "</select>";
	
	echo "<td></br><input type=submit value=".decode_lng_text('PRIVATE_ENTER')."></td>";
	echo "</tr></table></form>";
	echo "</center>";
	echo "</div>";

	foreach ($_SESSION['t_parents'] as $k=>$id) {
		$gp ="s".$k;

		if (strstr( $k,'Father') == false) { 
			$box = 'box1F';
		}
		else {
			$box = 'box1H';
		}
		if (isset($id)) {
			${$gp}  = "<div class='arbre box1 ".$box." w100p'>";
			${$gp} .= $this->Outils->affiche_lien_individu2($affichage, $id, true, true, $ttprenom).'</br>';
			${$gp} .= $this->Outils->affiche_lien_arbre($id);
			${$gp} .= "</div>";
		}
		else
		{
			${$gp} = "<div class='arbre box1 ".$box." w100p'>?</div>";
		}
	}
	
	echo "<div> <img src='".IMAGES."ligne_orange.png' width=100% height='2px'></br></div>";
	
	echo "<center><h1>".$_SESSION['s_Title']."</h1></center></br>";
	
	echo "<div id='arbre' >";
		echo "	<table>
			<tr>
				<td colspan='1' width=".$largeur." align='center'>".$sGGFather11."</td><td colspan='1' align='center'>&nbsp</td><td colspan='1' width=".$largeur." align='center'>".$sGGMother11."</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' width=".$largeur." align='center'>".$sGGFather12."</td><td colspan='1' align='center'>&nbsp</td><td colspan='1' width=".$largeur." align='center'>".$sGGMother12."</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' width=".$largeur." align='center'>".$sGGFather21."</td><td colspan='1' align='center'>&nbsp</td><td colspan='1' width=".$largeur." align='center'>".$sGGMother21."</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' width=".$largeur." align='center'>".$sGGFather22."</td><td colspan='1' align='center'>&nbsp</td><td colspan='1' width=".$largeur." align='center'>".$sGGMother22."</td>
			 </tr>
			<tr>
				<td colspan='1' align='center' >|</td><td colspan='1'></td><td colspan='1'align='center' >|</td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='1' align='center' >|</td><td colspan='1'></td><td colspan='1'align='center' >|</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' align='center' >|</td><td colspan='1'></td><td colspan='1'align='center' >|</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' align='center' >|</td><td colspan='1'></td><td colspan='1'align='center' >|</td>
			</tr>			 

			<tr>
				<td colspan='1' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='1' align='left'><hr  width='50%' align='left' /></td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='1' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='1' align='left'><hr  width='50%' align='left' /></td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='1' align='left'><hr  width='50%' align='left' /></td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='1' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='1' align='left'><hr  width='50%' align='left' /></td>
			</tr>
			<tr>
				<td align='center' colspan='3'>|</td>
				<td align='center' colspan='1'>
				<td align='center' colspan='3'>|</td>
				<td align='center' colspan='1'>
				<td align='center' colspan='3'>|</td>
				<td align='center' colspan='1'>
				<td align='center' colspan='3'>|</td>
			</tr>
			<tr>
				<td colspan='3' width=".$largeur." align='center'>".$sGFather1."</td><td colspan='1' align='center'>&nbsp</td><td colspan='3' width=".$largeur." align='center'>".$sGMother1."</td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='3' width=".$largeur." align='center'>".$sGFather2."</td><td colspan='1' align='center'>&nbsp</td><td colspan='3' width=".$largeur." align='center'>".$sGMother2."</td>
			</tr>
			<tr>
				<td colspan='3' align='center'>|</td><td colspan='1' align='center'>&nbsp</td><td colspan='3' align='center'>|</td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='3' align='center'>|</td><td colspan='1' align='center'>&nbsp</td><td colspan='3' align='center'>|</td>
			</tr>
			<tr>
				<td colspan='3' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='3' align='left'><hr width='50%' align='left' /></td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='3' align='right'><hr width='50%' align='right' /></td><td colspan='1' align='center'><hr width='100%' /></td><td colspan='3' align='left'><hr width='50%' align='left' /></td>
			</tr>
			<tr>
				<td colspan='7' align='center'>|</td>
				<td colspan='1' align='center'>&nbsp</td>
				<td colspan='7' align='center'>|</td>
			</tr>
			<tr>
				<td colspan='7' width=".$largeur." align='center'>".$sFather."</td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='7' width=".$largeur." align='center'>".$sMother."</td>
			</tr>
			<tr>
				<td colspan='7' align='center'>|</td>
				<td colspan='1' align='center'>&nbsp;</td>
				<td colspan='7' align='center'>|</td>
			</tr>
			<tr>
				<td colspan='7' align='right'><hr width='50%' align='right' /></td>
				<td colspan='1' align='center'><hr width='100%' /></td>
				<td colspan='7' align='left'><hr width='50%' align='left' /></td>
			</tr>
			<tr>
				<td colspan='15' align='center'>|</td>
			</tr>
			<tr>
			    <td colspan='15' align='center'>";
					if ($_SESSION['arbre_individu']['sexe']==0) { 
						echo "<div class='arbre box1 box1H w100p'>";
					}
					else {
						echo "<div class='arbre box1 box1F w100p'>";
					}
						
					echo $this->Outils->affiche_lien_individu2($affichage, $_SESSION['arbre_individu']['id'], true, true, $ttprenom).'</br>'.$this->Outils->affiche_lien_arbre($_SESSION['arbre_individu']['id'])."</div></td> 
			</tr>
		</table>";
			
echo "</div>";

?>


