<?php

declare(strict_types=1);

ob_start();

$old = $old ?? [];

?>

<div class="d-flex justify-content-between align-items-center mb-4">

    <div>

        <h2 class="mb-1">
            Create Role
        </h2>

        <p class="text-muted mb-0">
            Create a new system access role.
        </p>

    </div>

    <a
        href="/public/roles"
        class="btn btn-outline-secondary">

        <i class="bi bi-arrow-left me-1"></i>

        Back

    </a>

</div>


<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(
                            $error,
                            ENT_QUOTES,
                            'UTF-8'
                        ) ?>

                    </div>

                <?php endif; ?>


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

                    <div class="mb-3">

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

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

                    </div>


                    <div class="mb-3">

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

                        <textarea
                            name="description"
                            class="form-control"
                            rows="4"><?= htmlspecialchars(
                                (string) (
                                    $old['description']
                                    ?? ''
                                ),
                                ENT_QUOTES,
                                'UTF-8'
                            ) ?></textarea>

                    </div>


                    <div class="d-flex justify-content-end gap-2">

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

                            Cancel

                        </a>

                        <button
                            type="submit"
                            class="btn btn-primary">

                            Create Role

                        </button>

                    </div>

                </form>

            </div>

        </div>

    </div>

</div>

<?php

$content = ob_get_clean();

$title = 'Create Role';

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