<?php $this->include('rs/utils.php') ?>
<?= $this->extend('rs/template-admin'); ?>

<?= $this->section('content'); ?>


<?php if (session()->getFlashdata('success')): ?>
    <div class="alert alert-success">
        <?= session()->getFlashdata('success') ?>
    </div>
<?php endif; ?>

<?php if (session()->getFlashdata('error')): ?>
    <div class="alert alert-danger">
        <?= session()->getFlashdata('error') ?>
    </div>
<?php endif; ?>

<style>
    .form-control {
        border: 1px solid #aaa !important;
    }
    .btn {
        margin: 5px;
    }
</style>

<div class="card shadow mb-4">
    <div class="card-header justify-content-between align-items-center">
        <h4 class="card-title"><?= $edit ? 'Edit Country' : 'Add New Country' ?></h4>
    </div>
    <div class="card-body">
        <form action="<?= site_url('/countries/edit/' . ($country ? $country['id'] : '0')); ?>" method="post">
            <div class="form-group">
                <label for="country_name">Country Name</label>
                <input type="text" class="form-control" id="country_name" name="country_name" value="<?= old('country_name', $country ? $country['country_name'] : ''); ?>" required>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary"><?= $edit ? 'Update Country' : 'Add Country' ?></button>
                <a href="<?= site_url('/countries'); ?>" class="btn btn-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        //document.getElementById("countries").classList.add("active");
        document.getElementById("countries_bar").classList.add("active");
});

</script>

<?= $this->endsection(); ?>
