Location: PHPKode > projects > HuMo-gen > gezin.php
<?php
// *************************************************************
// *** Family                                                ***
// *************************************************************
$screen_mode='';
if (isset($_POST["screen_mode"]) AND $_POST["screen_mode"]=='PDF'){ $screen_mode='PDF'; }
if (isset($_GET["screen_mode"]) AND $_GET["screen_mode"]=='STAR'){ $screen_mode='STAR'; }
if (isset($_GET["screen_mode"]) AND $_GET["screen_mode"]=='STARSIZE'){ $screen_mode='STARSIZE'; }

$pdfbron= array();  // is set in show_sources.php with sourcenr as key to be used in source appendix
					// see end of this code

$kop='Gezin';
include("header.php");

$last_visited=$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$_SESSION['save_last_visitid']=$last_visited;

@set_time_limit(300);

if($screen_mode!='PDF') {  //we can't have a menu in pdf...
	include("menu.php");
}
if($screen_mode=='PDF') {  // if PDF mode: necessary parts from menu.php  
	if (isset($_SESSION['tree_prefix'])){
		$dataqry = "SELECT * FROM humo_trees LEFT JOIN humo_tree_texts
		ON humo_trees.tree_id=humo_tree_texts.treetext_tree_id
		AND humo_tree_texts.treetext_language='".$Taalkeuze."'
		WHERE tree_prefix='".veilig($_SESSION['tree_prefix'])."'";
		@$datasql = mysql_query($dataqry,$db);
		@$dataDb=mysql_fetch_object($datasql);
	}
}

include("include/language_date.php");
include("include/language_event.php");
include("include/date_place.php");
include("include/process_text.php");
include("include/calculate_age_cls.php");
include('include/person_cls.php');
include("include/marriage_cls.php");
include("include/show_sources.php");
include("include/witness.php");

$gezinnr=1;  // *** process multiple families ***
$gezin_id=1; // *** standard: show first family ***
$hoofdpersoon=''; // *** Mainperson of a family ***

if (isset($urlpart[1])){ $gezin_id=$urlpart[1]; }
if (isset($_GET["id"])){ $gezin_id=$_GET["id"]; }
if (isset($_POST["id"])){ $gezin_id=$_POST["id"]; }

if (isset($urlpart[2])){ $hoofdpersoon=$urlpart[2]; }
if (isset($_GET["hoofdpersoon"])){ $hoofdpersoon=$_GET["hoofdpersoon"]; }
if (isset($_POST["hoofdpersoon"])){ $hoofdpersoon=$_POST["hoofdpersoon"]; }

if($screen_mode=='STAR' OR $screen_mode=='STARSIZE') {
	$chosengen=4;
	if (isset($_GET["chosengen"])){ $chosengen=$_GET["chosengen"]; }
	if (isset($_POST["chosengen"])){ $chosengen=$_POST["chosengen"]; }
	$size=50;
	if (isset($_GET["chosensize"])){ $size=$_GET["chosensize"]; }
	if (isset($_POST["chosensize"])){ $size=$_POST["chosensize"]; }
	$keepgezin_id=$gezin_id;
	$keephoofdpersoon=$hoofdpersoon;
	$direction=0; // vertical
	if (isset($_GET["direction"])){ $direction=$_GET["direction"]; }
	if (isset($_POST["direction"])){ $direction=$_POST["direction"]; }
}

if($screen_mode=='STARSIZE') {
	if (isset($_SESSION['genarray'])){ $genarray=$_SESSION['genarray']; }	
}

if($screen_mode!='STAR' AND $screen_mode!='STARSIZE') {
	// ***************************************************************
	// *** NIEUW: Parenteel uitvoer                                ***
	// *** Zie ook vullen van array genealogie bij kinderen.       ***
	// *** Bij opvragen van 1 gezin wordt dit deel 1x doorlopen... ***
	// ***************************************************************
	// == definiker romijnse cijfers (max. 60 generaties)
	$romcijf = array( 1=>'I', 2=>'II', 3=>'III', 4=>'IV', 5=>'V', 6=>'VI', 7=>'VII', 8=>'VIII', 9=>'IX', 10=>'X',
	11=>'XI', 12=>'XII', 13=>'XIII', 14=>'XIV', 15=>'XV', 16=>'XVI', 17=>'XVII', 18=>'XVIII', 19=>'XIX', 20=>'XX',
	21=>'XXI', 22=>'XXII', 23=>'XXIII', 24=>'XXIV', 25=>'XXV', 26=>'XXVII', 27=>'XXVII', 28=>'XXVIII', 29=>'XXIX', 30=>'XXX',
	31=>'XXXI',32=>'XXXII',33=>'XXXIII',34=>'XXXIV',35=>'XXXV',36=>'XXXVII',37=>'XXXVII',38=>'XXXVIII',39=>'XXXIX',40=>'XL',
	41=>'XLI', 42=>'XLII', 43=>'XLIII', 44=>'XLIV', 45=>'XLV', 46=>'XLVII', 47=>'XLVII', 48=>'XLVIII', 49=>'XLIX', 50=>'L',
	51=>'LI',  52=>'LII',  53=>'LIII',  54=>'LIV',  55=>'LV',  56=>'LVII',  57=>'LVII',  58=>'LVIII',  59=>'LIX',  60=>'LX',);

	//a-z
	$cijfer[]=''; //(1e $cijfer wordt niet gebruikt)
	for ($i=1; $i<=26; $i++) {
		$cijfer[]=chr($i+96); //chr(97)=a
	}
	//aa-zz
	for ($i=1; $i<=676; $i++) {
		for ($j=1; $j<=26; $j++) {
			$cijfer[]=chr($i+96).chr($j+96); //chr(97)=a
		}
	}

	// ******************************************************
	// *** Maximaal weer te geven generaties in parenteel ***
	// ******************************************************
	$max_generatie=($humo_option["parenteel_generaties"]-1);

	$parenteel=false;
	if (isset($_GET['parenteel'])){ $parenteel=true; }
	if (isset($_POST['parenteel'])){ $parenteel=true; }

	// *** Compacte of uitgebreide weergave ***
	if (isset($_POST['gezin_uitgebreid'])){
		if ($_POST['gezin_uitgebreid']=='0'){
			$_SESSION['save_gezin_uitgebreid']='0';
		}
		else{
			$_SESSION['save_gezin_uitgebreid']='1';
		}
	}
	$gezin_uitgebreid=false;
	if (isset($_SESSION['save_gezin_uitgebreid']) AND $_SESSION['save_gezin_uitgebreid']=='1'){
		$gezin_uitgebreid=true;
	}
}
if($screen_mode=='STAR') {
	$parenteel=true;
	$genarray = array();
	$gezin_uitgebreid=false;
}

if($screen_mode=='PDF') {  //initialize pdf generation
	$gezin_uitgebreid=false;
	$pdfdetails=array();
	$pdfhuw=array();
	$pdf=new PDF();
	$pers=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
	WHERE pers_gedcomnumber='$hoofdpersoon'",$db);
	@$persDb=mysql_fetch_object($pers);
	// *** Personen verwerken met een class ***
	$pers_cls = New persoon_cls;
	$pers_cls->construct($persDb);
	if(!$parenteel==false) {
		$title=pdf_convert($language["main_descendant_report"].$language["main_of"].$pers_cls->naam($persDb));
	}
	else {
		$title=pdf_convert($language["main_family_sheet"].$language["main_of"].$pers_cls->naam($persDb));
	}
	$pdf->SetTitle($title);
	$pdf->SetAuthor('Huub Mons (pdf: Yossi Beck)');
	$pdf->AddPage();
	$pdf->SetFont('Arial','',12);
} // end if pdfmode

// **************************
// *** Show single person ***
// **************************
if (!$gezin_id){
	// starfieldchart is never called when there is no own fam so no need to mark this out
	// *** Privacy filter ***
	$persoonmn=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber='".veilig($hoofdpersoon)."'",$db);
	@$persoonmnDb=mysql_fetch_object($persoonmn);

	// *** Personen verwerken met een class ***
	$man_cls = New persoon_cls;
	$man_cls->construct($persoonmnDb);

	if($screen_mode=='PDF') {
		// *** Show familysheet name: user's choice or default ***
		$pdf->Cell(0,2," ",0,1);
		$pdf->SetFont('Arial','BI',12);
		$pdf->SetFillColor(196,242,107);
		if($dataDb->treetext_family_top) {
			$pdf->Cell(0,6,pdf_convert($dataDb->treetext_family_top),0,1,'L',true);
		}
		else {
			$pdf->Cell(0,6,pdf_convert($language["main_family_sheet"]),0,1,'L',true);
		}
		$pdf->SetFont('Arial','B',12);
		$pdf->Write(8,pdf_convert($man_cls->naam_uitgebreid("ouder1")));
		$pdf->SetFont('Arial','',12);
		$pdf->Write(8,"\n");
		$pdfdetails= pdf_convert($man_cls->gegevens("ouder1", $id));
		if($pdfdetails) {
			$pdf->pdfdisplay($pdfdetails,"parent");
		}
	}
	else {
		echo '<table class="humo gezin"><tr><td class="weergave" width="75%">';

		// *** Tekst boven gezin/ los persoon ***
		echo '<div class="tekstgezinsblad fonts">'.$dataDb->treetext_family_top.'<br></div>';

		echo '</td><td class="weergave fonts">';

		if (!$bot_visit){
			if($language["dir"]!="rtl") {
				// *** PDF button ***
				print '<form method="POST" action="'.$uri_pad.'gezin.php?bronnen_weergeven=1" style="display : inline;">';
				print '<input type="hidden" name="id" value="'.$gezin_id.'">';
				print '<input type="hidden" name="hoofdpersoon" value="'.$hoofdpersoon.'">';
				print '<input type="hidden" name="database" value="'.$database.'">';
				print '<input type="hidden" name="screen_mode" value="PDF">';
				print '<input class="fonts" type="Submit" name="submit" value="PDF Report">';

				//echo '<input type="image" src="images/pdf.jpeg" width="15" border="0" alt="PDF">';

				print '</form> ';
			}
			// *** Extended view button ***
			$stijl='';
			print '<form method="POST" action="'.$uri_pad.'gezin.php" style="display : inline;">';
			print '<input type="hidden" name="id" value="'.$gezin_id.'">';
			print '<input type="hidden" name="hoofdpersoon" value="'.$hoofdpersoon.'">';
			if ($parenteel==true){ print '<input type="hidden" name="parenteel" value="1">'; }
			if ($gezin_uitgebreid==true){
				print '<input type="hidden" name="gezin_uitgebreid" value="0">';
				print '<input class="fonts" type="Submit" name="submit" value="'.$language["main_concise_view"].'">';
			}
			else{
				print '<input type="hidden" name="gezin_uitgebreid" value="1">';
				print '<input class="fonts" type="Submit" name="submit" value="'.$language["main_expanded_view"].'">';
			}
			print '</form>';
		}

		echo '</td></tr>';
		echo '<tr><td colspan="2">';
			//*** Show person data ***
			echo '<span class="ouder1 fonts">';
			$man_cls->naam_uitgebreid("ouder1");
			$id='';
			$man_cls->gegevens("ouder1", $id);
			echo '</span>';

		echo '</td></tr>';
		echo '</table>';
	} // end if not pdf
}

// *******************
// *** Show family ***
// *******************
else{
	if($screen_mode=='PDF') {
		$pdf->SetFont('Arial','B',15);
		$pdf->Ln(4);
		if(!$parenteel==false) {
			$pdf->MultiCell(0,10,pdf_convert($language["main_descendant_report"].$language["main_of"].$pers_cls->naam($persDb)),0,'C');
		}
		else {
			$pdf->MultiCell(0,10,pdf_convert($language["main_family_sheet"].$language["main_of"].$pers_cls->naam($persDb)),0,'C');
		}
		$pdf->Ln(4);
		$pdf->SetFont('Arial','',12);
	}
	if($screen_mode!='STARSIZE') {
		$genealogie2[]=$gezin_id;
		$hoofdpersonen2[]=$hoofdpersoon;
	}

	if($screen_mode=='STAR') {
		$arraynr=0;
	}

	// *** Aantal generaties ***
	if($screen_mode=='STAR') {
		$max_generatie=$chosengen-2;
	}
	if($screen_mode!='STARSIZE') {
	for ($gen_lus=0; $gen_lus<=$max_generatie; $gen_lus++){
		$genealogie2[]=0;
		$hoofdpersonen[2]=0;
		if (!isset($genealogie2[1])){ break; }

		// *** Array kopieren ***
		unset ($genealogie);
		$genealogie=$genealogie2;
		unset ($genealogie2);

		unset ($hoofdpersonen);
		$hoofdpersonen=$hoofdpersonen2;
		unset ($hoofdpersonen2);

		if($screen_mode=='STAR') {
			if($gen_lus!=0) {
				if(isset($genarray[$arraynr])) {
					$temppar=$genarray[$arraynr]["par"];
				}
				while(isset($genarray[$temppar]["gen"]) AND $genarray[$temppar]["gen"]==$gen_lus-1) {
					$lst_in_array += $genarray[$temppar]["nrc"];
					$temppar++;
				}
			}
			$nrchldingen=0;
		}
		else {
			if ($parenteel==true){  
				if($screen_mode!='PDF') {
					echo '<div class="parenteel fonts">'.$language["fam_generation"].$romcijf[$gen_lus+1].'</div>';
				}
				else {
					$pdf->SetLeftMargin(10);
					$pdf->Cell(0,2,"",0,1);
					$pdf->SetFont('Arial','BI',14);
					$pdf->SetFillColor(200,220,255);
					if($pdf->GetY() > 250) { $pdf->AddPage(); $pdf->SetY(20); }
					$pdf->Cell(0,8,pdf_convert($language["fam_generation"]).$romcijf[$gen_lus+1],0,1,'C',true);
					$pdf->SetFont('Arial','',12);
				}
			}
		}
		// *** Aantal gezinnen in 1 generatie
		for ($gen_lus2=0; $gen_lus2<=count($genealogie); $gen_lus2++){

			if($screen_mode=='STAR') {
				while (isset($genarray[$arraynr]["non"]) AND $genarray[$arraynr]["non"]==1
				AND isset($genarray[$arraynr]["gen"]) AND $genarray[$arraynr]["gen"]==$gen_lus) {
					$genarray[$arraynr]["nrc"]==0;
					$arraynr++;
				}
			}

			if ($genealogie[$gen_lus2]==''){ break; }
			//$gezin_id=$genealogie[$gen_lus2];
			$gezin_id_lus=$genealogie[$gen_lus2];
			$hoofdpersoon=$hoofdpersonen[$gen_lus2];
			$gezinnr=1;

			// *** Tellen aantal huwelijken van man ***
			// *** YB: wijzigingen gemaakt om vrouw als hoofdpersoon weer te geven ***
			$gezin=mysql_query("SELECT fam_man, fam_woman FROM ".veilig($_SESSION['tree_prefix'])."family
				WHERE fam_gedcomnumber='".veilig($gezin_id_lus)."'",$db);
			@$gezinDb=mysql_fetch_object($gezin) or die("Geen geldig gezinsnummer.");

			$ouder1=''; $ouder2=''; $wissel_hoofdpersoon=false;
			// *** Standaard hoofdpersoon is de vader ***
			if ($gezinDb->fam_man){
				$ouder1=$gezinDb->fam_man;
			}
			// *** Bij klikken op de moeder, wordt de moeder de hoofdpersoon ***
			if ($gezinDb->fam_woman==$hoofdpersoon){
				$ouder1=$gezinDb->fam_woman;
				$wissel_hoofdpersoon=true;
			}

			// *** Controle op gezin met ouder1: N.N. ***
			if ($ouder1){
				// *** Gezinnen van man opslaan in array ***
				$persoon=mysql_query("SELECT pers_fams FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='".veilig($ouder1)."'",$db);
				@$personDb=mysql_fetch_object($persoon);
				$aantalhuw=explode(";",$personDb->pers_fams);
				$nummer=substr_count($personDb->pers_fams, ";");
			}
			else{
				$aantalhuw[0]=$gezin_id_lus;
				$nummer="0";
			}

			// *** Lus met meerdere huwelijken van hoofdpersoon ***
			for ($ouder1huw=0; $ouder1huw<=$nummer; $ouder1huw++){
				$id=$aantalhuw[$ouder1huw];
				$gezin=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family
					WHERE fam_gedcomnumber='".veilig($id)."'",$db);
				@$gezinDb=mysql_fetch_object($gezin);

				// *** Don't count search bots, crawlers etc. ***
				if (!$bot_visit){
					// *** (Oude) statistieken teller verhogen ***
					$Tel=$gezinDb->fam_counter+1;
					$sql="UPDATE ".veilig($_SESSION['tree_prefix'])."family SET fam_counter=$Tel
						WHERE fam_gedcomnumber='".veilig($id)."'";
					mysql_query($sql, $db) or die(mysql_error());

					// *** Uitgebreide statistieken, alleen uitvoeren als de tabel aanwezig is ***
					$tabel_controle = mysql_query("SELECT * FROM humo_stat_date LIMIT 0,1",$db);
					if ($tabel_controle AND $parenteel==false AND $user['group_statistics']=='j'){

						$datasql = mysql_query("SELECT * FROM humo_trees
							WHERE tree_prefix='".veilig($_SESSION['tree_prefix'])."'",$db);
						$datasqlDb=mysql_fetch_object($datasql);
						$stat_easy_id=$datasqlDb->tree_id.'-'.$gezinDb->fam_gedcomnumber.'-'.$gezinDb->fam_man.'-'.$gezinDb->fam_woman;
						if (function_exists('date_default_timezone_set')){
							date_default_timezone_set('Europe/Amsterdam');
						}
						$datum=date("Y-m-d H:i");
						$stat_date_linux=time();

						// *** Automatic installation or update datafield stat_user_agent ***
						$tabel_controleDb=mysql_fetch_object($tabel_controle);
						if (isset($tabel_controleDb->stat_id)){
							if (!isset($tabel_controleDb->stat_user_agent)){
								$sql="ALTER TABLE humo_stat_date
									ADD stat_user_agent VARCHAR( 255 ) NOT NULL;";
								$result=mysql_query($sql) or die(mysql_error());
							}
						}

						$gebeurtsql="INSERT INTO humo_stat_date SET
							stat_easy_id='".$stat_easy_id."',
							stat_ip_address='".$_SERVER['REMOTE_ADDR']."',
							stat_user_agent='".$_SERVER['HTTP_USER_AGENT']."',
							stat_tree_id='".$datasqlDb->tree_id."',
							stat_gedcom_fam='".$gezinDb->fam_gedcomnumber."',
							stat_gedcom_man='".$gezinDb->fam_man."',
							stat_gedcom_woman='".$gezinDb->fam_woman."',
							stat_date_stat='".$datum."',
							stat_date_linux='".$stat_date_linux."'";
						$result=mysql_query($gebeurtsql) or die(mysql_error());
					}
				}

				// *** Privacy filter man en vrouw ***
				$persoonmn=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='$gezinDb->fam_man'",$db);
				@$persoonmnDb=mysql_fetch_object($persoonmn);

				// *** Personen verwerken met een class ***
				$man_cls = New persoon_cls;
				$man_cls->construct($persoonmnDb);

				$persoonvr=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='$gezinDb->fam_woman'",$db);
				@$persoonvrDb=mysql_fetch_object($persoonvr);

				// *** Personen verwerken met een class ***
				$vrouw_cls = New persoon_cls;
				$vrouw_cls->construct($persoonvrDb);

				// *** Huwelijk verwerken met een class ***
				$huw_cls = New huwelijk_cls;
				$huw_cls->construct($gezinDb, $man_cls->privacy, $vrouw_cls->privacy);
				$gezinlevend=$huw_cls->privacy;

				// *******************************************************************
				// *** Show family                                                 ***
				// *******************************************************************
			if($screen_mode!='STAR') {
				// *** Interne link voor parenteel ***
				if ($parenteel==true){ 
					// *** Interne link (Romeins cijfer) ***
					if($screen_mode!='PDF') {
						echo '<a name="'.$romcijf[$gen_lus+1].'-'.$cijfer[$gen_lus2+1].'">';
						echo '&nbsp;</a>';
					}
					else {
						// put internal PDF link to family
						$pdf->Cell(0,1," ",0,1);
						$romannr=$romcijf[$gen_lus+1].'-'.$cijfer[$gen_lus2+1];
						if(isset($link[$romannr])) {
							$pdf->SetLink($link[$romannr],-1); //link to this family from child with "volgt"
						}
						$parlink[$id]=$pdf->Addlink();
						$pdf->SetLink($parlink[$id],-1);   // link to this family from parents
					}
				}

				if($screen_mode!='PDF') {
					echo '<table class="humo gezin"><tr><td class="weergave" width="75%">';

					// *** Tekst boven gezin ***
					echo '<div class="tekstgezinsblad fonts">'.$dataDb->treetext_family_top.'<br></div>';
					echo '</td><td class="weergave fonts">';

					if (!$bot_visit){
						if($language["dir"]!="rtl") {
							// *** PDF button ***
							print '<form method="POST" action="'.$uri_pad.'gezin.php?bronnen_weergeven=1" style="display : inline;">';
							print '<input type="hidden" name="id" value="'.$gezin_id.'">';
							print '<input type="hidden" name="hoofdpersoon" value="'.$hoofdpersoon.'">';
							print '<input type="hidden" name="database" value="'.$database.'">';
							print '<input type="hidden" name="screen_mode" value="PDF">';
							if($parenteel==true) {
								print '<input type="hidden" name="parenteel" value="'.$parenteel.'">';
							}
							print '<input class="fonts" type="Submit" name="submit" value="PDF Report">';

							//echo '<input type="image" src="images/pdf.jpeg" width="20" border="0" alt="PDF">';

							print '</form> ';
						}

						// *** Extended view button ***
						$stijl='';
						print '<form method="POST" action="'.$uri_pad.'gezin.php" style="display : inline;">';
						print '<input type="hidden" name="id" value="'.$gezin_id.'">';
						print '<input type="hidden" name="hoofdpersoon" value="'.$hoofdpersoon.'">';
						if ($parenteel==true){ print '<input type="hidden" name="parenteel" value="1">'; }
						if ($gezin_uitgebreid==true){
							print '<input type="hidden" name="gezin_uitgebreid" value="0">';
							print '<input class="fonts" type="Submit" name="submit" value="'.$language["main_concise_view"].'">';
						}
						else{
							print '<input type="hidden" name="gezin_uitgebreid" value="1">';
							print '<input class="fonts" type="Submit" name="submit" value="'.$language["main_expanded_view"].'">';
						}
						print '</form>';
					}
					
					echo '</td></tr>';

					echo '<tr><td colspan="2">';
				} //end  "if not pdf"
				else {
					//Show "Family Page", user's choice or default
					$pdf->SetLeftMargin(10);
					$pdf->Cell(0,2," ",0,1);
					if($pdf->GetY() > 260 AND $gen_lus2!=0) {
						// move to next page so family sheet banner won't be last on page
						// but if we are in first family in generation, the gen banner
						// is already checked so no need here
						$pdf->AddPage(); $pdf->SetY(20);
					}
					$pdf->SetFont('Arial','BI',12);
					$pdf->SetFillColor(186,244,193);
					if($dataDb->treetext_family_top) {
						$pdf->SetLeftMargin(10);
						$pdf->Cell(0,6,$dataDb->treetext_family_top,0,1,'L',true);
					}
					else {
						$pdf->SetLeftMargin(10);
						$pdf->Cell(0,6,$language["main_family_sheet"],0,1,'L',true);
					}
					$pdf->SetFont('Arial','',12);
				}
			}  // end if not STAR

				// *************************************************************
				// *** Parent1 (normally the father)                         ***
				// *************************************************************
				if ($gezinDb->fam_kind!='PRO-GEN'){  //onecht kind, vrouw zonder man
					if ($gezinnr==1){
						//*** Gegevens man weergeven ***
						if($screen_mode=='') {
							echo '<div class="ouder1 fonts">';
							// *** Bij parenteel een romeins cijfer weergeven ***
							if ($parenteel==true){ echo '<b>'.$romcijf[$gen_lus+1].'-'.$cijfer[$gen_lus2+1].'</b> '; }
						}
						if($screen_mode=='PDF') {
							if ($parenteel==true) { $pdf->Write(8,$romcijf[$gen_lus+1].'-'.$cijfer[$gen_lus2+1]." "); }
						}

						if ($wissel_hoofdpersoon==true){
							if($screen_mode=='') {
								$vrouw_cls->naam_uitgebreid("ouder1");
								$vrouw_cls->gegevens("ouder1", $id);
							}
							if($screen_mode=='PDF') {
								//  PDF rendering of name + details
								$pdf->writename($persoonvrDb->pers_sexe,$pdf->GetX()+5,$vrouw_cls->naam_uitgebreid("ouder1"),"long");
								$pdf->SetLeftMargin($indent);
								$pdfdetails= $vrouw_cls->gegevens("ouder1", $id);
								if($pdfdetails) {
									$pdf->pdfdisplay($pdfdetails,"parent1");
								}
								$pdf->SetLeftMargin($indent-5);
							}
							if($screen_mode=='STAR') {
								if($gen_lus==0) {
									$genarray[$arraynr]["nam"]=$vrouw_cls->naam($persoonvrDb);
									$genarray[$arraynr]["init"]=substr($persoonvrDb->pers_firstname,0,1).'.'.substr($persoonvrDb->pers_lastname,0,1).'.';
									$genarray[$arraynr]["sex"]="v";
									$genarray[$arraynr]["fams"]=$id;
									$genarray[$arraynr]["gednr"]=$persoonvrDb->pers_gedcomnumber;
									$genarray[$arraynr]["2nd"]=0;
								}
							}
						}
						else{
							if($screen_mode=='') {
								$man_cls->naam_uitgebreid("ouder1");
								$man_cls->gegevens("ouder1", $id);
							}
							if($screen_mode=='PDF') {
								//  PDF rendering of name + details
								$pdf->writename($persoonmnDb->pers_sexe,$pdf->GetX()+5,$man_cls->naam_uitgebreid("ouder1"),"long");
								$pdf->SetLeftMargin($indent);
								$pdfdetails= $man_cls->gegevens("ouder1", $id);
								if($pdfdetails) {
									$pdf->pdfdisplay($pdfdetails,"parent1");
								}
								$pdf->SetLeftMargin($indent-5);
							}
							if($screen_mode=='STAR') {
								if($gen_lus==0) {
									$genarray[$arraynr]["nam"]=$man_cls->naam($persoonmnDb);
									$genarray[$arraynr]["init"]=substr($persoonmnDb->pers_firstname,0,1).'.'.substr($persoonmnDb->pers_lastname,0,1).'.';
									$genarray[$arraynr]["sex"]="m";
									$genarray[$arraynr]["fams"]=$id;
									$genarray[$arraynr]["gednr"]=$persoonmnDb->pers_gedcomnumber;
									$genarray[$arraynr]["2nd"]=0;
								}
							}
						}

						if($screen_mode=='') {  echo '</div>';}
						//$gezinnr++;
					}
					else{
						// *** Standaard huwelijkstekst weergeven ***
						//echo $huw_cls->huwelijk($gezinDb,$gezinnr,'kort').' ';
						if($screen_mode=='') {
							echo $huw_cls->huwelijk($gezinDb,$gezinnr,'korter').' ';
						}
						if($screen_mode=='PDF') {
							// echo 'pdf ANOTHER MARRIAGE<br>';
							$pdf->SetLeftMargin($indent);
							$pdfhuw=$huw_cls->huwelijk($gezinDb,$gezinnr,'korter');
							$pdf->Write(8,pdf_convert($pdfhuw["relnr_rel"]).$language["main_of"]."\n");
						}

						// *** Alleen de naam weergeven bij 2e, 3e, etc. huwelijk (niet alles herhalen) ***
						if($screen_mode!='STAR') {
							if ($wissel_hoofdpersoon==true){
								if($screen_mode!='PDF') {
									echo '<br>';
									$vrouw_cls->naam_uitgebreid("ouder1");
									echo '<br>';
								}
								else {
									// PDF rendering of name
									$pdf->writename($persoonvrDb->pers_sexe,$indent,$vrouw_cls->naam_uitgebreid("ouder1"),"kort");
								}
							}
							else{
								if($screen_mode!='PDF') {
									echo '<br>';
									$man_cls->naam_uitgebreid("ouder1");
									echo '<br>';
								}
								else {
									//  PDF rendering of name
									$pdf->writename($persoonmnDb->pers_sexe,$indent,$man_cls->naam_uitgebreid("ouder1"),"kort");
								}
							}
						}
						else { //screenmode is STAR
							if($gen_lus==0) {
								$genarray[$arraynr]=$genarray[$arraynr-1];
								$genarray[$arraynr]["2nd"]=1;
								$genarray[$arraynr]["fams"]=$id;
							}
							$genarray[$arraynr]["huw"]=$huw_cls->huwelijk($gezinDb,$gezinnr,'korter');
						}
					}
					$gezinnr++;
				} // *** einde controle PRO-GEN ***

				// *************************************************************
				// *** Marriage                                              ***
				// *************************************************************
				if ($gezinDb->fam_kind!='PRO-GEN'){  //onecht kind, vrouw zonder man
					if($screen_mode=='') {
						echo '<br><span class="huwelijk fonts">';
						// *** $gezinlevend='1' betekent filteren ***
						if ($gezinlevend){
							// *** Standaard huwelijkstekst weergeven ***
							echo $huw_cls->huwelijk($gezinDb,'','kort');
						}
						else{
							echo $huw_cls->huwelijk();
						}
						echo '</span><br><br>';
					}
					if($screen_mode=='PDF') {
						if($gezinlevend) {
							$pdfhuw=$huw_cls->huwelijk($gezinDb,'','kort');
							$pdf->SetLeftMargin($indent);
							if($pdfhuw) {
								$pdf->displayrel($pdfhuw,"dummy");
							}
						}
						else {
							$pdfhuw=$huw_cls->huwelijk();
							$pdf->SetLeftMargin($indent);
							if($pdfhuw) {
								$pdf->displayrel($pdfhuw,"dummy");
							}
						}
					}
					if($screen_mode=='STAR') {
						if($gezinlevend) {
							$genarray[$arraynr]["htx"]=$huw_cls->huwelijk($gezinDb,'','kort');
						}
						else {
							$genarray[$arraynr]["htx"]=$huw_cls->huwelijk();
						}
					}
				}

				// *************************************************************
				// *** Parent2 (normally the mother)                         ***
				// *************************************************************
				if($screen_mode=='') {
					echo '<div class="ouder2 fonts">';
				}
				if ($wissel_hoofdpersoon==true){
					if($screen_mode=='') {
						$man_cls->naam_uitgebreid("ouder2");
						$man_cls->gegevens("ouder2", $id);
					}
					if($screen_mode=='PDF') {
						// PDF rendering of name + details
						$pdf->Write(8," "); // IMPORTANT - otherwise at bottom of page man/woman.gif image will print, but name may move to following page!
						$pdf->writename($persoonmnDb->pers_sexe,$indent,$man_cls->naam_uitgebreid("ouder2"),"kort");
						$pdfdetails= $man_cls->gegevens("ouder2", $id);
						$pdf->SetLeftMargin($indent);
						if($pdfdetails) {
							$pdf->pdfdisplay($pdfdetails,"parent2");
						}
					}
					if($screen_mode=='STAR') {
					if($persoonmnDb) {
						$genarray[$arraynr]["sps"]=$man_cls->naam($persoonmnDb);
						$genarray[$arraynr]["spgednr"]=$persoonmnDb->pers_gedcomnumber;
					}
					else { $genarray[$arraynr]["sps"]= $language["nn"]; }
						$genarray[$arraynr]["spfams"]=$id;
					}
				}
				else{
					if($screen_mode=='') {
						$vrouw_cls->naam_uitgebreid("ouder2");
						$vrouw_cls->gegevens("ouder2", $id);
					}
					if($screen_mode=='PDF'){
						// PDF rendering of name + details
						$pdf->Write(8," ");   // IMPORTANT - otherwise at bottom of page man/woman.gif image will print, but name may move to following page!
						$pdf->writename($persoonvrDb->pers_sexe,$indent,$vrouw_cls->naam_uitgebreid("ouder2"),"kort");
						$pdfdetails= $vrouw_cls->gegevens("ouder2", $id);
						$pdf->SetLeftMargin($indent);
						if($pdfdetails) {
						$pdf->pdfdisplay($pdfdetails,"parent2");
						}
					}
					if($screen_mode=='STAR') {
					if($persoonvrDb) {
						$genarray[$arraynr]["sps"]=$vrouw_cls->naam($persoonvrDb);
						$genarray[$arraynr]["spgednr"]=$persoonvrDb->pers_gedcomnumber;
						}
						else { $genarray[$arraynr]["sps"]= $language["nn"]; }
						$genarray[$arraynr]["spfams"]=$id;
					}
				}
				if($screen_mode=='') {
					echo '</div>';
				}

				// *************************************************************
				// *** Marriagetext                                          ***
				// *************************************************************
			if($screen_mode!='STAR') {
				if ($gezinlevend){
					//Geen huwelijkstekst weergeven
				}
				else{
					if ($gezinDb->fam_text){
						if($screen_mode!='PDF') {
							echo '<br>'.werktekstomzet($gezinDb->fam_text);

							// *** BK: source by family text ***							
							if (isset($gezinDb->fam_text_source) AND $gezinDb->fam_text_source){
								echo bronweergave($gezinDb->fam_text_source); 
							}

						}
						else {
							// PDF rendering of marriage notes
							$pdf->SetFont('Arial','I',11);
							$pdf->Write(6,pdf_convert(werktekstomzet($gezinDb->fam_text))."\n");
							$pdf->SetFont('Arial','',12);
						}
					}
				}

				// *** Adressen weergeven ***
				if ($user["woonplaats"]=='j'){
					if ($gezinDb->fam_gedcomnumber){
						$adresaantal=0;
						$adresqry=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."addresses
						WHERE address_family_id='$gezinDb->fam_gedcomnumber'",$db);
						if($screen_mode!='PDF') {
						while($adresDb=mysql_fetch_object($adresqry)){
							$adresaantal++;
							if ($adresaantal=='1'){ echo '<span class="woonplaats fonts">'.$language["pers_living_place"]; }
							if ($adresaantal>1){ echo ', '; }
							if ($adresDb->address_date){ echo datumplaats($adresDb->address_date,'').' '; } //standaard weergave, plaats is er niet...
							echo $adresDb->address_place;
							// *** Bron bij adres weergeven ***
							if ($adresDb->address_source){ echo bronweergave($adresDb->address_source); }
							if ($adresDb->address_text) { echo ' '.$adresDb->address_text; }
						}
						if ($adresaantal>0){ echo '</span>'; }
						}
						else {
							//  PDF rendering of addresses
							while($adresDb=mysql_fetch_object($adresqry)){
								$adresaantal++;
								$pdf->SetFont('Arial','',12);
								if ($adresaantal=='1'){ $pdf->Write(6,$language["pers_living_place"]); }
								if ($adresaantal>1){ $pdf->Write(6,', '); }
								if ($adresDb->address_date){$pdf->Write(6,pdf_convert(datumplaats($adresDb->address_date,'')).' '); }
								$pdf->Write(6,$adresDb->address_place);
								// *** Bron bij adres weergeven ***
								if ($adresDb->address_source){
									$pdf->SetFont('Times','',12);  $pdf->Write(6,pdf_convert(bronweergave($adresDb->address_source))); }
								if ($adresDb->address_text) {$pdf->SetFont('Arial','I',11);  $pdf->Write(6,' '.$adresDb->address_text); }
							} // end while
							if($adresaantal>0) {$pdf->Ln(6); }
						}  // end else (pdf)
					}   // end if gedcomnummer
				}   // end if gebruiker woonplaats

				// *** Bron bij gezin ***
				//if ($gezinDb->bronid){ echo bronweergave($gezinDb->bronid); }
				$bronnen='';
				$bronqry=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."events
					WHERE event_family_id='$gezinDb->fam_gedcomnumber' AND event_kind='bron'",$db);
				while($bronDb=mysql_fetch_object($bronqry)){
					if ($bronnen!=''){
						$bronnen.=';'.$bronDb->event_source;
					}
					else {
						$bronnen=$bronDb->event_source;
					}
				}
				if ($bronnen!=''){
					if($screen_mode!='PDF') {
						echo bronweergave($bronnen);
					}
					else {
						// PDF rendering of sources
						$pdf->Write(6,pdf_convert(bronweergave($bronnen))."\n");
					}
				}
			} //end "if not STAR"

			if($screen_mode=='STAR') {
					if($gen_lus==0) {
					$lst_in_array=$nummer;
					$genarray[$arraynr]["gen"]=0;
					$genarray[$arraynr]["par"]=-1;
					$genarray[$arraynr]["chd"]=$arraynr + 1;
					$genarray[$arraynr]["non"]=0;
				}
			}

				// *************************************************************
				// *** Children                                              ***
				// *************************************************************

				if($screen_mode=='STAR') {
					if (!$gezinDb->fam_children){
						$genarray[$arraynr]["nrc"]=0;
					}
				}

				if ($gezinDb->fam_children){
					$teller=1;
					$aantalkinderen=explode(";",$gezinDb->fam_children);

					if($screen_mode=='') {
						// *** Show "Child(ren):" ***
						if (count($aantalkinderen)=='1'){
							echo '<p><b>'.$language["fam_child"].'</b></p>';
						}
						else{
							echo '<p><b>'.$language["fam_children"].'</b></p>';
						}							

						echo "</td></tr>\n";
					}
					if($screen_mode=='PDF') {
						$pdf->SetLeftMargin(10);
						$pdf->SetDrawColor(200);  // grey line
						$pdf->Cell(0,2," ",'B',1);
					}
					if($screen_mode=='STAR') {
						$genarray[$arraynr]["nrc"]=count($aantalkinderen);
					}

					for ($i=0; $i<=substr_count($gezinDb->fam_children, ";"); $i++){
						$kind=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
						WHERE pers_gedcomnumber='$aantalkinderen[$i]'",$db);
						@$kindDb=mysql_fetch_object($kind);

						// *** Personen verwerken met een class ***
						$kind_cls = New persoon_cls;
						$kind_cls->construct($kindDb);

						if($screen_mode=='') {
							echo '<tr><td colspan="2"><div class="kinderen">';
							echo '<div class="kindnr">'.$teller.')</div> ';
							$kind_cls->naam_uitgebreid("Kind");
						}
						if($screen_mode=='PDF') {
							//  PDF rendering of name + details
							$pdf->SetFont('Arial','B',11);
							$pdf->SetLeftMargin($indent);
							$pdf->Write(6,$teller.') ');
							if($kindDb->pers_sexe=='M') {
								$pdf->Image("images/man.gif",$pdf->GetX()+1,$pdf->GetY()+1,3.5,3.5);
								$pdf->SetX($pdf->GetX()+5);
							}
							elseif($kindDb->pers_sexe=='F') {
								$pdf->Image("images/woman.gif",$pdf->GetX()+1,$pdf->GetY()+1,3.5,3.5);
								$pdf->SetX($pdf->GetX()+5);
							}
							else {
								$pdf->Image("images/unknown.gif",$pdf->GetX()+1,$pdf->GetY()+1,3.5,3.5);
								$pdf->SetX($pdf->GetX()+5);
							}
							$child_indent=$pdf->GetX();
							$pdf->Write(6,$kind_cls->naam_uitgebreid("Kind"));
							$pdf->SetFont('Arial','',12);
						}
						if($screen_mode=='STAR') {
							$chdn_in_gen=$nrchldingen + $teller;
							$place=$lst_in_array+$chdn_in_gen;
							$genarray[$place]["gen"]=$gen_lus+1;
							$genarray[$place]["par"]=$arraynr;
							$genarray[$place]["chd"]=$teller;
							$genarray[$place]["non"]=0;
							$genarray[$place]["nrc"]=0;
							$genarray[$place]["2nd"]=0;
							$genarray[$place]["nam"]=$kind_cls->naam($kindDb);
							$genarray[$place]["init"]=substr($kindDb->pers_firstname,0,1).'.'.substr($kindDb->pers_lastname,0,1).'.';
							$genarray[$place]["gednr"]=$kindDb->pers_gedcomnumber;
							if($kindDb->pers_fams) {
								$childfam=explode(";",$kindDb->pers_fams);
								$genarray[$place]["fams"]=$childfam[0];
							}
							else {
								$genarray[$place]["fams"]=$kindDb->pers_famc;
							}
							if($kindDb->pers_sexe == "F") { $genarray[$place]["sex"]="v"; }
								else { $genarray[$place]["sex"]="m"; }
						}

						// *** Parenteel opbouwen ***
						if ($parenteel==true AND $kindDb->pers_fams AND $gen_lus<$max_generatie){

						// *** 1e gezin van kind ***
						$linkkind=explode(";",$kindDb->pers_fams);
						$genealogie2[]=$linkkind[0];

						if($screen_mode=='STAR') {
							if(count($linkkind>1)) {
								for($k=1 ; $k<count($linkkind) ; $k++) {
									$teller++;
									$thisplace=$place+$k;
									$genarray[$thisplace]=$genarray[$place];
									$genarray[$thisplace]["chd"]=$teller;
									$genarray[$thisplace]["2nd"]=1;
									$genarray[$arraynr]["nrc"]+=1;
								}
							}
						}

						// *** YB: ervoor zorgen dat kinderen in in parenteel altijd als eerste worden vermeld ***
						$hoofdpersonen2[]=$kindDb->pers_gedcomnumber;
						if($screen_mode=='') {
								echo '<b><i>'.$language["pers_follows"].'</i></b>
							<a href="'.str_replace("&","&amp;",$_SERVER['REQUEST_URI']).'#'.$romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)].'">'.
							$romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)].'</a>';

						}
						if($screen_mode=='PDF') {
							// PDF rendering of link to own family
							$pdf->Write(6,$language["pers_follows"]);
							$romnr=$romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)];
							$link[$romnr]=$pdf->AddLink();
							$pdf->SetFont('Arial','U',11);  $pdf->SetTextColor(28,28,255);
							$pdf->Write(6,$romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)]."\n",$link[$romnr]);
							$pdf->SetFont('Arial','',12); $pdf->SetTextColor(0);
							$parentchild[$romnr]=$id;
						}

						//echo '<b><i>'.$language["pers_follows"].'</i></b>
						//  <a href="'.$_SERVER['PHP_SELF'].'#'.$romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)].'">'.
						//  $romcijf[$gen_lus+2].'-'.$cijfer[count($genealogie2)].'</a>';
						}
						else{
						if($screen_mode=='') {
							$kind_cls->gegevens("Kind", $id);
						}
						if($screen_mode=='PDF') { 
							//  PDF rendering of child details
							$pdf->Write(6,"\n");
							$pdfkind=$kind_cls->gegevens("Kind", $id);
							if($pdfkind) {
								$pdf->SetLeftMargin($child_indent);
								$pdf->pdfdisplay($pdfkind,"kind");
								$pdf->SetLeftMargin($indent);
							}
						}
						if($screen_mode=='STAR') {
							$genarray[$place]["non"]=1;
						}
						}

						if($screen_mode=='') {
						echo '</div></td></tr>'."\n";
						}
						$teller++;
					}
					if($screen_mode=='STAR') {
						$nrchldingen += ($teller-1);
					}
					if($screen_mode=='PDF') {
						$pdf->SetFont('Arial','',12);
					}
				}
				if($screen_mode=='') {
					echo "</table><br>\n";
				}
				if($screen_mode=='STAR') {
					$arraynr++;
				}

			} //Meerdere huwelijken weergeven

		} //einde aantal gezinnen in 1 generatie

	} //einde aantal generaties
	} //end if not STARSIZE
} // End of single person

// *** Extra footer text in family screen ***
if($screen_mode=='') {
	if ($parenteel==false) { echo $dataDb->treetext_family_footer; }
}

// list appendix of sources
if($screen_mode=="PDF" AND !empty($pdfbron)) {
	include("source.php");
	$pdf->AddPage(); // appendix on new page
	$pdf->SetFont('Arial',"B",14);
	$pdf->Write(8,$language["source_sources"]."\n\n");
	$pdf->SetFont('Arial','',10);
	// the $pdfbron array is set in show_sources.php with sourcenr as key and value if a linked bron is given
	foreach($pdfbron as $key => $value) {
		if(isset($pdfbron[$key])) {
			source_display($pdfbron[$key]);  // function source_display from source.php, called with source nr.
			$pdf->Write(2,"\n");
			$pdf->SetDrawColor(200);  // grey line
			$pdf->Cell(0,2," ",'B',1);
			$pdf->Write(4,"\n");
		}
	}
	unset($value);
}
if($screen_mode=='STAR' OR $screen_mode=='STARSIZE') {
	include("report_descendant.php");
	generate();
	printchart();
}

//if($screen_mode!='STARSIZE') {
//	mysql_close($db); //databaseverbinding sluiten.
//}
if($screen_mode!='PDF') {
	include("footer.php");
}
else {
	$pdf->Output($title.".pdf","I");
}

?>
Return current item: HuMo-gen