<?php $this->load->view('meta') ?>
  <div class="wrapper">
    <?php $this->load->view('navbar') ?>
    <?php $this->load->view('sidebar') ?>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <h1><?php echo $title ?></h1>
        <ol class="breadcrumb">
					<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
          <li><a href="#"><?php echo $module ?></a></li>
					<li class="active"><?php echo $title ?></li>
        </ol>
      </section>
      <!-- Main content -->
      <section class="content">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          <div class="col-lg-12">
						<div class="box box-<?php echo box_theme;?>">
              <div class="box-body">
                <?php
                if ($this->session->userdata('id_user_group') == "2"){
                ?>
								<a id="btn_add" onclick="open_modal('Tambah Data User','form_add','')" class="btn btn-success"><i class="fa fa-plus"></i> Tambah Data</a>
	            <?php
				}
				?>                  
			          <a class="btn btn-default" onclick="reload_table()"><i class="fa fa-refresh"></i> Refresh</a>
								<hr>
								<?php echo $this->session->userdata('message') <> '' ? $this->session->userdata('message') : ''; ?>
                <div class="table-responsive no-padding">
									<table id="datatable" class="table table-striped">
										<thead>
											<tr>
												<th style="text-align: center">No.</th>
												<th style="text-align: center">Nama</th>
												<th style="text-align: center">Username</th>
                        <th style="text-align: center">User Group</th>
												<th style="text-align: center">Jabatan</th>
                        <th style="text-align: center">Jobdesk</th>
                        <th style="text-align: center"></th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
                </div>
							</div>
						</div>
          </div><!-- ./col -->
        </div><!-- /.row -->
      </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
    <!-- Modal -->
    <div id="modal_page" class="modal fade" role="dialog">
        <div class="modal-dialog">
                <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title" id="modal_title"></h4>
                </div>
                <div id="modal_konten"></div>
            </div>
        </div>                    
    </div>
    <?php $this->load->view('footer') ?>
  </div><!-- ./wrapper -->
  <?php $this->load->view('js') ?>
	<!-- DATA TABLES-->
  <link href="<?php echo base_url('assets/plugins/') ?>datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
  <script src="<?php echo base_url('assets/plugins/') ?>datatables/jquery.dataTables.min.js" type="text/javascript"></script>
  <script src="<?php echo base_url('assets/plugins/') ?>datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
	<script type="text/javascript">
  var table;
  $(document).ready(function() {
    table = $('#datatable').DataTable({
      "processing": true, //Feature control the processing indicator.
      "serverSide": true, //Feature control DataTables' server-side processing mode.
      "bPaginate": true,
      "bLengthChange": true,
      "bFilter": true,
      "bSort": true,
      "bInfo": true,
      "bAutoWidth": false,
      "aaSorting": [[0,'desc']],
      "lengthMenu": [[10, 25, 50, 100, 500, 1000, -1], [10, 25, 50, 100, 500, 1000, "Semua"]],

      // Load data for the table's content from an Ajax source
      "ajax": {
        "url": "<?php echo site_url('user/ajax_list')?>",
        "type": "POST"
      },

      //Set column definition initialisation properties.
      "columnDefs": [
      {
        "targets": [ -1 ], //last column
      },
      ],
    });
  });

  function reload_table(){
    table.ajax.reload(null,false); //reload datatable ajax
  }
  function open_modal(title, form_open, id_data){
      $('#modal_title').html(title);
      $('#modal_konten').html('<div class="text-center"><br/><i class="fa fa-spinner spinner"></i> Loading...<br/><br/></div>');
      $('#modal_konten').slideDown('normal').load('user/form_open',{ 
                    form_open: form_open, id: id_data});
      $('#modal_page').modal('show');
    }
  </script>
</body>
</html>
