<?php

declare(strict_types=1);

ob_start();

$old = $old ?? [];

?>

<h2 class="mb-4">
    Add State / Administrative Area
</h2>

<div class="row">

    <div class="col-lg-7">

        <div class="card shadow-sm border-0">

            <div class="card-body p-4">

                <?php if (!empty($error)): ?>

                    <div class="alert alert-danger">

                        <?= htmlspecialchars(
                            (string) $error,
                            ENT_QUOTES,
                            'UTF-8'
                        ) ?>

                    </div>

                <?php endif; ?>

                <form
                    method="POST"
                    action="/public/states/create">

                    <div class="mb-3">

                        <label class="form-label">
                            Code
                        </label>

                        <input
                            type="text"
                            name="state_code"
                            class="form-control"
                            maxlength="30"
                            value="<?= htmlspecialchars(
                                (string) (
                                    $old['state_code'] ?? ''
                                ),
                                ENT_QUOTES,
                                'UTF-8'
                            ) ?>"
                            required>

                    </div>

                    <div class="mb-3">

                        <label class="form-label">
                            Name
                        </label>

                        <input
                            type="text"
                            name="state_name"
                            class="form-control"
                            maxlength="150"
                            value="<?= htmlspecialchars(
                                (string) (
                                    $old['state_name'] ?? ''
                                ),
                                ENT_QUOTES,
                                'UTF-8'
                            ) ?>"
                            required>

                    </div>

                    <div class="mb-4">

                        <label class="form-label">
                            Administrative Type
                        </label>

                        <select
                            name="administrative_type"
                            class="form-select"
                            required>

                            <option value="STATE">
                                State
                            </option>

                            <option value="ADMINISTRATIVE_AREA">
                                Administrative Area
                            </option>

                        </select>

                    </div>

                    <div class="d-flex justify-content-between">

                        <a
                            href="/public/states"
                            class="btn btn-light">
                            Cancel
                        </a>

                        <button
                            type="submit"
                            class="btn btn-primary">
                            Save Location
                        </button>

                    </div>

                </form>

            </div>

        </div>

    </div>

</div>

<?php

$content = ob_get_clean();

$title = 'Add State / Administrative Area';

include APP_PATH
    . '/Modules/Administration/Views/layouts/admin.php';