<?php

declare(strict_types=1);

ob_start();

?>

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

    <div>
        <h2 class="mb-1">
            Edit Organization
        </h2>

        <p class="text-muted mb-0">
            Update organization information.
        </p>
    </div>

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

        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/organizations/edit">

                    <input
                        type="hidden"
                        name="id"
                        value="<?= (int) $organization['id'] ?>">
<div class="mb-3">

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

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

</div>
                    <div class="mb-3">

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

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

                    </div>

                    <div class="mb-4">

                        <div class="form-check form-switch">

                            <input
                                type="checkbox"
                                class="form-check-input"
                                id="active"
                                name="active"
                                value="1"
                                <?= (int) $organization['active'] === 1
                                    ? 'checked'
                                    : '' ?>>

                            <label
                                class="form-check-label"
                                for="active">

                                Active Organization

                            </label>

                        </div>

                    </div>

                    <div class="text-end">

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

                            Save Changes

                        </button>

                    </div>

                </form>

            </div>

        </div>

    </div>

</div>

<?php

$content = ob_get_clean();

$title = 'Edit Organization';

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