1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees;
17
18/**
19 * Defined in session.php
20 *
21 * @global Tree   $WT_TREE
22 */
23global $WT_TREE;
24
25use Fisharebest\Webtrees\Controller\FamilyBookController;
26use Fisharebest\Webtrees\Functions\FunctionsEdit;
27use Fisharebest\Webtrees\Functions\FunctionsPrint;
28
29define('WT_SCRIPT_NAME', 'familybook.php');
30require './includes/session.php';
31
32$controller = new FamilyBookController;
33$controller
34    ->restrictAccess(Module::isActiveChart($WT_TREE, 'family_book_chart'))
35    ->pageHeader()
36    ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
37    ->addInlineJavascript('autocomplete();');
38
39?>
40<div id="familybook-page">
41    <h2><?php echo $controller->getPageTitle(); ?></h2>
42    <form method="get" name="people" action="?">
43        <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>">
44        <table class="list_table">
45            <tbody>
46                <tr>
47                    <td class="descriptionbox">
48                        <?php echo I18N::translate('Individual'); ?>
49                    </td>
50                    <td class="optionbox">
51                        <input class="pedigree_form" data-autocomplete-type="INDI" type="text" name="rootid" id="rootid" size="3" value="<?php echo $controller->root->getXref(); ?>">
52                        <?php echo FunctionsPrint::printFindIndividualLink('rootid'); ?>
53                    </td>
54                    <td class="descriptionbox">
55                        <?php echo I18N::translate('Show details'); ?>
56                    </td>
57                    <td class="optionbox">
58                        <?php echo FunctionsEdit::twoStateCheckbox('show_full', $controller->showFull()); ?>
59                    </td>
60                    <td rowspan="3" class="topbottombar vmiddle">
61                        <input type="submit" value="<?php echo /* I18N: A button label. */ I18N::translate('view'); ?>">
62                    </td>
63                </tr>
64                <tr>
65                    <td class="descriptionbox">
66                        <?php echo I18N::translate('Generations'); ?>
67                    </td>
68                    <td class="optionbox">
69                        <select name="generations">
70                            <?php
71                            for ($i = 2; $i <= $WT_TREE->getPreference('MAX_DESCENDANCY_GENERATIONS'); $i++) {
72                                echo '<option value="' . $i . '" ';
73                                if ($i == $controller->generations) {
74                                    echo 'selected';
75                                }
76                                echo '>' . I18N::number($i) . '</option>';
77                            }
78                            ?>
79                        </select>
80                    </td>
81                    <td rowspan="2" class="descriptionbox">
82                        <?php echo I18N::translate('Show spouses'); ?>
83                    </td>
84                    <td rowspan="2" class="optionbox">
85                        <input type="checkbox" value="1" name="show_spouse" <?php echo $controller->show_spouse ? 'checked' : ''; ?>>
86                    </td>
87                </tr>
88                <tr>
89                    <td class="descriptionbox">
90                        <?php echo I18N::translate('Descendant generations'); ?>
91                    </td>
92                    <td class="optionbox">
93                        <select name="descent">
94                            <?php
95                            for ($i = 0; $i <= 9; $i++) {
96                                echo '<option value="' . $i . '" ';
97                                if ($i === $controller->descent) {
98                                    echo 'selected';
99                                }
100                                echo '>' . I18N::number($i) . '</option>';
101                            }
102                            ?>
103                        </select>
104                    </td>
105                </tr>
106            </tbody>
107        </table>
108    </form>
109    <div id="familybook_chart" style="z-index:1;">
110    <?php
111    if ($controller->root) {
112        $controller->printFamilyBook($controller->root, $controller->descent);
113    }
114    ?>
115    </div>
116</div>
117