<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">

<div class="content-wrapper">
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1>Order</h1>
        </div>
      </div>
    </div>
  </section>

  <section class="content">
    <div class="container-fluid">
      <div class="card">
                <div class="card-header">
                  
                  <h3 class="card-title"></h3>
                    <?php
                  include '../config/koneksi.php'; 
                  $order_id = $_GET['order_id'];
                  $total_harga = $_GET['total_harga'];
                  $memberId = $_GET['member_id'];
                    ?>
                    <h3><?=$order_id?></h3>
                </div>
        <div class="card-body">
          <table id="tabelDetail" class="table table-bordered table-striped">
            <thead>
              <tr>
          <th>No</th>
        <th>Nama Produk</th>
        <th>Jumlah</th>
        <th>Harga Satuan</th>
        <th>SubTotal</th>
              </tr>
            </thead>
            <tbody>
             <?php
      $no = 1;
      $query = mysqli_query($conn, "SELECT order_items.*, products.nama_produk, products.harga FROM order_items JOIN products ON order_items.product_id = products.product_id WHERE order_items.order_id = '$order_id'");      
      while ($data = mysqli_fetch_array($query)) {
          
      ?>
      <tr>
        <td><?= $no++ ?></td>
        <td><?= $data['nama_produk'] ?></td>
        <td><?= $data['jumlah'] ?></td>
        <td><?= $data['harga_satuan'] ?></td>
        <td><?= $data['jumlah'] * $data['harga_satuan'] ?></td>
      </tr>
      <?php } ?>
            </tbody>
          </table>
            <h3 style="text-align: right;">Total : Rp.<?=number_format($total_harga, 0, ',', '.') ?></h3>
        </div>
      </div>
      <div class="card">
         <div class="card-body">
              <?php 
              $user = mysqli_query($conn, "SELECT * FROM members WHERE member_id = $memberId");

              while($datauser = mysqli_fetch_array($user)) {
              ?>
                  <h5>Nama Penerima: <?= $datauser['nama'] ?></h5 >
                  <p>Alamat: <?=$datauser['alamat'] ?> </p>

              <?php
              }
              ?>

         </div>
      </div>
    </div>
  </section>
</div>

<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>

<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>

<script>
$(document).ready(function () {
    $('#tabelDetail').DataTable({
        paging: false,
        ordering: false,  
        language: {
            zeroRecords: "Data tidak ditemukan",
            infoEmpty: ""          
        }
    });
});
</script>