forked from HuubMons/HuMo-genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_outline.php
526 lines (469 loc) · 19.3 KB
/
report_outline.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?php
//==================================================================
//=== OUTLINE REPORT - report_outline.php ===
//=== by Yossi Beck - Nov 2008 - (on basis of Huub's family.php) ===
//=== Jul 2011 Huub: translation of variables to English ===
//==================================================================
@set_time_limit(300);
global $show_date, $dates_behind_names, $nr_generations;
global $screen_mode, $language, $humo_option, $user, $selected_language;
// Check for PDF screen mode
$screen_mode='';
if (isset($_POST["screen_mode"]) AND ($_POST["screen_mode"]=='PDF-L' OR $_POST["screen_mode"]=='PDF-P')){ $screen_mode='PDF'; }
include_once("header.php"); // returns CMS_ROOTPATH constant
include_once(CMS_ROOTPATH."include/language_date.php");
include_once(CMS_ROOTPATH."include/language_event.php");
include_once(CMS_ROOTPATH."include/date_place.php");
include_once(CMS_ROOTPATH."include/process_text.php");
include_once(CMS_ROOTPATH."include/person_cls.php");
include_once(CMS_ROOTPATH."include/marriage_cls.php");
include_once(CMS_ROOTPATH."include/show_sources.php");
if($screen_mode!='PDF') { //we can't have a menu in pdf...
include_once(CMS_ROOTPATH."menu.php");
}
else {
if (isset($_SESSION['tree_prefix'])){
$dataqry = "SELECT * FROM humo_trees LEFT JOIN humo_tree_texts
ON humo_trees.tree_id=humo_tree_texts.treetext_tree_id
AND humo_tree_texts.treetext_language='".$selected_language."'
WHERE tree_prefix='".$tree_prefix_quoted."'";
@$datasql = $dbh->query($dataqry);
@$dataDb = $datasql->fetch(PDO::FETCH_OBJ);
$tree_id=$dataDb->tree_id;
}
include_once(CMS_ROOTPATH."include/db_functions_cls.php");
$db_functions = New db_functions;
$db_functions->set_tree_id($tree_id);
}
// *** Family gedcomnumber ***
$family_id=1; // *** Default: show 1st family ***
if (isset($urlpart[1])){ $family_id=$urlpart[1]; }
if (isset($_GET["id"])){ $family_id=$_GET["id"]; }
if (isset($_POST["id"])){ $family_id=$_POST["id"]; }
// *** Person gedcomnumber (backwards compatible) ***
$main_person=''; // *** Mainperson of family ***
if (isset($urlpart[2])){ $main_person=$urlpart[2];}
if (isset($_GET["main_person"])){ $main_person=$_GET["main_person"]; }
if (isset($_POST["main_person"])){ $main_person=$_POST["main_person"]; }
$show_date=true;
if (isset($_GET["show_date"])){ $show_date=$_GET["show_date"];}
if (isset($_POST["show_date"])){ $show_date=$_POST["show_date"];}
$dates_behind_names=true;
if (isset($_GET["dates_behind_names"])){ $dates_behind_names=$_GET["dates_behind_names"];}
if (isset($_POST["dates_behind_names"])){ $dates_behind_names=$_POST["dates_behind_names"];}
// **********************************************************
// *** Maximum number of generations in descendant_report ***
// **********************************************************
$nr_generations=($humo_option["descendant_generations"]-1);
if (isset($_GET["nr_generations"])){ $nr_generations=$_GET["nr_generations"];}
if (isset($_POST["nr_generations"])){ $nr_generations=$_POST["nr_generations"];}
if($screen_mode=='PDF') {
//initialize pdf generation
$pdfdetails=array();
$pdf_marriage=array();
@$persDb = $db_functions->get_person($main_person);
// *** Use person class ***
$pers_cls = New person_cls;
$pers_cls->construct($persDb);
$name=$pers_cls->person_name($persDb);
$title=pdf_convert(__('Outline report').__(' of ').$name["standard_name"]);
$pdf=new PDF();
$pdf->SetTitle($title);
$pdf->SetAuthor('Huub Mons (pdf: Yossi Beck)');
if(isset($_POST["screen_mode"]) AND $_POST["screen_mode"]=="PDF-L") { $pdf->AddPage("L"); }
else { $pdf->AddPage("P"); }
$pdf->SetFont('Arial','B',15);
$pdf->Ln(4);
$pdf->MultiCell(0,10,__('Outline report').__(' of ').$name["standard_name"],0,'C');
$pdf->Ln(4);
$pdf->SetFont('Arial','',12);
}
if($screen_mode != "PDF") {
echo '<div class="standard_header fonts">'.__('Outline report').'</div>';
echo '<div class="pers_name center">';
// ***************************************
// ******** Button: Show date ***********
// ***************************************
if(CMS_SPECIFIC=='Joomla') {
$qstr='';
if($_SERVER['QUERY_STRING'] != '') { $qstr='?'.$_SERVER['QUERY_STRING']; }
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].$qstr.'" style="display : inline;">';
}
else {
print '<form method="POST" action="'.$uri_path.'report_outline.php" style="display : inline;">';
}
print '<input type="hidden" name="id" value="'.$family_id.'">';
print '<input type="hidden" name="nr_generations" value="'.$nr_generations.'">';
print '<input type="hidden" name="main_person" value="'.$main_person.'">';
if ($show_date==true){
print '<input type="hidden" name="show_date" value="0">';
print '<input class="fonts" type="Submit" name="submit" value="'.__('Hide dates').'">';
}
else{
print '<input type="hidden" name="show_date" value="1">';
print '<input class="fonts" type="Submit" name="submit" value="'.__('Show dates').'">';
}
print '</form>';
// *****************************************************************
// ******** Show button: date after or below each other ************
// *****************************************************************
if(CMS_SPECIFIC=='Joomla') {
$qstr='';
if($_SERVER['QUERY_STRING'] != '') { $qstr='?'.$_SERVER['QUERY_STRING']; }
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].$qstr.'" style="display : inline;">';
}
else {
print ' <form method="POST" action="'.$uri_path.'report_outline.php" style="display : inline;">';
}
print '<input type="hidden" name="id" value="'.$family_id.'">';
print '<input type="hidden" name="nr_generations" value="'.$nr_generations.'">';
print '<input type="hidden" name="main_person" value="'.$main_person.'">';
if ($dates_behind_names=="1"){
print '<input type="hidden" name="dates_behind_names" value="0">';
print '<input type="Submit" class="fonts" name="submit" value="'.__('Dates below names').'">';
}
else{
print '<input type="hidden" name="dates_behind_names" value="1">';
print '<input type="Submit" class="fonts" name="submit" value="'.__('Dates beside names').'">';
}
print '</form>';
// ********************************************************
// ******** Show button: nr. of generations ************
// ********************************************************
echo ' <span class="button fonts">';
echo __('Choose number of generations to display').': ';
echo '<select size=1 name="selectnr_generations" onChange="window.location=this.value;" style="display:inline;">';
for ($i=2;$i<20;$i++) {
$nr_gen=$i-1;
echo '<option';
if($nr_gen==$nr_generations) { echo ' SELECTED';}
if(CMS_SPECIFIC=='Joomla') {
echo ' value="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&nr_generations='.$nr_gen.'&show_date='.$show_date.'&dates_behind_names='.$dates_behind_names.'">'.$i.'</option>';
}
else {
echo ' value="'.$_SERVER['PHP_SELF'].'?nr_generations='.$nr_gen.'&id='.$family_id.'&main_person='.$main_person.'&show_date='.$show_date.'&dates_behind_names='.$dates_behind_names.'">'.$i.'</option>';
}
}
echo '<option';
if($nr_generations==50) { echo ' SELECTED';}
if(CMS_SPECIFIC=='Joomla') {
echo ' value="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&nr_generations=50&show_date='.$show_date.'&dates_behind_names='.$dates_behind_names.'">'.'ALL'.'</option>';
}
else {
echo ' value="'.$_SERVER['PHP_SELF'].'?nr_generations=50&id='.$family_id.'&main_person='.$main_person.'&show_date='.$show_date.'&dates_behind_names='.$dates_behind_names.'"> ALL </option>';
}
echo '</select>';
echo '</span>';
echo ' <span>';
//if($language["dir"]!="rtl") {
if($user["group_pdf_button"]=='y' AND $language["dir"]!="rtl" AND $language["name"]!="简体中文") {
//Show pdf button
print ' <form method="POST" action="'.$uri_path.'report_outline.php" style="display : inline;">';
print '<input type="hidden" name="database" value="'.$_SESSION['tree_prefix'].'">';
print '<input type="hidden" name="screen_mode" value="PDF-P">';
print '<input type="hidden" name="id" value="'.$family_id.'">';
print '<input type="hidden" name="nr_generations" value="'.$nr_generations.'">';
print '<input type="hidden" name="dates_behind_names" value="'.$dates_behind_names.'">';
print '<input type="hidden" name="show_date" value="'.$show_date.'">';
print '<input type="hidden" name="main_person" value="'.$main_person.'">';
print '<input class="fonts" type="Submit" name="submit" value="PDF (Portrait)">';
print '</form>';
}
echo '</span>';
echo ' <span>';
//if($language["dir"]!="rtl") {
if($user["group_pdf_button"]=='y' AND $language["dir"]!="rtl" AND $language["name"]!="简体中文") {
//Show pdf button
print ' <form method="POST" action="'.$uri_path.'report_outline.php" style="display : inline;">';
print '<input type="hidden" name="database" value="'.$_SESSION['tree_prefix'].'">';
print '<input type="hidden" name="screen_mode" value="PDF-L">';
print '<input type="hidden" name="id" value="'.$family_id.'">';
print '<input type="hidden" name="nr_generations" value="'.$nr_generations.'">';
print '<input type="hidden" name="dates_behind_names" value="'.$dates_behind_names.'">';
print '<input type="hidden" name="show_date" value="'.$show_date.'">';
print '<input type="hidden" name="main_person" value="'.$main_person.'">';
print '<input class="fonts" type="Submit" name="submit" value="PDF (Landscape)">';
print '</form>';
}
echo '</span>';
echo '</div><br>';
} // if not PDF
$gn=0; // generatienummer
// *************************************
// ****** FUNCTION OUTLINE ************* // recursive function
// *************************************
//some PDO prepared statements before function and loops are used
$fam_prep=$dbh->prepare("SELECT fam_man, fam_woman FROM humo_families WHERE fam_tree_id='".$tree_id."' AND fam_gedcomnumber=?");
$fam_prep->bindParam(1,$fam_prep_var);
$pers_prep=$dbh->prepare("SELECT pers_fams FROM humo_persons WHERE pers_tree_id='".$tree_id."' AND pers_gedcomnumber=?");
$pers_prep->bindParam(1,$pers_prep_var);
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;
global $fam_prep, $pers_prep, $fam_prep_var, $pers_prep_var;
$family_nr=1; //*** Process multiple families ***
if($nr_generations<$gn) {return;}
$gn++;
// *** Count marriages of man ***
// *** YB: if needed show woman as main_person ***
$fam_prep_var = $family_id;
$fam_prep->execute();
try {
@$familyDb = $fam_prep->fetch(PDO::FETCH_OBJ);
} catch(PDOException $e) {
echo __('No valid family number');
}
$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 ***
$pers_prep_var = $parent1;
$pers_prep->execute();
@$personDb = $pers_prep->fetch(PDO::FETCH_OBJ);
$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 ' ('.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 ' ('.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 ' ('.@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 ' ('.@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 ' ('.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
} // End of outline function
// ******* Start function here - recursive if started ******
if($screen_mode != 'PDF') {
echo '<table class="humo outlinetable"><tr><td>';
}
outline($family_id, $main_person, $gn, $nr_generations);
if($screen_mode != 'PDF') {
echo '</td></tr></table>';
}
//include_once(CMS_ROOTPATH."footer.php");
if($screen_mode != 'PDF') {
include_once(CMS_ROOTPATH."footer.php");
}
else {
$pdf->Output($title.".pdf","I");
}
?>