<?php

use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Webtrees;

?>

<form method="post" autocomplete="off">
    <input name="lang" type="hidden" value="<?= e($lang) ?>">
    <input name="dbtype" type="hidden" value="<?= e($dbtype) ?>">
    <input name="dbhost" type="hidden" value="<?= e($dbhost) ?>">
    <input name="dbport" type="hidden" value="<?= e($dbport) ?>">
    <input name="dbuser" type="hidden" value="<?= e($dbuser) ?>">
    <input name="dbpass" type="hidden" value="<?= e($dbpass) ?>">
    <input name="wtname" type="hidden" value="<?= e($wtname) ?>">
    <input name="wtuser" type="hidden" value="<?= e($wtuser) ?>">
    <input name="wtpass" type="hidden" value="<?= e($wtpass) ?>">
    <input name="wtemail" type="hidden" value="<?= e($wtemail) ?>">

    <h2>
        <?= I18N::translate('Database connection') ?> – SQLite
    </h2>

    <?php foreach ($errors as $error) : ?>
        <p class="alert alert-danger"><?= $error ?></p>
    <?php endforeach ?>

    <?php foreach ($warnings as $warning) : ?>
        <p class="alert alert-warning"><?= $warning ?></p>
    <?php endforeach ?>

    <div class="row form-group">
        <label class="col-form-label col-sm-3" for="dbname">
            <?= I18N::translate('Database name') ?>
        </label>

        <div class="col-sm-9">
            <div class="input-group" dir="ltr">
                <div class="input-group-prepend">
                    <span class="input-group-text"><?=e(realpath(Webtrees::ROOT_DIR)) ?>/data/</span>
                </div>

                <input class="form-control" id="dbname" name="dbname" pattern="[a-zA-Z0-9_]{1,63}" type="text" value="<?= e($dbname) ?>">

                <div class="input-group-append">
                    <span class="input-group-text">.sqlite</span>
                </div>
            </div>

            <p class="small text-muted">
                <?= I18N::translate('Use letters A-Z, a-z, digits 0-9, or underscores') ?>
            </p>
        </div>
    </div>

    <div class="row form-group">
        <label class="col-form-label col-sm-3" for="tblpfx">
            <?= I18N::translate('Table prefix') ?>
        </label>

        <div class="col-sm-9">
            <input class="form-control" dir="ltr" id="tblpfx" maxlength="15" name="tblpfx" pattern="[a-zA-Z0-9_]+" type="text" value="<?= e($tblpfx) ?>">

            <p class="small text-muted">
                <?= I18N::translate('The prefix is optional, but recommended. By giving the table names a unique prefix you can let several different applications share the same database.') ?>
                <?= I18N::translate('Use letters A-Z, a-z, digits 0-9, or underscores') ?>
            </p>
        </div>
    </div>

    <hr>

    <div class="d-flex justify-content-between">
        <button class="btn btn-primary" name="step" type="submit" value="5">
            <?= I18N::translate('next') ?>
        </button>

        <button class="btn btn-secondary" name="step" type="submit" value="3">
            <?= I18N::translate('previous') ?>
        </button>
    </div>
</form>
