<?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;
}

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

  return $result;
}

?>

<div class="modal-content" style="background-color: #e6f0ff">
  <div class="modal-header" style="background-color: #b3d1ff">
    <h5 class="modal-title" id="modal-title"></h5>
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body">

    <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;">Nama</th>
            <th style="text-align: center;">No. Rawat</th>
            <th style="text-align: center;">Tanggal Daftar</th>
            <th style="text-align: center;">Jam Daftar</th>
            <th style="text-align: center;">Satusehat Pasien</th>
            <th style="text-align: center;">Debitur</th>
            <th style="text-align: center;">Response</th>
          </tr>
        </thead>
        <tbody>
          <?php $urut = 0; if(!empty($data)){ foreach ($data as $key){ $urut++; ?>
            <tr>
              <td style="text-align: center;"><?php echo $urut ?></td> 
              <td><?php echo $key->nama ?></td>    
              <td style="text-align: center;"><?php echo $key->no_rawat ?></td>
              <td style="text-align: center;"><?php echo $key->tgl_daftar ?></td> 
              <td style="text-align: center;"><?php echo $key->jam_daftar ?></td> 
              <td style="text-align: center;"><?php echo $key->pasien_satusehat_id ?></td>  
              <td style="text-align: center;"><?php echo debitur($key->debitur_value) ?></td> 
              <td style="text-align: center;"><?php echo $key->response_kirim ?></td> 
            </tr> 
          <?php } } else echo '<tr><td colspan="8">Tidak ada data yang gagal kirim</td></tr>'?>
        </tbody>
      </table>
    </div>
  </div>
  <div class="modal-footer">
    <table width="100%">
      <tr>
        <td align="left"><span class="text-red" style="text-align: left;"> * Wajib diisi</span></td>
        <td align="right">
          <button type="button" class="btn btn-default" data-dismiss="modal" class="close"><i class="fas fa-times"></i> Batal</button>
        </td>
      </tr>
    </table>      
  </div>
</div>