<?php use Fisharebest\Webtrees\Auth; ?>
<?php use Fisharebest\Webtrees\FontAwesome; ?>
<?php use Fisharebest\Webtrees\I18N; ?>

<div class="dropdown wt-page-menu">
    <button class="btn btn-primary dropdown-toggle wt-page-menu-button" type="button" id="page-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <?= FontAwesome::decorativeIcon('edit') ?>
        <?= I18N::translate('edit') ?>
    </button>
    <div class="dropdown-menu dropdown-menu-right wt-page-menu-items" aria-labelledby="page-menu">
        <?php if ($count_sex === 0) : ?>
            <a class="dropdown-item menu-indi-editraw" href="<?= e(route('add-fact', ['fact' => 'SEX', 'ged' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
                <?= I18N::translate('Edit the gender') ?>
            </a>

        <?php endif ?>

        <a class="dropdown-item menu-indi-editraw" href="<?= e(route('add-name', ['ged' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
            <?= I18N::translate('Add a name') ?>
        </a>

        <?php if ($count_names > 1) : ?>
            <a class="dropdown-item menu-indi-editraw" href="<?= e(route('reorder-names', ['ged' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
                <?= I18N::translate('Re-order names') ?>
            </a>
        <?php endif ?>

        <?php if (empty($individual->facts(['SEX']))) : ?>
            <a class="dropdown-item menu-indi-editraw" href="<?= e(route('add-fact', ['fact' => 'SEX', 'ged' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
                <?= I18N::translate('Edit the gender') ?>
            </a>
        <?php endif ?>


        <a class="dropdown-item menu-indi-del" href="#" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', strip_tags($individual->getFullName())) ?>" onclick="return confirm(this.dataset.confirm) && delete_record('<?= e($individual->xref()) ?>', '<?= e($individual->tree()->name()) ?>');">
            <?= I18N::translate('Delete') ?>
        </a>

        <?php if (Auth::isAdmin() || $individual->tree()->getPreference('SHOW_GEDCOM_RECORD')) : ?>
            <div class="dropdown-divider"></div>

            <a class="dropdown-item menu-indi-editraw" href="<?= e(route('edit-raw-record', ['ged' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>">
                <?= I18N::translate('Edit the raw GEDCOM') ?>
            </a>
        <?php endif ?>
    </div>
</div>
