<?php

use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\I18N;

?>

<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>

<h1><?= $title ?></h1>

<?php if ($xrefs > 0) : ?>
    <p>
        <?= I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.') ?>
    </p>
    <p>
        <?= I18N::plural(/* I18N: An XREF is the identification number used in GEDCOM files. */ 'The two family trees have %1$s record which uses the same “XREF”.', 'The two family trees have %1$s records which use the same “XREF”.', $xrefs, I18N::number($xrefs)) ?>
    </p>
    <p>
        <?= I18N::translate('You must renumber the records in one of the trees before you can merge them.') ?>
    </p>
    <p>
        <a class="current" href="<?= e(route('admin-trees-renumber', ['tree' => $tree1->name()])) ?>">
            <?= I18N::translate('Renumber family tree') ?> — <?= e($tree1->title()) ?>
        </a>
    </p>
    <p>
        <a class="current" href="<?= e(route('admin-trees-renumber', ['tree' => $tree2->name()])) ?>">
            <?= I18N::translate('Renumber family tree') ?> — <?= e($tree2->title()) ?>
        </a>
    </p>
<?php endif ?>

<form method="post" action="<?= e(route('admin-trees-merge')) ?>">
    <?= csrf_field() ?>
    <p class="form-inline">
        <?= I18N::translate(/* I18N: Copy all the records from [family tree 1] into [family tree 2] */
            'Copy all the records from %1$s into %2$s.',
            view('components/select', ['name' => 'tree1_name', 'selected' => $tree1 ? $tree1->name() : '', 'options' => $tree_list]),
            view('components/select', ['name' => 'tree2_name', 'selected' => $tree2 ? $tree2->name() : '', 'options' => $tree_list])
        ) ?>
    </p>

    <button type="submit" class="btn btn-primary">
        <?= view('icons/save') ?>
        <?= I18N::translate('continue') ?>
    </button>
</form>
