<style type="text/css">
.buttons-html5, .buttons-print{background: orange; color:#fff; border:0px; float: left; margin-right: 5px; margin-top: 7px}
.DTFC_LeftBodyWrapper{margin-top: -7px;}
table.dataTable{margin-top: 0px !important}
</style>

<div class="row" id="portlet-content">
    <div class="col-md-12">

        <?php if($this->session->flashdata('sukses')){ ?>
        <div class="alert alert-success">
            <strong>Sukses !!</strong>
            <p>Data berhasil di update.</p>
        </div>
        <?php }?>
        <?php if($this->session->flashdata('pass_tidak_sama')){ ?>
        <div class="alert alert-danger">
            <strong>Terjadi Kesalahan !!</strong>
            <p>Pastikan Password dan Confirm Password sama.</p>
        </div>
        <?php }?>
        <?php if($this->session->flashdata('pass_tidak_boleh_kosong')){ ?>
        <div class="alert alert-danger">
            <strong>Terjadi Kesalahan !!</strong>
            <p>Password tidak boleh kosong.</p>
        </div>
        <?php }?>
        <?php if($this->session->flashdata('username_sudah_ada')){ ?>
        <div class="alert alert-danger">
            <strong>Terjadi Kesalahan !!</strong>
            <p>Username sudah ada, silahkan gunakan username lain.</p>
        </div>
        <?php }?>
        <?php if($this->session->flashdata('error')){ ?>
        <div class="alert alert-danger">
            <strong>Terjadi Kesalahan !!</strong>
            <p>Terjadi intrupsi silahkan ulangi kembali.</p>
        </div>
        <?php }?>

        

        <div class="portlet light" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-list"></i> Hakakses BBMC
                </div>
                <div class="portlet-title" style="float: right;">
                  
                </div>
            </div>           
            <?php if($query->num_rows() != 0){ ?>
            <div id="dataTables_processing">
                Loading Entry Data..
            </div>
            <?php }?>
            <div class="portlet-body" id="page-content" style="<?=$query->num_rows()!=0?'display: nonee':''?>">
                <div class="table-responsive" style="border:0px;">
                    <?php 
                    if($query->num_rows() == 0){ ?>
                    <div class="" class="form-group" style="margin-bottom:40px; margin-top: 0px; margin-left:0px; padding-bottom: 30px; border-radius:4px; background: linear-gradient(to left, #d14415,#d16b49, #fad2d2 ,transparent,transparent,transparent,transparent)">
                      <div class="col-sm-12 col-md-12" style="text-align: right; color: #fff"><h2><strong>No data entry</strong></h2></div><br><br>
                    </div>
                    <?php }else{ ?>
                    <table id="example" class="table table-bordered table-striped table-hover datatable" >
                      <thead>

                        <tr style="background: #5578eb; color:#fff;">
                          <th style="min-width: 30px"><i class="fa fa-th-large"></i></th>
                          <th class="text-center" style="min-width:30px; width: 30px !important" style="margin-left: 200px;"><div style="width:30px !important">NO.</div></th>
                          <th class="text-left" style="min-width: 200px">USER</th>
                          <th class="text-left" style="min-width: 180px">JABATAN</th>
                          <th class="text-left" style="min-width: 180px">USERNAME</th>
                          <th class="text-left" style="min-width: 350px">HAKAKSES</th>
                          
                        </tr>
                      </thead>
                      <tbody>
                       
                        <?php $i=1; foreach($query->result() as $key) { ?>
                          <tr style="font-size:12px">
                            <td class="" style="background: #fcf4dc;" align="left">
                                <a class="tooltips btn-xs btn-info" data-toggle="m-tooltip" data-container="body" title="Update Password" href="<?=site_url()?>/setting/insert_userpanel/update/<?=$key->id_staff?>" ><i class='fa fa-edit'></i></a>  
                                <a class="tooltips btn-xs btn-info" data-toggle="m-tooltip" data-container="body" title="Hak Akses" href="<?=site_url()?>/setting/hakakses_userpanel/update/<?=$key->id_staff?>" ><i class='fa fa-book'></i></a>  
                            </td>
                            <td align="center"> <?=$i;?> </td>
                            <td align="left"><?=$this->M_general->get_value('bbmc_re_staff','id_re_staff',$key->id_re_staff,'nama_staff')?></td>
                            <td align="left">
                              <?php $id_jabatan = $this->M_general->get_value('bbmc_re_staff','id_re_staff',$key->id_re_staff,'id_jabatan')?>
                              <?=$this->M_general->get_value('global_jabatan','id_global_jabatan',$id_jabatan,'nama_jabatan')?>    
                            </td>
                            <td align="left">
                              <?=$this->M_general->get_value('global_user','id_user',$key->id_re_staff,'username')?>

                            </td>
                            <td align="left">
                              <?php
                              $this->db->where('id_user',$key->id_re_staff); 
                              foreach ($this->M_general->select_db('global_user_hakakses_bbmc')->result() as $key ) { ?>
                                <div style="background: darkgrey; border-radius:3px; color:#fff; margin: 2px; padding:2px; float: left; text-align: center;"><?=$this->M_general->get_value('global_hakakses','id_global_hakakses',$key->id_hakakses,'jenis_hakakses')?></div>
                              <?php }?>
                            </td>
                          </tr>
                        <?php $i++; } ?>
                      </tbody>     
                    </table>
                    <?php }?>



                </div>
            </div>
         
           
        </div>
    </div>
</div>


<script>
$(document).ready(function() {
    var buttonCommon = {
        exportOptions: {
            format: {
                body: function ( data, row, column, node ) {
                    return (column === 5) ? data.replace( /\n/g, '"&CHAR(10)&CHAR(13)&"' ) : data.replace(/(&nbsp;|<([^>]+)>)/ig, "\n");;
                }
            }
        },
        customize: function( xlsx ) {
          var sheet = xlsx.xl.worksheets['sheet1.xml'];
          $('row c', sheet).attr( 's', '55' );
       }
    };
 
    $('#example').DataTable( {
        scrollY:        "300px",
        scrollX:        true,
        scrollCollapse: true,
        dom: 'lBfrtip',
        buttons: [
            $.extend( true, {}, buttonCommon, {
                extend: 'excelHtml5',
                text: 'Print Table Data',
                title:''
            } )
        ],
        lengthMenu: [ [10, 50, 200, -1], [10, 50, 200, 'All Data'] ],
        fixedColumns: {
            leftColumns: 1
        },
        fnInitComplete: function(oSettings, json) {
          $('#dataTables_processing').css('display','none');
          $('#page-content').css('display','block');
          $('#fillter-content').css('display','block');
        }

    } );
} );

$('.tooltips').tooltip({ container: 'body' }) 
$(".date" ).datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-60:+0",
    dateFormat: 'yy-mm-dd'
});
</script>

