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\AjaxController;
26use Fisharebest\Webtrees\Controller\PageController;
27use Fisharebest\Webtrees\Functions\FunctionsPrint;
28
29define('WT_SCRIPT_NAME', 'statistics.php');
30require './includes/session.php';
31
32// check for on demand content loading
33$tab  = Filter::getInteger('tab', 0, 3);
34$ajax = Filter::getBool('ajax');
35
36if (!$ajax) {
37    $controller = new PageController;
38    $controller
39        ->restrictAccess(Module::isActiveChart($WT_TREE, 'statistics_chart'))
40        ->setPageTitle(I18N::translate('Statistics'))
41        ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
42        ->addInlineJavascript('
43			jQuery("#statistics_chart").css("visibility", "visible");
44			jQuery("#statistics_chart").tabs({
45				load: function() {
46					jQuery("#loading-indicator").removeClass("loading-image");
47				},
48				beforeLoad: function(event, ui) {
49					// Only load each tab once
50					if (ui.tab.data("loaded")) {
51						event.preventDefault();
52						return;
53					}
54					else {
55						jQuery("#loading-indicator").addClass("loading-image");
56					}
57					ui.jqXHR.success(function() {
58						ui.tab.data("loaded", true);
59					});
60				}
61			});
62		')
63        ->pageHeader();
64
65    echo '<div id="statistics-page"><h2>', I18N::translate('Statistics'), '</h2>',
66    '<div id="statistics_chart">',
67    '<ul>',
68    '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&amp;ajax=1&amp;tab=0">',
69    '<span id="stats-indi">', I18N::translate('Individuals'), '</span></a></li>',
70    '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&amp;ajax=1&amp;tab=1">',
71    '<span id="stats-fam">', I18N::translate('Families'), '</span></a></li>',
72    '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&amp;ajax=1&amp;tab=2">',
73    '<span id="stats-other">', I18N::translate('Others'), '</span></a></li>',
74    '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&amp;ajax=1&amp;tab=3">',
75    '<span id="stats-own">', I18N::translate('Own charts'), '</span></a></li>',
76    '</ul>',
77    '<div id="loading-indicator" style="margin:auto;width:100%;"></div>',
78    '</div>', // statistics_chart
79    '</div>', // statistics-page
80    '<br><br>';
81} else {
82    $controller = new AjaxController;
83    $controller
84        ->pageHeader()
85        ->addInlineJavascript('autocomplete();')
86        ->addInlineJavascript('jQuery("#loading-indicator").removeClass("loading-image");');
87    $stats = new Stats($WT_TREE);
88    if ($tab == 0) {
89        echo '<fieldset>
90		<legend>', I18N::translate('Total individuals: %s', $stats->totalIndividuals()), '</legend>
91		<table class="facts_table">
92			<tr>
93				<td class="facts_label">', I18N::translate('Total males'), '</td>
94				<td class="facts_label">', I18N::translate('Total females'), '</td>
95				<td class="facts_label">', I18N::translate('Total living'), '</td>
96				<td class="facts_label">', I18N::translate('Total dead'), '</td>
97			</tr>
98			<tr>
99				<td class="facts_value statistics-page">', $stats->totalSexMales(), '</td>
100				<td class="facts_value statistics-page">', $stats->totalSexFemales(), '</td>
101				<td class="facts_value statistics-page">', $stats->totalLiving(), '</td>
102				<td class="facts_value statistics-page">', $stats->totalDeceased(), '</td>
103			</tr>
104			<tr>
105				<td class="facts_value statistics-page" colspan="2">', $stats->chartSex(), '</td>
106				<td class="facts_value statistics-page" colspan="2">', $stats->chartMortality(), '</td>
107			</tr>
108		</table>
109		<br>
110		<b>', I18N::translate('Events'), '</b>
111		<table class="facts_table">
112			<tr>
113				<td class="facts_label">', I18N::translate('Total births'), '</td>
114				<td class="facts_label">', I18N::translate('Total deaths'), '</td>
115			</tr>
116			<tr>
117				<td class="facts_value statistics-page">', $stats->totalBirths(), '</td>
118				<td class="facts_value statistics-page">', $stats->totalDeaths(), '</td>
119			</tr>
120			<tr>
121				<td class="facts_label">', I18N::translate('Births by century'), '</td>
122				<td class="facts_label">', I18N::translate('Deaths by century'), '</td>
123			</tr>
124			<tr>
125				<td class="facts_value statistics-page">', $stats->statsBirth(), '</td>
126				<td class="facts_value statistics-page">', $stats->statsDeath(), '</td>
127			</tr>
128			<tr>
129				<td class="facts_label">', I18N::translate('Earliest birth'), '</td>
130				<td class="facts_label">', I18N::translate('Earliest death'), '</td>
131			</tr>
132			<tr>
133				<td class="facts_value">', $stats->firstBirth(), '</td>
134				<td class="facts_value">', $stats->firstDeath(), '</td>
135			</tr>
136			<tr>
137				<td class="facts_label">', I18N::translate('Latest birth'), '</td>
138				<td class="facts_label">', I18N::translate('Latest death'), '</td>
139			</tr>
140			<tr>
141				<td class="facts_value">', $stats->lastBirth(), '</td>
142				<td class="facts_value">', $stats->lastDeath(), '</td>
143			</tr>
144		</table>
145		<br>
146		<b>', I18N::translate('Lifespan'), '</b>
147		<table class="facts_table">
148			<tr>
149				<td class="facts_label">', I18N::translate('Average age at death'), '</td>
150				<td class="facts_label">', I18N::translate('Males'), '</td>
151				<td class="facts_label">', I18N::translate('Females'), '</td>
152			</tr>
153			<tr>
154				<td class="facts_value statistics-page">', $stats->averageLifespan(true), '</td>
155				<td class="facts_value statistics-page">', $stats->averageLifespanMale(true), '</td>
156				<td class="facts_value statistics-page">', $stats->averageLifespanFemale(true), '</td>
157			</tr>
158			<tr>
159				<td class="facts_value statistics-page" colspan="3">', $stats->statsAge(), '</td>
160			</tr>
161		</table>
162		<br>
163		<b>', I18N::translate('Greatest age at death'), '</b>
164		<table class="facts_table">
165			<tr>
166				<td class="facts_label">', I18N::translate('Males'), '</td>
167				<td class="facts_label">', I18N::translate('Females'), '</td>
168			</tr>
169			<tr>
170				<td class="facts_value">', $stats->topTenOldestMaleList(), '</td>
171				<td class="facts_value">', $stats->topTenOldestFemaleList(), '</td>
172			</tr>
173		</table>
174		<br>';
175        if (Auth::check()) {
176            echo '<b>', I18N::translate('Oldest living individuals'), '</b>
177			<table class="facts_table">
178				<tr>
179					<td class="facts_label">', I18N::translate('Males'), '</td>
180					<td class="facts_label">', I18N::translate('Females'), '</td>
181				</tr>
182				<tr>
183					<td class="facts_value">', $stats->topTenOldestMaleListAlive(), '</td>
184					<td class="facts_value">', $stats->topTenOldestFemaleListAlive(), '</td>
185				</tr>
186			</table>
187			<br>';
188        }
189        echo '<b>', I18N::translate('Names'), '</b>
190		<table class="facts_table">
191			<tr>
192				<td class="facts_label">', I18N::translate('Total surnames'), '</td>
193				<td class="facts_label">', I18N::translate('Total given names'), '</td>
194			</tr>
195			<tr>
196				<td class="facts_value statistics-page">', $stats->totalSurnames(), '</td>
197				<td class="facts_value statistics-page">', $stats->totalGivennames(), '</td>
198			</tr>
199			<tr>
200				<td class="facts_label">', I18N::translate('Top surnames'), '</td>
201				<td class="facts_label">', I18N::translate('Top given names'), '</td>
202			</tr>
203			<tr>
204				<td class="facts_value statistics-page">', $stats->chartCommonSurnames(), '</td>
205				<td class="facts_value statistics-page">', $stats->chartCommonGiven(), '</td>
206			</tr>
207		</table>
208		</fieldset>';
209    } elseif ($tab == 1) {
210        echo '<fieldset>
211		<legend>', I18N::translate('Total families: %s', $stats->totalFamilies()), '</legend>
212		<b>', I18N::translate('Events'), '</b>
213		<table class="facts_table">
214			<tr>
215				<td class="facts_label">', I18N::translate('Total marriages'), '</td>
216				<td class="facts_label">', I18N::translate('Total divorces'), '</td>
217			</tr>
218			<tr>
219				<td class="facts_value statistics-page">', $stats->totalMarriages(), '</td>
220				<td class="facts_value statistics-page">', $stats->totalDivorces(), '</td>
221			</tr>
222			<tr>
223				<td class="facts_label">', I18N::translate('Marriages by century'), '</td>
224				<td class="facts_label">', I18N::translate('Divorces by century'), '</td>
225			</tr>
226			<tr>
227				<td class="facts_value statistics-page">', $stats->statsMarr(), '</td>
228				<td class="facts_value statistics-page">', $stats->statsDiv(), '</td>
229			</tr>
230			<tr>
231				<td class="facts_label">', I18N::translate('Earliest marriage'), '</td>
232				<td class="facts_label">', I18N::translate('Earliest divorce'), '</td>
233			</tr>
234			<tr>
235				<td class="facts_value">', $stats->firstMarriage(), '</td>
236				<td class="facts_value">', $stats->firstDivorce(), '</td>
237			</tr>
238			<tr>
239				<td class="facts_label">', I18N::translate('Latest marriage'), '</td>
240				<td class="facts_label">', I18N::translate('Latest divorce'), '</td>
241			</tr>
242			<tr>
243				<td class="facts_value">', $stats->lastMarriage(), '</td>
244				<td class="facts_value">', $stats->lastDivorce(), '</td>
245			</tr>
246		</table>
247		<br>
248		<b>', I18N::translate('Length of marriage'), '</b>
249		<table class="facts_table">
250			<tr>
251				<td class="facts_label">', I18N::translate('Longest marriage'), ' - ', $stats->topAgeOfMarriage(), '</td>
252				<td class="facts_label">', I18N::translate('Shortest marriage'), ' - ', $stats->minAgeOfMarriage(), '</td>
253			</tr>
254			<tr>
255				<td class="facts_value">', $stats->topAgeOfMarriageFamily(), '</td>
256				<td class="facts_value">', $stats->minAgeOfMarriageFamily(), '</td>
257			</tr>
258		</table>
259		<br>
260		<b>', I18N::translate('Age in year of marriage'), '</b>
261		<table class="facts_table">
262			<tr>
263				<td class="facts_label">', I18N::translate('Youngest male'), ' - ', $stats->youngestMarriageMaleAge(true), '</td>
264				<td class="facts_label">', I18N::translate('Youngest female'), ' - ', $stats->youngestMarriageFemaleAge(true), '</td>
265			</tr>
266			<tr>
267				<td class="facts_value">', $stats->youngestMarriageMale(), '</td>
268				<td class="facts_value">', $stats->youngestMarriageFemale(), '</td>
269			</tr>
270			<tr>
271				<td class="facts_label">', I18N::translate('Oldest male'), ' - ', $stats->oldestMarriageMaleAge(true), '</td>
272				<td class="facts_label">', I18N::translate('Oldest female'), ' - ', $stats->oldestMarriageFemaleAge(true), '</td>
273			</tr>
274			<tr>
275				<td class="facts_value">', $stats->oldestMarriageMale(), '</td>
276				<td class="facts_value">', $stats->oldestMarriageFemale(), '</td>
277			</tr>
278			<tr>
279				<td class="facts_value statistics-page" colspan="2">', $stats->statsMarrAge(), '</td>
280			</tr>
281		</table>
282		<br>
283		<b>', I18N::translate('Age at birth of child'), '</b>
284		<table class="facts_table">
285			<tr>
286				<td class="facts_label">', I18N::translate('Youngest father'), ' - ', $stats->youngestFatherAge(true), '</td>
287				<td class="facts_label">', I18N::translate('Youngest mother'), ' - ', $stats->youngestMotherAge(true), '</td>
288			</tr>
289			<tr>
290				<td class="facts_value">', $stats->youngestFather(), '</td>
291				<td class="facts_value">', $stats->youngestMother(), '</td>
292			</tr>
293			<tr>
294				<td class="facts_label">', I18N::translate('Oldest father'), ' - ', $stats->oldestFatherAge(true), '</td>
295				<td class="facts_label">', I18N::translate('Oldest mother'), ' - ', $stats->oldestMotherAge(true), '</td>
296			</tr>
297			<tr>
298				<td class="facts_value">', $stats->oldestFather(), '</td>
299				<td class="facts_value">', $stats->oldestMother(), '</td>
300			</tr>
301		</table>
302		<br>
303		<b>', I18N::translate('Children in family'), '</b>
304		<table class="facts_table">
305			<tr>
306				<td class="facts_label">', I18N::translate('Average number of children per family'), '</td>
307				<td class="facts_label">', I18N::translate('Number of families without children'), '</td>
308			</tr>
309			<tr>
310				<td class="facts_value statistics-page">', $stats->averageChildren(), '</td>
311				<td class="facts_value statistics-page">', $stats->noChildrenFamilies(), '</td>
312			</tr>
313			<tr>
314				<td class="facts_value statistics-page">', $stats->statsChildren(), '</td>
315				<td class="facts_value statistics-page">', $stats->chartNoChildrenFamilies(), '</td>
316			</tr>
317			<tr>
318				<td class="facts_label">', I18N::translate('Largest families'), '</td>
319				<td class="facts_label">', I18N::translate('Largest number of grandchildren'), '</td>
320			</tr>
321			<tr>
322				<td class="facts_value">', $stats->topTenLargestFamilyList(), '</td>
323				<td class="facts_value">', $stats->topTenLargestGrandFamilyList(), '</td>
324			</tr>
325		</table>
326		<br>
327		<b>', I18N::translate('Age difference'), '</b>
328		<table class="facts_table">
329			<tr>
330				<td class="facts_label">', I18N::translate('Age between siblings'), '</td>
331				<td class="facts_label">', I18N::translate('Greatest age between siblings'), '</td>
332			</tr>
333			<tr>
334				<td class="facts_value">', $stats->topAgeBetweenSiblingsList(), '</td>
335				<td class="facts_value">', $stats->topAgeBetweenSiblingsFullName(), '</td>
336			</tr>
337			<tr>
338				<td class="facts_label">', I18N::translate('Age between husband and wife'), '</td>
339				<td class="facts_label">', I18N::translate('Age between wife and husband'), '</td>
340			</tr>
341			<tr>
342				<td class="facts_value">', $stats->ageBetweenSpousesMFList(), '</td>
343				<td class="facts_value">', $stats->ageBetweenSpousesFMList(), '</td>
344			</tr>
345		</table>
346		</fieldset>';
347    } elseif ($tab == 2) {
348        echo '
349		<fieldset>
350			<legend>', I18N::translate('Records'), ': ', $stats->totalRecords(), '</legend>
351			<table class="facts_table">
352			<tr>
353				<td class="facts_label">', I18N::translate('Media objects'), '</td>
354				<td class="facts_label">', I18N::translate('Sources'), '</td>
355				<td class="facts_label">', I18N::translate('Notes'), '</td>
356				<td class="facts_label">', I18N::translate('Repositories'), '</td>
357			</tr>
358			<tr>
359				<td class="facts_value statistics-page">', $stats->totalMedia(), '</td>
360				<td class="facts_value statistics-page">', $stats->totalSources(), '</td>
361				<td class="facts_value statistics-page">', $stats->totalNotes(), '</td>
362				<td class="facts_value statistics-page">', $stats->totalRepositories(), '</td>
363			</tr>
364			</table>
365		</fieldset>
366		<fieldset>
367			<legend>', I18N::translate('Total events'), ': ', $stats->totalEvents(), '</legend>
368			<table class="facts_table">
369				<tr>
370					<td class="facts_label">', I18N::translate('First event'), ' - ', $stats->firstEventType(), '</td>
371					<td class="facts_label">', I18N::translate('Last event'), ' - ', $stats->lastEventType(), '</td>
372				</tr>
373				<tr>
374					<td class="facts_value">', $stats->firstEvent(), '</td>
375					<td class="facts_value">', $stats->lastEvent(), '</td>
376				</tr>
377			</table>
378		</fieldset>
379		<fieldset>
380			<legend>', I18N::translate('Media objects'), ': ', $stats->totalMedia(), '</legend>
381			<table class="facts_table">
382				<tr>
383					<td class="facts_label">', I18N::translate('Media objects'), '</td>
384				</tr>
385				<tr>
386					<td class="facts_value statistics-page">', $stats->chartMedia(), '</td>
387				</tr>
388			</table>
389		</fieldset>
390		<fieldset>
391			<legend>', I18N::translate('Sources'), ': ', $stats->totalSources(), '</legend>
392			<table class="facts_table">
393				<tr>
394					<td class="facts_label">', I18N::translate('Individuals with sources'), '</td>
395					<td class="facts_label">', I18N::translate('Families with sources'), '</td>
396				</tr>
397				<tr>
398					<td class="facts_value statistics-page">', $stats->totalIndisWithSources(), '</td>
399					<td class="facts_value statistics-page">', $stats->totalFamsWithSources(), '</td>
400				</tr>
401				<tr>
402					<td class="facts_value statistics-page">', $stats->chartIndisWithSources(), '</td>
403					<td class="facts_value statistics-page">', $stats->chartFamsWithSources(), '</td>
404				</tr>
405			</table>
406		</fieldset>
407		<fieldset>
408			<legend>', I18N::translate('Places'), ': ', $stats->totalPlaces(), '</legend>
409			<table class="facts_table">
410				<tr>
411					<td class="facts_label">', I18N::translate('Birth places'), '</td>
412					<td class="facts_label">', I18N::translate('Death places'), '</td>
413				</tr>
414				<tr>
415					<td class="facts_value">', $stats->commonBirthPlacesList(), '</td>
416					<td class="facts_value">', $stats->commonDeathPlacesList(), '</td>
417				</tr>
418				<tr>
419					<td class="facts_label">', I18N::translate('Marriage places'), '</td>
420					<td class="facts_label">', I18N::translate('Events in countries'), '</td>
421				</tr>
422				<tr>
423					<td class="facts_value">', $stats->commonMarriagePlacesList(), '</td>
424					<td class="facts_value">', $stats->commonCountriesList(), '</td>
425				</tr>
426				<tr>
427					<td class="facts_value" colspan="2">', $stats->chartDistribution(), '</td>
428				</tr>
429			</table>
430		</fieldset>';
431    } elseif ($tab == 3) {
432        ?>
433        <script>
434            function statusHide(sel) {
435                var box = document.getElementById(sel);
436                box.style.display = 'none';
437                var box_m = document.getElementById(sel + '_m');
438                if (box_m) {
439                    box_m.style.display = 'none';
440                }
441                if (sel == 'map_opt') {
442                    var box_axes = document.getElementById('axes');
443                    if (box_axes) {
444                        box_axes.style.display = '';
445                    }
446                    var box_zyaxes = document.getElementById('zyaxes');
447                    if (box_zyaxes) {
448                        box_zyaxes.style.display = '';
449                    }
450                }
451            }
452            function statusShow(sel) {
453                var box = document.getElementById(sel);
454                box.style.display = '';
455                var box_m = document.getElementById(sel + '_m');
456                if (box_m) {
457                    box_m.style.display = 'none';
458                }
459                if (sel == 'map_opt') {
460                    var box_axes = document.getElementById('axes');
461                    if (box_axes) {
462                        box_axes.style.display = 'none';
463                    }
464                    var box_zyaxes = document.getElementById('zyaxes');
465                    if (box_zyaxes) {
466                        box_zyaxes.style.display = 'none';
467                    }
468                }
469            }
470            function statusShowSurname(x) {
471                if (x.value == 'surname_distribution_chart') {
472                    document.getElementById('surname_opt').style.display = '';
473                } else if (x.value !== 'surname_distribution_chart') {
474                    document.getElementById('surname_opt').style.display = 'none';
475                }
476            }
477            function statsModalDialog() {
478                var form = jQuery('#own-stats-form');
479                jQuery.get(form.attr('action'), form.serialize(), function (response) {
480                    jQuery(response).dialog({
481                        modal: true,
482                        width: 964,
483                        open: function () {
484                            var self = this;
485                            // Close the window when we click outside it.
486                            jQuery(".ui-widget-overlay").on("click", function () {
487                                $(self).dialog('close');
488                            });
489                        }
490                    });
491                });
492                return false;
493            }
494        </script>
495        <fieldset>
496            <legend>
497                <?php echo I18N::translate('Create your own chart') ?>
498            </legend>
499            <div id="own-stats">
500                <form method="post" id="own-stats-form" action="statisticsplot.php" onsubmit="return statsModalDialog();">
501                    <input type="hidden" name="action" value="update">
502                    <table style="width:100%">
503                        <tr>
504                            <td class="descriptionbox width25 wrap">
505                                <?php echo I18N::translate('Chart type') ?>
506                            </td>
507                            <td class="optionbox">
508                                <label>
509                                    <input type="radio" name="x-as" value="11" checked onclick="statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
510                                    <?php echo I18N::translate('Month of birth') ?>
511                                </label>
512                                <br>
513                                <label>
514                                    <input type="radio" name="x-as" value="12" onclick="statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
515                                    <?php echo I18N::translate('Month of death') ?>
516                                </label>
517                                <br>
518                                <label>
519                                    <input type="radio" name="x-as" value="13" onclick="statusChecked('z_none'); statusDisable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
520                                    <?php echo I18N::translate('Month of marriage'); ?>
521                                </label>
522                                <br>
523                                <label>
524                                    <input type="radio" name="x-as" value="15" onclick="statusChecked('z_none'); statusDisable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
525                                    <?php echo I18N::translate('Month of first marriage') ?>
526                                </label>
527                                <br>
528                                <label>
529                                    <input type="radio" name="x-as" value="14" onclick="statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
530                                    <?php echo I18N::translate('Month of birth of first child in a relation') ?>
531                                </label>
532                                <br>
533                                <label>
534                                    <input type="radio" name="x-as" value="17" onclick="statusEnable('z_sex'); statusShow('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
535                                    <?php echo I18N::translate('Age related to birth year') ?>
536                                </label>
537                                <br>
538                                <label>
539                                    <input type="radio" name="x-as" value="18" onclick="statusEnable('z_sex'); statusShow('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
540                                    <?php echo I18N::translate('Age related to death year') ?>
541                                </label>
542                                <br>
543                                <label>
544                                    <input type="radio" name="x-as" value="19" onclick="statusEnable('z_sex'); statusHide('x_years'); statusShow('x_years_m'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
545                                    <?php echo I18N::translate('Age in year of marriage') ?>
546                                </label>
547                                <br>
548                                <label>
549                                    <input type="radio" name="x-as" value="20" onclick="statusEnable('z_sex'); statusHide('x_years'); statusShow('x_years_m'); statusHide('x_months'); statusHide('x_numbers'); statusHide('map_opt');">
550                                    <?php echo I18N::translate('Age in year of first marriage') ?>
551                                </label>
552                                <br>
553                                <label>
554                                    <input type="radio" name="x-as" value="21" onclick="statusEnable('z_sex'); statusHide('x_years'); statusHide('x_months'); statusShow('x_numbers'); statusHide('map_opt');">
555                                    <?php echo I18N::translate('Number of children') ?>
556                                </label>
557                                <br>
558                                <label>
559                                    <input type="radio" name="x-as" value="1" onclick="statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusShow('chart_type'); statusHide('axes');">
560                                    <?php echo I18N::translate('Individual distribution') ?>
561                                </label>
562                                <br>
563                                <label>
564                                    <input type="radio" name="x-as" value="2" onclick="statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');">
565                                    <?php echo I18N::translate('Birth by country') ?>
566                                </label>
567                                <br>
568                                <label>
569                                    <input type="radio" name="x-as" value="4" onclick="statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');">
570                                    <?php echo I18N::translate('Marriage by country') ?>
571                                </label>
572                                <br>
573                                <label>
574                                    <input type="radio" name="x-as" value="3" onclick="statusHide('x_years'); statusHide('x_months'); statusHide('x_numbers'); statusShow('map_opt'); statusHide('chart_type'); statusHide('surname_opt');">
575                                    <?php echo I18N::translate('Death by country') ?>
576                                </label>
577                                <br>
578                                <br>
579                                <div id="x_years" style="display:none;">
580                                    <label for="x-axis-boundaries-ages">
581                                        <?php echo I18N::translate('Select the desired age interval') ?>
582                                    </label>
583                                    <br>
584                                        <select id="x-axis-boundaries-ages" name="x-axis-boundaries-ages">
585                                            <option value="1,5,10,20,30,40,50,60,70,80,90,100" selected>
586                                                <?php echo I18N::plural('interval %s year', 'interval %s years', 10, I18N::number(10)) ?>
587                                            </option>
588                                            <option value="5,20,40,60,75,80,85,90">
589                                                <?php echo I18N::plural('interval %s year', 'interval %s years', 20, I18N::number(20)) ?>
590                                            </option>
591                                            <option value="10,25,50,75,100">
592                                                <?php echo I18N::plural('interval %s year', 'interval %s years', 25, I18N::number(25)) ?>
593                                            </option>
594                                        </select>
595                                    <br>
596                                </div>
597                                <div id="x_years_m" style="display:none;">
598                                    <label for="x-axis-boundaries-ages_m">
599                                        <?php echo I18N::translate('Select the desired age interval') ?>
600                                    </label>
601                                    <br>
602                                    <select id="x-axis-boundaries-ages_m" name="x-axis-boundaries-ages_m">
603                                        <option value="16,18,20,22,24,26,28,30,32,35,40,50" selected>
604                                            <?php echo I18N::plural('interval %s year', 'interval %s years', 2, I18N::number(2)) ?>
605                                        </option>
606                                        <option value="20,25,30,35,40,45,50">
607                                            <?php echo I18N::plural('interval %s year', 'interval %s years', 5, I18N::number(5)) ?>
608                                        </option>
609                                    </select>
610                                    <br>
611                                </div>
612                                <div id="x_months" style="display:none;">
613                                    <label for="x-axis-boundaries-months">
614                                        <?php I18N::translate('Select the desired age interval') ?>
615                                    </label>
616                                    <br>
617                                    <select id="x-axis-boundaries-months" name="x-axis-boundaries-months">
618                                        <option value="0,8,12,15,18,24,48" selected>
619                                            <?php echo I18N::translate('months after marriage') ?>
620                                        </option>
621                                        <option value="-24,-12,0,8,12,18,24,48">
622                                            <?php echo I18N::translate('months before and after marriage') ?>
623                                        </option>
624                                        <option value="0,6,9,12,15,18,21,24">
625                                            <?php echo I18N::translate('quarters after marriage') ?>
626                                        </option>
627                                        <option value="0,6,12,18,24">
628                                            <?php echo I18N::translate('half-year after marriage') ?>
629                                        </option>
630                                    </select>
631                                    <br>
632                                </div>
633                                <div id="x_numbers" style="display:none;">
634                                    <label for="x-axis-boundaries-numbers">
635                                        <?php echo I18N::translate('Select the desired count interval') ?>
636                                    </label>
637                                    <br>
638                                    <select id="x-axis-boundaries-numbers" name="x-axis-boundaries-numbers">
639                                        <option value="1,2,3,4,5,6,7,8,9,10" selected>
640                                            <?php echo I18N::translate('interval one child') ?>
641                                        </option>
642                                        <option value="2,4,6,8,10,12">
643                                            <?php echo I18N::translate('interval two children') ?>
644                                        </option>
645                                    </select>
646                                    <br>
647                                </div>
648                                <div id="map_opt" style="display:none;">
649                                    <div id="chart_type">
650                                        <label>
651                                            <?php echo I18N::translate('Chart type') ?>
652                                            <br>
653                                            <select name="chart_type" onchange="statusShowSurname(this);">
654                                                <option value="indi_distribution_chart" selected>
655                                                    <?php echo I18N::translate('Individual distribution chart') ?>
656                                                </option>
657                                                <option value="surname_distribution_chart">
658                                                    <?php echo I18N::translate('Surname distribution chart') ?>
659                                                </option>
660                                            </select>
661                                        </label>
662                                        <br>
663                                    </div>
664                                    <div id="surname_opt" style="display:none;">
665                                        <label for="SURN">
666                                            <?php echo GedcomTag::getLabel('SURN') ?>
667                                        </label>
668                                        <?php echo FunctionsPrint::helpLink('google_chart_surname'); ?>
669                                        <br>
670                                        <input data-autocomplete-type="SURN" type="text" id="SURN" name="SURN" size="20">
671                                        <br>
672                                    </div>
673                                        <label for="chart_shows">
674                                            <?php echo I18N::translate('Geographic area') ?>
675                                        </label>
676                                        <br>
677                                        <select id="chart_shows" name="chart_shows">
678                                            <option value="world" selected>
679                                                <?php echo I18N::translate('World') ?>
680                                            </option>
681                                            <option value="europe">
682                                                <?php echo I18N::translate('Europe') ?>
683                                            </option>
684                                            <option value="usa">
685                                                <?php echo I18N::translate('United States') ?>
686                                            </option>
687                                            <option value="south_america">
688                                                <?php echo I18N::translate('South America') ?>
689                                            </option>
690                                            <option value="asia">
691                                                <?php echo I18N::translate('Asia') ?>
692                                            </option>
693                                            <option value="middle_east">
694                                                <?php echo I18N::translate('Middle East') ?>
695                                            </option>
696                                            <option value="africa">
697                                                <?php echo I18N::translate('Africa') ?>
698                                            </option>
699                                        </select>
700                                    </div>
701                                </td>
702                            <td class="descriptionbox width20 wrap" id="axes">
703                                    <?php echo I18N::translate('Categories') ?>
704                            </td>
705                            <td class="optionbox width30" id="zyaxes">
706                                <label>
707                                    <input type="radio" id="z_none" name="z-as" value="300" onclick="statusDisable('z-axis-boundaries-periods');">
708                                    <?php echo I18N::translate('overall') ?>
709                                </label>
710                                <br>
711                                <label>
712                                    <input type="radio" id="z_sex" name="z-as" value="301" onclick="statusDisable('z-axis-boundaries-periods');">
713                                    <?php echo I18N::translate('gender') ?>
714                                </label>
715                                <br>
716                                <label>
717                                    <input type="radio" id="z_time" name="z-as" value="302" checked onclick="statusEnable('z-axis-boundaries-periods');">
718                                    <?php echo I18N::translate('date periods') ?>
719                                </label>
720                                <br>
721                                <br>
722                                <label for="z-axis-boundaries-periods">
723                                    <?php echo I18N::translate('Date range') ?>
724                                </label>
725                                <br>
726                                <select id="z-axis-boundaries-periods" name="z-axis-boundaries-periods">
727                                    <option value="1700,1750,1800,1850,1900,1950,2000" selected>
728                                        <?php echo /* I18N: from 1700 interval 50 years */ I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 50, I18N::digits(1700), I18N::number(50)) ?>
729                                    </option>
730                                    <option value="1800,1840,1880,1920,1950,1970,2000">
731                                        <?php echo I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 40, I18N::digits(1800), I18N::number(40)) ?>
732                                    </option>
733                                    <option value="1800,1850,1900,1950,2000">
734                                        <?php echo I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 50, I18N::digits(1800), I18N::number(50)) ?>
735                                    </option>
736                                    <option value="1900,1920,1940,1960,1980,1990,2000">
737                                        <?php echo I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 20, I18N::digits(1900), I18N::number(20)) ?>
738                                    </option>
739                                    <option value="1900,1925,1950,1975,2000">
740                                        <?php echo I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 25, I18N::digits(1900), I18N::number(25)) ?>
741                                    </option>
742                                    <option value="1940,1950,1960,1970,1980,1990,2000">
743                                        <?php echo I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 10, I18N::digits(1940), I18N::number(10)) ?>
744                                    </option>
745                                </select>
746                                <br>
747                                <br>
748                                <?php echo I18N::translate('Results') ?>
749                                <br>
750                                <label>
751                                    <input type="radio" name="y-as" value="201" checked>
752                                    <?php echo I18N::translate('numbers') ?>
753                                </label>
754                                <br>
755                                <label>
756                                    <input type="radio" name="y-as" value="202">
757                                    <?php echo I18N::translate('percentage') ?>
758                                </label>
759                                <br>
760                            </td>
761                        </tr>
762                    </table>
763                    <p class="center">
764                        <button type="submit">
765                            <?php echo I18N::translate('show the chart') ?>
766                        </button>
767                    </p>
768                </form>
769            </div>
770        </fieldset>
771        <?php
772    }
773}
774