<p class='sidebar-title block-title'><?php echo $title; ?></p>
<?php
if ($total['proses'] == '0') {
  $proses = '<i class="text-danger">Pending</i>';
} elseif ($total['proses'] == '1') {
  $proses = '<i class="text-warning">Proses</i>';
} elseif ($total['proses'] == '2') {
  $proses = '<i class="text-info">Konfirmasi</i>';
} elseif ($total['proses'] == '3') {
  $proses = '<i class="text-info">Diterima</i>';
}

echo "<div class='col-md-8' style='padding:0px'>
        <dl class='dl-horizontal'>
            <dt>Nama</dt>       <dd>$rows[nama_lengkap]</dd>
            <dt>No Telpon/Hp</dt>       <dd>$rows[no_hp]</dd>
            <dt>Email</dt>       <dd>$rows[email]</dd>
            <dt>Kota</dt>               <dd>$rows[nama_kota]</dd>
            <dt>Alamat Lengkap</dt>     <dd>$rows[alamat_lengkap]</dd>
        </dl>
    </div>

    <div class='col-md-4' style='padding:0px'>
        <center>
        Total Tagihan 
        <h4 style='margin:0px;'>Rp " . rupiah($total['total'] + $total['ongkir']) . "<br> <br> 
          <span style='text-transform:uppercase'>$total[kurir]</span> ($total[service])
        </h4>
        Status : <i>$proses</i>   
        </center>
    </div>

    <table class='table table-striped table-condensed'>
        <thead>
            <tr bgcolor='#e3e3e3'>
                <th width='47%'>Nama Produk</th>
                <th>Harga</th>
                <th>Qty</th>
                <th>Berat</th>
                <th>Total</th>
            </tr>
        </thead>
        <tbody>";

$no = 1;
foreach ($record->result_array() as $row) {
  $sub_total = (($row['harga_jual'] - $row['diskon']) * $row['jumlah']);
  echo "<tr>
            <td class='valign'><a href='" . base_url() . "produk/detail/$row[produk_seo]'>$row[nama_produk]</a></td>
            <td class='valign'>" . rupiah($row['harga_jual'] - $row['diskon']) . "</td>
            <td class='valign'>$row[jumlah]</td>
            <td class='valign'>" . ($row['berat'] * $row['jumlah']) . " Gram</td>
            <td class='valign'>Rp " . rupiah($sub_total) . "</td>
        </tr>";
  $no++;
}

// Calculate discount if total is greater than or equal to Rp 500,000
$discount = 0;
if ($total['total'] >= 500000) {
  $discount = 0.1 * $total['total'];
}
$final_total = $total['total'] - $discount;

echo "<tr class='success'>
        <td colspan='4'><b>Berat</b> <small><i class='pull-right'>(" . terbilang($total['total_berat']) . " Gram)</i></small></td>
        <td><b>$total[total_berat] Gram</b></td>
    </tr>

    <tr class='success'>
        <td colspan='4'><b>Ongkos Kirim</b> <small><i class='pull-right'>(" . terbilang($total['ongkir']) . " Rupiah)</i></small></td>
        <td><b>Rp " . rupiah($total['ongkir']) . "</b></td>
    </tr>

    <tr class='success'>
        <td colspan='4'><b>Total</b> <small><i class='pull-right'>(" . terbilang($total['total']) . " Rupiah)</i></small></td>
        <td><b>Rp " . rupiah($total['total']) . "</b></td>
    </tr>

    <tr class='success'>
        <td colspan='4'><b>Discount</b> <small><i class='pull-right'>(" . terbilang($discount) . " Rupiah)</i></small></td>
        <td><b>Rp " . rupiah($discount) . "</b></td>
    </tr>

    <tr class='success'>
        <td colspan='4'><b>Total after Discount</b> <small><i class='pull-right'>(" . terbilang($final_total) . " Rupiah)</i></small></td>
        <td><b>Rp " . rupiah($final_total) . "</b></td>
    </tr>

    <tr class='danger'>
        <td style='color:Red' colspan='4'><b>Subtotal</b> <small><i class='pull-right'>(" . terbilang($final_total + $total['ongkir']) . " Rupiah)</i></small></td>
        <td style='color:Red'><b>Rp " . rupiah($final_total + $total['ongkir']) . "</b></td>
    </tr>
</tbody>
</table><br>";
?>