<?php $page_title = "Transaction History" ?>
<?php include 'user_header.php'; ?>

<div class="container-fluid content-inner pb-0">
    <div class="row">
        <div class="bd-example table-responsive">
            <h5 class="text-center p-3">Total Deposit History</h5>
            <table class="table">
                <thead>
                    <tr>
                        <th scope="col">Tranx ID</th>
                        <th scope="col">Type</th>
                        <th scope="col">Amount</th>
                        <th scope="col">Coin</th>
                        <th scope="col">Address</th>
                        <th scope="col">Status</th>
                        <th scope="col">Date</th>
                    </tr>
                </thead>
                <tbody>
                  <?php
                      $query = "SELECT * FROM transaction WHERE transaction_user_id = '$user_id' ORDER BY transaction_id DESC";
                      $query_run = mysqli_query($connection, $query);
                      $i = 1;
                      if(mysqli_num_rows($query_run) > 0){
                        while ($row = mysqli_fetch_assoc($query_run)){
                            $trans_ref = $row['trans_ref'];
                            $transaction_type = $row['transaction_type'];
                            $method = $row['t_mode'];
                            $asset = $row['asset'];
                            $amount = $row['transaction_amount'];
                            $wallet_address = $row['wallet_address'];
                            $status = $row['transaction_status'];
                            $date = $row['transaction_date'];

                           $damount = number_format("$amount",2);

                  ?>
                  <tr>
                    <th scope="row">#<?php echo $trans_ref ?></th>
                    <td><?php echo $transaction_type ?></td>
                    <td><?php echo $currency.' '.$damount ?></td>
                    <td><?php echo $method ?></td>
                    <td><?php echo $wallet_address ?></td>
                    <?php if ($status == "pending"): ?>
                      <td class="badge rounded-pill bg-warning"><?php echo $status ?></td>
                    <?php elseif ($status == "success"): ?>
                      <td class="badge rounded-pill bg-success"><?php echo $status ?></td>
                    <?php elseif ($status == "cancel"): ?>
                      <td class="badge rounded-pill bg-danger"><?php echo $status ?></td>
                    <?php endif; ?>

                    <td><?php echo $date ?></td>
                  </tr>
                  <?php
                      }
                  }
                  else {

                  ?>
                  <tr>
                       <td></td>
                       <th>No Transaction yet...</th>
                  </tr>
                <?php } ?>
                </tbody>
            </table>
        </div>

    </div>
</div>

 <?php include 'user_footer.php'; ?>
