function popup($text, $show_data = true)
{
    global $dbh, $tree_id, $lang, $number, $c, $tree_prefix_quoted;
    $person = $text;
    $text = '';
    include_once "../include/person_cls.php";
    include_once "../include/marriage_cls.php";
    //$person_man=$dbh->query("SELECT * FROM ".safe_text($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber='".safe_text($person)."'");
    $person_man = $dbh->query("SELECT * FROM humo_persons\n\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . safe_text($person) . "'");
    @($person_manDb = $person_man->fetch(PDO::FETCH_OBJ));
    //*** Use class to show person ***
    $man_cls = new person_cls();
    $man_cls->construct($person_manDb);
    $man_privacy = $man_cls->privacy;
    $name = $man_cls->person_name($person_manDb);
    if ($person_manDb->pers_sexe == "M") {
        $text .= '<li><img src="../images/man.gif" class="ui-li-icon">';
    } elseif ($person_manDb->pers_sexe == "F") {
        $text .= '<li><img src="../images/woman.gif" class="ui-li-icon">';
    } else {
        $text .= '<li><img src="../images/unknown.gif" class="ui-li-icon">';
    }
    $number_text = '';
    if ($number == 1) {
        $number_text = $c + 1 . ' ';
    }
    $text .= '<p>' . $number_text . '<a href="family.php?id=' . $person_manDb->pers_gedcomnumber . '">' . $name["index_name"] . '</a><br>';
    if ($show_data == true) {
        if ($man_privacy) {
            $text .= __(' PRIVACY FILTER');
        } else {
            // no privacy set
            if ($person_manDb->pers_birth_date or $person_manDb->pers_birth_place) {
                $text .= ucfirst(__('*')) . ' ' . date_place($person_manDb->pers_birth_date, $person_manDb->pers_birth_place) . '<br>';
            } elseif ($person_manDb->pers_bapt_date or $person_manDb->pers_bapt_place) {
                $text .= ucfirst(__('~')) . ' ' . date_place($person_manDb->pers_bapt_date, $person_manDb->pers_bapt_place) . '<br>';
            }
            if ($person_manDb->pers_death_date or $person_manDb->pers_death_place) {
                $text .= ucfirst(__('&#134;')) . ' ' . date_place($person_manDb->pers_death_date, $person_manDb->pers_death_place) . '<br>';
            } elseif ($person_manDb->pers_buried_date or $person_manDb->pers_buried_place) {
                if ($person_manDb->pers_cremation) {
                    $var .= ucfirst(__('crem.')) . ' ';
                } else {
                    $var .= ucfirst(__('buried')) . ' ';
                }
                $var .= date_place($person_manDb->pers_buried_date, $person_manDb->pers_buried_place) . '<br>';
            } else {
                $text .= '</p></li>';
            }
        }
    }
    return $text;
}
Exemple #2
0
function witness($gedcomnr, $event, $field = 'person')
{
    global $dbh, $db_functions;
    $counter = 0;
    $text = '';
    if ($gedcomnr) {
        $witness_cls = new person_cls();
        if ($field == 'person') {
            $witness_qry = $db_functions->get_events_person($gedcomnr, $event);
        } else {
            $witness_qry = $db_functions->get_events_family($gedcomnr, $event);
        }
        foreach ($witness_qry as $witnessDb) {
            $counter++;
            if ($counter > 1) {
                $text .= ', ';
            }
            if ($witnessDb->event_event) {
                if (substr($witnessDb->event_event, 0, 1) == '@') {
                    // *** Connected witness ***
                    $witness_nameDb = $db_functions->get_person(substr($witnessDb->event_event, 1, -1));
                    $name = $witness_cls->person_name($witness_nameDb);
                    $text .= '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $witness_nameDb->pers_indexnr . '&amp;main_person=' . $witness_nameDb->pers_gedcomnumber . '">' . rtrim($name["standard_name"]) . '</a>';
                } else {
                    // *** Witness as text ***
                    $text .= $witnessDb->event_event;
                }
            }
            if ($witnessDb->event_date) {
                $text .= ' ' . date_place($witnessDb->event_date, '');
            }
            // *** Use date_place function, there is no place here... ***
            $source = show_sources2($field, "pers_event_source", $witnessDb->event_id);
            if ($source) {
                $text .= $source;
            }
        }
    }
    return $text;
}
function printchart()
{
    global $dbh, $tree_id, $db_functions, $genarray, $size, $tree_prefix_quoted, $language, $chosengen, $keepfamily_id, $keepmain_person, $uri_path, $database;
    global $vbasesize, $hsize, $vsize, $vdist, $hdist, $user, $direction, $dna;
    global $dirmark1, $dirmark2, $rtlmarker, $alignmarker, $base_person_gednr, $base_person_name, $base_person_sexe, $base_person_famc;
    // YB: -- check browser type & version. we need this further on to detect IE7 with it's widely reported z-index bug
    $browser_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
    global $hourglass, $divlen, $divhi;
    if ($hourglass === false) {
        // find rightmost and bottommost positions to calculate size of the canvas needed for png image
        $divlen = 0;
        $divhi = 0;
        for ($i = 0; $i < count($genarray); $i++) {
            if ($genarray[$i]["x"] > $divlen) {
                $divlen = $genarray[$i]["x"];
            }
            if ($genarray[$i]["y"] > $divhi) {
                $divhi = $genarray[$i]["y"];
            }
        }
        $divlen += 200;
        $divhi += 300;
        // the width and length of following div are set with $divlen en $divhi in java function "showimg"
        // (at bottom of this file) otherwise double scrollbars won't work.
        echo '<div id="png">';
        //======== HELP POPUP ========================
        echo '<div id="helppopup" class="' . $rtlmarker . 'sddm" style="position:absolute;left:10px;top:10px;display:inline;">';
        echo '<a href="#"';
        echo ' style="display:inline" ';
        echo 'onmouseover="mopen(event,\'help_menu\',0,0)"';
        echo 'onmouseout="mclosetime()">';
        echo '<b>' . __('Help') . '</b>';
        echo '</a>&nbsp;';
        //echo '<div style="z-index:40; padding:4px; direction:'.$rtlmarker.'" id="help_menu" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';
        echo '<div class="sddm_fixed" style="z-index:10; padding:4px; text-align:' . $alignmarker . ';  direction:' . $rtlmarker . ';" id="help_menu" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';
        echo __('<b>USE:</b>
<p><b>Hover over square:</b> Display popup menu with details and report & chart options<br>
<b>Click on square:</b> Move this person to the center of the chart<br>
<b>Click on spouse\'s name in popup menu:</b> Go to spouse\'s family page<br><br>
<b>LEGEND:</b>');
        echo '<p><span style="background-image: linear-gradient(to bottom, #ffffff 0%, #81bef7 100%); border:1px brown solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' . __('Male') . '</br>';
        echo '<span style="background-image: linear-gradient(to bottom, #ffffff 0%, #f5bca9 100%); border:1px brown solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' . __('Female') . '</br>';
        if ($dna == "ydna" or $dna == "ydnamark" or $dna == "mtdna" or $dna == "mtdnamark") {
            echo '<p style="line-height:3px"><span style="background-image: linear-gradient(to bottom, #ffffff 0%, #81bef7 100%); border:3px solid #999999;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' . __('Male Y-DNA or mtDNA carrier (Base person has red border)') . '</p>';
            echo '<p style="line-height:10px"><span style="background-image: linear-gradient(to bottom, #ffffff 0%, #f5bca9 100%); border:3px solid #999999;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' . __('Female MtDNA carrier (Base person has red border)') . '</p>';
        }
        echo '<p><span style="color:blue">=====</span>&nbsp;' . __('Additional marriage of same person') . '<br><br>';
        echo __('<b>SETTINGS:</b>
<p>Horizontal/Vertical button: toggle direction of the chart from top-down to left-right<br>
<b>Nr. Generations:</b> choose between 2 - 15 generations<br>
(large number of generations will take longer to generate)<br>
<b>Box size:</b> Use the slider to choose display size (9 steps): <br>
step 1-3: small boxes with popup for details<br>
step 4-7: larger boxes with initials of name + popup for details<br>
step 8:   rectangles with name inside + popup with further details<br>
step 9:   large rectangles with name, birth and death details + popup with further details');
        echo '</div>';
        echo '</div>';
        //=================================
        if ($dna == "none") {
            echo '<div class="standard_header fonts" style="align:center; text-align: center;"><b>' . __('Descendant chart') . __(' of ') . $genarray[0]["nam"] . '</b>';
        } elseif ($dna == "ydna" or $dna == "ydnamark") {
            echo '<div class="standard_header fonts" style="align:center; text-align: center;"><b>' . __('Same Y-DNA as ') . $base_person_name . '</b>';
        } elseif ($dna == "mtdna" or $dna == "mtdnamark") {
            echo '<div class="standard_header fonts" style="align:center; text-align: center;"><b>' . __('Same mtDNA as ') . $base_person_name . '</b>';
        }
        echo '<br><input type="button" id="imgbutton" value="' . __('Get image of chart for printing (allow popup!)') . '" onClick="showimg();">';
        echo '</div>';
        if ($direction == 0) {
            $latter = count($genarray) - 1;
            $the_height = $genarray[$latter]["y"] + 130;
        } else {
            $hgt = 0;
            for ($e = 0; $e < count($genarray); $e++) {
                if ($genarray[$e]["y"] > $hgt) {
                    $hgt = $genarray[$e]["y"];
                }
            }
            $the_height = $hgt + 130;
        }
        echo '<style type="text/css">';
        echo '#doublescroll { position:relative; width:auto; height:' . $the_height . 'px; overflow: auto; overflow-y: hidden;z-index:10; }';
        echo '</style>';
        //print '<div class="wrapper" style="position:relative; direction:'.$rtlmarker.';">';
        //print '<div id="doublescroll" class="wrapper" style="direction:'.$rtlmarker.';"><br style="line-height:50%">';
        print '<div id="doublescroll" class="wrapper" style="direction:' . $rtlmarker . ';">';
        // generation and size choice box:
        if ($dna == "none") {
            $boxwidth = "520";
        } else {
            $boxwidth = "730";
        }
        // DNA charts
        echo '<div id="menubox" class="search_bar" style="margin-top:5px; direction:ltr; z-index:20; width:' . $boxwidth . 'px; text-align:left;">';
        print '<div style="display:inline;">';
        if (CMS_SPECIFIC == 'Joomla') {
            print '<form method="POST" name="desc_form" action="index.php?option=com_humo-gen&task=family&chosensize=' . $size . '&amp;screen_mode=STARSIZE" style="display : inline;">';
        } else {
            print '<form method="POST" name="desc_form" action="' . CMS_ROOTPATH . 'family.php?chosensize=' . $size . '&amp;screen_mode=STARSIZE" style="display : inline;">';
        }
        print '<input type="hidden" name="id" value="' . $keepfamily_id . '">';
        print '<input type="hidden" name="chosengen" value="' . $chosengen . '">';
        print '<input type="hidden" name="main_person" value="' . $keepmain_person . '">';
        print '<input type="hidden" name="database" value="' . $database . '">';
        if ($dna != "none") {
            print '<input type="hidden" name="dnachart" value="' . $dna . '">';
            print '<input type="hidden" name="bf" value="' . $base_person_famc . '">';
            print '<input type="hidden" name="bs" value="' . $base_person_sexe . '">';
            print '<input type="hidden" name="bn" value="' . $base_person_name . '">';
            print '<input type="hidden" name="bg" value="' . $base_person_gednr . '">';
        }
        print '<input id="dirval" type="hidden" name="direction" value="">';
        // will be filled in next lines
        if ($direction == "1") {
            // horizontal
            print '<input type="button" name="dummy" value="' . __('vertical') . '" onClick=\'document.desc_form.direction.value="0";document.desc_form.submit();\'>';
        } else {
            print '<input type="button" name="dummy" value="' . __('horizontal') . '" onClick=\'document.desc_form.direction.value="1";document.desc_form.submit();\'>';
        }
        print '</form>';
        $result = $dbh->query("SELECT pers_sexe FROM humo_persons\n\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber ='" . $keepmain_person . "'");
        $resultDb = $result->fetch(PDO::FETCH_OBJ);
        if ($dna != "none") {
            echo "&nbsp;&nbsp;" . __('DNA: ');
            echo '<select name="dnachart" style="width:150px" onChange="window.location=this.value">';
            //		echo $selected="selected"; if($dna!="none") $selected="";
            //		echo '<option value="'.$uri_path.'family.php?id='.$keepfamily_id.'&amp;main_person='.
            //				$keepmain_person.'&amp;direction='.$direction.'&amp;database='.$database.'&amp;dnachart='."none".'&amp;chosensize='.
            //				$size.'&amp;chosengen='.$chosengen.'&amp;screen_mode=STAR" '.$selected.'>'.__('All').'</option>';
            if ($base_person_sexe == "M") {
                // only show Y-DNA option if base person is male
                //echo $selected=""; if($dna=="ydna") $selected="selected";
                echo $selected = "selected";
                if ($dna != "ydna") {
                    $selected = "";
                }
                echo '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . "ydna" . '&amp;chosensize=' . $size . '&amp;chosengen=' . $chosengen . '&amp;screen_mode=STAR" ' . $selected . '>' . __('Y-DNA Carriers only') . '</option>';
                //echo $selected="selected"; if($dna!="ydnamark") $selected="";
                echo $selected = "";
                if ($dna == "ydnamark") {
                    $selected = "selected";
                }
                echo '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . "ydnamark" . '&amp;chosensize=' . $size . '&amp;chosengen=' . $chosengen . '&amp;screen_mode=STAR" ' . $selected . '>' . __('Y-DNA Mark carriers') . '</option>';
            }
            if ($base_person_sexe == "F" or $base_person_sexe == "M" and isset($base_person_famc) and $base_person_famc != "") {
                // if base person is male, only show mtDNA if there are ancestors since he can't have mtDNA descendants...
                echo $selected = "";
                if ($dna == "mtdna") {
                    $selected = "selected";
                }
                echo '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . "mtdna" . '&amp;chosensize=' . $size . '&amp;chosengen=' . $chosengen . '&amp;screen_mode=STAR" ' . $selected . '>' . __('mtDNA Carriers only') . '</option>';
                if ($base_person_sexe == "F") {
                    echo $selected = "selected";
                    if ($dna != "mtdnamark") {
                        $selected = "";
                    }
                } else {
                    echo $selected = "";
                    if ($dna == "mtdnamark") {
                        $selected = "selected";
                    }
                }
                echo '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . "mtdnamark" . '&amp;chosensize=' . $size . '&amp;chosengen=' . $chosengen . '&amp;screen_mode=STAR" ' . $selected . '>' . __('mtDNA Mark carriers') . '</option>';
            }
            echo '</select>';
        }
        print '</div>';
        print '&nbsp;&nbsp;';
        print '&nbsp;' . __('Nr. generations') . ': ';
        print '<select name="chosengen" onChange="window.location=this.value">';
        for ($i = 2; $i <= 15; $i++) {
            if (CMS_SPECIFIC == 'Joomla') {
                print '<option value="index.php?option=com_humo-gen&task=family&id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . $dna . '&amp;chosensize=' . $size . '&amp;chosengen=' . $i . '&amp;screen_mode=STAR" ';
            } else {
                print '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . $dna . '&amp;chosensize=' . $size . '&amp;chosengen=' . $i . '&amp;screen_mode=STAR" ';
            }
            if ($i == $chosengen) {
                print "selected=\"selected\" ";
            }
            print ">" . $i . "</option>";
        }
        //NEW - option "All" for all generations
        print '<option value="' . $uri_path . 'family.php?id=' . $keepfamily_id . '&amp;main_person=' . $keepmain_person . '&amp;direction=' . $direction . '&amp;database=' . $database . '&amp;dnachart=' . $dna . '&amp;chosensize=' . $size . '&amp;chosengen=All&amp;screen_mode=STAR" ';
        if ($chosengen == "All") {
            print "selected=\"selected\" ";
        }
        print ">" . "All" . "</option>";
        print '</select>';
        print '&nbsp;&nbsp;';
        $dna_params = "";
        if ($dna != "none") {
            $dna_params = '
					bn: "' . $base_person_name . '",
					bs: "' . $base_person_sexe . '",
					bf: "' . $base_person_famc . '",
					bg: "' . $base_person_gednr . '",';
        }
        //NEW min:0 (for extra first step - now 10 steps: 0-9), then twice value +1 so on display first step is shown as 1, not 0
        echo ' 
			<script>
			$(function() {
				$( "#slider" ).slider({
					value: ' . ($size / 5 - 1) . ',
					min: 0,
					max: 9,
					step: 1,
					database: "' . $database . '",
					main_person: "' . $keepmain_person . '",
					id: "' . $keepfamily_id . '",
					chosengen: "' . $chosengen . '",
					direction: "' . $direction . '",
					dna: "' . $dna . '",' . $dna_params . '
					slide: function( event, ui ) {
						$( "#amount" ).val(ui.value+1);
					}
				});
				$( "#amount" ).val($( "#slider" ).slider( "value" )+1 );
			});
			</script>
		';
        //echo '<label for="amount">Zoom in/out:</label>';
        echo '<label for="amount">' . __('Zoom level:') . '</label> ';
        echo '<input type="text" id="amount" disabled="disabled" style="width:15px;border:0; color:#0000CC; font-weight:normal;font-size:115%;" />';
        echo '<div id="slider" style="float:right;width:135px;margin-top:7px;margin-right:15px;"></div>';
        echo '</div>';
    }
    // end if not hourglass
    for ($w = 0; $w < count($genarray); $w++) {
        $xvalue = $genarray[$w]["x"];
        $yvalue = $genarray[$w]["y"];
        var_dump($w, $genarray[$w]["x"]);
        $sexe_colour = '';
        $backgr_col = "#FFFFFF";
        if ($genarray[$w]["sex"] == "v") {
            $sexe_colour = ' ancestor_woman';
            $backgr_col = "#FBDEC0";
            //"#f8bdf1";
        } else {
            $sexe_colour = ' ancestor_man';
            $backgr_col = "#C0F9FC";
            //"#bbf0ff";
        }
        // *** Start person class and calculate privacy ***
        if ($genarray[$w]["gednr"]) {
            $man = $db_functions->get_person($genarray[$w]["gednr"]);
            $man_cls = new person_cls();
            $man_cls->construct($man);
            $man_privacy = $man_cls->privacy;
        }
        //echo '<div style="position:absolute; background-color:'.$bkcolor.';height:'.$vsize.'px; width:'.$hsize.'px; border:1px brown solid; left:'.$xvalue.'px; top:'.$yvalue.'px">';
        $bkgr = "";
        if (($dna == "ydnamark" or $dna == "mtdnamark" or $dna == "ydna" or $dna == "mtdna") and $genarray[$w]["dna"] == 1) {
            $bkgr = "border:3px solid #999999;background-color:" . $backgr_col . ";";
            if ($genarray[$w]["gednr"] == $base_person_gednr) {
                // base person
                $bkgr = "border:3px solid red;background-color:" . $backgr_col . ";";
            }
        } else {
            $bkgr = "border:1px solid #8C8C8C;background-color:" . $backgr_col . ";";
        }
        if ($genarray[$w]["gen"] == 0 and $hourglass === true) {
            $bkgr = "background-color:" . $backgr_col . ";";
        }
        echo '<div class="ancestor_name' . $sexe_colour . '" style="' . $bkgr . 'position:absolute; height:' . $vsize . 'px; width:' . $hsize . 'px; left:' . $xvalue . 'px; top:' . $yvalue . 'px;">';
        $replacement_text = '';
        if ($size >= 25) {
            /*
            if(CMS_SPECIFIC=='Joomla') {
            	$replacement_text.= '<a class="nam" href="index.php?option=com_humo-gen&task=family&id='.$genarray[$w]["fams"].'&amp;main_person='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
            }
            else {
            	$replacement_text.= '<a class="nam" href="'.CMS_ROOTPATH.'family.php?id='.$genarray[$w]["fams"].'&amp;main_person='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
            }
            
            $replacement_text.= ' style="font-size:9px; text-align:center; display:block; width:100%; height:100%" ';
            $replacement_text.= 'onmouseover="mopen(event,\'m1'.$w.'\',0,0)"';
            $replacement_text.= 'onmouseout="mclosetime()">';
            */
            if (strpos($browser_user_agent, "msie 7.0") === false) {
                if ($size == 50) {
                    // *** Show picture ***
                    if (!$man_privacy and $user['group_pictures'] == 'j') {
                        //  *** Path can be changed per family tree ***
                        global $dataDb;
                        $tree_pict_path = $dataDb->tree_pict_path;
                        $picture_qry = $db_functions->get_events_person($man->pers_gedcomnumber, 'picture');
                        // *** Only show 1st picture ***
                        if (isset($picture_qry[0])) {
                            $pictureDb = $picture_qry[0];
                            $picture = show_picture($tree_pict_path, $pictureDb->event_event, 60, 65);
                            //$replacement_text.='<img src="'.$tree_pict_path.$picture['thumb'].$picture['picture'].'" style="float:left; margin:5px;" alt="'.$pictureDb->event_text.'" height="65px">';
                            $replacement_text .= '<img src="' . $tree_pict_path . $picture['thumb'] . $picture['picture'] . '" style="float:left; margin:5px;" alt="' . $pictureDb->event_text . '" width="' . $picture['width'] . '"';
                            //if (isset($picture['height'])) $replacement_text.=' height="'.$picture['height'].'"';
                            $replacement_text .= '>';
                        }
                    }
                    //$replacement_text.= '<strong>'.$genarray[$w]["nam"].'</strong>';
                    //$replacement_text.= '<span class="anc_box_name">'.$genarray[$w]["nam"].'</span>';
                    $replacement_text .= '<span class="anc_box_name">' . $genarray[$w]["nam"] . '</span>';
                    if ($man_privacy) {
                        $replacement_text .= '<br>' . __(' PRIVACY FILTER') . '<br>';
                        //Tekst privacy weergeven
                    } else {
                        //if ($man->pers_birth_date OR $man->pers_birth_place){
                        if ($man->pers_birth_date) {
                            //$replacement_text.= '<br>'.__('*').$dirmark1.' '.date_place($man->pers_birth_date,$man->pers_birth_place);
                            $replacement_text .= '<br>' . __('*') . $dirmark1 . ' ' . date_place($man->pers_birth_date, '');
                        } elseif ($man->pers_bapt_date) {
                            //$replacement_text.= '<br>'.__('~').$dirmark1.' '.date_place($man->pers_bapt_date,$man->pers_bapt_place);
                            $replacement_text .= '<br>' . __('~') . $dirmark1 . ' ' . date_place($man->pers_bapt_date, '');
                        }
                        //if ($man->pers_death_date OR $man->pers_death_place){
                        if ($man->pers_death_date) {
                            //$replacement_text.= '<br>'.__('&#134;').$dirmark1.' '.date_place($man->pers_death_date,$man->pers_death_place);
                            $replacement_text .= '<br>' . __('&#134;') . $dirmark1 . ' ' . date_place($man->pers_death_date, '');
                        } elseif ($man->pers_buried_date) {
                            //$replacement_text.= '<br>'.__('[]').$dirmark1.' '.date_place($man->pers_buried_date,$man->pers_buried_place);
                            $replacement_text .= '<br>' . __('[]') . $dirmark1 . ' ' . date_place($man->pers_buried_date, '');
                        }
                        if ($genarray[$w]["non"] == 0) {
                            // otherwise for an unmarried child it would give the parents' marriage!
                            $ownfam = $db_functions->get_family($genarray[$w]["fams"]);
                            //if ($ownfam->fam_marr_date OR $ownfam->fam_marr_place){
                            if ($ownfam->fam_marr_date) {
                                //$replacement_text.= '<br>'.__('X').$dirmark1.' '.date_place($ownfam->fam_marr_date,$ownfam->fam_marr_place);
                                $replacement_text .= '<br>' . __('X') . $dirmark1 . ' ' . date_place($ownfam->fam_marr_date, '');
                            }
                        }
                    }
                } elseif ($size == 45) {
                    $replacement_text .= $genarray[$w]["nam"];
                } elseif ($size == 40) {
                    $replacement_text .= '<span class="wordwrap" style="font-size:75%">' . $genarray[$w]["short"] . '</span>';
                } elseif ($size >= 25 and $size < 40) {
                    $replacement_text .= $genarray[$w]["init"];
                }
            }
        } else {
            if (isset($genarray[$w]["fams"]) and isset($genarray[$w]["gednr"])) {
                /*
                if(CMS_SPECIFIC=='Joomla') {
                	$replacement_text.= '<a href="index.php?option=com_humo-gen&task=family&id='.$genarray[$w]["fams"].'&amp;main_person='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
                }
                else {
                	$replacement_text.= '<a href="'.CMS_ROOTPATH.'family.php?id='.$genarray[$w]["fams"].'&amp;main_person='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
                }
                $replacement_text.= ' style="display:block; width:100%; height:100%" ';
                $replacement_text.= ' onmouseover="mopen(event,\'m1'.$w.'\',0,0)"';
                $replacement_text.= 'onmouseout="mclosetime()">';
                */
                if (strpos($browser_user_agent, "chrome") !== false or strpos($browser_user_agent, "safari") !== false) {
                    $replacement_text .= "&nbsp;";
                }
                //  (Chrome and Safari need some character here - even &nbsp - or else popup won't work..!
            }
        }
        //$replacement_text.='</a>';
        // *** POP-UP box ***
        $extra_popup_text = '';
        if ($genarray[$w]["2nd"] == 1) {
            $extra_popup_text .= $genarray[$w]["huw"] . "<br>";
        }
        if ($genarray[$w]["non"] != 1) {
            // *** Start person class and calculate privacy ***
            $woman_cls = '';
            // prevent use of $woman_cls from previous wife if another wife is NN
            if (isset($genarray[$w]["spgednr"]) and $genarray[$w]["spgednr"]) {
                @($woman = $db_functions->get_person($genarray[$w]["spgednr"]));
                $woman_cls = new person_cls();
                $woman_cls->construct($woman);
                $woman_privacy = $woman_cls->privacy;
            }
            // *** Marriage data ***
            $extra_popup_text .= '<br>' . $genarray[$w]["htx"] . "<br>";
            if ($woman_cls) {
                $name = $woman_cls->person_name($woman);
                if (isset($genarray[$w]["spfams"]) and isset($genarray[$w]["spgednr"]) and isset($genarray[$w]["sps"])) {
                    if (CMS_SPECIFIC == 'Joomla') {
                        $extra_popup_text .= '<a href="index.php?option=com_humo-gen&task=family&id=' . $genarray[$w]["spfams"] . '&amp;main_person=' . $genarray[$w]["spgednr"] . '">' . '<strong>' . $name["standard_name"] . '</strong></a>';
                    } else {
                        $extra_popup_text .= '<a href="' . CMS_ROOTPATH . 'family.php?id=' . $genarray[$w]["spfams"] . '&amp;main_person=' . $genarray[$w]["spgednr"] . '">' . '<strong>' . $name["standard_name"] . '</strong></a>';
                    }
                } else {
                    $extra_popup_text .= $name["standard_name"];
                }
                if ($woman_privacy) {
                    $extra_popup_text .= __(' PRIVACY FILTER') . '<br>';
                    //Tekst privacy weergeven
                } else {
                    if ($woman->pers_birth_date or $woman->pers_birth_place) {
                        $extra_popup_text .= __('born') . $dirmark1 . ' ' . date_place($woman->pers_birth_date, $woman->pers_birth_place) . '<br>';
                    }
                    if ($woman->pers_death_date or $woman->pers_death_place) {
                        $extra_popup_text .= __('died ') . $dirmark1 . ' ' . date_place($woman->pers_death_date, $woman->pers_death_place) . '<br>';
                    }
                }
            } else {
                $extra_popup_text .= __('N.N.');
            }
        }
        echo $man_cls->person_popup_menu($man, true, $replacement_text, $extra_popup_text);
        echo '</div>';
        // div of square
        if ($direction == 0) {
            // if vertical
            // draw dotted line from first marriage to following marriages
            if (isset($genarray[$w]["2nd"]) and $genarray[$w]["2nd"] == 1) {
                $startx = $genarray[$w - 1]["x"] + $hsize + 2;
                $starty = $genarray[$w - 1]["y"] + $vsize / 2;
                $width = $genarray[$w]["x"] - ($genarray[$w - 1]["x"] + $hsize) - 2;
                print '<div style="position:absolute;border:1px blue dashed;height:2px;width:' . $width . 'px;left:' . $startx . 'px;top:' . $starty . 'px"></div>';
            }
            // draw line to children
            if ($genarray[$w]["nrc"] != 0) {
                $startx = $genarray[$w]["x"] + $hsize / 2;
                $starty = $genarray[$w]["y"] + $vsize + 2;
                print '<div class="chart_line" style="position:absolute; height:' . ($vdist / 2 - 2) . 'px; width:1px; left:' . $startx . 'px; top:' . $starty . 'px"></div>';
            }
            // draw line to parent
            if ($genarray[$w]["gen"] != 0 and $genarray[$w]["2nd"] != 1) {
                $startx = $genarray[$w]["x"] + $hsize / 2;
                $starty = $genarray[$w]["y"] - $vdist / 2;
                print '<div class="chart_line" style="position:absolute; height:' . $vdist / 2 . 'px;width:1px;left:' . $startx . 'px;top:' . $starty . 'px"></div>';
            }
            // draw horizontal line from 1st child in fam to last child in fam
            if ($genarray[$w]["gen"] != 0) {
                $parent = $genarray[$w]["par"];
                if ($genarray[$w]["chd"] == $genarray[$parent]["nrc"]) {
                    // last child in fam
                    $z = $w;
                    while ($genarray[$z]["2nd"] == 1) {
                        //if last is 2nd (3rd etc) marriage, the line has to stop at first marriage
                        $z--;
                    }
                    $startx = $genarray[$parent]["fst"] + $hsize / 2;
                    $starty = $genarray[$z]["y"] - $vdist / 2;
                    $width = $genarray[$z]["x"] - $genarray[$parent]["fst"];
                    print '<div class="chart_line" style="position:absolute; height:1px; width:' . $width . 'px; left:' . $startx . 'px; top:' . $starty . 'px"></div>';
                }
            }
        } else {
            // if horizontal
            // draw dotted line from first marriage to following marriages
            if (isset($genarray[$w]["2nd"]) and $genarray[$w]["2nd"] == 1) {
                $starty = $genarray[$w - 1]["y"] + $vsize + 2;
                $startx = $genarray[$w - 1]["x"] + $hsize / 2;
                $height = $genarray[$w]["y"] - ($genarray[$w - 1]["y"] + $vsize) - 2;
                print '<div style="position:absolute;border:1px blue dashed;height:' . $height . 'px; width:3px; left:' . $startx . 'px;top:' . $starty . 'px"></div>';
            }
            // draw line to children
            if ($genarray[$w]["nrc"] != 0) {
                $starty = $genarray[$w]["y"] + $vsize / 2;
                $startx = $genarray[$w]["x"] + $hsize + 3;
                print '<div class="chart_line" style="position:absolute; height:1px; width:' . ($hdist / 2 - 2) . 'px; left:' . $startx . 'px; top:' . $starty . 'px"></div>';
            }
            // draw line to parent
            if ($genarray[$w]["gen"] != 0 and $genarray[$w]["2nd"] != 1) {
                $starty = $genarray[$w]["y"] + $vsize / 2;
                $startx = $genarray[$w]["x"] - $hdist / 2;
                print '<div class="chart_line" style="position:absolute; width:' . $hdist / 2 . 'px; height:1px; left:' . $startx . 'px; top:' . $starty . 'px"></div>';
            }
            // draw vertical line from 1st child in fam to last child in fam
            if ($genarray[$w]["gen"] != 0) {
                $parent = $genarray[$w]["par"];
                if ($genarray[$w]["chd"] == $genarray[$parent]["nrc"]) {
                    // last child in fam
                    $z = $w;
                    while ($genarray[$z]["2nd"] == 1) {
                        //if last is 2nd (3rd etc) marriage, the line has to stop at first marriage
                        $z--;
                    }
                    $starty = $genarray[$parent]["fst"] + $vsize / 2;
                    $startx = $genarray[$z]["x"] - $hdist / 2;
                    $height = $genarray[$z]["y"] - $genarray[$parent]["fst"];
                    print '<div class="chart_line" style="position:absolute; width:1px; height:' . $height . 'px; left:' . $startx . 'px; top:' . $starty . 'px"></div>';
                }
            }
        }
        // end if horizontal
    }
    echo '</div>';
    // id=png
    print "<br><br></div>";
    // id=doublescroll
    // YB:
    // before creating the image we want to hide unnecessary items such as the help link, the menu box etc
    // we also have to set the width and height of the "png" div (this can't be set before because then the double scrollbars won't work
    // after generating the image, all those items are returned to their  previous state....
    echo '<script type="text/javascript">';
    if ($hourglass === false) {
        echo "\n\t\tfunction showimg() { \n\t\t\tdocument.getElementById('helppopup').style.visibility = 'hidden';\n\t\t\tdocument.getElementById('menubox').style.visibility = 'hidden';\n\t\t\tdocument.getElementById('imgbutton').style.visibility = 'hidden';\n\t\t\tdocument.getElementById('png').style.width = '" . $divlen . "px';\n\t\t\tdocument.getElementById('png').style.height= '" . $divhi . "px';\n\t\t\thtml2canvas( [ document.getElementById('png') ], {  \n\t\t\t\tonrendered: function( canvas ) {\n\t\t\t\t\tdocument.getElementById('helppopup').style.visibility = 'visible';\n\t\t\t\t\tdocument.getElementById('menubox').style.visibility = 'visible';\n\t\t\t\t\tdocument.getElementById('imgbutton').style.visibility = 'visible';\n\t\t\t\t\tvar img = canvas.toDataURL();\n\t\t\t\t\tdocument.getElementById('png').style.width = 'auto';\n\t\t\t\t\tdocument.getElementById('png').style.height= 'auto';\n\t\t\t\t\tvar newWin = window.open();\n\t\tnewWin.document.open();\n\t\tnewWin.document.write('<!DOCTYPE html><head></head><body>" . __('Right click on the image below and save it as a .png file to your computer.<br>You can then print it over multiple pages with dedicated third-party programs, such as the free: ') . "<a href=\"http://posterazor.sourceforge.net/index.php?page=download&lang=english\" target=\"_blank\">\"PosteRazor\"</a><br>" . __('If you have a plotter you can use its software to print the image on one large sheet.') . "<br><br><img src=\"' + img + '\"></body></html>');\n\t\tnewWin.document.close();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t";
    } else {
        echo "\n\t\tfunction showimg() { \n\t\t\tdocument.getElementById('png').style.width = '" . $divlen . "px';\n\t\t\tdocument.getElementById('png').style.height= '" . $divhi . "px';\n\t\t\thtml2canvas( [ document.getElementById('png') ], {  \n\t\t\t\tonrendered: function( canvas ) {\n\t\t\t\tvar img = canvas.toDataURL();\n\t\t\t\tdocument.getElementById('png').style.width = 'auto';\n\t\t\t\tdocument.getElementById('png').style.height= 'auto';\n\t\t\t\tvar newWin = window.open();\n\t\tnewWin.document.open();\n\t\tnewWin.document.write('<!DOCTYPE html><head></head><body>" . __('Right click on the image below and save it as a .png file to your computer.<br>You can then print it over multiple pages with dedicated third-party programs, such as the free: ') . "<a href=\"http://posterazor.sourceforge.net/index.php?page=download&lang=english\" target=\"_blank\">\"PosteRazor\"</a><br>" . __('If you have a plotter you can use its software to print the image on one large sheet.') . "<br><br><img src=\"' + img + '\"></body></html>');\n\t\tnewWin.document.close();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t";
    }
    echo "</script>";
    ?>
	<script type='text/javascript'>
		function DoubleScroll(element) {
			var scrollbar= document.createElement('div');
			scrollbar.appendChild(document.createElement('div'));
			scrollbar.style.overflow= 'auto';
			scrollbar.style.overflowY= 'hidden';
			scrollbar.firstChild.style.width= element.scrollWidth+'px';
			scrollbar.firstChild.style.paddingTop= '1px';
			scrollbar.firstChild.style.height= '20px';
			scrollbar.firstChild.appendChild(document.createTextNode('\xA0'));
			scrollbar.onscroll= function() {
				element.scrollLeft= scrollbar.scrollLeft;
			};
			element.onscroll= function() {
				scrollbar.scrollLeft= element.scrollLeft;
			};
			element.parentNode.insertBefore(scrollbar, element);
		}

		DoubleScroll(document.getElementById('doublescroll'));
	</script>
<?php 
    // here place div at bottom so there is some space under last boxes
    $last = count($genarray) - 1;
    $putit = $genarray[$last]["y"] + 130;
    print '<div style="position:absolute;left:1px;top:' . $putit . 'px;">&nbsp; </div>';
}
Exemple #4
0
     $orderlast = "CONCAT(pers_prefix,pers_lastname)";
 } else {
     $orderlast = "pers_lastname";
 }
 $desc_search = "SELECT * FROM humo_persons\n\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_fams !='' ORDER BY " . $orderlast . ", pers_firstname";
 $desc_search_result = $dbh->query($desc_search);
 echo '&nbsp;&nbsp;' . __('Pick a name or enter ID:') . '<br>';
 echo '<form method="POST" action="" style="display : inline;">';
 echo '<select style="max-width:396px;background:#eee" ' . $select_size . ' onChange="window.location=this.value;" id="desc_map" name="desc_map">';
 echo '<option value="toptext">' . __('Pick a name from the pulldown list') . '</option>';
 //prepared statement out of loop
 $chld_prep = $dbh->prepare("SELECT fam_children FROM humo_families\n\t\tWHERE fam_tree_id='" . $tree_id . "' AND fam_gedcomnumber =? AND fam_children != ''");
 $chld_prep->bindParam(1, $chld_var);
 while ($desc_searchDb = $desc_search_result->fetch(PDO::FETCH_OBJ)) {
     $countmarr = 0;
     $man_cls = new person_cls();
     $fam_arr = explode(";", $desc_searchDb->pers_fams);
     foreach ($fam_arr as $value) {
         if ($countmarr == 1) {
             break;
         }
         //this person is already listed
         $chld_var = $value;
         $chld_prep->execute();
         while ($chld_search_resultDb = $chld_prep->fetch(PDO::FETCH_OBJ)) {
             $countmarr = 1;
             $selected = '';
             //if($desc_searchDb->pers_gedcomnumber == $chosenperson) { $selected = ' SELECTED '; }
             $man_cls->construct($desc_searchDb);
             $privacy_man = $man_cls->privacy;
             $date = '';
Exemple #5
0
            print '<li data-role="list-divider">' . __('Children') . '</li>';
            $child = explode(";", $children);
            //$nopict=1;
            $number = 1;
            // 1 = show child number.
            for ($c = 0; $c <= count($child) - 1; $c++) {
                $res2 = $dbh->query("SELECT * FROM humo_persons\n\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber LIKE '" . safe_text($child[$c]) . "'");
                $info2 = $res2->fetch();
                $text = $info2['pers_gedcomnumber'];
                echo popup($text, false);
                // father
                // *** Show person details using standard HuMo-gen function ***
                //$child_sql=$dbh->query("SELECT * FROM ".safe_text($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber='".safe_text($text)."'");
                $child_sql = $dbh->query("SELECT * FROM humo_persons\n\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . safe_text($text) . "'");
                @($childDb = $child_sql->fetch(PDO::FETCH_OBJ));
                $child_cls = new person_cls();
                $child_cls->construct($childDb);
                echo $child_cls->person_data("mobile", 0);
                echo '</li>';
            }
            $number = '';
        }
        //else{
        //	print '<li><p>'.__('No known children or without children').'</p></li>';
        //}
    }
}
// if $marriage !=Null
echo '</ul>';
echo '</div>';
echo '<div data-role="footer" data-theme="b">';
Exemple #6
0
function show_person($personDb)
{
    global $dbh, $db_functions, $index_list, $selected_place, $language, $user;
    global $bot_visit, $humo_option, $uri_path, $search_database, $list_expanded;
    global $selected_language, $privacy, $dirmark1, $dirmark2, $rtlmarker;
    global $select_birth, $select_bapt, $select_place, $select_death, $select_buried;
    global $selectsort;
    $pers_tree_prefix = $personDb->pers_tree_prefix;
    $db_functions->set_tree_prefix($pers_tree_prefix);
    $db_functions->set_tree_id($personDb->pers_tree_id);
    if (CMS_SPECIFIC == 'Joomla') {
        $start_url = 'index.php?option=com_humo-gen&amp;task=family&amp;database=' . $pers_tree_prefix . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber;
    } elseif ($humo_option["url_rewrite"] == "j") {
        // *** url_rewrite ***
        // *** $uri_path made in header.php ***
        $start_url = $uri_path . 'family/' . $pers_tree_prefix . '/' . $personDb->pers_indexnr . '/' . $personDb->pers_gedcomnumber . '/';
    } else {
        $start_url = CMS_ROOTPATH . 'family.php?database=' . $pers_tree_prefix . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber;
    }
    // *** Person class used for name and person pop-up data ***
    $person_cls = new person_cls();
    $person_cls->construct($personDb);
    $name = $person_cls->person_name($personDb);
    // *** Show name ***
    $index_name = '';
    if ($name["show_name"] == false) {
        $index_name = __('Name filtered');
    } else {
        // *** If there is no lastname, show a - character. ***
        if ($personDb->pers_lastname == "") {
            // Don't show a "-" by pers_patronymes
            if (!isset($_GET['pers_patronym'])) {
                $index_name = "-&nbsp;&nbsp;";
            }
        }
        $index_name .= $name["index_name_extended"] . $name["colour_mark"];
    }
    // *** Show extra colums before a person in index places ***
    if ($index_list == 'places') {
        if ($selected_place != $personDb->place_order) {
            echo '<td colspan="7"><b>' . $dirmark2 . "{$personDb->place_order}</b></td></tr><tr>";
        }
        $selected_place = $personDb->place_order;
        echo '<td valign="top" style="white-space:nowrap;width:90px">';
        if ($select_birth == '1') {
            if ($selected_place == $personDb->pers_birth_place) {
                echo '<span class="place_index place_index_selected">' . __('*') . '</span>';
            } else {
                echo '<span class="place_index">&nbsp;</span>';
            }
        }
        if ($select_bapt == '1') {
            if ($selected_place == $personDb->pers_bapt_place) {
                echo '<span class="place_index place_index_selected">' . __('~') . '</span>';
            } else {
                echo '<span class="place_index">&nbsp;</span>';
            }
        }
        if ($select_place == '1') {
            if ($selected_place == $personDb->pers_place_index) {
                echo '<span class="place_index place_index_selected">' . __('^') . '</span>';
            } else {
                echo '<span class="place_index">&nbsp;</span>';
            }
        }
        if ($select_death == '1') {
            if ($selected_place == $personDb->pers_death_place) {
                echo '<span class="place_index place_index_selected">' . __('&#134;') . '</span>';
            } else {
                echo '<span class="place_index">&nbsp;</span>';
            }
        }
        if ($select_buried == '1') {
            if ($selected_place == $personDb->pers_buried_place) {
                echo '<span class="place_index place_index_selected">' . __('[]') . '</span>';
            } else {
                echo '<span class="place_index">&nbsp;</span>';
            }
        }
        echo '</td>';
    }
    echo '<td valign="top" style="border-right:0px; white-space:nowrap;">';
    // *** Show person popup menu ***
    echo $person_cls->person_popup_menu($personDb);
    // *** Show picture man or wife ***
    if ($personDb->pers_sexe == "M") {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/man.gif" alt="man" style="vertical-align:top">';
    } elseif ($personDb->pers_sexe == "F") {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/woman.gif" alt="woman" style="vertical-align:top">';
    } else {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/unknown.gif" alt="unknown" style="vertical-align:top">';
    }
    // *** Add own icon by person, using a file name in own code ***
    if ($personDb->pers_own_code != '' and is_file("images/" . $personDb->pers_own_code . ".gif")) {
        echo $dirmark1 . '<img src="' . CMS_ROOTPATH . 'images/' . $personDb->pers_own_code . '.gif" alt="' . $personDb->pers_own_code . '">&nbsp;';
    }
    echo '</td><td style="border-left:0px;">';
    // *** Show name of person ***
    echo ' <a href="' . $start_url . '">' . $index_name . '</a>';
    //*** Show spouse/ partner ***
    if ($list_expanded == true and $personDb->pers_fams) {
        $marriage_array = explode(";", $personDb->pers_fams);
        $nr_marriages = count($marriage_array);
        for ($x = 0; $x <= $nr_marriages - 1; $x++) {
            $fam_partnerDb = $db_functions->get_family($marriage_array[$x]);
            // *** This check is better then a check like: $personDb->pers_sexe=='F', because of unknown sexe or homosexual relations. ***
            if ($personDb->pers_gedcomnumber == $fam_partnerDb->fam_man) {
                $partner_id = $fam_partnerDb->fam_woman;
            } else {
                $partner_id = $fam_partnerDb->fam_man;
            }
            $relation_short = __('&amp;');
            if ($fam_partnerDb->fam_marr_date or $fam_partnerDb->fam_marr_place or $fam_partnerDb->fam_marr_church_date or $fam_partnerDb->fam_marr_church_place or $fam_partnerDb->fam_kind == 'civil') {
                $relation_short = __('X');
            }
            if ($fam_partnerDb->fam_div_date or $fam_partnerDb->fam_div_place) {
                $relation_short = __(') (');
            }
            if ($partner_id != '0' and $partner_id != '') {
                $partnerDb = $db_functions->get_person($partner_id);
                $partner_cls = new person_cls();
                $name = $partner_cls->person_name($partnerDb);
            } else {
                $name["standard_name"] = __('N.N.');
            }
            if ($nr_marriages > 1 and $x > 0) {
                echo ',';
            }
            echo ' <span class="index_partner" style="font-size:10px;">';
            if ($nr_marriages > 1) {
                if ($x == 0) {
                    echo __('1st');
                } elseif ($x == 1) {
                    echo __('2nd');
                } elseif ($x == 2) {
                    echo __('3rd');
                } elseif ($x > 2) {
                    echo $x + 1 . __('th');
                }
            }
            echo ' ' . $relation_short . ' ' . rtrim($name["standard_name"]) . '</span>';
        }
    }
    // *** End spouse/ partner ***
    echo '</td><td style="white-space:nowrap;">';
    $info = "";
    if ($personDb->pers_bapt_date) {
        $info = __('~') . ' ' . date_place($personDb->pers_bapt_date, '');
    }
    if ($personDb->pers_birth_date) {
        $info = __('*') . ' ' . date_place($personDb->pers_birth_date, '');
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td>';
    $info = "";
    if ($personDb->pers_bapt_place) {
        $info = __('~') . ' ' . $personDb->pers_bapt_place;
    }
    if ($personDb->pers_birth_place) {
        $info = __('*') . ' ' . $personDb->pers_birth_place;
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td style="white-space:nowrap;">';
    $info = "";
    if ($personDb->pers_buried_date) {
        $info = __('[]') . ' ' . date_place($personDb->pers_buried_date, '');
    }
    if ($personDb->pers_death_date) {
        $info = __('&#134;') . ' ' . date_place($personDb->pers_death_date, '');
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td>';
    $info = "";
    if ($personDb->pers_buried_place) {
        $info = __('[]') . ' ' . $personDb->pers_buried_place;
    }
    if ($personDb->pers_death_place) {
        $info = __('&#134;') . ' ' . $personDb->pers_death_place;
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    // *** Show name of family tree, if search in multiple family trees is used ***
    if ($search_database == 'all_trees' or $search_database == 'all_but_this') {
        $treetext = show_tree_text($pers_tree_prefix, $selected_language);
        echo '</td><td>';
        echo '<i><font size="-1">' . $treetext['name'] . '</font></i>';
    }
    echo '</td></tr>';
}
echo '<th>' . __('Name') . "</th>\n";
echo '<th>' . ucfirst(__('died')) . "</th>\n";
echo "</tr>\n";
// *** Build query ***
$sql = "SELECT *,\r\n\tabs(substring( pers_birth_date,1,2 )) as birth_day,\r\n\tsubstring( pers_birth_date,-4 ) as birth_year\r\n\tFROM humo_persons\r\n\tWHERE pers_tree_id='" . $tree_id . "' AND (substring( pers_birth_date,  4,3) = :month\r\n\tOR substring( pers_birth_date,  3,3) = :month)\r\n\torder by birth_day ";
try {
    $qry = $dbh->prepare($sql);
    $qry->bindValue(':month', $month, PDO::PARAM_STR);
    $qry->execute();
} catch (PDOException $e) {
    echo $e->getMessage() . "<br/>";
}
while ($record = $qry->fetch(PDO::FETCH_OBJ)) {
    $calendar_day = $record->birth_day;
    $birth_day = $record->birth_day . ' ' . $month;
    $person_cls = new person_cls();
    $name = $person_cls->person_name($record);
    $person_cls->construct($record);
    $person_name = '<a href="' . CMS_ROOTPATH . 'family.php?id=' . $record->pers_indexnr . '&amp;main_person=' . $record->pers_gedcomnumber . '">' . $name["standard_name"] . '</a>';
    $death_date = $record->pers_death_date;
    $age = $year - $record->birth_year;
    // pers_death_date known: print
    // pers_death_date not known, age > 110, pers_death_date is not known, otherwise empty (probably alive)
    if ($death_date != '') {
        $died = language_date($death_date);
    } else {
        if ($age > $max_age) {
            $died = '? ';
        } else {
            $died = '  ';
        }
 function name_extended($person_kind)
 {
     global $dbh, $db_functions, $humo_option, $uri_path, $user, $language;
     global $screen_mode, $dirmark1, $dirmark2, $rtlmarker;
     global $selected_language, $family_expanded, $bot_visit;
     global $sect;
     // *** RTF Export ***
     $text_name = '';
     $text_name2 = '';
     $text_colour = '';
     $text_parents = '';
     $child_marriage = '';
     $personDb = $this->personDb;
     $privacy = $this->privacy;
     if (!$personDb) {
         // *** Show unknown person N.N. ***
         $text_name = __('N.N.');
     } else {
         $tree_prefix_quoted = $personDb->pers_tree_prefix;
         $db_functions->set_tree_prefix($tree_prefix_quoted);
         // *** Show pop-up menu ***
         $text_name .= $this->person_popup_menu($personDb);
         // *** Check privacy filter ***
         if ($privacy and $user['group_filter_name'] == 'n') {
             //dummy
         } else {
             // *** Show man or woman picture ***
             if ($screen_mode != "PDF") {
                 //  pdf does this elsewhere
                 if ($screen_mode == "RTF") {
                     //  rtf does this in family.php
                     //
                 } else {
                     $text_name .= $dirmark1;
                     if ($personDb->pers_sexe == "M") {
                         $text_name .= '<img src="' . CMS_ROOTPATH . 'images/man.gif" alt="man">';
                     } elseif ($personDb->pers_sexe == "F") {
                         $text_name .= '<img src="' . CMS_ROOTPATH . 'images/woman.gif" alt="woman">';
                     } else {
                         $text_name .= '<img src="' . CMS_ROOTPATH . 'images/unknown.gif" alt="unknown">';
                     }
                     // *** Add own icon by person, using a file name in own code ***
                     if ($personDb->pers_own_code != '' and is_file("images/" . $personDb->pers_own_code . ".gif")) {
                         $text_name .= '<img src="' . CMS_ROOTPATH . 'images/' . $personDb->pers_own_code . '.gif" alt="' . $personDb->pers_own_code . '">&nbsp;';
                     }
                 }
                 // *** Source by sexe ***
                 $source = '';
                 if ($person_kind != 'outline') {
                     $source = show_sources2("person", "pers_sexe_source", $personDb->pers_gedcomnumber) . ' ';
                 }
                 if ($source) {
                     $text_name .= $source;
                 }
             }
         }
         $name = $this->person_name($personDb);
         $standard_name = $name["standard_name"] . $dirmark2;
         // *** Show gedcomnummer #I5 as #5 ***
         if ($user['group_gedcomnr'] == 'j') {
             $show_gedcomnumber = $personDb->pers_gedcomnumber;
             if (substr($show_gedcomnumber, 0, 1) == 'I') {
                 $show_gedcomnumber = substr($show_gedcomnumber, 1);
             }
             $standard_name .= $dirmark1 . " #" . $show_gedcomnumber;
         }
         // *** Check privacy filter for callname ***
         if ($privacy and $user['group_filter_name'] == 'n' or $user["group_pers_hide_totally_act"] == 'j' and strpos($personDb->pers_own_code, $user["group_pers_hide_totally"]) > 0) {
             //
         } else {
             if ($personDb->pers_callname) {
                 $standard_name .= ', ' . __('Nickname') . ': ' . $personDb->pers_callname;
             }
         }
         // *** No links if gen_protection is enabled ***
         if ($user["group_gen_protection"] == 'j') {
             $person_kind = '';
         }
         if (($person_kind == 'child' or $person_kind == 'outline') and $personDb->pers_fams) {
             $child_link = explode(";", $personDb->pers_fams);
             // *** Link to 1st family of person ***
             if (CMS_SPECIFIC == 'Joomla') {
                 $standard_name = '<a href="index.php?option=com_humo-gen&task=family&database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $child_link[0] . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">' . $standard_name;
                 // Link to 1st family of person
             } elseif ($humo_option["url_rewrite"] == "j") {
                 // *** $uri_path is made in header.php ***
                 $standard_name = '<a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $child_link[0] . '/' . $personDb->pers_gedcomnumber . '/">' . $standard_name;
             } else {
                 $standard_name = '<a href="' . CMS_ROOTPATH . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $child_link[0] . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">' . $standard_name;
                 // Link to 1st family of person
             }
             // *** Show name with link ***
             $text_name = $text_name . $standard_name . '</a>';
         } else {
             $text_name .= $standard_name;
         }
         // *** Show name without link **
         // *** Check privacy filter ***
         $text_name2 = '';
         if ($privacy) {
             //dummy
         } else {
             // *** Text by name ***
             if ($user["group_texts_pers"] == 'j') {
                 $work_text = process_text($personDb->pers_name_text);
                 if ($work_text) {
                     //$templ_person["name_text"]=", ".$work_text;
                     $templ_person["name_text"] = " " . $work_text;
                     $text_name2 .= $templ_person["name_text"];
                 }
             }
             // *** Source by name ***
             $source = '';
             if ($person_kind != 'outline') {
                 $source = show_sources2("person", "pers_name_source", $personDb->pers_gedcomnumber);
             }
             if ($source) {
                 // PDF doesn't work...
                 if ($screen_mode == 'PDF') {
                     $templ_person["name_source"] = $source;
                     $temp = "name_source";
                 } else {
                     $text_name2 .= $source;
                 }
             }
         }
         // *** Add colour marks to person ***
         $text_colour = $name["colour_mark"];
         // *********************************************************************
         // *** Show: son of/ daughter of/ child of name-father & name-mother ***
         // *********************************************************************
         if (($person_kind == 'parent1' or $person_kind == 'parent2') and $personDb->pers_famc) {
             if ($personDb->pers_sexe == 'M') {
                 $text_parents .= __('son of') . ' ';
             }
             if ($personDb->pers_sexe == 'F') {
                 $text_parents .= __('daughter of') . ' ';
             }
             if ($personDb->pers_sexe == '') {
                 $text_parents .= __('child of') . ' ';
             }
             if ($family_expanded == true) {
                 $text_parents = ucfirst($text_parents);
             } else {
                 $templ_person["parent_childof"] = ', ' . $text_parents;
                 $temp = "parent_childof";
                 $text_parents = $templ_person["parent_childof"];
             }
             // *** Find parents ID ***
             $parents_familyDb = $db_functions->get_family($personDb->pers_famc);
             // *** Father ***
             if ($parents_familyDb->fam_man) {
                 $fatherDb = $db_functions->get_person($parents_familyDb->fam_man);
                 $name = $this->person_name($fatherDb);
                 $templ_person["parents"] = $name["standard_name"];
             } else {
                 $templ_person["parents"] = __('N.N.');
             }
             $templ_person["parents"] .= ' ' . __('and') . ' ';
             $temp = "parents";
             $text = $templ_person["parents"];
             // *** Mother ***
             if ($parents_familyDb->fam_woman) {
                 $motherDb = $db_functions->get_person($parents_familyDb->fam_woman);
                 $name = $this->person_name($motherDb);
                 $templ_person["parents"] .= $name["standard_name"];
                 $text .= $name["standard_name"];
             } else {
                 $text .= __('N.N.');
             }
             // *** Add link for parents ***
             if (CMS_SPECIFIC == 'Joomla') {
                 $text2 = '<a href="index.php?option=com_humo-gen&task=family&database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $personDb->pers_famc;
                 if (isset($fatherDb->pers_gedcomnumber)) {
                     $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                 }
                 $text2 .= '">';
             } elseif ($humo_option["url_rewrite"] == "j") {
                 // *** $uri_path is made in header.php ***
                 $text2 = '<a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $personDb->pers_famc;
                 // *** Added this number for better Google indexing links (otherwise too many links to index) ***
                 if (isset($fatherDb->pers_gedcomnumber)) {
                     $text2 .= '/' . $fatherDb->pers_gedcomnumber;
                 }
                 $text2 .= '/">';
             } else {
                 $text2 = '<a href="' . $uri_path . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $personDb->pers_famc;
                 if (isset($fatherDb->pers_gedcomnumber)) {
                     $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                 }
                 $text2 .= '">';
             }
             // *** Add link ***
             if ($user['group_gen_protection'] == 'n') {
                 $text = $text2 . $text . '</a>';
             }
             $text_parents .= '<span class="parents">' . $text . $dirmark2 . '.</span>';
         }
         // ********************************************************************************************
         // *** Check for adoptive parents (just for sure: made it for multiple adoptive parents...) ***
         // ********************************************************************************************
         if ($person_kind == 'parent1' or $person_kind == 'parent2') {
             $famc_adoptive_qry = $db_functions->get_events_person($personDb->pers_gedcomnumber, 'adoption');
             foreach ($famc_adoptive_qry as $famc_adoptiveDb) {
                 $text_parents .= ' ' . ucfirst(__('adoption parents')) . ': ';
                 // *** Just in case: empty $text ***
                 $text = '';
                 // *** Find parents ID ***
                 $parents_familyDb = $db_functions->get_family($famc_adoptiveDb->event_event);
                 //*** Father ***
                 if ($parents_familyDb->fam_man) {
                     $fatherDb = $db_functions->get_person($parents_familyDb->fam_man);
                     $name = $this->person_name($fatherDb);
                     $text = $name["standard_name"];
                     //$templ_person["parents"]=$name["standard_name"];
                     //$temp="parents";
                 } else {
                     $text = __('N.N.');
                     //$templ_person["parents"]=__('N.N.');
                     //$temp="parents";
                 }
                 $text .= ' ' . __('and') . ' ';
                 //$templ_person["parents"].=' '.__('and').' ';
                 //$temp="parents";
                 //*** Mother ***
                 if ($parents_familyDb->fam_woman) {
                     $motherDb = $db_functions->get_person($parents_familyDb->fam_woman);
                     $name = $this->person_name($motherDb);
                     $text .= $name["standard_name"];
                     //$templ_person["parents"].=$name["standard_name"];
                     //$temp="parents";
                 } else {
                     $text .= __('N.N.');
                 }
                 if (CMS_SPECIFIC == 'Joomla') {
                     $text2 = '<a href="index.php?option=com_humo-gen&task=family&database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $famc_adoptiveDb->event_event;
                     if (isset($fatherDb->pers_gedcomnumber)) {
                         $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                     }
                     $text2 .= '">';
                 } elseif ($humo_option["url_rewrite"] == "j") {
                     // *** $uri_path is gemaakt in header.php ***
                     $text2 = '<a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $famc_adoptiveDb->event_event;
                     // *** Dit nummer toegevoegd, anders krijgt Google heel veel te indexeren gezinnen ***
                     if (isset($fatherDb->pers_gedcomnumber)) {
                         $text2 .= '/' . $fatherDb->pers_gedcomnumber;
                     }
                     $text2 .= '/">';
                 } else {
                     $text2 = '<a href="' . $uri_path . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $famc_adoptiveDb->event_event;
                     if (isset($fatherDb->pers_gedcomnumber)) {
                         $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                     }
                     $text2 .= '">';
                 }
                 // *** Add link ***
                 if ($user['group_gen_protection'] == 'n') {
                     $text = $text2 . $text . '</a>';
                 }
                 //$text_parents.='<span class="parents">'.$text.$dirmark2.' </span>';
                 $text_parents .= '<span class="parents">' . $text . ' </span>';
             }
         }
         // ********************************************************
         // *** Check for adoptive parent ESPECIALLY FOR ALDFAER ***
         // ********************************************************
         if ($person_kind == 'parent1' or $person_kind == 'parent2') {
             $famc_adoptive_qry = $db_functions->get_events_person($personDb->pers_gedcomnumber, 'adoption_by_person');
             foreach ($famc_adoptive_qry as $famc_adoptiveDb) {
                 if ($famc_adoptiveDb->event_gedcom == 'steph') {
                     $text_parents .= ' ' . ucfirst(__('stepparent')) . ': ';
                 } elseif ($famc_adoptiveDb->event_gedcom == 'legal') {
                     $text_parents .= ' ' . ucfirst(__('legal parent')) . ': ';
                 } elseif ($famc_adoptiveDb->event_gedcom == 'foster') {
                     $text_parents .= ' ' . ucfirst(__('foster parent')) . ': ';
                 } else {
                     $text_parents .= ' ' . ucfirst(__('adoption parent')) . ': ';
                 }
                 //*** Father ***
                 //if ($parents_familyDb->fam_man){
                 $fatherDb = $db_functions->get_person($famc_adoptiveDb->event_event);
                 $name = $this->person_name($fatherDb);
                 $text = $name["standard_name"];
                 //$templ_person["parents"]=$name["standard_name"];
                 //$temp="parents";
                 //}
                 //else{
                 //	$text=__('N.N.');
                 //$templ_person["parents"]=__('N.N.');
                 //$temp="parents";
                 //}
                 if (isset($fatherDb->pers_indexnr)) {
                     if (CMS_SPECIFIC == 'Joomla') {
                         $text2 = '<a href="index.php?option=com_humo-gen&task=family&database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $fatherDb->pers_indexnr;
                         if (isset($fatherDb->pers_gedcomnumber)) {
                             $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                         }
                         $text2 .= '">';
                     } elseif ($humo_option["url_rewrite"] == "j") {
                         // *** $uri_path is made in header.php ***
                         $text2 = '<a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $fatherDb->pers_indexnr;
                         // *** Added number to prevent too much search engine index links ***
                         if (isset($fatherDb->pers_gedcomnumber)) {
                             $text2 .= '/' . $fatherDb->pers_gedcomnumber;
                         }
                         $text2 .= '/">';
                     } else {
                         $text2 = '<a href="' . $uri_path . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $fatherDb->pers_indexnr;
                         if (isset($fatherDb->pers_gedcomnumber)) {
                             $text2 .= '&amp;main_person=' . $fatherDb->pers_gedcomnumber;
                         }
                         $text2 .= '">';
                     }
                 }
                 // *** Add link ***
                 if ($user['group_gen_protection'] == 'n') {
                     $text = $text2 . $text . '</a>';
                 }
                 //$text_parents.='<span class="parents">'.$text.$dirmark2.' </span>';
                 $text_parents .= '<span class="parents">' . $text . ' </span>';
             }
         }
         //*** Show spouse/ partner by child ***
         if (!$bot_visit and $person_kind == 'child' and $personDb->pers_fams) {
             $marriage_array = explode(";", $personDb->pers_fams);
             $nr_marriages = count($marriage_array);
             for ($x = 0; $x <= $nr_marriages - 1; $x++) {
                 $fam_partnerDb = $db_functions->get_family($marriage_array[$x]);
                 // *** This check is better then a check like: $personDb->pers_sexe=='F', because of unknown sexe or homosexual relations. ***
                 if ($personDb->pers_gedcomnumber == $fam_partnerDb->fam_man) {
                     $partner_id = $fam_partnerDb->fam_woman;
                 } else {
                     $partner_id = $fam_partnerDb->fam_man;
                 }
                 //$relation_short=__('&');
                 $relation_short = __('relationship with');
                 if ($fam_partnerDb->fam_marr_date or $fam_partnerDb->fam_marr_place or $fam_partnerDb->fam_marr_church_date or $fam_partnerDb->fam_marr_church_place or $fam_partnerDb->fam_kind == 'civil') {
                     //$relation_short=__('X');
                     $relation_short = __('married to');
                     if ($nr_marriages > 1) {
                         $relation_short = __('marriage with');
                     }
                 }
                 if ($fam_partnerDb->fam_div_date or $fam_partnerDb->fam_div_place) {
                     //$relation_short=__(') (');
                     $relation_short = __('divorced from');
                     if ($nr_marriages > 1) {
                         $relation_short = __('marriage (divorced) with');
                     }
                 }
                 if ($partner_id != '0' and $partner_id != '') {
                     $partnerDb = $db_functions->get_person($partner_id);
                     $partner_cls = new person_cls();
                     $name = $partner_cls->person_name($partnerDb);
                     $famc = $partnerDb->pers_indexnr;
                     // *** Used for partner link ***
                     $pers_gedcomnumber = $partnerDb->pers_gedcomnumber;
                 } else {
                     $name["standard_name"] = __('N.N.');
                     $famc = $personDb->pers_indexnr;
                     // *** For partner link, if partner is N.N. ***
                     $pers_gedcomnumber = $personDb->pers_gedcomnumber;
                 }
                 // *** Link for partner ***
                 if ($humo_option["url_rewrite"] == "j") {
                     // *** $uri_path is made in header.php ***
                     $text_link = '<a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $famc;
                     // *** Added this number for better Google indexing links (otherwise too many links to index) ***
                     //if (isset($fatherDb->pers_gedcomnumber)){ $text2.= '/'.$fatherDb->pers_gedcomnumber; }
                     $text_link .= '/' . $pers_gedcomnumber;
                     $text_link .= '/">';
                 } else {
                     $text_link = '<a href="' . $uri_path . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $famc;
                     //if (isset($fatherDb->pers_gedcomnumber)){ $text2.='&amp;main_person='.$fatherDb->pers_gedcomnumber; }
                     $text_link .= '&amp;main_person=' . $pers_gedcomnumber;
                     $text_link .= '">';
                 }
                 $name["standard_name"] = $text_link . $name["standard_name"] . '</a>';
                 //$child_marriage.=' <span class="index_partner" style="font-size:10px;">';
                 if ($nr_marriages > 1) {
                     if ($x == 0) {
                         $child_marriage .= ' ' . __('1st');
                     } elseif ($x == 1) {
                         $child_marriage .= ', ' . __('2nd');
                     } elseif ($x == 2) {
                         $child_marriage .= ', ' . __('3rd');
                     } elseif ($x > 2) {
                         $child_marriage .= ', ' . ($x + 1) . __('th');
                     }
                 } else {
                     $child_marriage .= ' ';
                 }
                 $child_marriage .= ' ' . $relation_short . ' ' . $dirmark1 . $name["standard_name"] . $dirmark1;
                 //$child_marriage.='</span>';
             }
         }
         // *** End spouse/ partner ***
     }
     if ($family_expanded == true) {
         $text_parents = '<div class="margin_person">' . $text_parents . '</div>';
         $child_marriage = '<div class="margin_child">' . $child_marriage . '</div>';
     }
     //return '<span class="pers_name">'.$text_name.$dirmark1.'</span>'.$text_name2.$text_colour.$text_parents.$child_marriage;
     if ($screen_mode == 'RTF') {
         return '<b>' . $text_name . $dirmark1 . '</b>' . $text_name2 . $text_colour . $text_parents . $child_marriage;
     } else {
         return '<span class="pers_name">' . $text_name . $dirmark1 . '</span>' . $text_name2 . $text_colour . $text_parents . $child_marriage;
     }
 }
<?php

// *** Safety line ***
if (!defined('ADMIN_PAGE')) {
    exit;
}
@set_time_limit(3000);
require_once CMS_ROOTPATH_ADMIN . "statistics/maxChart.class.php";
// REQUIRED FOR STATISTICS
include_once CMS_ROOTPATH . "include/person_cls.php";
echo '<h1 align=center>' . __('Statistics') . '</h1>';
// *** Use a class to process person data ***
global $person_cls, $statistics_screen;
$person_cls = new person_cls();
// *** Show 1 statistics line ***
function statistics_line($familyDb)
{
    global $dbh, $language, $person_cls, $selected_language;
    $tree_id = $familyDb->tree_id;
    echo '<tr>';
    if (isset($familyDb->count_lines)) {
        echo '<td>' . $familyDb->count_lines . '</td>';
    }
    $treetext = show_tree_text($familyDb->tree_prefix, $selected_language);
    echo '<td>' . $treetext['name'] . '</td>';
    if (!isset($familyDb->count_lines)) {
        echo '<td>' . $familyDb->stat_date_stat . '</td>';
    }
    // *** Check if family is still in the genealogy! ***
    $check_sql = $dbh->query("SELECT * FROM humo_families\n\t\tWHERE fam_tree_id='" . $tree_id . "' AND fam_gedcomnumber='{$familyDb->stat_gedcom_fam}'");
    $checkDb = $check_sql->fetch(PDO::FETCH_OBJ);
Exemple #10
0
/**
* print ancestors on a fan chart
* @param array $treeid ancestry pid
* @param int $fanw fan width in px (default=840)
* @param int $fandeg fan size in deg (default=270)
*/
function print_fan_chart($treeid, $fanw = 840, $fandeg = 270)
{
    global $dbh, $tree_id, $db_functions, $fontsize, $date_display;
    global $fan_style, $family_id;
    global $printing, $language, $selected_language;
    global $pers_var, $tree_prefix_quoted;
    global $china_message;
    // check for GD 2.x library
    if (!defined("IMG_ARC_PIE")) {
        print "ERROR: NO GD LIBRARY";
        return false;
    }
    if (!function_exists("ImageTtfBbox")) {
        print "ERROR: NO GD LIBRARY";
        return false;
    }
    if (intval($fontsize) < 2) {
        $fontsize = 7;
    }
    $treesize = count($treeid);
    if ($treesize < 1) {
        return;
    }
    // generations count
    $gen = log($treesize) / log(2) - 1;
    $sosa = $treesize - 1;
    // fan size
    if ($fandeg == 0) {
        $fandeg = 360;
    }
    $fandeg = min($fandeg, 360);
    $fandeg = max($fandeg, 90);
    $cx = $fanw / 2 - 1;
    // center x
    $cy = $cx;
    // center y
    $rx = $fanw - 1;
    $rw = $fanw / ($gen + 1);
    $fanh = $fanw;
    // fan height
    if ($fandeg == 180) {
        $fanh = round($fanh * ($gen + 1) / ($gen * 2));
    }
    if ($fandeg == 270) {
        $fanh = round($fanh * 0.86);
    }
    $scale = $fanw / 840;
    // image init
    $image = ImageCreate($fanw, $fanh);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
    ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
    if ($printing == 1) {
        ImageColorTransparent($image, $white);
    }
    // *** Border colour ***
    $rgb = "";
    if (empty($rgb)) {
        $rgb = "#6E6E6E";
    }
    $grey = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // *** Text colour ***
    $rgb = "";
    if (empty($rgb)) {
        $rgb = "#000000";
    }
    $color = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // *** Background colour ***
    $rgb = "";
    if (empty($rgb)) {
        $rgb = "#EEEEEE";
    }
    $bgcolor = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // *** Man colour ***
    $rgb = "";
    if (empty($rgb)) {
        $rgb = "#B2DFEE";
    }
    $bgcolorM = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // *** wife colour ***
    $rgb = "";
    if (empty($rgb)) {
        $rgb = "#FFE4C4";
    }
    $bgcolorF = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // imagemap
    $imagemap = "<map id=\"fanmap\" name=\"fanmap\">";
    // loop to create fan cells
    while ($gen >= 0) {
        // clean current generation area
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $fandeg;
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_EDGED | IMG_ARC_NOFILL);
        $rx -= 3;
        // calculate new angle
        $p2 = pow(2, $gen);
        $angle = $fandeg / $p2;
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $angle;
        // special case for rootid cell
        if ($gen == 0) {
            $deg1 = 90;
            $deg2 = 360 + $deg1;
        }
        // draw each cell
        while ($sosa >= $p2) {
            $pid = $treeid[$sosa][0];
            $birthyr = $treeid[$sosa][1];
            $deathyr = $treeid[$sosa][4];
            $fontpx = $fontsize;
            if ($sosa >= 16 and $fandeg == 180) {
                $fontpx = $fontsize - 1;
            }
            if ($sosa >= 32 and $fandeg != 180) {
                $fontpx = $fontsize - 1;
            }
            if (!empty($pid)) {
                if ($sosa % 2) {
                    $bg = $bgcolorF;
                } else {
                    $bg = $bgcolorM;
                }
                if ($sosa == 1) {
                    if ($treeid[$sosa][5] == "F") {
                        $bg = $bgcolorF;
                    } else {
                        if ($treeid[$sosa][5] == "M") {
                            $bg = $bgcolorM;
                        } else {
                            $bg = $bgcolor;
                            // sex unknown
                        }
                    }
                }
                ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                if ($gen != 0) {
                    ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $grey, IMG_ARC_EDGED | IMG_ARC_NOFILL);
                } else {
                    ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $grey, IMG_ARC_NOFILL);
                }
                $name = $pid;
                // check if string is RTL language- if it is, it has to be reversed later on by persian_log2vis()
                $rtlstr = 0;
                //if(preg_match('/(*UTF8)[א-ת]/',$name)!==0 OR preg_match('/(*UTF8)[أ-ى]/',$name)!==0) {
                if (preg_match('/(*UTF8)[א-ת]/', $name) === 1 or preg_match('/(*UTF8)[أ-ى]/', $name) === 1) {
                    // this is either Hebrew, Arabic or Persian -> we have to reverse the text!
                    $rtlstr = 1;
                }
                $fontfile = CMS_ROOTPATH . "include/fanchart/dejavusans.ttf";
                // this default font serves: Latin,Hebrew,Arabic,Persian,Russian
                //if(preg_match('/(*UTF8)\p{Han}/',$name)!==0) {	// String is Chinese so use a Chinese ttf font if present in the folder
                if (preg_match('/(*UTF8)\\p{Han}/', $name) === 1) {
                    // String is Chinese so use a Chinese ttf font if present in the folder
                    if (is_dir(CMS_ROOTPATH . "include/fanchart/chinese")) {
                        $dh = opendir(CMS_ROOTPATH . "include/fanchart/chinese");
                        while (false !== ($filename = readdir($dh))) {
                            //if (strtolower(substr($filename, -3)) == "ttf"){
                            if (strtolower(substr($filename, -3)) == "otf" or strtolower(substr($filename, -3)) == "ttf") {
                                $fontfile = CMS_ROOTPATH . "include/fanchart/chinese/" . $filename;
                            }
                        }
                    }
                    if ($fontfile == CMS_ROOTPATH . "include/fanchart/dejavusans.ttf") {
                        //no Chinese ttf file found
                        $china_message = 1;
                    }
                }
                $text = $name;
                // names
                $text2 = "";
                // dates
                if ($date_display == 1) {
                    // don't show dates
                } else {
                    if ($date_display == 2) {
                        //show years only
                        // years only chosen but we also do this if no place in outer circles
                        $text2 .= substr($birthyr, -4) . " - " . substr($deathyr, -4);
                    } else {
                        if ($date_display == 3) {
                            //show full dates (but not in narrow outer circles!)
                            if ($gen > 5) {
                                $text2 .= substr($birthyr, -4) . " - " . substr($deathyr, -4);
                            } else {
                                if ($gen > 4 and $fan_style != 4) {
                                    $text2 .= substr($birthyr, -4) . " - " . substr($deathyr, -4);
                                } else {
                                    // full dates
                                    if ($birthyr) {
                                        $text2 .= "b." . $birthyr . "\n";
                                    }
                                    if ($deathyr) {
                                        $text2 .= "d." . $deathyr;
                                    }
                                }
                            }
                        }
                    }
                }
                // split and center text by lines
                $wmax = floor($angle * 7 / $fontpx * $scale);
                $wmax = min($wmax, 35 * $scale);
                //35
                //$wmax = floor((90*$wmax)/100);
                if ($gen == 0) {
                    $wmax = min($wmax, 17 * $scale);
                }
                //17
                $text = split_align_text($text, $wmax, $rtlstr, 1, $gen);
                $text2 = split_align_text($text2, $wmax, $rtlstr, 0, $gen);
                if ($rtlstr == 1) {
                    persian_log2vis($text);
                    // converts persian, arab and hebrew text from logical to visual and reverses it
                }
                $text .= "\n" . $text2;
                // text angle
                $tangle = 270 - ($deg1 + $angle / 2);
                if ($gen == 0) {
                    $tangle = 0;
                }
                // calculate text position
                $bbox = ImageTtfBbox((double) $fontpx, 0, $fontfile, $text);
                $textwidth = $bbox[4];
                //4
                $deg = $deg1 + 0.44;
                if ($deg2 - $deg1 > 40) {
                    $deg = $deg1 + ($deg2 - $deg1) / 11;
                }
                // 11
                if ($deg2 - $deg1 > 80) {
                    $deg = $deg1 + ($deg2 - $deg1) / 7;
                }
                //  7
                if ($deg2 - $deg1 > 140) {
                    $deg = $deg1 + ($deg2 - $deg1) / 4;
                }
                //  4
                if ($gen == 0) {
                    $deg = 180;
                }
                $rad = deg2rad($deg);
                $mr = ($rx - $rw / 4) / 2;
                if ($gen > 0 and $deg2 - $deg1 > 80) {
                    $mr = $rx / 2;
                }
                $tx = $cx + $mr * cos($rad);
                $ty = $cy - $mr * -sin($rad);
                if ($sosa == 1) {
                    $ty -= $mr / 2;
                }
                // print text
                ImageTtfText($image, (double) $fontpx, $tangle, $tx, $ty, $color, $fontfile, $text);
                $imagemap .= "<area shape=\"poly\" coords=\"";
                // plot upper points
                $mr = $rx / 2;
                $deg = $deg1;
                while ($deg <= $deg2) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg += ($deg2 - $deg1) / 6;
                }
                // plot lower points
                $mr = ($rx - $rw) / 2;
                $deg = $deg2;
                while ($deg >= $deg1) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg -= ($deg2 - $deg1) / 6;
                }
                // join first point
                $mr = $rx / 2;
                $deg = $deg1;
                $rad = deg2rad($deg);
                $tx = round($cx + $mr * cos($rad));
                $ty = round($cy - $mr * -sin($rad));
                $imagemap .= "{$tx}, {$ty}";
                if (CMS_SPECIFIC == "Joomla") {
                    $imagemap .= "\" href=\"index.php?option=com_humo-gen&amp;task=family&amp;id=" . $treeid[$sosa][2] . "&amp;main_person=" . $treeid[$sosa][3] . "\"";
                } else {
                    $imagemap .= "\" href=\"family.php?id=" . $treeid[$sosa][2] . "&amp;main_person=" . $treeid[$sosa][3] . "\"";
                }
                //NEW - add first spouse to base person's tooltip
                $spousename = "";
                if ($gen == 0 and $treeid[1][2] != "") {
                    // base person and has spouse
                    if ($treeid[1][5] == "F") {
                        $spouse = "fam_man";
                    } else {
                        $spouse = "fam_woman";
                    }
                    $spouse_result = $dbh->query("SELECT " . $spouse . " FROM humo_families\n\t\t\t\t\t\tWHERE fam_tree_id='" . $tree_id . "' AND fam_gedcomnumber='" . $treeid[1][2] . "'");
                    @($spouseDb = $spouse_result->fetch());
                    // fetch() with no parameter deaults to array which is what we want here
                    @($spouse2Db = $db_functions->get_person($spouseDb[$spouse]));
                    $spouse_cls = new person_cls();
                    $spouse_cls->construct($spouse2Db);
                    $spname = $spouse_cls->person_name($spouse2Db);
                    if ($treeid[1][5] == "F") {
                        $spouse_lan = "SPOUSE_MALE";
                    } else {
                        $spouse_lan = "SPOUSE_FEMALE";
                    }
                    if ($spname != "") {
                        $spousename = "\n(" . __($spouse_lan) . ": " . $spname["standard_name"] . ")";
                    }
                }
                $imagemap .= " alt=\"" . $pid . "\" title=\"" . $pid . $spousename . "\">";
            }
            $deg1 -= $angle;
            $deg2 -= $angle;
            $sosa--;
        }
        $rx -= $rw;
        $gen--;
    }
    $imagemap .= "</map>";
    echo $imagemap;
    $image_title = preg_replace("~<.*>~", "", $name) . "   - " . __('RELOAD FANCHART WITH \'VIEW\' BUTTON ON THE LEFT');
    echo "<p align=\"center\" >";
    if (CMS_SPECIFIC == "Joomla") {
        ImagePng($image, CMS_ROOTPATH . "include/fanchart/tmpimg.png");
        $ext = "?" . time();
        // add random string to file to prevent loading from cache and then replacing which is not nice
        echo "<img src=\"index.php?option=com_humo-gen&task=fanimage&format=raw&nochache=" . $ext . "\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\">";
    } else {
        ob_start();
        ImagePng($image);
        $image_data = ob_get_contents();
        ob_end_clean();
        $image_data = serialize($image_data);
        unset($_SESSION['image_data']);
        $_SESSION['image_data'] = $image_data;
        echo "<img src=\"include/fanchart/fanimage.php\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\">";
    }
    echo "</p>\n";
    ImageDestroy($image);
}
 function place_cells($type, $begin, $end, $increment, $maxchar, $numrows, $cellwidth)
 {
     global $dbh, $db_functions, $tree_prefix_quoted, $pdf, $data_array, $posy, $posx, $marr_date_array, $marr_place_array, $sexe, $gedcomnumber;
     $pdf->SetLeftMargin(16);
     $marg = 16;
     for ($m = $begin; $m <= $end; $m += $increment) {
         if ($type == "pers") {
             // person's name & details
             data_array($m, $maxchar, $numrows);
             $pdf->SetFont('Arial', 'B', 8);
             if ($m % 2 == 0 or $m == 1 and $sexe[$m] == "M") {
                 // male
                 $pdf->SetFillColor(191, 239, 255);
             } else {
                 // female
                 $pdf->SetFillColor(255, 228, 225);
             }
             $pdf->MultiCell($cellwidth, 4, $data_array[$m][0], "LTR", "C", true);
             $marg += $cellwidth;
             $pdf->SetFont('Arial', '', 8);
             $nstring = '';
             $used = $data_array[$m][3] + $data_array[$m][4] + $data_array[$m][5];
         } else {
             // marr date & place
             $space = '';
             if ($marr_date_array[$m] != '') {
                 $space = ' ';
             }
             if ($gedcomnumber[$m] != '') {
                 @($personDb = $db_functions->get_person($gedcomnumber[$m]));
                 $person_cls = new person_cls();
                 $person_cls->construct($personDb);
                 $pers_privacy = $person_cls->privacy;
             } else {
                 $pers_privacy = false;
             }
             if ($gedcomnumber[$m + 1] != '') {
                 @($womanDb = $db_functions->get_person($gedcomnumber[$m + 1]));
                 $woman_cls = new person_cls();
                 $woman_cls->construct($womanDb);
                 $woman_privacy = $person_cls->privacy;
             } else {
                 $woman_privacy = false;
             }
             if ($pers_privacy or $woman_privacy) {
                 $marr = __('PRIVACY FILTER');
             } else {
                 $marr = __('X') . ' ' . $marr_date_array[$m] . $space . $marr_place_array[$m];
             }
             $result = parse_line($marr, $maxchar, $numrows);
             $marg += $cellwidth;
             $nstring = '';
             $used = $result[0];
         }
         for ($x = 1; $x <= $numrows - $used; $x++) {
             $nstring .= "\n" . " ";
         }
         if ($type == "pers") {
             $breakln = '';
             if ($data_array[$m][1] != '' and $data_array[$m][2] != '') {
                 $breakln = "\n";
             }
             if ($data_array[$m][4] == 0 and $data_array[$m][5] == 0) {
                 $nstring = substr($nstring, 0, strlen($nstring) - 1);
             }
             $pdf->SetFont('Arial', '', 8);
             $pdf->MultiCell($cellwidth, 4, $data_array[$m][1] . $breakln . $data_array[$m][2] . $nstring, "LRB", "C", true);
         } else {
             $pdf->SetFont('Arial', 'I', 8);
             $pdf->MultiCell($cellwidth, 4, $result[1] . $nstring, "LR", "C", false);
         }
         if ($m < $end) {
             $pdf->SetLeftMargin($marg);
             $pdf->SetY($posy);
         }
     }
     $pdf->SetX($posx);
     $posy = $pdf->GetY();
 }
 function show_person($row)
 {
     global $humo_option, $uri_path;
     $person_cls = new person_cls();
     $person_cls->construct($row);
     $name = $person_cls->person_name($row);
     if (CMS_SPECIFIC == "Joomla") {
         return '<td align="center"><a href="index.php?option=com_humo-gen&task=family&id=' . $row->pers_indexnr . '"><i><b>' . $name["standard_name"] . '</b></i> </a> </td>';
     } else {
         if ($humo_option["url_rewrite"] == "j") {
             // *** $uri_path generated in header.php ***
             return '<td align="center"><a href="' . $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $row->pers_indexnr . '/' . $row->pers_gedcomnumber . '/"><i><b>' . $name["standard_name"] . '</b></i> </a> </td>';
         } else {
             return '<td align="center"><a href="family.php?id=' . $row->pers_indexnr . '"><i><b>' . $name["standard_name"] . '</b></i> </a> </td>';
         }
     }
 }
function outline($family_id, $main_person, $gn, $nr_generations)
{
    global $dbh, $db_functions, $tree_prefix_quoted, $pdf, $show_date, $dates_behind_names, $nr_generations;
    global $language, $dirmark1, $dirmark1, $screen_mode;
    $family_nr = 1;
    //*** Process multiple families ***
    if ($nr_generations < $gn) {
        return;
    }
    $gn++;
    // *** Count marriages of man ***
    // *** YB: if needed show woman as main_person ***
    @($familyDb = $db_functions->get_family($family_id, 'man-woman'));
    $parent1 = '';
    $parent2 = '';
    $change_main_person = false;
    // *** Standard main_person is the father ***
    if ($familyDb->fam_man) {
        $parent1 = $familyDb->fam_man;
    }
    // *** If mother is selected, mother will be main_person ***
    if ($familyDb->fam_woman == $main_person) {
        $parent1 = $familyDb->fam_woman;
        $change_main_person = true;
    }
    // *** Check family with parent1: N.N. ***
    if ($parent1) {
        // *** Save man's families in array ***
        @($personDb = $db_functions->get_person($parent1, 'famc-fams'));
        $marriage_array = explode(";", $personDb->pers_fams);
        $nr_families = substr_count($personDb->pers_fams, ";");
    } else {
        $marriage_array[0] = $family_id;
        $nr_families = "0";
    }
    // *** Loop multiple marriages of main_person ***
    for ($parent1_marr = 0; $parent1_marr <= $nr_families; $parent1_marr++) {
        @($familyDb = $db_functions->get_family($marriage_array[$parent1_marr]));
        // *** Privacy filter man and woman ***
        @($person_manDb = $db_functions->get_person($familyDb->fam_man));
        $man_cls = new person_cls();
        $man_cls->construct($person_manDb);
        $privacy_man = $man_cls->privacy;
        @($person_womanDb = $db_functions->get_person($familyDb->fam_woman));
        $woman_cls = new person_cls();
        $woman_cls->construct($person_womanDb);
        $privacy_woman = $woman_cls->privacy;
        $marriage_cls = new marriage_cls();
        $marriage_cls->construct($familyDb, $privacy_man, $privacy_woman);
        $familylevend = $marriage_cls->privacy;
        // *************************************************************
        // *** Parent1 (normally the father)                         ***
        // *************************************************************
        if ($familyDb->fam_kind != 'PRO-GEN') {
            //onecht kind, vrouw zonder man
            if ($family_nr == 1) {
                // *** Show data of man ***
                $dir = "";
                if ($language["dir"] == "rtl") {
                    $dir = "rtl";
                    // in the following code calls the css indentation for rtl pages: "div.rtlsub2" instead of "div.sub2"
                }
                $indent = $dir . 'sub' . $gn;
                // hier wordt de indent bepaald voor de namen div class (sub1, sub2 enz. die in gedcom.css staan)
                if ($screen_mode != "PDF") {
                    echo '<div class="' . $indent . '">';
                    echo '<b>' . $gn . ' </b>';
                } else {
                    $pdf->SetLeftMargin($gn * 10);
                    $pdf->Write(8, "\n");
                    $pdf->Write(8, $gn . '  ');
                }
                if ($change_main_person == true) {
                    if ($screen_mode != "PDF") {
                        echo $woman_cls->name_extended("outline");
                    } else {
                        $pdf->SetFont('Arial', 'B', 12);
                        $pdf->Write(8, $woman_cls->name_extended("outline"));
                        $pdf->SetFont('Arial', '', 12);
                    }
                    if ($show_date == "1" and !$privacy_woman) {
                        if ($screen_mode != "PDF") {
                            echo $dirmark1 . ',';
                            if ($dates_behind_names == false) {
                                echo '<br>';
                            }
                            echo ' &nbsp; (' . language_date($person_womanDb->pers_birth_date) . ' - ' . language_date($person_womanDb->pers_death_date) . ')';
                        } else {
                            if ($dates_behind_names == false) {
                                $pdf->SetLeftMargin($gn * 10 + 4);
                                $pdf->Write(8, "\n");
                            }
                            $pdf->Write(8, ' (' . language_date($person_womanDb->pers_birth_date) . ' - ' . language_date($person_womanDb->pers_death_date) . ')');
                        }
                    }
                } else {
                    if ($screen_mode != "PDF") {
                        echo $man_cls->name_extended("outline");
                    } else {
                        $pdf->SetFont('Arial', 'B', 12);
                        $pdf->Write(8, $man_cls->name_extended("outline"));
                        $pdf->SetFont('Arial', '', 12);
                    }
                    if ($show_date == "1" and !$privacy_man) {
                        if ($screen_mode != "PDF") {
                            echo $dirmark1 . ',';
                            if ($dates_behind_names == false) {
                                echo '<br>';
                            }
                            echo ' &nbsp; (' . language_date($person_manDb->pers_birth_date) . ' - ' . language_date($person_manDb->pers_death_date) . ')';
                        } else {
                            if ($dates_behind_names == false) {
                                $pdf->SetLeftMargin($gn * 10 + 4);
                                $pdf->Write(8, "\n");
                            }
                            $pdf->Write(8, ' (' . language_date($person_manDb->pers_birth_date) . ' - ' . language_date($person_manDb->pers_death_date) . ')');
                        }
                    }
                }
                if ($screen_mode != "PDF") {
                    echo '</div>';
                }
            } else {
            }
            // empty: no second show of data of main_person in outline report
            $family_nr++;
        }
        // *** end check of PRO-GEN ***
        // *************************************************************
        // *** Parent2 (normally the mother)                         ***
        // *************************************************************
        if ($screen_mode != "PDF") {
            echo '<div class="' . $indent . '" style="font-style:italic">';
            echo ' x ' . $dirmark1;
        } else {
            $pdf->SetLeftMargin($gn * 10);
            $pdf->Write(8, "\n");
            $pdf->Write(8, 'x  ');
        }
        if ($change_main_person == true) {
            if ($screen_mode != "PDF") {
                echo $man_cls->name_extended("outline");
            } else {
                $pdf->SetFont('Arial', 'BI', 12);
                $pdf->Write(8, $man_cls->name_extended("outline"));
                $pdf->SetFont('Arial', '', 12);
            }
            if ($show_date == "1" and !$privacy_man) {
                if ($screen_mode != "PDF") {
                    echo $dirmark1 . ',';
                    if ($dates_behind_names == false) {
                        echo '<br>';
                    }
                    echo ' &nbsp; (' . @language_date($person_manDb->pers_birth_date) . ' - ' . @language_date($person_manDb->pers_death_date) . ')';
                } else {
                    if ($dates_behind_names == false) {
                        $pdf->SetLeftMargin($gn * 10 + 4);
                        $pdf->Write(8, "\n");
                    }
                    $pdf->Write(8, ' (' . @language_date($person_manDb->pers_birth_date) . ' - ' . @language_date($person_manDb->pers_death_date) . ')');
                }
            }
        } else {
            if ($screen_mode != "PDF") {
                echo $woman_cls->name_extended("outline");
            } else {
                $pdf->SetFont('Arial', 'BI', 12);
                $pdf->Write(8, $woman_cls->name_extended("outline"));
                $pdf->SetFont('Arial', '', 12);
            }
            if ($show_date == "1" and !$privacy_woman) {
                if ($screen_mode != "PDF") {
                    echo $dirmark1 . ',';
                    if ($dates_behind_names == false) {
                        echo '<br>';
                    }
                    echo ' &nbsp; (' . @language_date($person_womanDb->pers_birth_date) . ' - ' . @language_date($person_womanDb->pers_death_date) . ')';
                } else {
                    if ($dates_behind_names == false) {
                        $pdf->SetLeftMargin($gn * 10 + 4);
                        $pdf->Write(8, "\n");
                    }
                    $pdf->Write(8, ' (' . @language_date($person_womanDb->pers_birth_date) . ' - ' . @language_date($person_womanDb->pers_death_date) . ')');
                }
            }
        }
        if ($screen_mode != "PDF") {
            echo '</div>';
        }
        // *************************************************************
        // *** Children                                              ***
        // *************************************************************
        if ($familyDb->fam_children) {
            $childnr = 1;
            $child_array = explode(";", $familyDb->fam_children);
            for ($i = 0; $i <= substr_count("{$familyDb->fam_children}", ";"); $i++) {
                @($childDb = $db_functions->get_person($child_array[$i]));
                $child_privacy = "";
                $child_cls = new person_cls();
                $child_cls->construct($childDb);
                $child_privacy = $child_cls->privacy;
                // *** Build descendant_report ***
                if ($childDb->pers_fams) {
                    // *** 1e family of child ***
                    $child_family = explode(";", $childDb->pers_fams);
                    $child1stfam = $child_family[0];
                    outline($child1stfam, $childDb->pers_gedcomnumber, $gn, $nr_generations);
                    // recursive
                } else {
                    // Child without own family
                    if ($nr_generations >= $gn) {
                        $childgn = $gn + 1;
                        $childindent = $dir . 'sub' . $childgn;
                        if ($screen_mode != "PDF") {
                            echo '<div class="' . $childindent . '">';
                            echo '<b>' . $childgn . ' ' . '</b>';
                            echo $child_cls->name_extended("outline");
                        } else {
                            $pdf->SetLeftMargin($childgn * 10);
                            $pdf->Write(8, "\n");
                            $pdf->Write(8, $childgn . '  ');
                            $pdf->SetFont('Arial', 'B', 12);
                            $pdf->Write(8, $child_cls->name_extended("outline"));
                            $pdf->SetFont('Arial', '', 12);
                        }
                        if ($show_date == "1" and !$child_privacy) {
                            if ($screen_mode != "PDF") {
                                echo $dirmark1 . ',';
                                if ($dates_behind_names == false) {
                                    echo '<br>';
                                }
                                echo ' &nbsp; (' . language_date($childDb->pers_birth_date) . ' - ' . language_date($childDb->pers_death_date) . ')';
                            } else {
                                if ($dates_behind_names == false) {
                                    $pdf->SetLeftMargin($childgn * 10 + 4);
                                    $pdf->Write(8, "\n");
                                }
                                $pdf->Write(8, ' (' . language_date($childDb->pers_birth_date) . ' - ' . language_date($childDb->pers_death_date) . ')');
                            }
                        }
                        if ($screen_mode != "PDF") {
                            echo '</div>';
                        }
                    }
                }
                if ($screen_mode != "PDF") {
                    echo "\n";
                } else {
                }
                $childnr++;
            }
        }
    }
    // Show  multiple marriages
}
     $picture_text2 .= $name["standard_name"] . '<br>';
     $privacy = $person_cls->set_privacy($personDb);
     if ($privacy) {
         $picture_privacy = true;
     }
     if ($afbDb->event_text != '') {
         $picture_text .= $afbDb->event_text . '<br>';
         $picture_text2 .= $afbDb->event_text . '<br>';
     }
 }
 // *** Show texts from connected objects ***
 $picture_qry = $dbh->query("SELECT * FROM humo_events\n\t\t\tWHERE event_tree_id='" . $tree_id . "' AND event_kind='object' AND LOWER(event_event)='" . strtolower($filename) . "'");
 while ($pictureDb = $picture_qry->fetch(PDO::FETCH_OBJ)) {
     $connect_qry = $dbh->query("SELECT * FROM humo_connections\n\t\t\t\tWHERE connect_tree_id='" . $tree_id . "'\n\t\t\t\tAND connect_sub_kind='pers_object'\n\t\t\t\tAND connect_source_id='" . $pictureDb->event_gedcomnr . "'");
     while ($connectDb = $connect_qry->fetch(PDO::FETCH_OBJ)) {
         $person_cls = new person_cls();
         @($personDb = $db_functions->get_person($connectDb->connect_connect_id));
         $name = $person_cls->person_name($personDb);
         $picture_text .= '<a href="' . CMS_ROOTPATH . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">' . $name["standard_name"] . '</a><br>';
         $picture_text2 .= $name["standard_name"] . '<br>';
         $privacy = $person_cls->set_privacy($personDb);
         if ($privacy) {
             $picture_privacy = true;
         }
         $picture_text .= $pictureDb->event_text . '<br>';
         $picture_text2 .= $pictureDb->event_text . '<br>';
     }
 }
 $picture2 = show_picture($dir, $filename, 175, 120);
 $picture = '<img src="' . $dir . $picture2['thumb'] . $picture2['picture'] . '" width="' . $picture2['width'] . '" alt="' . $filename . '"></a>';
 echo '<div class="photobook">';
function mapbirthplace($place)
{
    global $dbh, $tree_id, $language, $map_max;
    if (isset($_GET['namestring'])) {
        $temparray = explode("@", $_GET['namestring']);
        $namestring = " (";
        foreach ($temparray as $value) {
            //echo $value.'<br>';
            //$namestring .=  "pers_lastname = '".$value."' OR ";
            $namestring .= "CONCAT(pers_lastname,'_',LOWER(SUBSTRING_INDEX(pers_prefix,'_',1))) = '" . $value . "' OR ";
        }
        $namestring = substr($namestring, 0, -3) . ") AND ";
        //echo $namestring;
    } else {
        $namestring = '';
    }
    $desc_arr = '';
    $idstring = '';
    if (isset($_SESSION['desc_array'])) {
        $desc_arr = $_SESSION['desc_array'];
        $idstring = ' (';
        foreach ($desc_arr as $value) {
            $idstring .= " pers_gedcomnumber = '" . $value . "' OR ";
        }
        $idstring = substr($idstring, 0, -3) . ') AND ';
    }
    $min = 1;
    if ($place != "NONFOUND") {
        if ($_SESSION['type_birth'] == 1) {
            if (isset($_GET['all'])) {
                // the 'All birth locations' button
                echo '<b><u>' . __('All persons born here: ') . '</u></b><br>';
                //$maplist=$dbh->query("SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename FROM ".safe_text($_SESSION['tree_prefix'])."person WHERE ".$idstring.$namestring." (pers_birth_place = '".$place."' OR (pers_birth_place = '' AND pers_bapt_place = '".$place."')) ORDER BY wholename");
                $sql = "SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename\n\t\t\t\t\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "'\n\t\t\t\t\tAND " . $idstring . $namestring . " (pers_birth_place = '" . $place . "' OR (pers_birth_place = '' AND pers_bapt_place = '" . $place . "')) ORDER BY wholename";
                $maplist = $dbh->query($sql);
            } else {
                // the slider
                echo '<b><u>' . __('Persons born here until ') . $map_max . ':</u></b><br>';
                $sql = "SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename FROM humo_persons\n\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "'\n\t\t\t\t\tAND " . $idstring . $namestring . " (pers_birth_place = '" . $place . "' OR (pers_birth_place = '' AND pers_bapt_place = '" . $place . "'))\n\t\t\t\t\tAND ((SUBSTR(pers_birth_date,-LEAST(4,CHAR_LENGTH(pers_birth_date))) < " . $map_max . "\n\t\t\t\t\tAND SUBSTR(pers_birth_date,-LEAST(4,CHAR_LENGTH(pers_birth_date))) > " . $min . ")\n\t\t\t\t\tOR (pers_birth_date='' AND SUBSTR(pers_bapt_date,-LEAST(4,CHAR_LENGTH(pers_bapt_date))) < " . $map_max . "\n\t\t\t\t\t\tAND SUBSTR(pers_bapt_date,-LEAST(4,CHAR_LENGTH(pers_bapt_date))) > " . $min . "))\n\t\t\t\t\tORDER BY wholename";
                $maplist = $dbh->query($sql);
            }
        } elseif ($_SESSION['type_death'] == 1) {
            if (isset($_GET['all'])) {
                // the 'All birth locations' button
                echo '<b><u>' . __('All persons that died here: ') . '</u></b><br>';
                //$maplist=$dbh->query("SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename FROM ".safe_text($_SESSION['tree_prefix'])."person WHERE ".$idstring.$namestring." (pers_death_place = '".$place."' OR (pers_death_place = '' AND pers_buried_place = '".$place."')) ORDER BY wholename");
                $sql = "SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename\n\t\t\t\t\tFROM humo_persons\n\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "'\n\t\t\t\t\tAND " . $idstring . $namestring . "\n\t\t\t\t\t(pers_death_place = '" . $place . "' OR (pers_death_place = '' AND pers_buried_place = '" . $place . "'))\n\t\t\t\t\tORDER BY wholename";
                $maplist = $dbh->query($sql);
            } else {
                // the slider
                echo '<b><u>' . __('Persons that died here until ') . $map_max . ':</u></b><br>';
                $sql = "SELECT * , CONCAT(pers_lastname,pers_firstname) AS wholename FROM humo_persons\n\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND " . $idstring . $namestring . "\n\t\t\t\t\t(pers_death_place = '" . $place . "' OR (pers_death_place = '' AND pers_buried_place = '" . $place . "')) AND\n\t\t\t\t\t((SUBSTR(pers_death_date,-LEAST(4,CHAR_LENGTH(pers_death_date))) < " . $map_max . " AND SUBSTR(pers_death_date,-LEAST(4,CHAR_LENGTH(pers_death_date))) > " . $min . ") OR\n\t\t\t\t\t(pers_death_date='' AND SUBSTR(pers_buried_date,-LEAST(4,CHAR_LENGTH(pers_buried_date))) < " . $map_max . " AND SUBSTR(pers_buried_date,-LEAST(4,CHAR_LENGTH(pers_buried_date))) > " . $min . "))\n\t\t\t\t\tORDER BY wholename";
                $maplist = $dbh->query($sql);
            }
        }
        //echo 'TEST: '.$sql;
        $man_cls = new person_cls();
        echo '<div style="direction:ltr">';
        while (@($maplistDb = $maplist->fetch(PDO::FETCH_OBJ))) {
            $man_cls->construct($maplistDb);
            $privacy_man = $man_cls->privacy;
            $name = $man_cls->person_name($maplistDb);
            if ($name["show_name"] == true) {
                echo '<a href=family.php?database=' . safe_text($_SESSION['tree_prefix']) . '&amp;id=' . $maplistDb->pers_indexnr . '&amp;main_person=' . $maplistDb->pers_gedcomnumber . ' target="blank">';
            }
            if ($_SESSION['type_birth'] == 1) {
                echo $name["index_name"];
                $date = $maplistDb->pers_birth_date;
                $sign = __('born') . ' ';
                if (!$maplistDb->pers_birth_date and $maplistDb->pers_bapt_date) {
                    $date = $maplistDb->pers_bapt_date;
                    $sign = __('baptised') . ' ';
                }
            }
            if ($_SESSION['type_death'] == 1) {
                echo $name["index_name"];
                $date = $maplistDb->pers_death_date;
                $sign = __('died') . ' ';
                if (!$maplistDb->pers_death_date and $maplistDb->pers_buried_date) {
                    $date = $maplistDb->pers_buried_date;
                    $sign = __('buried') . ' ';
                }
            }
            if (!$privacy_man and $date and $name["show_name"] == true) {
                echo ' (' . $sign . date_place($date, '') . ')';
            }
            if ($name["show_name"] == true) {
                echo '</a>';
            }
            echo '<br>';
        }
        echo '</div>';
    } else {
        // Logically we can never get here
        echo 'No persons found';
    }
}
function display_result($result)
{
    // $result holds the entire track of persons from person A to person B
    // this string is made up of items sperated by ";"
    // each items starts with "par" (parent), "chd" (child) or "spo" (spouse), followed by the gedcomnumber of the person
    // example: parI232;parI65;chdI2304;spoI212;parI304
    // the par-chd-spo prefixes indicate if the person was called up by his parent, child or spouse so we can later create the graphical display
    global $person, $person2, $db_functions;
    echo '<div style="padding:3px;width:auto;background-color:#eeeeee"><input type="submit" name="next_path" value="' . __('Try to find another path') . '" style="font-size:115%;">';
    echo '&nbsp;&nbsp;' . __('(With each consecutive search the path may get longer and computing time may increase!)') . '</div>';
    $fampath = CMS_ROOTPATH . "family.php?";
    $tree = safe_text($_SESSION['tree_prefix']);
    $map = array();
    // array that will hold all data needed for the graphical display
    $tracks = explode(";", $result);
    // $tracks is array with each person in the trail
    /* initialize  */
    for ($x = 0; $x < count($tracks); $x++) {
        $map[$x][0] = "1";
        /* x value in graphical display */
        $map[$x][1] = "1";
        /* y value in graphical display */
        $map[$x][2] = "1";
        /* colspan value (usually 1, turns 2 for two column parent) */
        $map[$x][3] = substr($tracks[$x], 0, 3);
        /* call value (oar, chd, spo) */
        $map[$x][4] = substr($tracks[$x], 3);
        /* gedcomnumber value */
    }
    $xval = 1;
    $yval = 1;
    $miny = 1;
    $maxy = 1;
    $marrsign = array();
    // fill map array
    for ($x = 0; $x < count($tracks); $x++) {
        $ged = substr($tracks[$x], 3);
        // gedcomnumber
        $cal = substr($tracks[$x], 0, 3);
        // par, chd, spo
        if ($cal == "fst") {
            continue;
        }
        if ($cal == "spo") {
            $marrsign[$xval + 1] = $yval;
            $xval += 2;
            $map[$x][0] = $xval;
            $map[$x][1] = $yval;
        }
        if ($cal == "chd") {
            $yval--;
            if ($yval < $miny) {
                $miny = $yval;
            }
            $map[$x][0] = $xval;
            $map[$x][1] = $yval;
            if (isset($map[$x + 1]) and $map[$x + 1][3] == "par") {
                $map[$x][2] = 2;
            }
        }
        if ($cal == "par") {
            $yval++;
            if ($yval > $maxy) {
                $maxy = $yval;
            }
            if ($map[$x - 1][3] == "chd") {
                $xval++;
            }
            $map[$x][0] = $xval;
            $map[$x][1] = $yval;
        }
    }
    if ($miny < 1) {
        for ($x = 0; $x < count($map); $x++) {
            $map[$x][1] += 1 + abs($miny);
            if ($map[$x][1] > $maxy) {
                $maxy = $map[$x][1];
            }
        }
        if (isset($marrsign)) {
            foreach ($marrsign as $key => $value) {
                $marrsign[$key] += 1 + abs($miny);
            }
        }
    }
    // the following code displays the graphical view of the found trail
    echo '<br><table style="border:0px;border-collapse:separate;border-spacing:30px 1px;">';
    for ($a = 1; $a <= $maxy; $a++) {
        echo "<tr>";
        $nextline = "";
        for ($b = 1; $b <= $xval; $b++) {
            $colsp = false;
            $marr = false;
            for ($x = 0; $x < count($map); $x++) {
                if ($map[$x][0] == $b and $map[$x][1] == $a) {
                    $color = "#8ceffd";
                    $border = "border:1px solid #777777;";
                    $ancDb = $db_functions->get_person($map[$x][4]);
                    if ($ancDb->pers_sexe == "M") {
                        $ext_cls = "extended_man ";
                    } else {
                        $ext_cls = "extended_woman ";
                    }
                    if ($map[$x][4] == $person or $map[$x][4] == $person2) {
                        // person A and B (first and last) get thicker border
                        $color = "#72fe95";
                        $border = "border:2px solid #666666;";
                    }
                    if ($map[$x][2] == 2) {
                        $b++;
                        echo '<td class="' . $ext_cls . '" colspan=2 style="width:200px;text-align:center;' . $border . 'padding:2px">';
                        $nextline .= "&#8593;@&#8595;@";
                        // up and down arrows under two column parent
                    } elseif (isset($map[$x + 1][3]) and $map[$x + 1][3] == "par") {
                        $nextline .= "&#8595;@";
                        // down arrow
                        echo '<td class="' . $ext_cls . '"  style="width:200px;text-align:center;' . $border . 'padding:2px">';
                    } elseif (isset($map[$x][3]) and $map[$x][3] == "chd") {
                        $nextline .= "&#8593;@";
                        // up arrow
                        echo '<td class="' . $ext_cls . '" style="width:200px;text-align:center;' . $border . 'padding:2px">';
                    } else {
                        $nextline .= "&nbsp;@";
                        // empty box
                        echo '<td class="' . $ext_cls . '" style="width:200px;text-align:center;' . $border . 'padding:2px">';
                    }
                    $pers_cls = new person_cls();
                    $name = $pers_cls->person_name($ancDb);
                    $personname = $name["name"];
                    echo "<a href='" . $fampath . "database=" . $tree . "&amp;id=" . $ancDb->pers_indexnr . "&amp;main_person=" . $ancDb->pers_gedcomnumber . "'>" . $personname . "</a>";
                    $colsp = true;
                }
            }
            if ($colsp == false) {
                if (isset($marrsign[$b]) and $marrsign[$b] == $a) {
                    // display the X sign between two married people
                    echo '<td style="font-weight:bold;font-size:130%;width:10px;text-align:center;border:0px;padding:0px">X';
                } else {
                    echo '<td style="width:10px;text-align:center;border:0px;padding:0px">';
                }
                $nextline .= "&nbsp;@";
            }
            echo "</td>";
        }
        echo "</tr>";
        // The following code places a row with arrows (or blanks) under a row with name boxes
        if ($a != $maxy) {
            echo "<tr>";
            $nextline = substr($nextline, 0, -1);
            $next = explode("@", $nextline);
            foreach ($next as $value) {
                echo "<td style='padding:2px;color:black;width:10px;font-weight:bold;font-size:140%;text-align:center;'>" . $value . "</td>";
            }
            echo "</tr>";
        }
    }
    echo "</table>";
}
Exemple #17
0
         $key = array_search($familyDb->fam_marr_place, $location_array);
         if (isset($key) and $key > 0) {
             $text_array[$key] .= "\\n" . addslashes($google_name . ", " . strtolower(__('Married')) . ' ' . $familyDb->fam_marr_place);
         } else {
             $location_array[] = $familyDb->fam_marr_place;
             $lat_array[] = $info['location_lat'];
             $lon_array[] = $info['location_lng'];
             $text_array[] = addslashes($google_name . ", " . strtolower(__('Married')) . ' ' . $familyDb->fam_marr_place);
         }
     }
 }
 $child_array = explode(";", $familyDb->fam_children);
 for ($i = 0; $i <= substr_count($familyDb->fam_children, ";"); $i++) {
     @($childDb = $db_functions->get_person($child_array[$i]));
     // *** Use person class ***
     $person_cls = new person_cls();
     $person_cls->construct($childDb);
     if ($person_cls->privacy == '') {
         // *** Child birth ***
         $location_var = $childDb->pers_birth_place;
         $location_prep->execute();
         $child_result = $location_prep->rowCount();
         if ($child_result > 0) {
             $info = $location_prep->fetch();
             $name = $person_cls->person_name($childDb);
             $google_name = $name["standard_name"];
             $key = array_search($childDb->pers_birth_place, $location_array);
             if (isset($key) and $key > 0) {
                 $text_array[$key] .= "\\n" . addslashes($google_name . ", " . __('BORN_SHORT') . ' ' . $childDb->pers_birth_place);
             } else {
                 $location_array[] = $childDb->pers_birth_place;
    function tree_merge()
    {
        global $dbh, $data2Db, $phpself;
        global $page, $language, $tree_id, $menu_admin, $relatives_merge, $merge_chars;
        // check for stored settings and if not present set them
        $relatives_merge = '';
        $qry = "SELECT * FROM humo_settings WHERE setting_variable = 'rel_merge_" . $data2Db->tree_prefix . "'";
        $relmerge = $dbh->query($qry);
        if ($relmerge->rowCount() > 0) {
            $relmergeDb = $relmerge->fetch(PDO::FETCH_OBJ);
            $relatives_merge = $relmergeDb->setting_value;
        } else {
            // the rel_merge row didn't exist yet - make it, with empty value
            $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('rel_merge_" . $data2Db->tree_prefix . "', '')");
        }
        $result = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_chars'");
        // get it
        if ($result->rowCount() > 0) {
            $resultDb = $result->fetch(PDO::FETCH_OBJ);
            $merge_chars = $resultDb->setting_value;
        } else {
            $result = $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('merge_chars', '10')");
        }
        $result = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_lastname'");
        if ($result->rowCount() > 0) {
            $resultDb = $result->fetch(PDO::FETCH_OBJ);
            $merge_lastname = $resultDb->setting_value;
        } else {
            $result = $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('merge_lastname', 'YES')");
        }
        $result = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_firstname'");
        if ($result->rowCount() > 0) {
            $resultDb = $result->fetch(PDO::FETCH_OBJ);
            $merge_firstname = $resultDb->setting_value;
        } else {
            $result = $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('merge_firstname', 'YES')");
        }
        $result = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_dates'");
        if ($result->rowCount() > 0) {
            $resultDb = $result->fetch(PDO::FETCH_OBJ);
            $merge_dates = $resultDb->setting_value;
        } else {
            $result = $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('merge_dates', 'YES')");
        }
        $result = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_parentsdate'");
        if ($result->rowCount() > 0) {
            $resultDb = $result->fetch(PDO::FETCH_OBJ);
            $merge_parentsdate = $resultDb->setting_value;
        } else {
            $result = $dbh->query("INSERT INTO humo_settings (setting_variable, setting_value) VALUES ('merge_parentsdate', 'YES')");
        }
        // the following creates the pages that cycle through all duplicates that are stored in the dupl_arr array
        // the pages themselves are presented with the "show_pair function"
        if (isset($_POST['duplicate_compare'])) {
            if (!isset($_POST['no_increase'])) {
                // no increase is used if "switch left and right" was chosen
                $nr = ++$_SESSION['present_compare_' . $data2Db->tree_prefix];
                // present_compare is the pair that has to be shown next - saved to session
            } else {
                $nr = $_SESSION['present_compare_' . $data2Db->tree_prefix];
            }
            if (isset($_POST['choice_nr'])) {
                // choice number is the number from the "skip to" pulldown - saved to a session
                $nr = $_POST['choice_nr'];
                $_SESSION['present_compare_' . $data2Db->tree_prefix] = $_POST['choice_nr'];
            }
            // make sure the persons in the array are still there (in case in the mean time someone was merged)
            // after all, one person may be compared to more than one other person!
            while ($_SESSION['present_compare_' . $data2Db->tree_prefix] < count($_SESSION['dupl_arr_' . $data2Db->tree_prefix])) {
                $comp_set = explode(';', $_SESSION['dupl_arr_' . $data2Db->tree_prefix][$nr]);
                $qry = "SELECT * FROM humo_persons WHERE pers_id ='" . $comp_set[0] . "'";
                $res = $dbh->query($qry);
                $qry = "SELECT * FROM humo_persons WHERE pers_id ='" . $comp_set[1] . "'";
                $res2 = $dbh->query($qry);
                if (!$res or !$res2) {
                    // one or 2 persons are missing - continue with next pair
                    $nr = ++$_SESSION['present_compare_' . $data2Db->tree_prefix];
                    continue;
                    // look for next pair in array
                } else {
                    // we have got a valid pair
                    echo '<br' . __('Carefully compare these two persons. Only if you are <b>absolutely sure</b> they are identical, press "Merge right into left".<br>
If you don\'t want to merge, press "SKIP" to continue to the next pair of possible duplicates') . '<br><br>';
                    $left = $comp_set[0];
                    $right = $comp_set[1];
                    if (isset($_POST['left'])) {
                        $left = $_POST['left'];
                    }
                    if (isset($_POST['right'])) {
                        $right = $_POST['right'];
                    }
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                    echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                    echo '<input type="hidden" name="page" value="' . $page . '">';
                    echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                    echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                    echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                    echo '</form>';
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                    echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                    echo '<input type="hidden" name="page" value="' . $page . '">';
                    echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                    echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                    echo '<input type="hidden" name="no_increase" value="1">';
                    echo '<input type="hidden" name="left" value="' . $right . '">';
                    echo '<input type="hidden" name="right" value="' . $left . '">';
                    echo '<input type="Submit" name="duplicate_compare" value="' . __('<- Switch left and right ->') . '">';
                    echo '</form>';
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                    echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                    echo '<input type="hidden" name="page" value="' . $page . '">';
                    echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                    echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                    echo '<input type="Submit" name="duplicate_compare" value="' . __('Skip to next') . '">';
                    echo '</form>';
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;' . __('Skip to nr: ');
                    echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                    echo '<input type="hidden" name="page" value="' . $page . '">';
                    echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                    echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                    echo '<select style="max-width:60px" name="choice_nr">';
                    for ($x = 0; $x < count($_SESSION['dupl_arr_' . $data2Db->tree_prefix]); $x++) {
                        $selected = '';
                        if ($x == $_SESSION['present_compare_' . $data2Db->tree_prefix]) {
                            $selected = "SELECTED";
                        }
                        echo '<option value="' . $x . '" ' . $selected . '>' . ($x + 1) . '</option>';
                    }
                    echo '</select>';
                    echo '<input type="Submit" name="duplicate_compare" value="' . __('Go!') . '">';
                    echo '</form>';
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                    echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                    echo '<input type="hidden" name="page" value="' . $page . '">';
                    echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                    echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                    echo '<input type="hidden" name="dupl" value="1">';
                    echo '<input type="Submit" name="merge" value="' . __('Merge right into left') . '">';
                    echo '<br><br>';
                    $this->show_pair($left, $right, 'duplicate');
                    echo '<br>';
                    echo '</form>';
                    break;
                    // get out of the while loop. next loop will be called by skip or merge buttons
                }
            }
            if ($_SESSION['present_compare_' . $data2Db->tree_prefix] >= count($_SESSION['dupl_arr_' . $data2Db->tree_prefix])) {
                unset($_SESSION['present_compare_' . $data2Db->tree_prefix]);
                echo '<br><br>' . __('No more duplicates found') . '<br><br>';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                echo '</form>';
            }
        } elseif (isset($_POST['manual_compare'])) {
            // check if persons are of opposite sex - if so don't continue
            $qry1 = "SELECT * FROM humo_persons WHERE pers_id ='" . $_POST['left'] . "'";
            // left person
            $per1 = $dbh->query($qry1);
            $per1Db = $per1->fetch(PDO::FETCH_OBJ);
            $qry2 = "SELECT * FROM humo_persons WHERE pers_id ='" . $_POST['right'] . "'";
            // right person
            $per2 = $dbh->query($qry2);
            $per2Db = $per2->fetch(PDO::FETCH_OBJ);
            if ($per1Db->pers_sexe != $per2Db->pers_sexe) {
                // trying to merge opposite sexes
                echo '<br>' . __('You cannot merge persons of opposite sex. Please try again') . '.<br><br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="manual" value="' . __('Choose another pair') . '">';
                echo '</form>';
            } elseif ($per1Db->pers_gedcomnumber == $per2Db->pers_gedcomnumber) {
                // trying to merge same person!!
                echo '<br>' . __('This is one person already - you can\'t merge! Please try again') . '<br><br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="manual" value="' . __('Choose another pair') . '">';
                echo '</form>';
            } else {
                echo '<br>' . __('Carefully compare these two persons. Only if you are <b>absolutely sure</b> they are identical, press "Merge right into left"') . '.<br>';
                echo __('The checked items will be the ones entered into the database for the merged person. You can change the default settings') . '<br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                echo '</form>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="hidden" name="left" value="' . $_POST['right'] . '">';
                echo '<input type="hidden" name="right" value="' . $_POST['left'] . '">';
                echo '<input type="Submit" name="manual_compare" value="' . __('<- Switch left and right ->') . '">';
                echo '</form>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="manual" value="' . __('Choose another pair') . '">';
                echo '</form>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="hidden" name="manu" value="1">';
                echo '<input type="hidden" name="left" value="' . $_POST['left'] . '">';
                echo '<input type="hidden" name="right" value="' . $_POST['right'] . '">';
                echo '<input type="Submit" name="merge" value="' . __('Merge right into left') . '">';
                echo '<br><br>';
                $this->show_pair($_POST['left'], $_POST['right'], 'manual');
                echo '<br>';
                echo '</form>';
            }
        } elseif (isset($_POST['relatives'])) {
            // if skip - delete pair from database string
            if (isset($_POST['skip_rel'])) {
                // remove first entry (that the admin decided not to merge) from string
                $relcomp = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'rel_merge_" . $data2Db->tree_prefix . "'");
                $relcompDb = $relcomp->fetch(PDO::FETCH_OBJ);
                // database row: I23@I300;I54@I304;I34@I430;
                $firstsemi = strpos($relcompDb->setting_value, ';') + 1;
                $string = substr($relcompDb->setting_value, $firstsemi);
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $string . "' WHERE setting_variable = 'rel_merge_" . $data2Db->tree_prefix . "'");
                $relatives_merge = $string;
            }
            // merge
            if (isset($_POST['rela'])) {
                // the merge button was used
                $left = $_POST['left'];
                $right = $_POST['right'];
                $this->merge_them($left, $right, "relatives");
            }
            $relcomp = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'rel_merge_" . $data2Db->tree_prefix . "'");
            $relcompDb = $relcomp->fetch(PDO::FETCH_OBJ);
            // database row: I23@I300;I54@I304;I34@I430;
            if ($relcompDb->setting_value != '') {
                if (!isset($_POST['swap'])) {
                    $allpairs = explode(';', $relcompDb->setting_value);
                    // $allpairs[0]:  I23@I300
                    $pair = explode('@', $allpairs[0]);
                    // $pair[0]:  I23;
                    $lft = $pair[0];
                    // I23
                    $rght = $pair[1];
                    // I300
                    $leftqry = $dbh->query("SELECT * FROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber ='" . $lft . "'");
                    $leftDb = $leftqry->fetch(PDO::FETCH_OBJ);
                    $left = $leftDb->pers_id;
                    $rightqry = $dbh->query("SELECT * FROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber ='" . $rght . "'");
                    $rightDb = $rightqry->fetch(PDO::FETCH_OBJ);
                    $right = $rightDb->pers_id;
                } else {
                    // "switch left-right" button used"
                    $left = $_POST['left'];
                    $right = $_POST['right'];
                }
                echo '<br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                echo '</form>';
                // button skip
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="hidden" name="skip_rel" value="1">';
                echo '<input type="Submit" name="relatives" value="' . __('Skip to next') . '">';
                echo '</form>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="hidden" name="swap" value="1">';
                echo '<input type="hidden" name="left" value="' . $right . '">';
                echo '<input type="hidden" name="right" value="' . $left . '">';
                echo '<input type="Submit" name="relatives" value="' . __('<- Switch left and right ->') . '">';
                echo '</form>';
                // button merge
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="hidden" name="left" value="' . $left . '">';
                echo '<input type="hidden" name="right" value="' . $right . '">';
                echo '<input type="hidden" name="rela" value="1">';
                echo '<input type="Submit" name="relatives" value="' . __('Merge right into left') . '">';
                echo '<br><br>';
                $this->show_pair($left, $right, 'relatives');
                echo '<br>';
                echo '</form>';
            } else {
                echo '<br><br>' . __('No more surrounding relatives to check') . '.<br><br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                echo '</form>';
            }
        } elseif (isset($_POST['merge'])) {
            // do merge and allow to continue with comparing duplicates
            if (isset($_POST['manu'])) {
                $left = $_POST['left'];
                $right = $_POST['right'];
                $this->merge_them($left, $right, "man_dupl");
                // merge_them is called in manual/duplicate mode
            } elseif (isset($_POST['dupl'])) {
                // duplicate merging
                $nr = $_SESSION['present_compare_' . $data2Db->tree_prefix];
                $comp_set = explode(';', $_SESSION['dupl_arr_' . $data2Db->tree_prefix][$nr]);
                $left = $comp_set[0];
                $right = $comp_set[1];
                $this->merge_them($left, $right, "man_dupl");
                // merge_them is called in manual/duplicate mode
            }
        } elseif (isset($_POST['duplicate_choices'])) {
            echo '<br>';
            echo __('With "Duplicate merge" the program will look for all persons with a fixed set of criteria for identical data.
These are:
<ul><li>Same last name and same first name.<br>
By default, people with blank first or last names are included. You can disable that under "Settings" in the main menu.</li>
<li>Same birthdate or same deathdate.<br>
By default, when one or both persons have a missing birth/death date they will still be included when the name matches.
You can change that under "Settings" in the main menu.</li></ul>
The found duplicates will be presented to you, one pair after the other, with their details.<br>
You can then decide whether to accept the default merge, or change which details of the right person will be merged into the left.<br>
If you decide not to merge this pair, you can "skip" to the next pair.<br>
If after the merge there are surrounding relatives that might need merging too, you will be urged to move to "Relatives merge"<br>
If you have interrupted a duplicate merge in this session (for example to move to "relatives merge"),
this page will also show a "Continue duplicate merge" button so you can continue where you left off.<br>
<b>Please note that generating the duplicates may take some time, depending on the size of the tree.</b>');
            echo '<br><br>';
            if (isset($_SESSION['dupl_arr_' . $data2Db->tree_prefix])) {
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" style="min-width:150px" name="duplicate_compare" value="' . __('Continue duplicate merge') . '">';
                echo '</form>';
            }
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" style="min-width:150px" name="duplicate" value="' . __('Generate new duplicate merge') . '">';
            echo '</form>';
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
            echo '</form>';
        } elseif (isset($_POST['duplicate'])) {
            echo __('Please wait while duplicate list is generated') . '<br>';
            $qry = "SELECT pers_id,pers_firstname,pers_lastname, pers_birth_date, pers_death_date\n\t\t\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "' ORDER BY pers_id";
            $pers = $dbh->query($qry);
            unset($dupl_arr);
            // just to make sure...
            while ($persDb = $pers->fetch(PDO::FETCH_OBJ)) {
                // the exact phrasing of the query depends on the admin settings
                $qry2 = "SELECT pers_id,pers_firstname,pers_lastname, pers_birth_date, pers_death_date\n\t\t\t\tFROM humo_persons WHERE pers_id > " . $persDb->pers_id;
                if ($merge_firstname == 'YES') {
                    $qry2 .= " AND SUBSTR(pers_firstname,1," . $merge_chars . ") = SUBSTR('" . $persDb->pers_firstname . "',1," . $merge_chars . ")";
                } else {
                    $qry2 .= " AND pers_firstname != '' AND SUBSTR(pers_firstname,1," . $merge_chars . ") = SUBSTR('" . $persDb->pers_firstname . "',1," . $merge_chars . ")";
                }
                if ($merge_lastname == 'YES') {
                    $qry2 .= " AND pers_lastname ='" . $persDb->pers_lastname . "' ";
                } else {
                    $qry2 .= " AND pers_lastname != '' AND pers_lastname ='" . $persDb->pers_lastname . "' ";
                }
                if ($merge_dates == "YES") {
                    $qry2 .= " AND (pers_birth_date ='" . $persDb->pers_birth_date . "' OR pers_birth_date ='' OR '" . $persDb->pers_birth_date . "'='') ";
                    $qry2 .= " AND (pers_death_date ='" . $persDb->pers_death_date . "' OR pers_death_date ='' OR '" . $persDb->pers_death_date . "'='') ";
                } else {
                    $qry2 .= " AND (( pers_birth_date != '' AND pers_birth_date ='" . $persDb->pers_birth_date . "' AND !(pers_death_date != '" . $persDb->pers_death_date . "'))\n\t\t\t\t\tOR\n\t\t\t\t\t(  pers_death_date != '' AND pers_death_date ='" . $persDb->pers_death_date . "' AND !(pers_birth_date != '" . $persDb->pers_birth_date . "')) )";
                }
                $pers2 = $dbh->query($qry2);
                if ($pers2) {
                    while ($pers2Db = $pers2->fetch(PDO::FETCH_OBJ)) {
                        $dupl_arr[] = $persDb->pers_id . ';' . $pers2Db->pers_id;
                    }
                }
            }
            if (isset($dupl_arr)) {
                $_SESSION['dupl_arr_' . $data2Db->tree_prefix] = $dupl_arr;
                $_SESSION['present_compare_' . $data2Db->tree_prefix] = -1;
                echo '<br>' . __('Possible duplicates found: ') . count($dupl_arr) . '<br><br>';
                // possible duplicates found
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="duplicate_compare" value="' . __('Start comparing duplicates') . '">';
                // start comparing duplicates
                echo '</form>';
            } else {
                echo '<br>' . __('No duplicates found. Duplicate merge and Automatic merge won\'t result in merges!') . '<br>';
                // no duplicates were found
                echo __('You can try one of the other merge options') . '<br><br>';
                // try other options
                echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
                echo '</form>';
            }
        } elseif (isset($_POST['manual']) or isset($_POST["search1"]) or isset($_POST["search2"]) or isset($_POST["switch"])) {
            echo '<br>' . __('Pick the two persons you want to check for merging') . '.';
            echo ' ' . __('You can enter names (or part of names) or gedcom no. (INDI), or leave boxes empty') . '<br>';
            echo __('<b>TIP: when you click "search" with all boxes left empty you will get a list with all persons in the database. (May take a few seconds)</b>') . '<br><br>';
            // ===== BEGIN SEARCH BOX SYSTEM
            include_once CMS_ROOTPATH . "include/person_cls.php";
            $pers_cls = new person_cls();
            if (!isset($_POST["search1"]) and !isset($_POST["search2"]) and !isset($_POST["manual_compare"]) and !isset($_POST["switch"])) {
                // no button pressed: this is a fresh entry from humogen's frontpage link: start clean search form
                $_SESSION["search1"] = '';
                $_SESSION["search2"] = '';
                $_SESSION['rel_search_firstname'] = '';
                $_SESSION['rel_search_lastname'] = '';
                $_SESSION['rel_search_firstname2'] = '';
                $_SESSION['rel_search_lastname2'] = '';
                $_SESSION['search_indi'] = '';
                $_SESSION['search_indi2'] = '';
            }
            $left = '';
            if (isset($_POST["left"])) {
                $left = $_POST['left'];
            }
            $right = '';
            if (isset($_POST["right"])) {
                $right = $_POST['right'];
            }
            if (isset($_POST["search1"])) {
                $_SESSION["search1"] = 1;
            }
            if (isset($_POST["search2"])) {
                $_SESSION["search2"] = 1;
            }
            if (isset($_POST["switch"])) {
                $temp = $_SESSION['rel_search_firstname'];
                $_SESSION['rel_search_firstname'] = $_SESSION['rel_search_firstname2'];
                $_SESSION['rel_search_firstname2'] = $temp;
                $temp = $_SESSION['rel_search_lastname'];
                $_SESSION['rel_search_lastname'] = $_SESSION['rel_search_lastname2'];
                $_SESSION['rel_search_lastname2'] = $temp;
                $temp = $_SESSION['search_indi'];
                $_SESSION['search_indi'] = $_SESSION['search_indi2'];
                $_SESSION['search_indi2'] = $temp;
                $temp = $left;
                $left = $right;
                $right = $temp;
                $temp = $_SESSION["search1"];
                $_SESSION["search1"] = $_SESSION["search2"];
                $_SESSION["search2"] = $temp;
            }
            // if joomla component will be continued the following line has to be adjusted for joomla
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<table class="humo" style="text-align:center; width:100%;">';
            echo '<tr class="table_header"><td>';
            echo '&nbsp;';
            echo '</td><td>';
            echo __('First name') . ':';
            echo '</td><td>';
            echo __('Last name') . ':';
            echo '</td><td>';
            echo __('gedcom no. ("I43")') . ':';
            echo '</td><td>';
            echo __('Search');
            echo '</td><td colspan=2>' . __('Pick a name from search results') . '</td><td>';
            echo __('Show details');
            echo '</td></tr><tr><td style="white-space:nowrap">';
            $language_person = __('Person') . ' ';
            if (CMS_SPECIFIC == "Joomla") {
                $language_person = '';
            }
            // for joomla keep it short....
            echo $language_person . '1:';
            echo '</td><td>';
            $search_firstname = '';
            if (isset($_POST["search_firstname"]) and !isset($_POST["switch"])) {
                $search_firstname = safe_text($_POST['search_firstname']);
                $_SESSION['rel_search_firstname'] = $search_firstname;
            }
            if (isset($_SESSION['rel_search_firstname'])) {
                $search_firstname = $_SESSION['rel_search_firstname'];
            }
            $search_lastname = '';
            if (isset($_POST["search_lastname"]) and !isset($_POST["switch"])) {
                $search_lastname = safe_text($_POST['search_lastname']);
                $_SESSION['rel_search_lastname'] = $search_lastname;
            }
            if (isset($_SESSION['rel_search_lastname'])) {
                $search_lastname = $_SESSION['rel_search_lastname'];
            }
            $search_indi = '';
            if (isset($_POST["search_indi"]) and !isset($_POST["switch"])) {
                $search_indi = safe_text($_POST['search_indi']);
                $_SESSION['search_indi'] = $search_indi;
            }
            if (isset($_SESSION['search_indi'])) {
                $search_indi = $_SESSION['search_indi'];
            }
            echo ' <input type="text" class="fonts relboxes" name="search_firstname" value="' . $search_firstname . '" size="15"> ';
            echo '</td><td>';
            echo '&nbsp; <input class="fonts relboxes" type="text" name="search_lastname" value="' . $search_lastname . '" size="15">';
            echo '</td><td>';
            echo ' <input type="text" class="fonts relboxes" name="search_indi" value="' . $search_indi . '" size="10"> ';
            echo '</td><td>';
            echo '&nbsp; <input class="fonts" type="submit" name="search1" value="' . __('Search') . '">';
            echo '</td><td>';
            $len = 230;
            // length of name pulldown box
            if (CMS_SPECIFIC == "Joomla") {
                $len = 180;
            }
            // for joomla keep it short....
            if (isset($_SESSION["search1"]) and $_SESSION["search1"] == 1) {
                $indi_string = "";
                if (isset($_SESSION["search_indi"]) and $_SESSION["search_indi"] != "") {
                    // make sure it works with "I436", "i436" and "436"
                    $indi = (substr($search_indi, 0, 1) == "I" or substr($search_indi, 0, 1) == "i") ? strtoupper($search_indi) : "I" . $search_indi;
                    $indi_string = " AND pers_gedcomnumber ='" . $indi . "' ";
                }
                $search_qry = "SELECT * FROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND CONCAT(REPLACE(pers_prefix,'_',' '),pers_lastname)";
                $search_qry .= " LIKE '%" . $search_lastname . "%' AND pers_firstname LIKE '%" . $search_firstname . "%' " . $indi_string . " ORDER BY pers_lastname, pers_firstname";
                $search_result = $dbh->query($search_qry);
                if ($search_result) {
                    if ($search_result->rowCount() > 0) {
                        echo '<select class="fonts" size="1" name="left"  style="width:' . $len . 'px">';
                        while ($searchDb = $search_result->fetch(PDO::FETCH_OBJ)) {
                            $name = $pers_cls->person_name($searchDb);
                            if ($name["show_name"]) {
                                echo '<option';
                                if (isset($left)) {
                                    if ($searchDb->pers_id == $left and !(isset($_POST["search1"]) and $search_lastname == '' and $search_firstname == '')) {
                                        echo ' SELECTED';
                                    }
                                }
                                echo ' value="' . $searchDb->pers_id . '">' . $name["index_name"] . ' [' . $searchDb->pers_gedcomnumber . ']</option>';
                            }
                        }
                        echo '</select>';
                    } else {
                        echo '<select size="1" name="notfound" value="1" style="width:' . $len . 'px"><option>' . __('Person not found') . '</option></select>';
                    }
                }
            } else {
                echo '<select size="1" name="left" style="width:' . $len . 'px"><option></option></select>';
            }
            echo '</td><td rowspan=2>';
            echo '<input type="submit" alt="' . __('Switch persons') . '" title="' . __('Switch persons') . '" value=" " name="switch" style="background: #fff url(\'' . CMS_ROOTPATH . 'images/turn_around.gif\') top no-repeat;width:25px;height:25px">';
            echo '</td><td rowspan=2>';
            echo '<input type="submit" name="manual_compare" value="' . __('Show details') . '" style="font-size:115%;">';
            echo '</td></tr><tr><td  style="white-space:nowrap">';
            // SECOND PERSON
            echo $language_person . '2:';
            echo '</td><td>';
            $search_firstname2 = '';
            if (isset($_POST["search_firstname2"]) and !isset($_POST["switch"])) {
                $search_firstname2 = safe_text($_POST['search_firstname2']);
                $_SESSION['rel_search_firstname2'] = $search_firstname2;
            }
            if (isset($_SESSION['rel_search_firstname2'])) {
                $search_firstname2 = $_SESSION['rel_search_firstname2'];
            }
            $search_lastname2 = '';
            if (isset($_POST["search_lastname2"]) and !isset($_POST["switch"])) {
                $search_lastname2 = safe_text($_POST['search_lastname2']);
                $_SESSION['rel_search_lastname2'] = $search_lastname2;
            }
            if (isset($_SESSION['rel_search_lastname2'])) {
                $search_lastname2 = $_SESSION['rel_search_lastname2'];
            }
            $search_indi2 = '';
            if (isset($_POST["search_indi2"]) and !isset($_POST["switch"])) {
                $search_indi2 = safe_text($_POST['search_indi2']);
                $_SESSION['search_indi2'] = $search_indi2;
            }
            if (isset($_SESSION['search_indi2'])) {
                $search_indi2 = $_SESSION['search_indi2'];
            }
            echo ' <input type="text" class="fonts relboxes" name="search_firstname2" value="' . $search_firstname2 . '" size="15"> ';
            echo '</td><td>';
            echo '&nbsp; <input class="fonts relboxes" type="text" name="search_lastname2" value="' . $search_lastname2 . '" size="15">';
            echo '</td><td>';
            echo ' <input type="text" class="fonts relboxes" name="search_indi2" value="' . $search_indi2 . '" size="10"> ';
            echo '</td><td>';
            echo '&nbsp; <input class="fonts" type="submit" name="search2" value="' . __('Search') . '">';
            echo '</td><td>';
            if (isset($_SESSION["search2"]) and $_SESSION["search2"] == 1) {
                $indi_string2 = "";
                if (isset($_SESSION["search_indi2"]) and $_SESSION["search_indi2"] != "") {
                    // make sure it works with "I436", "i436" and "436"
                    $indi2 = (substr($search_indi2, 0, 1) == "I" or substr($search_indi2, 0, 1) == "i") ? strtoupper($search_indi2) : "I" . $search_indi2;
                    $indi_string2 = " AND pers_gedcomnumber ='" . $indi2 . "' ";
                }
                $search_qry = "SELECT * FROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND CONCAT(REPLACE(pers_prefix,'_',' '),pers_lastname)";
                $search_qry .= " LIKE '%" . $search_lastname2 . "%' AND pers_firstname LIKE '%" . $search_firstname2 . "%' " . $indi_string2 . " ORDER BY pers_lastname, pers_firstname";
                $search_result2 = $dbh->query($search_qry);
                if ($search_result2) {
                    if ($search_result2->rowCount() > 0) {
                        echo '<select class="fonts" size="1" name="right" style="width:' . $len . 'px">';
                        while ($searchDb2 = $search_result2->fetch(PDO::FETCH_OBJ)) {
                            $name = $pers_cls->person_name($searchDb2);
                            if ($name["show_name"]) {
                                echo '<option';
                                if (isset($right)) {
                                    if ($searchDb2->pers_id == $right and !(isset($_POST["search2"]) and $search_lastname2 == '' and $search_firstname2 == '')) {
                                        echo ' SELECTED';
                                    }
                                }
                                echo ' value="' . $searchDb2->pers_id . '">' . $name["index_name"] . ' [' . $searchDb2->pers_gedcomnumber . ']</option>';
                            }
                        }
                        echo '</select>';
                    } else {
                        echo '<select size="1" name="notfound" value="1" style="width:' . $len . 'px"><option>' . __('Person not found') . '</option></select>';
                    }
                }
            } else {
                echo '<select size="1" name="right" style="width:' . $len . 'px"><option></option></select>';
            }
            echo '</td></tr></table>';
            echo '</form>';
            // ===== END SEARCH BOX SYSTEM
        } elseif (isset($_POST['automatic'])) {
            echo '<br>';
            echo __('Automatic merge will go through the entire database and merge all persons who comply with ALL the following conditions:<br>
<ul><li>Both persons have a first name and a last name and they are identical</li>
<li>Both persons have parents with first and last names and those names are identical</li>
<li>Both persons\' parents have a marriage date and it is identical (This can be disabled under "Settings")</li>
<li>Both persons have a birth date and it is identical OR both have a death date and it is identical</li></ul>
<b>Please note that the automatic merge may take quite some time, depending on the size of the database and the number of merges.</b><br>
You will be notified of results as the action is completed');
            echo '<br><br>';
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" name="auto_merge" value="' . __('Perform automatic merge') . '">';
            echo '</form>';
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
            echo '</form>';
        } elseif (isset($_POST['auto_merge'])) {
            echo '<br>' . __('Please wait while the automatic merges are processed...') . '<br>';
            $merges = 0;
            $qry = "SELECT pers_id, pers_lastname, pers_firstname, pers_birth_date, pers_death_date, pers_famc\n\t\t\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND\n\t\t\t\tpers_lastname !='' AND\n\t\t\t\tpers_firstname !='' AND\n\t\t\t\t(pers_birth_date !='' OR pers_death_date !='') AND\n\t\t\t\tpers_famc !=''\n\t\t\t\tORDER BY pers_id";
            $pers = $dbh->query($qry);
            while ($persDb = $pers->fetch(PDO::FETCH_OBJ)) {
                $qry2 = "SELECT pers_id, pers_lastname, pers_firstname, pers_birth_date, pers_death_date, pers_famc  FROM humo_persons WHERE\n\t\t\t\tpers_tree_id='" . $tree_id . "' AND\n\t\t\t\tpers_id > " . $persDb->pers_id . " AND\n\t\t\t\t(pers_lastname !='' AND pers_lastname = '" . $persDb->pers_lastname . "') AND\n\t\t\t\t(pers_firstname !='' AND pers_firstname = '" . $persDb->pers_firstname . "') AND\n\t\t\t\t((pers_birth_date !='' AND pers_birth_date ='" . $persDb->pers_birth_date . "') OR\n\t\t\t\t(pers_death_date !='' AND pers_death_date ='" . $persDb->pers_death_date . "')) AND\n\t\t\t\tpers_famc !=''\n\t\t\t\tORDER BY pers_id";
                $pers2 = $dbh->query($qry2);
                if ($pers2) {
                    while ($pers2Db = $pers2->fetch(PDO::FETCH_OBJ)) {
                        // get the two families
                        $qry = "SELECT fam_man, fam_woman, fam_marr_date FROM humo_families\n\t\t\t\t\t\t\tWHERE fam_tree_id='" . $tree_id . "' AND fam_gedcomnumber='" . $persDb->pers_famc . "'";
                        $fam1 = $dbh->query($qry);
                        $fam1Db = $fam1->fetch(PDO::FETCH_OBJ);
                        $qry = "SELECT * FROM humo_families WHERE fam_tree_id='" . $tree_id . "' AND fam_gedcomnumber='" . $pers2Db->pers_famc . "'";
                        $fam2 = $dbh->query($qry);
                        $fam2Db = $fam2->fetch(PDO::FETCH_OBJ);
                        if ($fam1->rowCount() > 0 and $fam2->rowCount() > 0) {
                            $go = 1;
                            if ($merge_parentsdate == 'YES') {
                                // we want to check for wedding date of parents
                                if ($fam1Db->fam_marr_date != '' and $fam1Db->fam_marr_date == $fam2Db->fam_marr_date) {
                                    $go = 1;
                                } else {
                                    $go = 0;
                                    // no wedding date or no match --> no merge!
                                }
                            }
                            if ($go) {
                                // no use doing all this if the marriage date doesn't match
                                $qry = "SELECT pers_lastname, pers_firstname FROM humo_persons\n\t\t\t\t\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . $fam1Db->fam_man . "'";
                                $fath1 = $dbh->query($qry);
                                $fath1Db = $fath1->fetch(PDO::FETCH_OBJ);
                                $qry = "SELECT pers_lastname, pers_firstname FROM humo_persons\n\t\t\t\t\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . $fam1Db->fam_woman . "'";
                                $moth1 = $dbh->query($qry);
                                $moth1Db = $moth1->fetch(PDO::FETCH_OBJ);
                                $qry = "SELECT pers_lastname, pers_firstname FROM humo_persons\n\t\t\t\t\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . $fam2Db->fam_man . "'";
                                $fath2 = $dbh->query($qry);
                                $fath2Db = $fath2->fetch(PDO::FETCH_OBJ);
                                $qry = "SELECT pers_lastname, pers_firstname FROM humo_persons\n\t\t\t\t\t\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='" . $fam2Db->fam_woman . "'";
                                $moth2 = $dbh->query($qry);
                                $moth2Db = $moth2->fetch(PDO::FETCH_OBJ);
                                if ($fath1->rowCount() > 0 and $moth1->rowCount() > 0 and $fath2->rowCount() > 0 and $moth2->rowCount() > 0) {
                                    if ($fath1Db->pers_lastname != '' and $fath1Db->pers_lastname == $fath2Db->pers_lastname and $moth1Db->pers_lastname != '' and $moth1Db->pers_lastname == $moth2Db->pers_lastname and $fath1Db->pers_firstname != '' and $fath1Db->pers_firstname == $fath2Db->pers_firstname and $moth1Db->pers_firstname != '' and $moth1Db->pers_firstname == $moth2Db->pers_firstname) {
                                        // MERGE THEM !!
                                        $this->merge_them($persDb->pers_id, $pers2Db->pers_id, 'automatic');
                                        $mergedlist[] = $persDb->pers_id;
                                        $merges++;
                                    }
                                }
                            }
                            // end "if($go)"
                        }
                    }
                    // end while
                }
                // end "if($pers2)
            }
            if ($merges == 0) {
                echo '<br>' . __('No automatic merge options were found.') . '<br><br>';
            } else {
                echo '<br>' . __('Automatic merge completed') . ' ' . $merges . __(' merges were performed') . '<br><br>';
            }
            if ($relatives_merge != '') {
                echo __('It is recommended to continue with <b>"Relatives merge"</b> to consider merging persons affected by previous merges that were performed.') . '<br><br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" style="font-weight:bold;font-size:120%" name="relatives" value="' . __('Relatives merge') . '">';
                echo '</form>';
            } else {
                echo __('You may wish to proceed with duplicate merge or manual merge.') . '<br><br>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="duplicate_choices" value="' . __('Duplicate merge') . '">';
                echo '</form>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" name="manual" value="' . __('Manual merge') . '">';
                echo '</form>';
            }
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" value="' . __('Back to main merge menu') . '">';
            echo '</form>';
            if (isset($mergedlist)) {
                // there is a list of merged persons
                echo '<br><br><b><u>' . __('These are the persons that were merged:') . '</u></b><br>';
                for ($i = 0; $i < count($mergedlist); $i++) {
                    $result = $dbh->query("SELECT * FROM humo_persons WHERE pers_id='" . $mergedlist[$i] . "'");
                    $resultDb = $result->fetch(PDO::FETCH_OBJ);
                    echo $resultDb->pers_lastname . ', ' . $resultDb->pers_firstname . ' ' . strtolower(str_replace("_", " ", $resultDb->pers_prefix)) . ' (#' . $resultDb->pers_gedcomnumber . ')<br>';
                }
            }
        } elseif (isset($_POST['settings']) or isset($_POST['reset'])) {
            echo '<br>';
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            if (isset($_POST['reset'])) {
                // reset to default
                $dbh->query("UPDATE humo_settings SET setting_value ='10' WHERE setting_variable='merge_chars'");
            } elseif (isset($_POST['merge_chars'])) {
                // the "Save" button was pressed
                $merge_chars = $_POST['merge_chars'];
                // store into variable and write to database
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $merge_chars . "' WHERE setting_variable = 'merge_chars'");
            }
            $chars = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_chars'");
            $charsDb = $chars->fetch(PDO::FETCH_OBJ);
            if (isset($_POST['reset'])) {
                $dbh->query("UPDATE humo_settings SET setting_value ='YES' WHERE setting_variable='merge_dates'");
            } elseif (isset($_POST['merge_dates'])) {
                $merge_dates = $_POST['merge_dates'];
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $merge_dates . "' WHERE setting_variable = 'merge_dates'");
            }
            $dates = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_dates'");
            $datesDb = $dates->fetch(PDO::FETCH_OBJ);
            if (isset($_POST['reset'])) {
                $dbh->query("UPDATE humo_settings SET setting_value ='YES' WHERE setting_variable='merge_lastname'");
            } elseif (isset($_POST['merge_lastname'])) {
                $merge_lastname = $_POST['merge_lastname'];
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $merge_lastname . "' WHERE setting_variable = 'merge_lastname'");
            }
            $lastn = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_lastname'");
            $lastnDb = $lastn->fetch(PDO::FETCH_OBJ);
            if (isset($_POST['reset'])) {
                $dbh->query("UPDATE humo_settings SET setting_value ='YES' WHERE setting_variable='merge_firstname'");
            } elseif (isset($_POST['merge_firstname'])) {
                $merge_firstname = $_POST['merge_firstname'];
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $merge_firstname . "' WHERE setting_variable = 'merge_firstname'");
            }
            $firstn = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_firstname'");
            $firstnDb = $firstn->fetch(PDO::FETCH_OBJ);
            if (isset($_POST['reset'])) {
                $dbh->query("UPDATE humo_settings SET setting_value ='YES' WHERE setting_variable='merge_parentsdate'");
            } elseif (isset($_POST['merge_parentsdate'])) {
                $merge_parentsdate = $_POST['merge_parentsdate'];
                $dbh->query("UPDATE humo_settings SET setting_value ='" . $merge_parentsdate . "' WHERE setting_variable = 'merge_parentsdate'");
            }
            $pard = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable = 'merge_parentsdate'");
            $pardDb = $pard->fetch(PDO::FETCH_OBJ);
            echo '<table class="humo" style="width:900px;">';
            echo '<tr class="table_header"><th colspan="3">' . __('Merge filter settings') . '</th></tr>';
            echo '<tr><th style="width:300px" colspan="2">' . __('Settings') . '</th><th style="width:600px">' . __('Explanation') . '</th></tr>';
            echo '<tr><td style="font-weight:bold;text-align:left;vertical-align:top" colspan="3">';
            echo __('General') . '</td></tr><tr><td>';
            echo __('Max characters to match firstname:');
            echo '</td><td>';
            echo '<input type="text" name="merge_chars" value="' . $charsDb->setting_value . '"size="1">';
            echo '</td><td>';
            // explanation
            echo __('In different trees, first names may be listed differently: Thomas Julian Booth, Thomas J. Booth, Thomas Booth etc. By default a match of the first 10 characters of the first name will be considered a match. You can change this to another value. Try and find the right balance: if you set a low number of chars you will get many unwanted possible matches. If you set it too high, you may miss possible matches as in the example names above.');
            echo '</td></tr><tr><td style="font-weight:bold;text-align:left;vertical-align:top" colspan="3">';
            echo __('Duplicate merge');
            echo '</td></tr><tr><td>' . __('include blank lastnames');
            echo '</td><td>';
            echo '<select size="1" name="merge_lastname">';
            if ($lastnDb->setting_value == 'YES') {
                echo '<option value="YES" SELECTED>' . __('Yes') . '</option>';
                echo '<option value="NO">' . __('No') . '</option>';
            } else {
                echo '<option value="NO" SELECTED>' . __('No') . '</option>';
                echo '<option value="YES">' . __('Yes') . '</option>';
            }
            echo "</select>";
            echo '</td><td>';
            // explanation
            echo __('By default two persons with missing lastnames will be included as possible duplicates. Two persons called "John" without lastname will be considered a possible match. If you have many cases like this you could get a very long list of possible duplicates and you might want to disable this, so only persons with lastnames will be included.');
            echo '</td></tr><tr><td>' . __('include blank firstnames');
            echo '</td><td>';
            echo '<select size="1" name="merge_firstname">';
            if ($firstnDb->setting_value == 'YES') {
                echo '<option value="YES" SELECTED>' . __('Yes') . '</option>';
                echo '<option value="NO">' . __('No') . '</option>';
            } else {
                echo '<option value="NO" SELECTED>' . __('No') . '</option>';
                echo '<option value="YES">' . __('Yes') . '</option>';
            }
            echo "</select>";
            echo '</td><td>';
            // explanation
            echo __('Same as above, but for first names. When enabled (default), all persons called "Smith" without first name will be considered possible duplicates of each other. If you have many cases like this it could give you a long list and you might want to disable it.');
            echo '</td></tr><tr><td>' . __('include blank dates');
            echo '</td><td>';
            echo '<select size="1" name="merge_dates">';
            if ($datesDb->setting_value == 'YES') {
                echo '<option value="YES" SELECTED>' . __('Yes') . '</option>';
                echo '<option value="NO">' . __('No') . '</option>';
            } else {
                echo '<option value="NO" SELECTED>' . __('No') . '</option>';
                echo '<option value="YES">' . __('Yes') . '</option>';
            }
            echo "</select>";
            echo '</td><td>';
            // explanation
            echo __('By default, two persons with identical names, but with one or both missing birth/death dates are considered possible duplicates. In certain trees this can give a long list of possible duplicates. You can choose to disable this so only persons who both have a birth or death date and this date is identical, will be considered a possible match. This can drastically cut down the number of possible duplicates, but of course you may also miss out on pairs that actually are duplicates.');
            echo '</td></tr><tr><td style="font-weight:bold;text-align:left;vertical-align:top" colspan="3">';
            echo __('Automatic merge');
            echo '</td></tr><tr><td>' . __('include parents marriage date:');
            echo '</td><td>';
            echo '<select size="1" name="merge_parentsdate">';
            if ($pardDb->setting_value == 'YES') {
                echo '<option value="YES" SELECTED>' . __('Yes') . '</option>';
                echo '<option value="NO">' . __('No') . '</option>';
            } else {
                echo '<option value="NO" SELECTED>' . __('No') . '</option>';
                echo '<option value="YES">' . __('Yes') . '</option>';
            }
            echo "</select>";
            echo '</td><td>';
            // explanation
            echo __('Automatic merging is a dangerous business. Therefore many clauses are used to make sure the persons are indeed identical. Besides identical names, identical birth or death dates and identical names of parents, also the parents\' wedding date is included. If you consider this too much and rely on the above clauses, you can disable this.');
            echo '</td></tr>';
            echo '<tr><td colspan="2" style="text-align:center"><input type="Submit" name="settings" value="' . __('Save') . '">';
            echo '&nbsp;&nbsp;&nbsp;<input type="Submit" name="reset" value="' . __('Reset') . '"></td>';
            echo '</td><td>';
            echo '</tr></table><br><br><br>';
            echo '</form>';
        } else {
            echo '<br>';
            echo '<table class="humo" style="width:98%;">';
            echo '<tr class="table_header"><th colspan="2">' . __('Merge Options') . '</th></tr>';
            echo '<tr><td colspan="2" style="padding:10px">';
            echo __('<b>NOTE:</b> None of these buttons will cause immediate merging. You will first be presented with information and can then decide to make a merge.<br><br>
<b>TIP:</b> Start with automatic merge to get rid of all obvious merges. (If no automatic merge options are found, try the duplicate merge option).<br>
These will likely cause surrounding relatives to be found, so continue with the "Relatives merge" option.<br>
Once you finish that, most needed merges will have been performed. You can then use "Duplicate merge" to see if there are duplicates left to consider for merging.<br>
As a last resort you can perform manual merges.');
            echo '</td></tr>';
            echo '<tr><td style="vertical-align:center;text-align:center;width:200px">';
            // automatic merge option button
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" style="min-width:150px" name="automatic" value="' . __('Automatic merge') . '">';
            echo '</form>';
            echo '</td><td>';
            echo __('You will be shown the set of strict criteria used for automatic merging and then you can decide whether to continue.');
            // relatives merge option button (only shown as button if previous merges created a "surrounding relatives" array)
            echo '</td></tr><tr><td style="vertical-align:center;text-align:center;width:200px">';
            if ($relatives_merge != '') {
                echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
                echo '<input type="hidden" name="page" value="' . $page . '">';
                echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
                echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
                echo '<input type="Submit" style="min-width:150px" name="relatives" value="' . __('Relatives merge') . '">';
                echo '</form>';
            } else {
                echo __('Relatives merge');
            }
            echo '</td><td>';
            echo __('This button will become available if you have made merges, and surrounding relatives (parents, children or spouses) have to be considered for merging too.<br>
By pressing this button, you can then continue to check the surrounding relatives, pair by pair, and merge them if necessary. If those merges will create additional surrounding relatives to consider, they will be automatically added to the list.<br>
Surrounding relatives are saved to the database and you can also return to it at a later stage.');
            echo '</td></tr><tr><td style="vertical-align:center;text-align:center;width:200px">';
            // duplicate merge option button
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" style="min-width:150px" name="duplicate_choices" value="' . __('Duplicate merge') . '">';
            echo '</form>';
            echo '</td><td>';
            echo __('You will be presented, one after the other, with pairs of possible duplicates to consider for merging.<br>
After a merge you can switch to "relatives merge" and after that return to duplicate search where you left off.');
            echo '</td></tr><tr><td style="min-height:50px;vertical-align:center;text-align:center;width:200px">';
            // manual merge option button
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" style="min-width:150px" name="manual" value="' . __('Manual merge') . '">';
            echo '</form>';
            echo '</td><td>';
            echo __('You can pick two persons out of the database to consider for merging.');
            echo '</td></tr><tr><td style="vertical-align:center;text-align:center;width:200px">';
            // settings option button
            echo '<form method="post" action="' . $phpself . '" style="display : inline;">';
            echo '<input type="hidden" name="page" value="' . $page . '">';
            echo '<input type="hidden" name="tree_id" value="' . $tree_id . '">';
            echo '<input type="hidden" name="menu_admin" value="' . $menu_admin . '">';
            echo '<input type="Submit" style="min-width:150px" name="settings" value="' . __('Settings') . '">';
            echo '</form>';
            echo '</td><td>' . __('Here you can change the default filters for the different merge options.');
            echo '</td></tr></table>';
        }
    }
<?php

include_once "header.php";
// returns CMS_ROOTPATH constant
include_once CMS_ROOTPATH . "menu.php";
include_once CMS_ROOTPATH . "include/person_cls.php";
global $selected_language;
$person_cls = new person_cls();
// *** EXAMPLE of a UNION querie ***
//$qry = "(SELECT * FROM humo1_person ".$query.') ';
//$qry.= " UNION (SELECT * FROM humo2_person ".$query.')';
//$qry.= " UNION (SELECT * FROM humo3_person ".$query.')';
//$qry.= " ORDER BY pers_lastname, pers_firstname";
$person_qry = "(SELECT *, STR_TO_DATE(pers_changed_date,'%d %b %Y') AS changed_date, pers_changed_time as changed_time\n\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND pers_changed_date IS NOT NULL)";
$person_qry .= " UNION (SELECT *, STR_TO_DATE(pers_new_date,'%d %b %Y') AS changed_date, pers_new_time as changed_time\n\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND pers_changed_date IS NULL)";
$person_qry .= " ORDER BY changed_date DESC, changed_time DESC LIMIT 0,100";
$search_name = '';
if (isset($_POST["search_name"])) {
    $search_name = $_POST["search_name"];
    // *** EXAMPLE of a UNION querie ***
    //$qry = "(SELECT * FROM humo1_person ".$query.') ';
    //$qry.= " UNION (SELECT * FROM humo2_person ".$query.')';
    //$qry.= " UNION (SELECT * FROM humo3_person ".$query.')';
    //$qry.= " ORDER BY pers_lastname, pers_firstname";
    $person_qry = "(SELECT * , STR_TO_DATE(pers_changed_date,'%d %b %Y') AS changed_date, pers_changed_time as changed_time\n\t\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "'\n \t\tLEFT JOIN humo_events\n \t\t\tON pers_gedcomnumber=event_person_id AND event_kind='name' AND event_tree_id='" . $tree_id . "' \n\t\tWHERE (CONCAT(pers_firstname,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%{$search_name}%'\n \t\t\tOR event_event LIKE '%{$search_name}%')\n\t\t\tAND pers_changed_date IS NOT NULL\n\t\t\t)";
    $person_qry .= " UNION (SELECT * , STR_TO_DATE(pers_new_date,'%d %b %Y') AS changed_date, pers_new_time as changed_time\n\t\tFROM humo_persons WHERE pers_tree_id='" . $tree_id . "'\n \t\tLEFT JOIN humo_events\n \t\t\tON pers_gedcomnumber=event_person_id AND event_kind='name' AND event_tree_id='" . $tree_id . "'\n\t\tWHERE (CONCAT(pers_firstname,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%{$search_name}%'\n \t\t\tOR event_event LIKE '%{$search_name}%')\n\t\t\tAND pers_changed_date IS NULL)";
    $person_qry .= " ORDER BY changed_date DESC, changed_time DESC LIMIT 0,100";
}
$person_result = $dbh->query($person_qry);
echo '<h2 class="center">' . __('Recently changed and/or new persons') . '</h2>';
// *** Search box ***
Exemple #20
0
 $hide_tree_array = explode(";", $user['group_hide_trees']);
 $hide_tree = false;
 for ($x = 0; $x <= count($hide_tree_array) - 1; $x++) {
     if ($hide_tree_array[$x] == $dataDb->tree_id) {
         $hide_tree = true;
     }
 }
 if ($hide_tree == false) {
     //$person_qry = $dbh->query("SELECT * FROM ".safe_text($dataDb->tree_prefix)."person ORDER BY pers_lastname");
     $person_qry = $dbh->query("SELECT * FROM humo_persons\r\n\t\t\tWHERE pers_tree_id='" . $dataDb->tree_id . "' ORDER BY pers_lastname");
     //GENDEX:
     //person-URL|FAMILYNAME|Firstname /FAMILYNAME/|
     //Birthdate|Birthplace|Deathdate|Deathplace|
     while (@($personDb = $person_qry->fetch(PDO::FETCH_OBJ))) {
         // *** Use class for privacy filter ***
         $person_cls = new person_cls();
         $person_cls->construct($personDb);
         $privacy = $person_cls->privacy;
         // *** Completely filter person ***
         if ($user["group_pers_hide_totally_act"] == 'j' and strpos(' ' . $personDb->pers_own_code, $user["group_pers_hide_totally"]) > 0) {
             // *** Don't show person ***
         } else {
             $person_url = $personDb->pers_indexnr;
             if ($person_url == '') {
                 if ($personDb->pers_famc) {
                     // *** Person without own family ***
                     $person_url = $personDb->pers_famc;
                 } else {
                     // *** Person without parents or own family ***
                     $person_url = '&main_person=' . $personDb->pers_gedcomnumber;
                 }
function show_person($familyDb)
{
    global $dbh, $db_functions, $tree_id, $selected_place, $language, $user;
    global $bot_visit, $humo_option, $uri_path, $search_database, $list_expanded;
    global $selected_language, $privacy, $dirmark1, $dirmark2, $rtlmarker;
    global $select_marriage_notice, $select_marriage, $select_marriage_notice_religious, $select_marriage_religious;
    if ($familyDb->fam_man) {
        $selected_person1 = $familyDb->fam_man;
    } else {
        $selected_person1 = $familyDb->fam_woman;
    }
    $personDb = $db_functions->get_person($selected_person1);
    $pers_tree_prefix = $personDb->pers_tree_prefix;
    //if (CMS_SPECIFIC=='Joomla'){
    //	$start_url='index.php?option=com_humo-gen&amp;task=family&amp;database='.$pers_tree_prefix.
    //		'&amp;id='.$personDb->pers_indexnr.'&amp;main_person='.$personDb->pers_gedcomnumber;
    //}
    //else
    if ($humo_option["url_rewrite"] == "j") {
        // *** url_rewrite ***
        // *** $uri_path made in header.php ***
        $start_url = $uri_path . 'family/' . $pers_tree_prefix . '/' . $personDb->pers_indexnr . '/' . $personDb->pers_gedcomnumber . '/';
    } else {
        $start_url = CMS_ROOTPATH . 'family.php?database=' . $pers_tree_prefix . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber;
    }
    // *** Person class used for name and person pop-up data ***
    $person_cls = new person_cls();
    $person_cls->construct($personDb);
    $privacy = $person_cls->privacy;
    $name = $person_cls->person_name($personDb);
    // *** Show name ***
    $index_name = '';
    if ($name["show_name"] == false) {
        $index_name = __('Name filtered');
    } else {
        // *** If there is no lastname, show a - character. ***
        if ($personDb->pers_lastname == "") {
            // Don't show a "-" by pers_patronymes
            if (!isset($_GET['pers_patronym'])) {
                $index_name = "-&nbsp;&nbsp;";
            }
        }
        $index_name .= $name["index_name_extended"] . $name["colour_mark"];
    }
    // *** Show extra colums before a person in index places ***
    if ($selected_place != $familyDb->place_order) {
        echo '<td colspan="7"><b>' . $dirmark2 . "{$familyDb->place_order}</b></td></tr><tr>";
    }
    $selected_place = $familyDb->place_order;
    echo '<td valign="top" style="white-space:nowrap;width:90px">';
    if ($select_marriage_notice == '1') {
        if ($selected_place == $familyDb->fam_marr_notice_place) {
            echo '<span class="place_index place_index_selected">' . __('&infin;') . '</span>';
        } else {
            echo '<span class="place_index">&nbsp;</span>';
        }
    }
    if ($select_marriage_notice_religious == '1') {
        if ($selected_place == $familyDb->fam_marr_church_notice_place) {
            echo '<span class="place_index place_index_selected">' . __('o') . '</span>';
        } else {
            echo '<span class="place_index">&nbsp;</span>';
        }
    }
    if ($select_marriage == '1') {
        if ($selected_place == $familyDb->fam_marr_place) {
            echo '<span class="place_index place_index_selected">' . __('X') . '</span>';
        } else {
            echo '<span class="place_index">&nbsp;</span>';
        }
    }
    if ($select_marriage_religious == '1') {
        if ($selected_place == $familyDb->fam_marr_church_place) {
            echo '<span class="place_index place_index_selected">' . __('x') . '</span>';
        } else {
            echo '<span class="place_index">&nbsp;</span>';
        }
    }
    echo '</td>';
    echo '<td valign="top" style="border-right:0px; white-space:nowrap;">';
    // *** Show person popup menu ***
    echo $person_cls->person_popup_menu($personDb);
    // *** Show picture man or wife ***
    if ($personDb->pers_sexe == "M") {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/man.gif" alt="man" style="vertical-align:top">';
    } elseif ($personDb->pers_sexe == "F") {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/woman.gif" alt="woman" style="vertical-align:top">';
    } else {
        echo $dirmark1 . ' <img src="' . CMS_ROOTPATH . 'images/unknown.gif" alt="unknown" style="vertical-align:top">';
    }
    echo '</td><td style="border-left:0px;">';
    // *** Show name of person ***
    echo ' <a href="' . $start_url . '">' . rtrim($index_name) . '</a>';
    //*** Show spouse/ partner ***
    if ($list_expanded == true and $personDb->pers_fams) {
        $marriage_array = explode(";", $personDb->pers_fams);
        // *** Code to show only last marriage ***
        $nr_marriages = count($marriage_array);
        for ($x = 0; $x <= $nr_marriages - 1; $x++) {
            $fam_partnerDb = $db_functions->get_family($marriage_array[$x]);
            // *** This check is better then a check like: $personDb->pers_sexe=='F', because of unknown sexe or homosexual relations. ***
            if ($personDb->pers_gedcomnumber == $fam_partnerDb->fam_man) {
                $partner_id = $fam_partnerDb->fam_woman;
            } else {
                $partner_id = $fam_partnerDb->fam_man;
            }
            $relation_short = __('&amp;');
            if ($fam_partnerDb->fam_marr_date or $fam_partnerDb->fam_marr_place or $fam_partnerDb->fam_marr_church_date or $fam_partnerDb->fam_marr_church_place) {
                $relation_short = __('X');
            }
            if ($fam_partnerDb->fam_div_date or $fam_partnerDb->fam_div_place) {
                $relation_short = __(') (');
            }
            if ($partner_id != '0' and $partner_id != '') {
                $partnerDb = $db_functions->get_person($partner_id);
                $partner_cls = new person_cls();
                $privacy2 = $person_cls->privacy;
                $name = $partner_cls->person_name($partnerDb);
            } else {
                $name["standard_name"] = __('N.N.');
            }
            if ($nr_marriages > 1) {
                echo ',';
            }
            if (@$partnerDb->pers_gedcomnumber != $familyDb->fam_woman) {
                // *** Show actual relation/ marriage in special font ***
                echo ' <span class="index_partner" style="font-size:10px;">';
            } else {
                echo ' ';
            }
            if ($nr_marriages > 1) {
                if ($x == 0) {
                    echo __('1st');
                } elseif ($x == 1) {
                    echo ' ' . __('2nd');
                } elseif ($x == 2) {
                    echo ' ' . __('3rd');
                } elseif ($x > 2) {
                    echo ' ' . ($x + 1) . __('th');
                }
            }
            echo ' ' . $relation_short . ' ' . rtrim($name["standard_name"]);
            if (@$partnerDb->pers_gedcomnumber != $familyDb->fam_woman) {
                echo '</span>';
            }
        }
    }
    // *** End spouse/ partner ***
    echo '</td><td style="white-space:nowrap;">';
    $info = "";
    if ($familyDb->fam_marr_church_notice_date) {
        $info = __('o') . ' ' . date_place($familyDb->fam_marr_church_notice_date, '');
    }
    if ($familyDb->fam_marr_notice_date) {
        $info = __('&infin;') . ' ' . date_place($familyDb->fam_marr_notice_date, '');
    }
    //echo "<span style='font-size:90%'>".$info.$dirmark1."</span>";
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td>';
    $info = "";
    if ($familyDb->fam_marr_church_notice_place) {
        $info = __('o') . ' ' . $familyDb->fam_marr_church_notice_place;
    }
    if ($familyDb->fam_marr_notice_place) {
        $info = __('&infin;') . ' ' . $familyDb->fam_marr_notice_place;
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td style="white-space:nowrap;">';
    $info = "";
    if ($familyDb->fam_marr_church_date) {
        $info = __('x') . ' ' . date_place($familyDb->fam_marr_church_date, '');
    }
    if ($familyDb->fam_marr_date) {
        $info = __('X') . ' ' . date_place($familyDb->fam_marr_date, '');
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td><td>';
    $info = "";
    if ($familyDb->fam_marr_church_place) {
        $info = __('x') . ' ' . $familyDb->fam_marr_church_place;
    }
    if ($familyDb->fam_marr_place) {
        $info = __('X') . ' ' . $familyDb->fam_marr_place;
    }
    if ($privacy == 1 and $info) {
        echo ' ' . __('PRIVACY FILTER');
    } else {
        echo $info;
    }
    echo '</td></tr>';
}
     $privacy = $person_cls1->privacy;
     if ($privacy != 1) {
         $death_date = $record->pers_death_date;
         $calculated_age = '';
         if ($death_date != '') {
             $death_date = ' (&#8224; ' . $death_date . ')';
             if ($record->death_year - $record->birth_year < 120) {
                 $calculated_age = ' (' . ($record->death_year - $record->birth_year) . ')';
             }
         } else {
             $death_date = '';
             if ($year - $record->birth_year < 120) {
                 $calculated_age = ' (' . ($year - $record->birth_year) . ')';
             }
         }
         $person_cls = new person_cls();
         $name = $person_cls->person_name($record);
         $title = $name["standard_name"];
         $title = str_replace('&', '&amp;', $title);
         // Los & teken niet toegestaan in RSS
         $title .= $calculated_age . $death_date;
         $url = CMS_ROOTPATH . 'family.php?database=' . $dataDb->tree_prefix . '&amp;id=' . $record->pers_indexnr;
         // show content
         echo "<item>" . $newline;
         echo "<title>" . $title . "</title>" . $newline;
         echo "<link>" . $humo_option["rss_link"] . "/" . $url . "</link>" . $newline;
         echo "</item>" . $newline;
         $counter++;
     }
 }
 // close channel and rss
                        }
                        // end if grchildren
                    }
                    // end for chmarriages
                }
                //end if chldDb->pers_fams
            }
            //end for
        }
        // end if children
    }
}
// *********** END MARRIAGES & CHILDREN
// *********** CHECK IF ANY DATES ARE AVAILABLE. IF PART ARE MISSING ESTIMATE BIRTH/DEATH
// *** Check privacy filter ***
$person_cls = new person_cls();
$person_cls->construct($personDb);
$privacy = $person_cls->privacy;
if ($privacy == 1) {
    echo '<br><br>' . __('PRIVACY FILTER');
    exit;
}
if ($isborn == 0 and $isdeath == 0 and $ismarr == 0 and $ischild == 0) {
    // no birth or death dates available
    print "<br><br>" . __('There are no dates available for this person. Timeline can not be calculated.');
    exit;
}
if ($isborn == 1 and $isdeath == 0) {
    // birth date but no death date: we show 80 years from birth
    if ($bornyear != 0) {
        $deathyear = $bornyear + 80;
 function extra_links()
 {
     global $dbh, $tree_id, $humo_option, $uri_path;
     // *** Check if there are extra links ***
     $datasql = $dbh->query("SELECT * FROM humo_settings WHERE setting_variable='link'");
     @($num_rows = $datasql->rowCount());
     if ($num_rows > 0) {
         while (@($dataDb = $datasql->fetch(PDO::FETCH_OBJ))) {
             $item = explode("|", $dataDb->setting_value);
             $pers_own_code[] = $item[0];
             $link_text[] = $item[1];
             $link_order[] = $dataDb->setting_order;
         }
         include_once CMS_ROOTPATH . 'include/person_cls.php';
         $person = $dbh->query("SELECT * FROM humo_persons\n\t\t\t\tWHERE pers_tree_id='" . $tree_id . "' AND pers_own_code NOT LIKE ''");
         while (@($personDb = $person->fetch(PDO::FETCH_OBJ))) {
             if (in_array($personDb->pers_own_code, $pers_own_code)) {
                 if (CMS_SPECIFIC == 'Joomla') {
                     $path_tmp = 'index.php?option=com_humo-gen&amp;task=family&amp;database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber;
                 } elseif ($humo_option["url_rewrite"] == "j") {
                     // *** $uri_path is generated in header.php ***
                     $path_tmp = $uri_path . 'family/' . $_SESSION['tree_prefix'] . '/' . $personDb->pers_indexnr . '/' . $personDb->pers_gedcomnumber . '/';
                 } else {
                     $path_tmp = CMS_ROOTPATH . 'family.php?database=' . $_SESSION['tree_prefix'] . '&amp;id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber;
                 }
                 $person_cls = new person_cls();
                 $name = $person_cls->person_name($personDb);
                 $text_nr = array_search($personDb->pers_own_code, $pers_own_code);
                 $link_order2 = $link_order[$text_nr];
                 $link_text2[$link_order2] = '<a href="' . $path_tmp . '">' . $name["standard_name"] . '</a> ' . $link_text[$text_nr];
             }
         }
         // *** Show links ***
         if (isset($link_text2)) {
             for ($i = 1; $i <= count($link_text2); $i++) {
                 if (isset($link_text2[$i])) {
                     echo $link_text2[$i] . "<br>\n";
                 }
             }
         }
     }
 }
Exemple #25
0
function source_display($sourcenum)
{
    global $dbh, $db_functions, $tree_prefix_quoted, $dataDb, $user, $pdf, $screen_mode, $language;
    if ($screen_mode != "PDF") {
        include_once "header.php";
        //returns CMS_ROOTPATH constant
        include_once CMS_ROOTPATH . "menu.php";
        include_once CMS_ROOTPATH . "include/date_place.php";
        include_once CMS_ROOTPATH . "include/process_text.php";
    }
    // *** Check user authority ***
    if ($user['group_sources'] != 'j') {
        echo __('You are not authorised to see this page.');
        exit;
    }
    if ($screen_mode != "PDF") {
        include_once CMS_ROOTPATH . "include/language_date.php";
        include_once CMS_ROOTPATH . "include/person_cls.php";
        echo '<table class="humo standard">';
        echo "<tr><td><h2>" . __('Sources') . "</h2>";
    }
    $sourceDb = $db_functions->get_source($sourcenum);
    // *** If an unknown source ID is choosen, exit function ***
    if (!isset($sourceDb->source_id)) {
        exit(__('No valid source number.'));
    }
    if ($sourceDb->source_title) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Title') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_title . "\n");
        } else {
            echo '<b>' . __('Title') . ":</b> {$sourceDb->source_title}<br>";
        }
    }
    if ($sourceDb->source_date) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Date') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, language_date(strtolower($sourceDb->source_date)) . "\n");
        } else {
            echo '<b>' . __('Date') . ":</b> " . language_date(strtolower($sourceDb->source_date)) . "<br>";
        }
    }
    if ($sourceDb->source_publ) {
        $source_publ = $sourceDb->source_publ;
        $pdflink = 0;
        if (substr($source_publ, 0, 7) == 'http://') {
            $link = $source_publ;
            $source_publ = '<a href="' . $link . '">' . $link . '</a>';
            $pdflink = 1;
        }
        if (substr($source_publ, 0, 8) == 'https://') {
            $link = $source_publ;
            $source_publ = '<a href="' . $link . '">' . $link . '</a>';
            $pdflink = 1;
        }
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Publication') . ": ");
            $pdf->SetFont('Arial', '', 10);
            if ($pdflink == 1) {
                $pdf->SetFont('Arial', 'U', 10);
                $pdf->SetTextColor(28, 28, 255);
                $pdf->Write(6, strip_tags($source_publ) . "\n", strip_tags($source_publ));
                $pdf->SetFont('Arial', '', 10);
                $pdf->SetTextColor(0);
            } else {
                $pdf->Write(6, strip_tags($source_publ) . "\n");
            }
        } else {
            print '<b>' . __('Publication') . ":</b> {$source_publ}<br>";
        }
    }
    if ($sourceDb->source_place) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Place') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_place . "\n");
        } else {
            print '<b>' . __('Place') . ":</b> {$sourceDb->source_place}<br>";
        }
    }
    if ($sourceDb->source_refn) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Own code') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_refn . "\n");
        } else {
            print '<b>' . __('Own code') . ":</b> {$sourceDb->source_refn}<br>";
        }
    }
    if ($sourceDb->source_auth) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Author') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_auth . "\n");
        } else {
            print '<b>' . __('Author') . ":</b> {$sourceDb->source_auth}<br>";
        }
    }
    if ($sourceDb->source_subj) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Subject') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_subj . "\n");
        } else {
            print '<b>' . __('Subject') . ":</b> {$sourceDb->source_subj}<br>";
        }
    }
    if ($sourceDb->source_item) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Nr.') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_item . "\n");
        } else {
            print '<b>' . __('Nr.') . ":</b> {$sourceDb->source_item}<br>";
        }
    }
    if ($sourceDb->source_kind) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Kind') . ": ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_kind . "\n");
        } else {
            print '<b>' . __('Kind') . ":</b> {$sourceDb->source_kind}<br>";
        }
    }
    if ($sourceDb->source_repo_caln) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Archive') . " ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_repo_caln . "\n");
        } else {
            print '<b>' . __('Archive') . "</b> {$sourceDb->source_repo_caln}<br>";
        }
    }
    if ($sourceDb->source_repo_page) {
        if ($screen_mode == "PDF") {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Write(6, __('Page') . " ");
            $pdf->SetFont('Arial', '', 10);
            $pdf->Write(6, $sourceDb->source_repo_page . "\n");
        } else {
            print '<b>' . __('Page') . "</b> {$sourceDb->source_repo_page}<br>";
        }
    }
    if ($sourceDb->source_text) {
        if ($screen_mode == "PDF") {
            $source_text = $sourceDb->source_text;
            $source_text = str_replace('<br>', '', $source_text);
            //$pdf->Write(6,html_entity_decode($source_text)."\n");
            $pdf->Write(6, $source_text . "\n");
        } else {
            print '</td></tr><tr><td>' . process_text($sourceDb->source_text);
        }
    }
    // *** Source pictures not in use yet... ***
    // *** Show repository ***
    $repoDb = $db_functions->get_repository($sourceDb->source_repo_gedcomnr);
    if ($repoDb) {
        if ($screen_mode == "PDF") {
            // NO REPOSITORIES IN PDF YET...
        } else {
            echo '</td></tr><tr><td>';
            echo '<h3>' . __('Repository') . '</h3>';
            echo '<b>' . __('Title') . ':</b> ' . $repoDb->repo_name . '<br>';
            if ($user['group_addresses'] == 'j') {
                echo '<b>' . __('Zip code') . ':</b> ' . $repoDb->repo_zip . '<br>';
                echo '<b>' . __('Address') . ':</b> ' . $repoDb->repo_address . '<br>';
            }
            if ($repoDb->repo_date) {
                echo '<b>' . __('Date') . ':</b> ' . $repoDb->repo_date . '<br>';
            }
            if ($repoDb->repo_place) {
                echo '<b>' . __('Place') . ':</b> ' . $repoDb->repo_place . '<br>';
            }
            echo nl2br($repoDb->repo_text);
        }
    }
    if ($screen_mode != "PDF") {
        // we do not want all persons in the database as given online so
        // in the pdf file so we'll take just the above details
        // and leave references to persons
        print '</td></tr>';
        print '<tr><td>';
        $person_cls = new person_cls();
        // *** Find person data if source is connected to a family item ***
        // *** This seperate function speeds up the sources page ***
        function person_data($familyDb)
        {
            global $dbh, $tree_prefix_quoted, $db_functions;
            if ($familyDb->fam_man) {
                $personDb = $db_functions->get_person($familyDb->fam_man);
            } else {
                $personDb = $db_functions->get_person($familyDb->fam_woman);
            }
            return $personDb;
        }
        // *** Sources in connect table ***
        $connect_qry = "SELECT * FROM humo_connections WHERE connect_tree_id='" . $tree_id . "'\r\n\t\tAND connect_source_id='" . $sourceDb->source_gedcomnr . "'\r\n\t\tORDER BY connect_kind, connect_sub_kind, connect_order";
        $connect_sql = $dbh->query($connect_qry);
        while ($connectDb = $connect_sql->fetch(PDO::FETCH_OBJ)) {
            // *** Person source ***
            if ($connectDb->connect_kind == 'person') {
                if ($connectDb->connect_sub_kind == 'person_source') {
                    echo __('Source for:');
                }
                if ($connectDb->connect_sub_kind == 'pers_name_source') {
                    echo __('Source for name:');
                }
                if ($connectDb->connect_sub_kind == 'pers_birth_source') {
                    echo __('Source for birth:');
                }
                if ($connectDb->connect_sub_kind == 'pers_bapt_source') {
                    echo __('Source for baptism:');
                }
                if ($connectDb->connect_sub_kind == 'pers_death_source') {
                    echo __('Source for death:');
                }
                if ($connectDb->connect_sub_kind == 'pers_buried_source') {
                    echo __('Source for burial:');
                }
                if ($connectDb->connect_sub_kind == 'pers_text_source') {
                    echo __('Source for text:');
                }
                if ($connectDb->connect_sub_kind == 'pers_sexe_source') {
                    echo __('Source for sexe:');
                }
                //else { echo 'TEST'; }
                if ($connectDb->connect_sub_kind == 'pers_event_source') {
                    // *** Sources by event ***
                    $event_Db = $db_functions->get_event($connectDb->connect_connect_id);
                    // *** Person source ***
                    if ($event_Db->event_person_id) {
                        $personDb = $db_functions->get_person($event_Db->event_person_id);
                        $name = $person_cls->person_name($personDb);
                        print __('Source for:') . ' <a href="' . CMS_ROOTPATH . 'family.php?id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">';
                        echo $name["standard_name"] . '</a>';
                        if ($event_Db->event_event) {
                            echo ' ' . $event_Db->event_event;
                        }
                    }
                } elseif (substr($connectDb->connect_sub_kind, -14) == 'address_source') {
                    // *** Sources in address table ***
                    $address_sql = "SELECT * FROM humo_addresses WHERE address_id='" . $connectDb->connect_connect_id . "'";
                    @($address_qry = $dbh->query($address_sql));
                    $address_Db = $address_qry->fetch(PDO::FETCH_OBJ);
                    if ($address_Db->address_person_id) {
                        $personDb = $db_functions->get_person($address_Db->address_person_id);
                        $name = $person_cls->person_name($personDb);
                        echo __('Source for address:') . ' <a href="' . CMS_ROOTPATH . 'family.php?id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">';
                        echo $name["standard_name"] . '</a>';
                    }
                } else {
                    //$db_functions->set_tree_prefix($tree_prefix_quoted);
                    //echo 'TEST: '.$tree_id.' '.$connectDb->connect_sub_kind.' '.$connectDb->connect_connect_id.'<br>';
                    $personDb = $db_functions->get_person($connectDb->connect_connect_id);
                    echo ' <a href="' . CMS_ROOTPATH . 'family.php?id=' . $personDb->pers_indexnr . '&amp;main_person=' . $personDb->pers_gedcomnumber . '">';
                    $name = $person_cls->person_name($personDb);
                    echo $name["standard_name"] . '</a>';
                }
            }
            // *** Family source ***
            if ($connectDb->connect_kind == 'family') {
                if ($connectDb->connect_sub_kind == 'family_source') {
                    echo __('Source for family:');
                }
                if ($connectDb->connect_sub_kind == 'fam_relation_source') {
                    echo __('Source for cohabitation:');
                }
                if ($connectDb->connect_sub_kind == 'fam_marr_notice_source') {
                    echo __('Source for marriage notice:');
                }
                if ($connectDb->connect_sub_kind == 'fam_marr_source') {
                    echo __('Source for marriage:');
                }
                if ($connectDb->connect_sub_kind == 'fam_marr_church_notice_source') {
                    echo __('Source for marriage notice (church):');
                }
                if ($connectDb->connect_sub_kind == 'fam_marr_church_source') {
                    echo __('Source for marriage (church):');
                }
                if ($connectDb->connect_sub_kind == 'fam_div_source') {
                    echo __('Source for divorce:');
                }
                if ($connectDb->connect_sub_kind == 'fam_text_source') {
                    echo __('Source for family text:');
                }
                //else{
                //	echo 'TEST2';
                //}
                //if ($connectDb->connect_sub_kind=='event'){
                if ($connectDb->connect_sub_kind == 'fam_event_source') {
                    // *** Sources by event ***
                    $event_Db = $db_functions->get_event($connectDb->connect_connect_id);
                    // *** Family source ***
                    if ($event_Db->event_family_id) {
                        print __('Source for family:');
                        $familyDb = $db_functions->get_family($event_Db->event_family_id);
                        $personDb = person_data($familyDb);
                        echo ' <a href="' . CMS_ROOTPATH . 'family.php?id=' . $event_Db->event_family_id . '">';
                        $name = $person_cls->person_name($personDb);
                        echo $name["standard_name"] . '</a>';
                        if ($event_Db->event_event) {
                            echo ' ' . $event_Db->event_event;
                        }
                    }
                } else {
                    $familyDb = $db_functions->get_family($connectDb->connect_connect_id);
                    $personDb = person_data($familyDb);
                    echo ' <a href="' . CMS_ROOTPATH . 'family.php?id=' . $connectDb->connect_connect_id . '">';
                    $name = $person_cls->person_name($personDb);
                    echo $name["standard_name"] . '</a>';
                }
            }
            // *** Source by address ***
            if ($connectDb->connect_kind == 'address' and $connectDb->connect_sub_kind == 'address_source') {
                $sql = "SELECT * FROM humo_addresses WHERE address_id='" . $connectDb->connect_connect_id . "'";
                $address_sql = $dbh->query($sql);
                $addressDb = $address_sql->fetch(PDO::FETCH_OBJ);
                if ($addressDb->address_address) {
                    $text = $addressDb->address_address;
                }
                if ($addressDb->address_place) {
                    $text .= ' ' . $addressDb->address_place;
                }
                echo __('Source for address:');
                echo ' <a href="address.php?gedcomnumber=' . $addressDb->address_gedcomnr . '">' . $text . '</a>';
            }
            // *** Extra source connect information by every source ***
            if ($connectDb->connect_date or $connectDb->connect_place) {
                echo " " . date_place($connectDb->connect_date, $connectDb->connect_place);
            }
            // *** Source role ***
            if ($connectDb->connect_role) {
                echo ', ' . __('role') . ': ' . $connectDb->connect_role;
            }
            // *** Source page ***
            if ($connectDb->connect_page) {
                echo ', ' . strtolower(__('Page')) . ': ' . $connectDb->connect_page;
            }
            echo '<br>';
        }
        print '</td></tr>';
        print '</table>';
        include_once CMS_ROOTPATH . "footer.php";
    }
    // end if not PDF
}