<?php

use ChurchCRM\dto\SystemURLs;

include SystemURLs::getDocumentRoot() . '/Include/Header.php';
?>

<div class="container-fluid">
    <div class="card shadow-sm">
        <div class="card-body">
            <form method="POST" action="<?= SystemURLs::getRootPath() ?>/admin/website/gallery/<?= $image ? 'edit/' . $image['gal_id'] : 'create' ?>" enctype="multipart/form-data">
                <div class="mb-3">
                    <label class="form-label"><?= gettext('Image URL') ?> <span class="text-danger">*</span></label>
                    <input type="url" name="image_url" class="form-control" placeholder="https://example.com/photo.jpg" value="<?= $image['gal_image_url'] ?? '' ?>">
                    <small class="text-secondary"><?= gettext('Or upload a file below') ?></small>
                    <input type="file" name="image_file" class="form-control mt-1" accept="image/*">
                </div>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label class="form-label"><?= gettext('Title') ?></label>
                        <input type="text" name="title" class="form-control" value="<?= $image['gal_title'] ?? '' ?>">
                    </div>
                    <div class="col-md-6 mb-3">
                        <label class="form-label"><?= gettext('Category') ?></label>
                        <input type="text" name="category" class="form-control" placeholder="e.g. Worship, Events, Outreach" value="<?= $image['gal_category'] ?? '' ?>">
                    </div>
                </div>

                <div class="mb-3">
                    <label class="form-label"><?= gettext('Description') ?></label>
                    <textarea name="description" class="form-control" rows="3"><?= $image['gal_description'] ?? '' ?></textarea>
                </div>

                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">
                        <i class="fa-solid fa-save me-1"></i> <?= gettext('Save') ?>
                    </button>
                    <a href="<?= SystemURLs::getRootPath() ?>/admin/website/gallery" class="btn btn-outline-secondary">
                        <?= gettext('Cancel') ?>
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>

<?php include SystemURLs::getDocumentRoot() . '/Include/Footer.php'; ?>
