
<!-- Full Width Column -->
  <div class="content-wrapper">
    <div class="container">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <h1>
          Riwayat
        </h1>
        
      </section>

      <!-- Main content -->
      <section class="content">
        <?php if ($barang == null) : ?>
      <div class="row justify-content-center">
         <div class="col-md-9">
            <div class="justify-content-center">
               <div class="alert alert-danger" role="alert">
                  <h1 class="mb-4 text-center"><i class="fa fa-frown-o"></i></h1>
                  <h2 class="alert-heading text-center">Transaksi tidak ditemukan!</h2>
                  <p class="text-center">Sepertinya anda belum melakukan transaksi</p>
               </div>
            </div>
         </div>
      </div>
   <?php else : ?>
    <?php
$query2 = $this->db->query("SELECT sum(total_bayar) AS TOT FROM tb_pesanan_detail where id_pesanan=''");
$row = $query2->row();
echo $row->TOT;
?>
    <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Riwayat Reservasi</h3>

              <div class="box-tools">
                <div class="input-group input-group-sm" style="width: 150px;">
                  <input type="text" name="table_search" class="form-control pull-right" placeholder="Search">

                  <div class="input-group-btn">
                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                  </div>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <table class="table table-hover">
                <tr>
                  <th>No Transaksi</th>
                  <th>Tanggal Reservasi Masuk</th>
                  <th>Tanggal Reservasi Keluar</th>
                  <th>Status</th>
                  <th>Total Pembayaran</th>
                  <th>#</th>
                </tr>
               <?php foreach ($barang as $barang) :
               $query2 = $this->db->query("SELECT sum(total_bayar*qty) AS TOT FROM tb_pesanan_detail where id_pesanan='$barang[id_pesanan]'");
                $row = $query2->row();
                $midtrans = $this->db->query("SELECT * FROM tb_transaksi where id_transaksi='$barang[id_transaksi]'");
                $rowrans = $midtrans->row();
               ?>

                <tr>
                  <td><?=$barang['id_pesanan']?></td>
                  <td><?=date('d F Y', strtotime($barang['tgl_in'])) ?></td>
                  <td><?=date('d F Y', strtotime($barang['tgl_out'])) ?></td>
                  <td><?=$barang['status']?></td>
                  <td>Rp. <?= number_format($row->TOT); ?> </td>
                  <td><?php if ($barang['id_transaksi']=='0') {?>
                  <a href="<?= base_url('transaksi/pembayaran/') . $barang['id_pesanan'] ?>" class="btn btn-sm btn-warning"> Pilih Metode Pembayaran</a>
                  <?php }else{ ?>
                  <a href="<?= base_url('snap/detail/') . $barang['id_pesanan'] ?>" class="btn btn-sm btn-success"> Detail</a>
                    <?php } ?></td>
                </tr>
               <?php endforeach; ?>
               
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>

 
   <?php endif; ?>
      </section>
      <!-- /.content -->
    </div>
    <!-- /.container -->
  </div>
  <!-- /.content-wrapper -->
