<?php
defined('BASEPATH') OR exit('No direct script access allowed');

function tgl_convert($date)
{  
  $bulan = array (
    1 =>   'Januari',
    'Februari',
    'Maret',
    'April',
    'Mei',
    'Juni',
    'Juli',
    'Agustus',
    'September',
    'Oktober',
    'November',
    'Desember'
  );

  if($date != '0000-00-00')
  {
    $split = explode('-', $date); 
    $tgl = $split[2].' '.$bulan[(int)$split[1]].' '.$split[0];
  } 
  else $tgl = '00-00-0000';

  return $tgl;
}

?>

<div class="table-responsive">
  <table class="table table-sm table-bordered table-striped table-hover">
    <thead>
      <tr>
        <th style="text-align: center; width: 50px">No</th>
        <th style="text-align: center;">Kode</th>
        <th style="text-align: center;">Nama</th>
        <th style="text-align: center;">NIK</th>
        <th style="text-align: center;">ID <span class="badge bg-primary">Satusehat</span></th>
        <th style="text-align: center;">Status</th>
        <th style="text-align: center; width: 130px">Aksi</th>
      </tr>
    </thead>
    <tbody>
      <?php $urut = $page; foreach ($data as $key){ $urut++; ?>
        <tr>
          <td style="text-align: center;"><?php echo $urut ?></td> 
          <td style="text-align: center;"><?php echo $key->id ?></td> 
          <td style="text-align: center;"><?php echo $key->nama ?></td>  
          <td style="text-align: center;"><?php echo $key->nik ?></td>     
          <td style="text-align: center;"><?php echo $key->satusehat_id ?></td>   
          <td style="text-align: center;"><?php echo $key->status ?></td>
          <td style="text-align: center;">
            <button class="btn btn-info btn-rounded btn-xs" data-toggle="modal" data-target="#modal-data" data-backdrop="static" data-keyboard="false" onclick="get_dokter('<?php echo $key->id ?>')"><i class="fas fa-edit"></i> Get ID</button>
          </td>
        </tr> 
      <?php } ?>
    </tbody>
  </table>
</div>

<div class="row">
  <div class="col-12 col-sm-6">
    <p>Jumlah Data: <b><?php echo $jml_data ?></b></p>
  </div>
  <div class="col-12 col-sm-6">
    <?php echo $pagination; ?>
  </div>
</div>

<script type="text/javascript">
  var page_curr = '<?php echo $page_curr ?>';
  $('.pagination').on('click','a',function(e){
   e.preventDefault(); 
   var url_page = $(this).attr('href');
   load_tabel(url_page);
 });
</script>