<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->

<!-- Title of the page -->
<?= $this->section('title') ?>User Maintenance<?= $this->endSection() ?>
<!-- .Title -->

<!-- CSS of the page -->
<?= $this->section('css') ?>
<?= $this->endSection() ?>
<!-- .CSS -->

<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->

<!-- Container title -->
<?= $this->section('containertitle') ?>Change User Group<?= $this->endSection() ?>
<!-- .Container title -->

<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item"><a href="<?= base_url('/adminuser') ?>">User Maintenance</a></li>
<li class="breadcrumb-item active">Change User Group</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->

<!-- Main content -->
<?= $this->section('main') ?>

<div class="row">
    <div class="col-7">
        <div class="card">
            <form action="<?= url_to('adminuser/saveusergroup') ?>" method="post">
                <div class="card-header">
                    <h3 class="card-title">Change User Group of <?= $user->display_name ?></h3>
                    <input type="hidden" name="id" value="<?= $user->id ?>">
                </div>
                <div class="card-body p-0 table-responsive">
                    <table class="table">
                        <?php foreach($allgroups as $key => $group): ?>
                        <tr>
                            <td>
                                <div class="form-group">
                                    <input type="checkbox" class="mr-2" name="membershipgroups[]" value="<?= $key ?>" <?= $group['ismember'] ? 'checked' : '' ?>>
                                    <?= $group['title'] ?>
                                    <p class="text-muted"><?= $group['description'] ?></p>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </table>
                </div>
                <div class="card-footer">
                    <button type="submit" class="btn btn-primary">Submit</button>
                    <button type="reset" class="btn btn-default">Reset</button>
                    <a href="<?= base_url('/adminuser') ?>" class="btn btn-default">Cancel</a>
                </div>
            </form>
        </div>
    </div>

    <div class="col-5">
        <div class="card card-info">
            <div class="card-header">
                <h3 class="card-title">Groups on this System</h3>
            </div>
            <div class="card-body">
                <h5>About Groupings</h5>
                <p class="text-muted">
                    System groups has heirarchy. The topmost is superadmin, followed by admin. The default groups is 
                    <strong>User</strong> which is, considered an employee on this system and it represent the lowest level.
                </p>
                <p  class="text-muted">
                    If you checked a group, all permission of that group will be added to the user. You don't need to add one-by-one. But 
                    If you like to specify permission, you may modify it under the <a href="<?= base_url('/adminuser/edituserpermission/' . $user->id) ?>">User Permission</a>
                </p>
                <p class="text-muted">
                    Permission can be assigned even if the group is not selected. The only problem is that, navigation menu filters 
                    group membership instead of permissions.
                </p>
                <h5>Assigning Groups</h5>
                <p class="text-muted">Click on the checkbox to select a group and click on the submit button. The system will automatically add permissions to the group.</p>
                <h5>Other Link</h5>
                <p class="text-muted">To change user permission, go to <a href="<?= base_url('/adminuser/edituserpermission/' . $user->id) ?>">User Permission</a></p>
            </div>
        </div>
    </div>
    <!-- This card was hidden because of redundancy. 

    <div class="col-5">
        <div class="card card-warning">
            <div class="card-header">
                <h3 class="card-title">Current Group of <?= $user->display_name ?> Summary</h3>
            </div>
            <div class="card-body p-0">
                <table class="table table-responsive">
                <?php foreach($allgroups as $key => $group): ?>
                        <?php if($group['ismember']): ?>
                            <tr>
                                <td>
                                    <?= $group['title'] ?>
                                </td>
                            </tr>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </table>
            </div>
        </div>
    </div>

    -->
</div>

<?= $this->endSection() ?>
<!-- .Main content -->

<!-- Javascript -->

<?= $this->section('js') ?>

<script>
$(document).ready(function() {
    
});



</script>

<?= $this->endSection() ?>

<!-- .Javascript -->