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

function status($value)
{
  if($value == 'true')
  {
    $result = '<span class="badge bg-success">'.$value.'</span>';
  }
  else $result = '<span class="badge bg-danger">'.$value.'</span>';

  return $result;
}

function value_array($key)
{
  $array = "";

  foreach ($key as $column => $value){ $array .= ", ".$column.": "."'".$value."'"; };

  return $array;
}

?>

<div class="table-responsive">
  <table class="table table-sm table-bordered table-striped table-hover">
    <thead>
      <tr>
        <th style="text-align: center;">Organization ID</th>
        <th style="text-align: center;">Name</th>
        <th style="text-align: center;">Code</th>
        <th style="text-align: center;">Display</th>
        <th style="text-align: center;">System</th>
        <th style="text-align: center;">Active</th>
        <th style="text-align: center; width: 130px">Aksi</th>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($data as $key){ ?>
        <tr>
          <td style="text-align: center;"><?php echo $key->organization_id ?></td> 
          <td style="text-align: center;"><?php echo $key->name ?></td> 
          <td style="text-align: center;"><?php echo $key->coding_code ?></td>  
          <td style="text-align: center;"><?php echo $key->coding_display ?></td>     
          <td style="text-align: center;"><?php echo $key->coding_system ?></td> 
          <td style="text-align: center;"><?php echo $key->active ?></td> 
          <td style="text-align: center;">          	
            <button type="button" class="btn btn-xs btn-info" onclick="edit_data({table_name: 'mapping_organisasi'<?php echo value_array($key) ?>})"> <i class="fa fa-edit"> Edit </i></button>
            <button class="btn btn-danger btn-rounded btn-xs" onclick="hapus_data({table_name: 'mapping_organisasi'<?php echo value_array($key) ?>})"><i class="fas fa-times"></i></button>
          </td>
          </td>
        </tr> 
      <?php } ?>
    </tbody>
  </table>
</div>
