<div class="col-xs-12">
  <div class="box">
    <div class="box-header">
      <h3 class="box-title">Data Detail Transaksi Penjualan</h3>
      <a class='pull-right btn btn-default btn-sm'
        href='<?php echo base_url() . $this->uri->segment(1); ?>/pembelian'>Kembali</a>
    </div><!-- /.box-header -->
    <div class="box-body">
      <table class='table table-condensed table-bordered'>
        <tbody>
          <?php if ($rows['proses'] == '0') {
            $proses = '<i class="text-danger">Menunggu Konfirmasi</i>';
          } elseif ($row['proses'] == '1') {
            $proses = '<i class="text-success">Selesai</i>';
          } else {
            $proses = '<i class="text-info">Selesai</i>';
          } ?>
          <tr>
            <th width='140px' scope='row'>Kode Pembelian</th>
            <td><?php echo "$rows[kode_transaksi]"; ?></td>
          </tr>
          <tr>
            <th scope='row'>Nama Reseller</th>
            <td><?php echo "$rows[nama_reseller]"; ?></td>
          </tr>
          <tr>
            <th scope='row'>Waktu Transaksi</th>
            <td><?php echo "$rows[waktu_transaksi]"; ?></td>
          </tr>
          <tr>
            <th scope='row'>Proses</th>
            <td><?php echo "$proses"; ?></td>
          </tr>
        </tbody>
      </table>
      <hr>
      <table class="table table-bordered table-striped">
        <thead>
          <tr>
            <th style='width:40px'>No</th>
            <th>Nama Produk</th>
            <th>Harga Jual</th>
            <th>Jumlah Jual</th>
            <th>Diskon</th>
            <th>Satuan</th>
            <th>Sub Total</th>
          </tr>
        </thead>
        <tbody>
          <?php
          $no = 1;
          foreach ($record as $row) {
            $sub_total = ($row['harga_jual'] * $row['jumlah']) - $row['diskon'];
            echo "<tr><td>$no</td>
                              <td>$row[nama_produk]</td>
                              <td>Rp " . rupiah($row['harga_jual']) . "</td>
                              <td>$row[jumlah]</td>
                              <td>Rp " . rupiah($row['diskon']) . "</td>
                              <td>$row[satuan]</td>
                              <td>Rp " . rupiah($sub_total) . "</td>
                          </tr>";
            $no++;
          }
          $total = $this->db->query("SELECT sum((a.harga_jual*a.jumlah)-a.diskon) as total FROM `rb_penjualan_detail` a where a.id_penjualan='" . $this->uri->segment(3) . "'")->row_array();
          echo "<tr class='success'>
                            <td colspan='6'><b>Total</b></td>
                            <td><b>Rp " . rupiah($total['total']) . "</b></td>
                          </tr>";
          ?>
        </tbody>
      </table>
    </div>