Location: PHPKode > projects > HuMo-gen > report_ancestor.php
<?php
// Oorspronkelijke test scipt gemaakt door: Klaas de Winkel
// Oorspronkelijke grafische script gemaakt door: Theo Huitema
// Grafische deel: mooiere lay-out (kleuren) en afbeeldingen door: Reni Janssen
// PDF uitvoer en Kwartierblad: Yossi Beck.

@set_time_limit(3000);

// == definiker romijnse cijfers (max. 60 generaties)
$romcyf = 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',);

$screen_mode=''; 
if (isset($_POST["screen_mode"]) AND $_POST["screen_mode"]=='PDF'){ $screen_mode='PDF'; }
//if (isset($_POST["screen_mode"]) AND $_POST["screen_mode"]=='KWBLAD'){ $screen_mode='KWBLAD'; }
if (isset($_GET["screen_mode"]) AND $_GET["screen_mode"]=='KWBLAD'){ $screen_mode='KWBLAD'; }

//if (isset($_POST["screen_mode"]) AND $_POST["screen_mode"]=='GRAFISCH'){ $screen_mode='GRAFISCH'; }
if (isset($_GET["screen_mode"]) AND $_GET["screen_mode"]=='GRAFISCH'){ $screen_mode='GRAFISCH'; }

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

$kop="ovzkwartier";
include("header.php");

include ("include/language_date.php");
include("include/language_event.php");
include("include/calculate_age_cls.php");
include('include/person_cls.php');
include('include/witness.php');

//Voor de functie huwelijkgegevens:
include ('include/process_text.php');
include ('include/date_place.php');
include("include/marriage_cls.php");
include("include/show_sources.php");

if($screen_mode!='PDF') {  //we can't have a menu in pdf...
	include("menu.php");
}
else {
	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);
	}
}

$gezin_id=1; // *** 1e gezin weergeven als dit bestand rechtstreeks wordt aangeroepen. ***
if (isset($_GET["id"])){ $gezin_id=$_GET["id"]; }
if (isset($_POST["id"])){ $gezin_id=$_POST["id"]; }

if($screen_mode!='PDF') {
	if ($screen_mode!="KWBLAD") {
		echo '<div class="parenteel fonts">'.$language["main_ancestor_report"];
			if($language["dir"]!="rtl") {
				// pdf knop tonen
				print ' <form method="POST" action="'.$uri_pad.'report_ancestor.php?bronnen_weergeven=1" style="display : inline;">';
				print '<input type="hidden" name="id" value="'.$gezin_id.'">';
				print '<input type="hidden" name="database" value="'.$_SESSION['tree_prefix'].'">';
				print '<input type="hidden" name="screen_mode" value="PDF">';
				print '<input class="fonts" type="Submit" name="submit" value="PDF Report">';
				print '</form>';
			}
		echo '</div>';
	}
	//echo '<p>';
}
else {
	//initialize pdf generation
	$pdfdetails=array();
	$pdfhuw=array();
	$pdf=new PDF();
	$pers=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber='$gezin_id'",$db);
	@$persDb=mysql_fetch_object($pers);
	// *** Personen verwerken met een class ***
	$pers_cls = New persoon_cls;
	$pers_cls->construct($persDb);   
	$title=pdf_convert($language["main_ancestor_report"].$language["main_of"].$pers_cls->naam($persDb));
	$pdf->SetTitle($title);
	$pdf->SetAuthor('Huub Mons (pdf: Yossi Beck)');
	$pdf->AddPage();

	$pdf->SetFont('Arial','B',15);
	$pdf->Ln(4);
	$pdf->MultiCell(0,10,pdf_convert($language["main_ancestor_report"].$language["main_of"].$pers_cls->naam($persDb)),0,'C');
	$pdf->Ln(4);
	$pdf->SetFont('Arial','',12);
}

if ($screen_mode!='GRAFISCH' AND $screen_mode!='KWBLAD'){
	$kwartier2[] = $gezin_id;
	$kwartiernummer2[]=1;
	$huwelijksnummer2[]=0;
	$generatie = 1;

	if($screen_mode!='PDF') {
		echo '<table style="border-style:none" align="center"><tr><td></td></tr>';
	}

	$listed_array=array();

	// *** Loop gehele kwartierstaat ***
	while (isset($kwartier2[0])){
		unset($kwartier);
		$kwartier=$kwartier2;
		unset($kwartier2);

		unset($kwartiernummer);
		$kwartiernummer=$kwartiernummer2;
		unset($kwartiernummer2);

		unset($huwelijksnummer);
		$huwelijksnummer=$huwelijksnummer2;
		unset($huwelijksnummer2);

		if($screen_mode!='PDF') {
			echo '</table>';

				echo '<div class="kwartierstaat fonts">'.$language["fam_generation"].$romcyf[$generatie];
				if (isset($language["gen".$generatie]) AND $language["gen".$generatie]){
					echo ' ('.$language["gen".$generatie].')'; }
				echo '</div><br>';

			echo '<table class="humo gezin rand" align="center">';
		}
		else {
			//echo 'pdf GENERATIE<br>';
			$pdf->Cell(0,2,"",0,1);
			$pdf->SetFont('Arial','BI',14);
			$pdf->SetFillColor(200,220,255);
			if($pdf->GetY() > 260) { $pdf->AddPage(); $pdf->SetY(20); }
			if (isset($language["gen".$generatie]) AND $language["gen".$generatie]){
				$pdf->Cell(0,8,pdf_convert($language["fam_generation"].$romcyf[$generatie].' ('.$language["gen".$generatie]).')',0,1,'C',true);
			}
			else {
				$pdf->Cell(0,8,pdf_convert($language["fam_generation"]).$romcyf[$generatie],0,1,'C',true);
			}
			$pdf->SetFont('Arial','',12);
		}

		// *** Loop per generatie ***
		for ($i=0; $i<count($kwartier); $i++) {

			$listednr='';
			foreach ($listed_array as $key => $value) {
				if($value==$kwartier[$i]) {$listednr=$key;}
				// if person was already listed, $listednr gets kwartier number for reference in report:
				// instead of person's details it will say: "already listed above under number 4234"
				// and no additional ancestors will be looked for, to prevent duplicated branches
			}
			if($listednr=='') {  //if not listed yet, add person to array
				$listed_array[$kwartiernummer[$i]]=$kwartier[$i];  
			}

			if ($kwartier[$i]!='0'){
				$persoonmn=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='".veilig($kwartier[$i])."'",$db);
				@$persoonmnDb=mysql_fetch_object($persoonmn);
				$man_cls = New persoon_cls;
				$man_cls->construct($persoonmnDb);
				$levendmn=$man_cls->privacy;
				
				// for pdf function kwartiernaam() further along
				//$sexe=$persoonmnDb->pers_sexe;
				
				if (strtolower($persoonmnDb->pers_sexe)=='m' AND $kwartiernummer[$i]>1){
					$gezin=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family
						WHERE fam_gedcomnumber='".veilig($huwelijksnummer[$i])."'",$db);
					@$gezinDb=mysql_fetch_object($gezin);

					// *** Privacy filter van de vrouw mee berekenen ***
					$persoonvr=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
						WHERE pers_gedcomnumber='".veilig($gezinDb->fam_woman)."'",$db);
					@$persoonvrDb=mysql_fetch_object($persoonvr);
					$vrouw_cls = New persoon_cls;
					$vrouw_cls->construct($persoonvrDb);
					$levendvr=$vrouw_cls->privacy;

					//$gezinlevend=privacyhuwelijk($gezinDb, $levendmn, $levendvr);
					// *** Huwelijk verwerken met een class ***
					$huw_cls = New huwelijk_cls;
					$huw_cls->construct($gezinDb, $levendmn, $levendvr);
					$gezinlevend=$huw_cls->privacy;
				}
				if($screen_mode!='PDF') {
					echo '<tr><td valign="top" width="80" nowrap><b>'.$kwartiernummer[$i].
						'</b> ('.floor($kwartiernummer[$i]/2).')</td>';

					echo '<td>';
					//*** Gegevens man weergeven ***
					echo '<div class="ouder1">';
					// ***  Voorlopig opvragen als "Kind", dan komt er een link naar het eigen gezin. ***
					echo $man_cls->naam_uitgebreid("Kind");

					if ($listednr=='') {
						echo $man_cls->gegevens("Man", $kwartier[$i]);
					}
					else { // person was already listed
						echo ' <strong> ('.$language["ancestor_listed"].$listednr.') </strong>';
					}

					echo '</div>';
					echo '</td></tr>';
				}
				else {
					// pdf NUMBER + MAN NAME + DATA
					$pdf->kwartiernaam($kwartiernummer[$i],$persoonmnDb->pers_sexe,$man_cls->naam_uitgebreid("Kind"));
					if($listednr=='') {
						$pdfdetails= $man_cls->gegevens("Man",$kwartier[$i]);
						if($pdfdetails) {
							$pdf->pdfdisplay($pdfdetails,"kwartier");
						}
						elseif ($kwartiernummer[$i]>9999) {
							$pdf->Ln(8); // (number) was placed under previous number
							//  and there's no data so we have to move 1 line down for next person 
						}
					}
					else { // person was already listed
						$thisx=$pdf->GetX();
						$pdf->SetX($thisx+28);
						$pdf->Write(8,$language["ancestor_listed"].$listednr."\n");
						$pdf->SetX($thisx);
					}

					$temp=0;
					$temp=floor($kwartiernummer[$i]%2);
					if($kwartiernummer[$i]>1 AND $temp==1 AND $i+1<count($kwartier)) {
						// if we're not in first generation (one person)
						// and we are after writing the woman's details
						// and there is at least one person of another family to come in this generation
						// then place a devider line
						$pdf->Cell(0,1,"",'B',1);
						$pdf->Ln(1);
					}
				}

				// Eigen huwelijk weergeven (op nieuwe regel na weergave van de man)
				if (strtolower($persoonmnDb->pers_sexe)=='m' AND $kwartiernummer[$i]>1){
					if($screen_mode!='PDF') {
						echo '<tr><td>&nbsp;</td><td>';
						echo '<span class="huwelijk">';
					}
					// *** $gezinlevend='1' betekent filteren ***
					if ($gezinlevend){
						if($screen_mode!='PDF') {
							echo $language["fam_to"];
						}
						else {
							$pdf->SetX(37);
							$pdf->Write(6,pdf_convert($language["fam_to"])."\n");
						}

						//Ook bij privacy filter een scheiding aangeven
						if ($gezinDb->fam_div_date OR $gezinDb->fam_div_place){
							if($screen_mode!='PDF') {
								echo ' <span class="scheiding">('.trim($language["fam_divorced"]).')</span>';
							}
							else {
								$pdf->Write(6,' ('.pdf_convert(trim($language["fam_divorced"])).')');
							}
						}
						//einde relatie hier weergeven?
						//if ($gezinDb->fam_relation_end_date){
						//  echo ' <span class="scheiding">('.trim($language["fam_divorced"]).')</span>';
						//}
					}
					else{
						if($screen_mode!='PDF') {
							echo $huw_cls->huwelijk();
						}
						else {
							//show pdf MARRIAGE DATA
							$pdfhuw=$huw_cls->huwelijk();
							if($pdfhuw) {
								$pdf->displayrel($pdfhuw,"kwartier");
							}
						}
					}
					if($screen_mode!='PDF') {
						echo '</span>';
						echo '</td></tr>';
					}
				}

				// ==	ga na of er ouders zijn
				if ($persoonmnDb->pers_famc  AND $listednr==''){
					$query_gezin	= "SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family WHERE fam_gedcomnumber = '".$persoonmnDb->pers_famc."'";
					$result_gezin = mysql_query($query_gezin,$db);
					@$record_gezin = mysql_fetch_object($result_gezin);
					if ($record_gezin->fam_man){
						$kwartier2[] = $record_gezin->fam_man;
						$kwartiernummer2[]=(2*$kwartiernummer[$i]);
						$huwelijksnummer2[]=$persoonmnDb->pers_famc;
					}

					if ($record_gezin->fam_woman){
						$kwartier2[]= $record_gezin->fam_woman;
						$kwartiernummer2[]=(2*$kwartiernummer[$i]+1);
						$huwelijksnummer2[]=$persoonmnDb->pers_famc;
					}
					else{
						// *** N.N. naam ***
						$kwartier2[]= '0';
						$kwartiernummer2[]=(2*$kwartiernummer[$i]+1);
						$huwelijksnummer2[]=$persoonmnDb->pers_famc;
					}
				}

			}
			else{
				// *** N.N. persoon weergeven ***
				$persoonmn=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
					WHERE pers_gedcomnumber='".veilig($kwartier[$i])."'",$db);
				@$persoonmnDb=mysql_fetch_object($persoonmn);
				$man_cls = New persoon_cls;
				$man_cls->construct($persoonmnDb);
				$levendmn=$man_cls->privacy;

				if($screen_mode!='PDF') {
					echo '<tr><td valign="top" width="80" nowrap><b>'.$kwartiernummer[$i].
						'</b> ('.floor($kwartiernummer[$i]/2).')</td>';

					echo '<td>';
					//*** Gegevens man weergeven ***
					echo '<div class="ouder1">';
						// ***  Voorlopig opvragen als "Kind", dan komt er een link naar het eigen gezin. ***
						echo $man_cls->naam_uitgebreid("Kind");
						echo $man_cls->gegevens("Man", $kwartier[$i]);
					echo '</div>';
					echo '</td></tr>';
				}
				else {
					// pdf NUMBER + NAME + DATA  NN PERSON

					$pdf->kwartiernaam($kwartiernummer[$i],$persoonmnDb->pers_sexe,$man_cls->naam_uitgebreid("Kind"));
					$pdfdetails= $man_cls->gegevens("Man",$kwartier[$i]);
					if($pdfdetails) {
						$pdf->pdfdisplay($pdfdetails,"kwartier");
					}
					elseif ($kwartiernummer[$i]>9999) {
							$pdf->Ln(8); // (number) was placed under previous number
											//  and there's no data so we have to move 1 line down for next person 
					}
					$temp=0;
					$temp=floor($kwartiernummer[$i]%2);
					if($kwartiernummer[$i]>1 AND $temp==1 AND $i+1<count($kwartier)) {
						// if we're not in first generation (one person)
						// and we are after writing the woman's details
						// and there is at least one person of another family to come in this generation
						// then place a devider line between the families in this generation
						$pdf->Cell(0,1,"",'B',1);
						$pdf->Ln(1);
					}
				}
			}
		}	// loop per generatie
		$generatie++;
	}	// loop kwartierstaat

} // *** Einde tekst kwartierstaat
else{



	// persoon 01
	$persoon = mysql_fetch_object(mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
		WHERE `pers_gedcomnumber`='".veilig($gezin_id)."'")) ;
	$gedcomnummer[1]= $persoon->pers_gedcomnumber;
	$perspers_famc[1]=$persoon->pers_famc;
	$geslacht[1]=$persoon->pers_sexe;
	$Gouder[2]='';  $Gouder[3]='';
	if ($perspers_famc[1]){
		$ouders = mysql_fetch_object(mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family
			WHERE `fam_gedcomnumber`='".veilig($perspers_famc[1])."'"))   ;
		$Gouder[2]=$ouders->fam_man; $Gouder[3]=$ouders->fam_woman ;
		$huw[2]=$ouders->fam_marr_date ; $huwpl[2]=$ouders->fam_marr_place ;
	}
	// einde persoon 1

	// lus om persoonsgegevens op te zoeken
	for ($teller = 2; $teller < 64; $teller++){
		$gedcomnummer[$teller]= '';  $pers_lastname[$teller]= '';
		$perspers_famc[$teller]= '';
		$geslacht[$teller]= '';
		if ($Gouder[$teller]){
			$persoon = mysql_fetch_object(mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
			WHERE `pers_gedcomnumber`='".veilig($Gouder[$teller])."'")) ;
			$gedcomnummer[$teller]= $persoon->pers_gedcomnumber;
			//$pers_lastname[$teller]= $persoon->pers_lastname;
			$perspers_famc[$teller]=$persoon->pers_famc;
			$geslacht[$teller]=$persoon->pers_sexe;
		}

		$Vteller=$teller*2; $Mteller=$Vteller+1;
		$Gouder[$Vteller]=''; $Gouder[$Mteller]='';
		$huw[$Vteller]=''; $huwpl[$Vteller]='';
		if ($perspers_famc[$teller]){
			$ouders = mysql_fetch_object(mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."family
				WHERE `fam_gedcomnumber`='".veilig($perspers_famc[$teller])."'")) ;
			$Gouder[$Vteller]=$ouders->fam_man; $Gouder[$Mteller]=$ouders->fam_woman ;
			$huw[$Vteller]=$ouders->fam_marr_date ; $huwpl[$Vteller]=$ouders->fam_marr_place ;
		}
	}

	// *** Functie voor weergeven van gegevens ***
	//SOORT_VAK (groot, medium, klein)
	function kwartierstaat_persoon($id, $soort_vak){
		global $humo_option, $user, $db;
		global $huw, $huwpl;
		global $gedcomnummer;
		global $language;
		global $screen_mode, $dirmark1, $dirmark2;
		$tekst=''; $popup='';

		if ($gedcomnummer[$id]){ 
			$persoonqry = "SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber = '".veilig($gedcomnummer[$id])."'";
			$result_persoon = mysql_query($persoonqry,$db);
			@$persoon = mysql_fetch_object($result_persoon);

			$persoon_cls = New persoon_cls;
			$persoon_cls->construct($persoon);
			$levend=$persoon_cls->privacy;

			if ($user["group_pers_hide_totally_act"]=='j' AND strpos(' '.$persoon->pers_own_code,$user["group_pers_hide_totally"])>0){
				$tekst.=$language["privacy"];
			}
			else{ 
				$pers_prefix=str_replace( "_", " ", $persoon->pers_prefix );
				if ($screen_mode=="KWBLAD" OR $language["dir"]=="rtl") {
					$pers_firstname=$persoon->pers_firstname;
				}
				else {
					$pers_firstname = substr ($persoon->pers_firstname, 0, 1);
				}
				if ($pers_prefix=="") {
					$naam=$pers_firstname." ".$persoon->pers_lastname;
				} else {
					$naam=$pers_firstname." ".$pers_prefix." ".$persoon->pers_lastname;
				}
				//$naam.= $dirmark2;
				$naam=$dirmark2.$naam.$dirmark2;
				if ($persoon->pers_fams){
					$linkkind=explode(";",$persoon->pers_fams);
					// LINK BIJ NAAM
					//$naam='<a href="gezin.php?id='.$linkkind[0]."\">$naam</a> ";
				}

				echo '<div class="ltrsddm"  style="display:inline;">';

				// *** Create link for pop-up box ***
                                $idmark=rand();
				$tekst.= '<a class="nam" href="report_ancestor.php?id='.$persoon->pers_gedcomnumber.'&amp;screen_mode=GRAFISCH"';
				$tekst.= ' style="font-size:9px; text-align:center; display:block; width:100%; height:100%" ';
				//$tekst.= 'onmouseover="mopen(event,\'m1'.$persoon->pers_id.'\')"';
				$tekst.= 'onmouseover="mopen(event,\'m1'.$idmark.$persoon->pers_id.'\',0,0)"';
				$tekst.= 'onmouseout="mclosetime()">';

				// *** Start POP-UP box ***
				$popup.='<div class="sddm_fixed" style="z-index:40;" id="m1'.$idmark.$persoon->pers_id.'" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';

				// *** Show picture in pop-up box ***
				if (!$levend AND $user["afbeeldingen"]=='j' AND $soort_vak=='groot'){
					//  *** pad nu per stamboom aan te geven ***
					global $dataDb;
					$PAD=$dataDb->tree_pict_path;
					$afbqry=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."events
						WHERE event_person_id='$persoon->pers_gedcomnumber' AND event_kind='afbeelding'",$db);
					$afbDb=mysql_fetch_object($afbqry);
					if (isset($afbDb->event_event)){
						if (file_exists($PAD.'thumb_'.strtolower($afbDb->event_event))){
							$popup.='<img src="'.$PAD.'thumb_'.strtolower($afbDb->event_event).'" style="margin-left:50px; margin-top:5px;" alt="'.$afbDb->event_text.'">';
						}
						else {
							$popup.='<img src="'.$PAD.strtolower($afbDb->event_event).'" style="margin-left:50px; margin-top:5px; alt="'.$afbDb->event_text.'">';						
						}
					}
				}

				$popup.= '<a href="gezin.php?id='.$persoon->pers_indexnr.'&amp;hoofdpersoon='.$persoon->pers_gedcomnumber.'">'.'<strong>'.$persoon_cls->naam($persoon).'</strong></a>';

				if ($screen_mode=="KWBLAD") {  // *** Kwartierblad: name bold, id not ***
					$tekst.=$id.' <b>'.$naam.'</b>';
				}
				else {
					$tekst.='<b>'.$id.'</b>';  // *** Kwartiernummer: id bold, name not ***
					$tekst.=$dirmark2.' '.$naam;
				}
			}

			// >>>>> link om de rest van de kwartierstaat weer te geven
			if ($soort_vak=='klein' AND isset($persoon->pers_gedcomnumber) AND $screen_mode!="KWBLAD"){
				//$tekst.= ' <a href="'.$_SERVER['PHP_SELF'].'?id='.$persoon->pers_gedcomnumber.
				//	"&amp;screen_mode=GRAFISCH\">&gt;&gt;&gt;&gt;&#x200E;</a> ";
				$tekst.=' &gt;&gt;&gt;&gt;'.$dirmark1;
			}

			if ($levend){
				$tekst.='<br>'.$language["privacy"];  //Tekst privacy weergeven
			}
			else{
				if ($soort_vak!='klein'){
					if ($persoon->pers_birth_date OR $persoon->pers_birth_place){
						$tekst.='<br>'.$language["lng_birth_short"].$dirmark1.' '.datumplaats($persoon->pers_birth_date,$persoon->pers_birth_place); }

					if ($persoon->pers_death_date OR $persoon->pers_death_place){
						$tekst.='<br>'.$language["lng_death_short"].$dirmark1.' '.
						datumplaats($persoon->pers_death_date,$persoon->pers_death_place); }

					if ($soort_vak!='medium'){
						$huwdatum=''; if (isset($huw[$id]) AND ($huw[$id]!='')){ $huwdatum=$huw[$id]; }
						$huwplaats=''; if (isset($huwpl[$id]) AND ($huwpl[$id]!='')){
						$huwplaats=$huwpl[$id]; }
						if ($huwdatum OR $huwplaats){
							$tekst.='<br>'.$language["fam_marriage_short"].$dirmark1.' '.datumplaats($huwdatum,$huwplaats); }
					}
					if ($soort_vak=='kwbladhuw'){
						$tekst='';
						$huwdatum=''; if (isset($huw[$id]) AND ($huw[$id]!='')){ $huwdatum=$huw[$id]; }
						$huwplaats=''; if (isset($huwpl[$id]) AND ($huwpl[$id]!='')){
							$huwplaats=$huwpl[$id]; }
						if ($huwdatum OR $huwplaats){
							$tekst=$language["fam_marriage_short"].$dirmark1.' '.datumplaats($huwdatum,$huwplaats); }
							else $tekst=$language["fam_marriage_short"]; // if no details in the row we don't want the row to collapse         
					}
					if ($soort_vak=='kwheader'){
						$tekst='';
						$tekst.=strip_tags($naam);
						$tekst.= $dirmark2;
					}
				}

				// *** Pop-up tekst ***
				if ($persoon->pers_birth_date OR $persoon->pers_birth_place){
					$popup.=$language["lng_birth_short"].$dirmark1.' '.datumplaats($persoon->pers_birth_date,$persoon->pers_birth_place);
				}
				if ($persoon->pers_death_date OR $persoon->pers_death_place){
					$popup.='<br>'.$language["lng_death_short"].$dirmark1.' '.
					datumplaats($persoon->pers_death_date,$persoon->pers_death_place);
				}
				$huwdatum=''; if (isset($huw[$id]) AND ($huw[$id]!='')){ $huwdatum=$huw[$id]; }
				$huwplaats=''; if (isset($huwpl[$id]) AND ($huwpl[$id]!='')){ $huwplaats=$huwpl[$id]; }
				if ($huwdatum OR $huwplaats){
					$popup.='<br>'.$language["fam_marriage_short"].$dirmark1.' '.datumplaats($huwdatum,$huwplaats);
				}

			}
                        if ($soort_vak!='kwbladhuw' AND $soort_vak!='kwheader' ){ // cause in that case there is no link
			        $tekst.= '</a>'; // *** End of pop-up link ***
                        }
			if ($popup){
				$tekst.=$popup.'</div>';
			}	
			$tekst.="</div>";

		}

		return $tekst."\n";
	}
	// *** Einde functie kwartierstaat_persoon ***	

	if($screen_mode!="KWBLAD") {
	// *** Eerste kolom naam ***
	$links=10;
	$geslacht_kleur='';
	if ($geslacht[1] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
	if ($geslacht[1] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
	echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: 530px; left: '.$links.'px; height: 80px; width:180px;';
	echo '">';
	echo kwartierstaat_persoon('1', 'groot');
	echo '</div>';

	$links=80;
	$top=330;
	// *** Tweede kolom split ***
	echo '<div class="kwartierst_split" style="top: '.$top.'px; left: '.$links.'px; height: 199px"></div>';
	echo '<div class="kwartierst_split" style="top: '.($top+281).'px; left: '.$links.'px; height: 199px"></div>';
	// *** Tweede kolom namen ***
	for ($i=1; $i<3; $i++){
		$geslacht_kleur='';
		if ($geslacht[$i+1] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
		if ($geslacht[$i+1] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
		echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: '.(($top-530)+($i*480)).'px; left: '.($links+20).'px; height: 80px; width:180px;';
		echo '">';
		echo kwartierstaat_persoon($i+1, 'groot');
		echo '</div>';
	}

	$links=140;
	$top=199;
	// *** Derde kolom split ***
	echo '<div class="kwartierst_split" style="top: '.$top.'px; left: '.($links+20).'px; height: 80px;"></div>';
	echo '<div class="kwartierst_split" style="top: '.($top+162).'px; left: '.($links+20).'px; height: 80px;"></div>';
	echo '<div class="kwartierst_split" style="top: '.($top+480).'px; left: '.($links+20).'px; height: 80px;"></div>';
	echo '<div class="kwartierst_split" style="top: '.($top+642).'px; left: '.($links+20).'px; height: 80px;"></div>';
	// *** Derde kolom namen ***
	for ($i=1; $i<5; $i++){
		$geslacht_kleur='';
		if ($geslacht[$i+3] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
		if ($geslacht[$i+3] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
		echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: '.(($top-279)+($i*240)).'px; left: '.($links+40).'px; height: 80px; width:180px;';
		echo '">';
		echo kwartierstaat_persoon($i+3, 'groot');
		echo '</div>';
	}

	$links=360;
	$top=-290;
	// *** Vierde kolom lijn ***
	for ($i=1; $i<3; $i++){
		echo '<div class="kwartierst_lijn" style="top: '.($top+($i*480)).'px; left: '.($links+1).'px; height: 240px;"></div>';
	}
	// *** Vierde kolom split ***
	for ($i=1; $i<5; $i++){
		echo '<div class="kwartierst_split" style="top: '.(($top+185)+($i*240)).'px; left: '.($links+20).'px; height: 120px;"></div>';
	}
	// *** Vierde kolom namen ***
	for ($i=1; $i<9; $i++){
		$geslacht_kleur='';
		if ($geslacht[$i+7] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
		if ($geslacht[$i+7] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
		echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: '.(($top+265)+($i*120)).'px; left: '.($links+40).'px; height: 80px; width:180px;';
		echo '">';
		echo kwartierstaat_persoon($i+7, 'groot');
		echo '</div>';
	}

	$links=580;
	$top=-110;
	// *** Vijfde kolom lijn ***
	for ($i=1; $i<5; $i++){
		echo '<div class="kwartierst_lijn" style="top: '.($top+($i*240)).'px; left: '.($links+1).'px; height: 120px;"></div>';
	}
	// *** Vijfde kolom split ***
	for ($i=1; $i<9; $i++){
		echo '<div class="kwartierst_split" style="top: '.(($top+90)+($i*120)).'px; left: '.($links+20).'px; height: 60px;"></div>';
	}
	// *** Vijfde kolom namen ***
	for ($i=1; $i<17; $i++){
		$geslacht_kleur='';
		if ($geslacht[$i+15] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
		if ($geslacht[$i+15] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
		echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: '.(($top+130)+($i*60)).'px; left: '.($links+40).'px; height: 50px; width:160px;';
		echo '">';
		echo kwartierstaat_persoon($i+15, 'medium');
		echo '</div>';
	}

	$links=780;
	$top=-15;
	// *** Laatste kolom lijn ***
	for ($i=1; $i<9; $i++){
		echo '<div class="kwartierst_lijn" style="top: '.($top+($i*120)).'px; left: '.($links+1).'px; height: 60px;"></div>';
	}
	// *** Laatste kolom split ***
	for ($i=1; $i<17; $i++){
		echo '<div class="kwartierst_split" style="top: '.(($top+45)+($i*60)).'px; left: '.($links+20).'px; height: 30px;"></div>';
	}
	// *** Laatste kolom namen ***
	for ($i=1; $i<33; $i++){
		$geslacht_kleur='';
		if ($geslacht[$i+31] == 'F'){ $geslacht_kleur=' kwartierst_woman'; }
		if ($geslacht[$i+31] == 'M'){ $geslacht_kleur=' kwartierst_man'; }
		echo '<div class="kwartierst_naam'.$geslacht_kleur.'" style="top: '.(($top+65)+($i*30)).'px; left: '.($links+40).'px; height:16px; width:160px;';
		echo '">';
		echo kwartierstaat_persoon($i+31, 'klein');
		echo '</div>';
	}
	
	}   // end "if not KWBLAD"
	
	if($screen_mode=="KWBLAD") {
		// print names and details for each row in the table
		function kwname($start,$end,$increment,$fontclass,$colspan,$type) {
			print '<tr>';
			for($x=$start;$x<$end;$x+=$increment) {
				if($colspan>1) {
					print '<td class="'.$fontclass.'" colspan='.$colspan.'>';
				}
				else{
					print '<td class="'.$fontclass.'">';
				}
                                $kwpers=kwartierstaat_persoon($x,$type);
				if($kwpers!='') {
					print $kwpers;
				}
				else {   // if we don't do this IE7 wil not print borders of cells
					print '&nbsp;';
				}
				print '</td>';
			}
			print '</tr>';
		}
		// check if there is anyone in a generation so no empty and collapsed rows will be shown
		function check_gen($start,$end) {
			global $gedcomnummer;
			$is_gen=0;
			for($i=$start;$i<$end;$i++) {
				if(isset($gedcomnummer[$i]) AND $gedcomnummer[$i]!='') {
					$is_gen=1;
				}
			}
			return $is_gen;
		}

		print '<table class="humo kwblad">';
		print '<tr><th class="kwhead" colspan=8>';  // adjusted for IE7
		print $language["kwartierblad"].$language["main_of"].kwartierstaat_persoon(1,"kwheader");  
		print '</th></tr>';

		$gen=0; $gen=check_gen(16,32); if($gen==1) {
			kwname(16,32,2,"kw-small",1,"medium");
			kwname(16,32,2,"kw-small",1,"kwbladhuw");
			kwname(17,33,2,"kw-small",1,"medium");
			print '<tr><td colspan=8 class="kwdevider">&nbsp;</td></tr>';  // adjusted for IE7
		}
		$gen=0; $gen=check_gen(8,16); if($gen==1) {
			kwname(8,16,1,"kw-small",1,"medium");
			kwname(8,16,2,"kw-small",2,"kwbladhuw");
		}
		$gen=0; $gen=check_gen(4,8); if($gen==1) {
			kwname(4,8,1,"kw-medium",2,"medium");
			kwname(4,8,2,"kw-small",4,"kwbladhuw");
		}
		kwname(2,4,1,"kw-bigger",4,"medium");
		kwname(2,4,2,"kw-small",8,"kwbladhuw");
		kwname(1,2,1,"kw-big",8,"medium");	
		print '</table>';
		print '<br><p class="kwlegend">';
		print '<b>Legend</b><br>';
		print $language["lng_birth_short"].'  '.$language["pers_born"].', '.$language["lng_death_short"].'  '.$language["pers_died"].', '.$language["fam_marriage_short"].'  '.$language["fam_marriage"];
		if(function_exists('date_default_timezone_set')){
			date_default_timezone_set('Europe/Amsterdam');
		}		
		print '<br>Generated with HuMo-gen (PHP) on '.date("d M Y - H:i");
		print '</p>';
	}
}

// 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!="PDF") {
	if($screen_mode!="KWBLAD" AND $screen_mode!="GRAFISCH") {echo '</table>';} 
	include("footer.php");
}
else {
	$pdf->Output($title.".pdf","I");
}
?>
Return current item: HuMo-gen