<div class="settingsPage">
    <div class="left-column">
        <?php include(APPPATH.'views/appsetting/settingsSideBar.php');?>
    </div>
    <div class="right-column margin-bottom">
        <div class="pageTitle">
            <h1>
                <span>Role based access control settings</span>
            </h1>
        </div>
        <ol class="breadcrumb">
            <li>RBAC</li>
            <li class="active">Settings</li>
        </ol>
        <?php if (isset($message) && is_array($message)) { ?>
            <div class="alert <?= $message['type'] ?>">
                <button class="close" data-dismiss="alert"><i class="bi bi-x"></i></button>
                <?= $message['content'] ?>
            </div>
        <?php } ?>
        <hr class="margin-bottom-large" />
         <?php if ($canEditHostFiltering) { ?>
            <div class="margin-bottom">
                <h3>Host filtering (database level RBAC)</h3>
                <span class="help-block" style="max-width: 650px;">
                    Host filtering limits the report data a user can see to the hosts matching the classes allowed for
                    their role. While it is off, every user sees data from all hosts.
                </span>

                <?php echo form_open('settings/rbac', ['class' => 'form-horizontal', 'id' => 'rbacSettings']); ?>
                <div class="control-group">
                    <label style="text-align: left; width: 100px;" class="control-label" for="rbac_on">Host filtering</label>
                    <div style="margin-left: 0;" class="controls">
                        <label for="rbac_on" class="radio inline">
                            <?php
                            echo form_radio([
                                'name' => 'rbac',
                                'id' => 'rbac_on',
                                'value' => 1,
                                'checked' => $rbacEnabled,
                            ]);
                            ?>
                            On
                        </label>

                        <label for="rbac_off" class="radio inline">
                            <?php
                            echo form_radio([
                                'name' => 'rbac',
                                'id' => 'rbac_off',
                                'value' => 0,
                                'checked' => !$rbacEnabled,
                            ]);
                            ?>
                            Off
                        </label>
                    </div>
                </div>

                <div class="buttons">
                    <?php echo form_submit([
                        'name' => 'submit',
                        'class' => 'btn btn-primary btn-large pull-left',
                        'value' => 'Apply',
                    ]); ?>
                </div>
                <?php echo form_close(); ?>
            </div>
            <hr class="margin-bottom-large" />
        <?php } ?>

        <div class="margin-bottom">
            <h3>Web UI access control</h3>
            <span class="help-block" style="max-width: 650px;">
                Web UI access controls which parts of Mission Portal a role can use, such as changing settings or
                managing users. Select a role to edit its permissions.
            </span>
            <table id="users_table" class="table table-horizontal table-hover">
                <thead>
                <tr>
                    <th>Role</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($roles as $role) { ?>
                    <tr>
                        <td><?= anchor('/settings/rbac/edit/' .$role, ucfirst($role)) ?></td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
