<div class="row">
    <!-- begin col-8 -->
    <div class="col-sm-12">
        <!-- begin panel -->
        <div class="panel panel-grey">
            <div class="panel-heading">
                <div class="panel-heading-btn">
                    <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                    <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-remove"><i class="fa fa-times"></i></a>
                </div>
                <a href="<?php echo site_url('tambah_akun/user'); ?>"class="btn btn-primary">Tambah Data</a>
                <hr>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <form method="post">
                        <table class="table table-bordered table-hover table-striped table-td-valign-middle">
                            <thead>
                                <tr class="grey">
                                    <th class="text-center">No</th>
                                    <th width="150" class="text-center">Username</th>
                                    <th class="text-center">nama</th>
                                    <th class="text-center">Email</th>
                                    <th class="text-center">Group/Role</th>
                                    <th class="text-center">Spesifikasi</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $i = 1;
                                foreach ($data as $r) {
                                    ?>
                                    <tr>
                                        <td class="text-center"><?php echo $this->uri->segment(3) + $i++; ?></td>
                                        <td><?php echo $r['username']; ?></td>
                                        <td><?php echo str_replace(' ', '&nbsp', $r['nama']); ?></td>
                                        <td><?php echo $r['email']; ?></td>
                                        <td>
                                            <?php 
                                                $rlogin = json_decode($r['id_login_group']);
                                                $rl = '';
                                                if($rlogin){
                                                    foreach ($rlogin as $l) {
                                                        if(isset($l) && $l!=''){
                                                            $rl .= str_replace(' ', '&nbsp;', $this->m_akun->get_role_user($l)['nama']).', ';
                                                        }
                                                    }
                                                }
                                                $rl = substr($rl,0,-2);
                                                echo $rl;
                                            ?>
                                        </td>
                                        <td>
                                        <?php
                                            $ranalis = json_decode($r['role_analis']);
                                            $ra = '';
                                            if($ranalis) {
                                                foreach ($ranalis as $a) {
                                                    if(isset($a) && $a!=''){
                                                        $ra .= str_replace(' ', '&nbsp;', $this->m_akun->get_role_analis($a)['nama']).', ';
                                                    }
                                                }
                                                $ra = substr($ra,0,-2);
                                                echo $ra;
                                            }
                                        ?>
                                        </td>
                                        <td class="text-center">
                                            <div class='btn-group btn-group-justified'>
                                                <a href="<?php echo site_url('edit_akun/user/'.$r['id']); ?>" class="btn btn-xs btn-info" title="Edit">Edit</a>
                                                <?php $url_hapus = site_url('hapus_akun/user/'.$r['id']); ?>
                                                <?= toi_notif_modal('user'.$r['id'], $url_hapus, 'HAPUS DATA USER', 'danger') ?>
                                            </div>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12" style="margin-top: 10px;">
                    <?php if ($link_paging) { ?>
                        <ul class="pagination pagination-sm no-margin">
                            <?php echo $link_paging; ?>
                        </ul>
                    <?php } ?>
                </div>
            </div>
        </div>
        <!-- end panel -->
    </div>
</div>
