-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsurname.php
106 lines (97 loc) · 2.69 KB
/
surname.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*
Grampsphpexporter.- export gramps genealogy program to the web
Copyright (C) 2012 William Bell <[email protected]>
Grampsphpexporter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grampsphpexporter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'template.php';
echo head('Surname', '');
try
{
$surname = $_GET["surname"];
print("\n<h3>".$surname."</h3>\n");
if ($surname == 'Unknown')
{
$surname = "";
}
//open the database
$db = new PDO('sqlite:../../.sqlite/gramps1.db');
//get all names with a specific surname
$stmt = $db->prepare(
"select
P.gid as gid,
P.gender as gender,
first_name,
max(D.date1) as date1,
max(D.quality) as quality,
max(N.private) as private,
max(E.private) as BirthPrivate
from name N
inner join person P
on P.gid = N.gid
inner join surname S
on P.gid = S.gid
left join event_ref ER
on ER.gid = P.gid
left join event E
on ER.event_gid = E.gid
and E.the_type = 12
left join date D
on D.gid = E.gid
where S.surname = ?
group by P.gid, first_name
order by first_name");
$stmt->execute(array($_GET["surname"]));
$result = $stmt->fetchAll();
$prevLetter = 'ZZZ';
foreach($result as $row)
{
$gid = $row['gid'];
$private = $row['private'];
$descrip = '*';
if ($row['BirthPrivate'] == 0)
$descrip = substr($descrip.$row['date1'], 0, 5);
if ($descrip == '*')
$descrip = "";
if ($private == 1)
$first_name = substr($row['first_name'], 0, 1);
else
$first_name = $row['first_name'];
$gender = $row['gender'];
if ($first_name == '')
{
if ($gender == 'F')
$first_name = "Unknown Female";
elseif ($gender == 'M')
$first_name = "Unknown Male";
else
$first_name = "Unknown";
}
if ($prevLetter != $first_name[0])
{
if ($prevLetter != 'ZZZ')
print("</div>\n");
$prevLetter = $first_name[0];
print("<div class=\"section\">\n\t<div class=\"letter\">".$prevLetter."</div>\n");
}
print("\t<div class=\"name\"><a href=\"person.php?gid=".$gid."\">".$first_name."</a> ".$descrip."</div>\n");
}
print("</div>\n");
// close the database connection
$db = NULL;
}
catch(PDOException $e)
{
print 'Exception : '.$e->getMessage();
}
echo foot();
?>