<?php
class Outils extends Model{
/*
* cette classe regroupe les fonctions utilitaires de recherches dans la base de données 
* utilisées dans divers programmes
* fonctions transférées de lib_inc.php à cause des appels à la BDD
*/	
	
function affiche_lien_individu($id_individual, $bAffichePatronyme=true, $bAfficheDate=false, $bAfficheSurnom=false,$bCreerLien=true) {
	
//$_SESSION['ind_affiche']=1;		
		$table = 'oxg_individuals, oxg_patronyms';
		$this->table = $table;
		$condition  = 'id_individual='.$id_individual;
		$condition .= ' and oxg_individuals.id_patronym=oxg_patronyms.id_patronym ';
		$condition .= $_SESSION['s_ReqFamille'];
		
		$field= 'first_name, libelle';
		if($_SESSION['b_Sosa']==true) {
			$field .= ', sosa';
		}
		$field .= ', date_naissance, date_deces, contemporary ';
		$result = $this->find(array(
			'fields'     => $field,
			'conditions'  => $condition
		));	

	foreach($result as $k => $row) {
		if($bCreerLien==true) {
			$sInd.="<a href='".Router::url('individus/detail_individu/'.$id_individual)."' >"; //target='_blank'
		}
		
		if($row->first_name=="")
		{
			$sInd.="?";
		}
		else
		{
			$firstname .=$row->first_name;
			$sInd.=$firstname;
		}
		if($bAffichePatronyme==true)
		{
			$sInd.= ' '.$row->libelle;
		}
		if($bAfficheSurnom==true)
		{
			$sInd.=$this->display_nickname($id_individual, $_SESSION['s_ReqFamille'], "GIVN", "NICK", $row->sex);
		}
		$sInd.="</a>";
		
		if($row->sosa!='-1')
		{
			$sInd.=" <strong><font color=red>$row->sosa</font></strong>";
		}
		
		if($bAfficheDate==true && ($row->date_naissance!="" || $row->date_deces!=""))
		{
			$sInd.=" (";
			if($row->date_naissance!="")
			{
				$sInd.=decode_date_eng($row->date_naissance);
			}
			else
			{
				$sInd.="?";
			}
			if($row->date_deces!="")
			{
				$sInd.=" - ";
				$sInd.=decode_date_eng($row->date_deces);
			}
			$sInd.=")";
		}
	}
	if ($row->first_name=="" AND $row->libelle=="")
	{
		return "?";
	}
	else
	{	
		if ($_SESSION['b_connecte']==false  and $row->contemporary==0)
		{
			return decode_lng_text('PRIVATE_MSG');
		}
		else
		{
			return $sInd;
		}
	}
}
function affiche_lien_individu2($id_affichage, $id_individual, $bAffichePatronyme=true, $bAfficheDate=false, $ttprenom) {
	
	$table = 'oxg_individuals, oxg_patronyms';
	$this->table = $table;
	$condition  = 'id_individual='.$id_individual;
	$condition .= ' and oxg_individuals.id_patronym=oxg_patronyms.id_patronym ';
	$condition .= $_SESSION['s_ReqFamille'];

	$field= 'first_name, libelle, sex, date_naissance, date_deces, id_ville_naissance, id_ville_deces, lieu_naissance, lieu_deces, contemporary';
	if($_SESSION['b_Sosa']==true) {
		$field .= ', sosa';
	}

	$result = $this->find(array(
		'fields'     => $field,
		'conditions'  => $condition
	));	

	foreach($result as $k => $row) {
	if ($row->sex== 0) {
		$sInd="<a class='lienCouleurH' href='".Router::url('individus/detail_individu/'.$id_individual)."' >"; //target='_blank'
	}
	else {
		$sInd="<a class='lienCouleurF' href='".Router::url('individus/detail_individu/'.$id_individual)."' >"; //target='_blank'
	}
	if($row->first_name == "")
	{
		$sInd.="?";
	}
	else
	{
		$firstname = $row->first_name;
		if ($ttprenom==2) {
			$firstname = explode(" ",$firstname);
			$firstname = trim($firstname[0],',');
		}
		$sInd.=$firstname;
	}
	if($bAffichePatronyme==true)
	{
		$sInd.=" ".$row->libelle;
	}
	$sInd.="</a>";
	if($row->sosa != '-1')
	{
		$sInd .= " <strong><font color=red>".$row->sosa."</font></strong>";
	}
	
	if($_SESSION['b_connecte'] == true && $bAfficheDate==true && ($row->date_naissance != "" || $row->date_deces != ""))
	{
		if ($id_affichage==2) {
			$sInd.="<br>";
			if($row->date_naissance != "")
			{
				$newdate = decode_date2($row->date_naissance);
				$sInd.="( ".$newdate;
			}
			else
			{
				$sInd.="( ?";
			}
			if($row->date_deces != "")
			{
				$sInd.=" - ";
				$newdate = decode_date2($row->date_deces);
				$sInd.=$newdate;
			}
			else
			{
			if (substr($row->date_naissance,-4)<1910) {$sInd.=" - ?";}
			}
			$sInd.=" )";
		}
		if ($id_affichage==3)
		{
			$sInd.="</br>";
			if($row->date_naissance!="")
			{
			$newdate = decode_date2($row->date_naissance);
				if ($row->id_ville_naissance=="0")
					{
					$ville = $row->lieu_naissance;
					$ville = explode(",",$ville);
					$ville = $ville[0];
				}
				else	{

					$ville = self::RechercheVille($row->id_ville_naissance);
				}
				$sInd.=utf8_decode('°')." ".$newdate." - ".$ville."</br>";
			}
			else
			{
			$sInd.=utf8_decode('°'). " ?</br>";
			}


			if($row->date_deces!="") {
				$sInd.="+ ";
				$newdate = decode_date2($row->date_deces);
					if ($row->id_ville_deces=="0")
					{
						$ville = $row->lieu_deces;
						$ville = explode(",",$ville);
						$ville = $ville[0];
					}
					else	{

						$ville = self::RechercheVille($row->id_ville_deces);
					}
				$sInd.=$newdate." - ".$ville."</br>";
			}
			else {
				if (substr($row->date_naissance,-4)<1910) {$sInd.="+ ?";}
			}
			//$sInd.=")";
		}
	}
	}

	return $sInd;
	}

	function RechercheVille($ville) {
		$table = 'oxg_cities';
		$this->table = $table;
		$condition  = 'id_city='.$ville;
		$result_ville= $this->find(array(
			'fields'     => 'libelle',
			'conditions'  => $condition
		));	

		foreach($result_ville as $k => $row_ville) {
			$libelle =$row_ville->libelle;
		}
	return $libelle;
	}
	
	function affiche_lien_individu_bis($row, $bAffichePatronyme=true, $bAfficheDate=false) {
		
		$sInd="";
		
		if($row->first_name=="") {
			$sInd.="?";
		}
		else {
			$sInd.= $row->first_name;
		}
		if($bAffichePatronyme==true) {
			$sInd.= " ".$row->libelle;
		}
					
		if($bAfficheDate==true && ($row->date_naissance!="" || $row->date_deces!=""))
		{
			$sInd.=" (";
			if($row->date_naissance != "") {
				$sInd.=$row->date_naissance;
			}
			else {
				$sInd.="?";
			}
			if($row->date_deces != "") {
				$sInd.=" - ";
				$sInd.= $row->date_deces;
			}
			$sInd.=")";
		}
		
		if ($row->first_name=="" AND $row->libelle=="") {
			return "?";
		}
		else {	
			if ($_SESSION['b_connecte']==false and $row->contemporary==0) 	{
				return decode_lng_text('PRIVATE_MSG');
			}
			else {return $sInd;}
		}
	}  //fin  function affiche_lien_individu_bis
	
function affiche_ligne_individu($id_individual) {
	
		$table = 'oxg_individuals, oxg_patronyms';
		$this->table = $table;
		$condition  = 'id_individual='.$id_individual;
		$condition .= ' and oxg_individuals.id_patronym=oxg_patronyms.id_patronym ';
		$condition .= $_SESSION['s_ReqFamille'];
		$field= 'first_name, libelle';
		if($_SESSION['b_Sosa']==true) {
			$field .= ', sosa';
		}
		$field .= ', date_naissance, date_deces, contemporary ';
		$result = $this->find(array(
			'fields'     => $field,
			'conditions'  => $condition
		));	

		foreach($result as  $row) {

			$sInd="";
	
			//$sInd.="<td>";
			$sInd.="<a href='".Router::url('individus/detail_individu/'.$id_individual)."'>";
			if($row->first_name=="")
			{
				$sInd.="?";
			}
			else
			{
				$sInd.=$row->first_name;
			}
				$sInd.=" ".$row->libelle." ";
			$sInd.="</a>";
			if($_SESSION['b_Sosa']==true && $row->sosa!='-1')
			{
				$sInd.=" <strong><font color=red>".$row->sosa."</font></strong>";
			}
			$sInd.="</td><td>";
			if($row->date_naissance!="")
			{
				$sInd.="<center>".decode_date_eng($row->date_naissance)."</center>";
			}
			else
			{
				$sInd.="<center>?</center>";
			}
			$sInd.="</td><td>";

			if($row->date_deces!="")
			{
				$sInd.="<center>".decode_date_eng($row->date_deces)."</center>"; 
			}
			else
			{
				if (substr($row->date_naissance,-4)<1910) {
					$sInd.="<center>?</center>";
				} 
				else {
					$sInd.="<center>-</center>";
				}
			}
			$sInd.="</td>";
		}
	return $sInd;
}


function show_Children ($gen, $new_gen, $tab) {
	
	$nb_child = 0;
	$nb_child = 0;
	$nb_enfants = 0;
	$num_up = 0;
	$tab2 = array();
	$_SESSION['return_ligne'] = array ();
	$i=0;
	while ($i<count($tab)) 	{

		// Children
		$nb_enfants = 1;
		//$gen++;
		$parent=$tab[$i]['ind'];
		$num_up=$tab[$i]['num'];
		$old_conjoint = "";
		
		$table = 'oxg_individuals, oxg_patronyms';
		$this->table = $table;
		$condition  = "(id_father=".$parent." or id_mother=".$parent.")";
		$condition .= ' and oxg_individuals.id_patronym=oxg_patronyms.id_patronym ';
		$condition .= $_SESSION['s_ReqFamille'];
		$result_ind = $this->find(array(
			'fields'     => "oxg_individuals.id_individual as id_ind, oxg_individuals.first_name, sex, oxg_patronyms.libelle, id_father, id_mother",
			'conditions' => $condition,
			'order' 	 => "id_father, id_mother,  right(date_naissance,4)"
		));	

		foreach($result_ind as $row_ind) {
			$nom_individu='';
			$nom_pere='';
			$nom_mere='';
				if($parent!=$row_ind->id_father) {
						$id_conjoint=$row_ind->id_father;
					}
					if($parent!=$row_ind->id_mother) {
						$id_conjoint=$row_ind->id_mother;
					}

		
					if ($num_up==0) {$affiche = $nb_enfants;} else {$affiche = $num_up.".".$nb_enfants;}
					$nb_child = $nb_child + 1;
					$nb_enfants++;
					if ($_SESSION['s_affichage']==3) {
						$nom_individu = self::affiche_ligne_individu($row_ind->id_ind);
					}
					else {
						$nom_individu = self::affiche_lien_individu($row_ind->id_ind,true,true);
					}
					$nom_pere     = self::affiche_lien_individu($parent,true,true);
					$nom_mere     = self::affiche_lien_individu($id_conjoint,true,true);
					
					
					$_SESSION['return_ligne'][]= array('generation'=>$gen, 'affiche'=>$affiche, 'id_individual'=>$row->id_individual, 'nom_individu'=>$nom_individu,'sex'=>$row_ind->sex, 'nom_conjoint'=>'', 'id_father'=>$row_ind->id_father, 'nom_pere'=>$nom_pere, 'id_mother'=>$row_ind->id_mother, 'nom_mere'=>$nom_mere);	
					
					$tab2[] = array('num' => $affiche, 'ind' => $row_ind->id_ind);
		}

		$i++;
	}

	return $tab2;
}



function nb_Children ($parent){

//$_SESSION['ind_affiche']=1;
		$children = array();
		$_SESSION['t_arbre_children'] = array();
		
		$table = 'oxg_individuals, oxg_patronyms';
		$this->table = $table;
		$condition  = "(id_father=".$parent." or id_mother=".$parent.")";
		$condition .= ' and oxg_individuals.id_patronym=oxg_patronyms.id_patronym ';
		$condition .= $_SESSION['s_ReqFamille'];
		$order      = 'id_father, id_mother';
	//	$order     .= 	$_SESSION['b_connecte'] ==false ? '' : ', right(date_naissance,4)';
		$order     .= ', right(date_naissance,4)';
		
		$result_ind = $this->find(array(
			'fields'     => "oxg_individuals.id_individual as id_ind, oxg_individuals.first_name, sex, date_naissance, oxg_patronyms.libelle, id_father, id_mother",
			'conditions' => $condition,
			'order' 	 => $order
		));	

		foreach($result_ind as $k => $row_ind) { 
			if ($row_ind->id_father == $parent) { $id_conjoint = $row_ind->id_mother;  } else { $id_conjoint = $row_ind->id_father; }
			
			$_SESSION['t_arbre_children'][] = array('id_conjoint'=>$id_conjoint, 'sex'=>$row_ind->sex,'id_child'=>$row_ind->id_ind, 'naissance'=>$row_ind->date_naissance);
		}
}

function get_event($id_individual, $sReqFam, $sParentEvntCode, $sEvntCode)
{
	// fonction transférée de lib_inc.php 
//$_SESSION['ind_affiche']=1;
	$table = 'oxg_events_type';
	$this->table = $table;
	$condition = "code='". $sParentEvntCode."'";
	$result_ind=$this->find(array(
			'fields'     => 'id_type_event',
			'conditions'  => $condition
	));
	
	foreach ($result_ind as $row_ind) {
		$sId_type_event=$row_ind->id_type_event;
	}
	if($sId_type_event=="")
	{
		return "";
	}

	$table = 'oxg_events';
	$this->table = $table;
	$condition  = 'type_father=0 and type= '.$sId_type_event.' and id_father= '.$id_individual;
	$condition .= $sReqFam;
	$result_ind=$this->find(array(
			'fields'     => 'id_event',
			'conditions'  => $condition
	));
	foreach ($result_ind as $row_ind) {
		$sId_event=$row_ind->id_event;
	}
	if($sId_event=="") 	{
		return "";
	}

	$table = 'oxg_events_type';
	$this->table = $table;
	$condition = "code='". $sEvntCode."'";
	$result_ind=$this->find(array(
			'fields'     => 'id_type_event',
			'conditions'  => $condition
	));

	foreach ($result_ind as $row_ind) {
		$sId_type_event=$row_ind->id_type_event;
	}

	if($sId_type_event=="") {
		return "";
	}
			
	$table = 'oxg_events';
	$this->table = $table;
	$condition = 'type_father=1 and type= '.$sId_type_event.' and id_father= '.$sId_event;
	$condition .= $sReqFam;
	$result_ind=$this->find(array(
			'fields'     => 'libelle',
			'conditions'  => $condition
	));

	foreach ($result_ind as $row_ind) {
		$sLibelle=$row_ind->libelle;
	}
	
	return $sLibelle;
}

function display_nickname($id_individual, $sReqFam, $sParentEvntCode, $sEvntCode, $sSex)
{
		// fonction transférée dans OutilsController.php (c'est le lieu d'utilisation unique) 
	$sResult="";
	$sNickname=$this->get_event($id_individual, $sReqFam, "GIVN", "NICK");
	if($sNickname!="")
	{
		if($sSex==1)	// Female
		{
			$sResult=" dite ".$sNickname;
		}
		else
		{
			$sResult=" dit ".$sNickname;
		}
	}
	return $sResult;
}


public function get_id_event_type($sEvntCode)
{
	$table = 'oxg_events_type';
	$this->table = $table;	
	
	$condition  = " code='".$sEvntCode."'";

	$row_ind = $this->findFirst(array(
			'fields'     => 'id_type_event',
			'conditions'  => $condition
	));

	return $row_ind->id_type_event;
}

public function donne_ind_evnt($id_family, $id_evnt) {	
	
	$table = 'oxg_events';
	$this->table = $table;	
	
	$condition  = ' id_event= '.$id_evnt;
	$condition .= $_SESSION['s_ReqFamille'];

	$row_ind = $this->findFirst(array(
			'fields'     => 'id_father, type_father',
			'conditions'  => $condition
	));
	//var_dump($row_ind);
//	echo $id_evnt.': '.$row_ind->id_father.' /'.$row_ind->type_father.'<br/>';

	if($row_ind->type_father==0) 
	{
		$sRes=$row_ind->id_father;
	}
	else
	{
		$sRes = $this->donne_ind_evnt($id_family, $row_ind->id_father);
	}

	return $sRes;
	
}

public function affiche_lien_arbre($id_individual)
{

//$_SESSION['ind_affiche']=1;		
	$table = 'oxg_individuals';
	$this->table = $table;	
	
	$condition  = " id_individual = '".$id_individual."'";
	$condition .= $_SESSION['s_ReqFamille'];

	$result=$this->find(array(
			'fields'     => 'id_father, id_mother',
			'conditions'  => $condition
	));

	foreach($result as $row) {

		if($row->id_father!=-1 || $row->id_mother!=-1)
		{
			$sLink.="<a href='".Router::url('arbres/arbre_individu/V/'.$id_individual)."'><img src=".IMAGES.'tree2.png'." alt=\"";
			$sLink.=decode_lng_text("DETAIL_IND_ARBRE");
			$sLink.="\"></a> ";

			$sLink.="<a href='".Router::url('arbres/arbre_individu/H/'.$id_individual)."'><img  src=".IMAGES.'tree2_h.png'." alt=\"";
			$sLink.=decode_lng_text("DETAIL_IND_ARBRE");
			$sLink.="\"></a>";
		}
	}
	
	return $sLink;
	
} 
/*
* cette fonction n'est plus utilisée
*/
/* 
function affiche_liste_patro($INITIALE, $FAMILY)
{
	if ($INITIALE=='Tous') {
		$table = 'oxg_patronyms, oxg_individuals';
		$this->Dates->table = $table;
		
		$condition  = "oxg_patronyms.id_patronym=oxg_individuals.id_patronym";
		$condition .= $_SESSION['s_ReqFamille'];
		$condition .= $_SESSION['s_ReqContemporain'];
		
		$result=$this->Dates->find(array(
				'fields'      => ' oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord, COUNT(*) as somme ',
				'conditions'  => $condition, 
				'group' 	  => "oxg_patronyms.id_patronym, oxg_patronyms.libelle, oxg_patronyms.libelle_ord having (ASCII(upper(left(oxg_patronyms.libelle_ord,1)))<65 or ASCII(upper(left(oxg_patronyms.libelle_ord,1)))>90)",
				'order'       => "oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym"
		));

		foreach($result as $k => $row) {
			$nb_res_max = $row->somme;
		}
	}
	elseif ($INITIALE=='Autres') {
	
		$table = 'oxg_patronyms, oxg_individuals';
		$this->Dates->table = $table;
		
		$condition  = "oxg_patronyms.id_patronym=oxg_individuals.id_patronym";
		$condition .= $_SESSION['s_ReqFamille'];
		$condition .= $_SESSION['s_ReqContemporain'];
		
		$result=$this->Dates->find(array(
				'fields'      => ' oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord, COUNT(*) as somme ',
				'conditions'  => $condition, 
				'group' 	  => "oxg_patronyms.id_patronym, oxg_patronyms.libelle, oxg_patronyms.libelle_ord having (ASCII(upper(left(oxg_patronyms.libelle_ord,1)))<65 or ASCII(upper(left(oxg_patronyms.libelle_ord,1)))>90)",
				'order'       => "oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym"
		));

		foreach($result as $k => $row) {
			$nb_res_max = $row->somme;
		}
	}
	else {
		
		$table = 'oxg_patronyms';
		$this->Dates->table = $table;
		
		$condition  = "upper(left(oxg_patronyms.libelle_ord,1))='".$INITIALE."' ";
		$condition .= $_SESSION['s_ReqFamille'];
		// if ($_SESSION['b_connecte']==false ) {
			// $condition .= $_SESSION['s_ReqContemporain'];
		// }			
		$result=$this->Dates->find(array(
				'fields'      => ' oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord, COUNT(*) as somme ',
				'conditions'  => $condition, 
				'group' 	  => "oxg_patronyms.id_patronym, oxg_patronyms.libelle, oxg_patronyms.libelle_ord having (ASCII(upper(left(oxg_patronyms.libelle_ord,1)))<65 or ASCII(upper(left(oxg_patronyms.libelle_ord,1)))>90)",
				'order'       => "oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym"
		));

		foreach($result as $k => $row) {
			$nb_res_max = $row->somme;
		}
	}		
	if($INITIALE=='AUTRES')
	{
		echo "<h3>";
		display_lng_text("PATRO_LIST_NO_LETTER");
		echo " <a name=\"AUTRES\"></a>";
		display_lng_text("PATRO_PEOPLE");
		echo ")</h3>";
	//	$sql_query="select oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord, COUNT(*) as SOMME from oxg_patronyms, oxg_individuals where oxg_patronyms.id_patronym=oxg_individuals.id_patronym $sReqFam $sReqCont GROUP BY oxg_patronyms.id_patronym, oxg_patronyms.libelle, oxg_patronyms.libelle_ord having (ASCII(upper(left(oxg_patronyms.libelle_ord,1)))<65 or ASCII(upper(left(oxg_patronyms.libelle_ord,1)))>90) ORDER BY oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym";
	}
	else
	{
		echo "<h3>";
		display_lng_text("PATRO_LIST_BEGINNING");
		echo " <a name=\"$INITIALE\">$INITIALE</a>";
		echo "</h3>";
	// 	$sql_query="select oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord from oxg_patronyms where upper(left(oxg_patronyms.libelle_ord,1))='$INITIALE' ORDER BY oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym";
	}
	
	flush();
	mysql_query("SET SQL_BIG_SELECTS=1") or die(": FAILED");
	$result = mysql_query( $sql_query ) or mysql_die();
		
	while($row = mysql_fetch_array($result))
	{
		$sql_query="select count(*) as SOMME from oxg_individuals where id_patronym=$row[id_patronym] $sReqFam $sReqCont";
		$result2 = mysql_query( $sql_query ) or mysql_die();
		$row2 = mysql_fetch_array($result2);
		if($row2['SOMME']!=0)
		{
			echo "<A HREF='detail_patro.php?PATRO=$row[id_patronym]&FAMILY=$FAMILY'>";
			if($row['libelle_ord']=="")
			{
				echo "?</A> ($row2[SOMME])<BR>";
			}
			else
			{
				echo "$row[libelle_ord]</A> ($row2[SOMME])<BR>";
			}
			
			flush();
		}
	}
	echo "<p><a href=\"#top\">";
	display_lng_text("PATRO_LIST_TOP");
	echo "</a></p>";
}	
 */

/*
*  récupérer les zones associées à un pays
*  pour les afficher dans le formulaire Recherches
*/


function Recherches_Zones($country) {
	
		$table = 'oxg_patronyms';
		$this->Dates->table = $table;
		
		$condition  = "upper(left(oxg_patronyms.libelle_ord,1))='".$INITIALE."' ";
		$condition .= $_SESSION['s_ReqFamille'];
		// $condition .= $_SESSION['s_ReqContemporain'];

		
		$result=$this->Dates->find(array(
				'fields'      => ' oxg_patronyms.id_patronym, oxg_patronyms.libelle_ord, COUNT(*) as somme ',
				'conditions'  => $condition, 
				'group' 	  => "oxg_patronyms.id_patronym, oxg_patronyms.libelle, oxg_patronyms.libelle_ord having (ASCII(upper(left(oxg_patronyms.libelle_ord,1)))<65 or ASCII(upper(left(oxg_patronyms.libelle_ord,1)))>90)",
				'order'       => "oxg_patronyms.libelle_ord, oxg_patronyms.id_patronym"
		));

		foreach($result as $k => $row) {
			$nb_res_max = $row->somme;
		}
	
}

function rechercheParents($individu) {
		//$this->loadModel('arbres');
	
		$table = 'oxg_individuals';
		$this->table = $table;

		$condition  = "id_individual='".$individu."'";
		$condition .= $_SESSION['s_ReqFamille'];

		$result_ind=$this->find(array(
				'fields'     => "id_father, id_mother",
				'conditions' => $condition
		));

		foreach ($result_ind as $row_ind) {
	
			$id_father = !isset($row_ind->id_father) ? '-1' : $row_ind->id_father ;
			$id_mother = !isset($row_ind->id_mother) ? '-1' : $row_ind->id_mother ;
		}

		return array('id_father'=>$id_father,'id_mother'=>$id_mother );

	
	} //fin de fonction recherche_parents





} // fin de classe