<?php
require("header.php")
?>
<style>
  .btn-group>.btn:not(:last-child):not(.dropdown-toggle) {
    background: black;
  }

  .btn-group>.btn-group:not(:first-child)>.btn {
    background: black;
  }

  .page-item.active .page-link {
    background: black;
  }

  .dt-button-collection .dropdown-menu .buttons-columnVisibility {
    background-color: black;
  }
</style>
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <!-- <h1>Credits History</h1> -->
        </div>
        <div class="col-sm-6">

        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-12">
          <!-- /.card -->

          <div class="card card-secondary">
            <div class="card-header" style="background-color: black;">
              <h3 class="card-title">WITHDRAWAL USTD Request</h3>
              <ol class="breadcrumb float-sm-right" style="background-color: black;">
                <li class="breadcrumb-item"><a href="#">Home</a></li>
                <li class="breadcrumb-item">USTD Request</li>
              </ol>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>Date /Time</th>
                    <th>User Id</th>
                    <th>Amount</th>
                    <th>Txn Id</th>

                    <th>Status</th>

                  </tr>
                </thead>
                <tbody>
                  <?php

                  $rid = $_SESSION['username'];
                  // echo "Reseller ID: " . $rid;
                  include('connection.php');
                  $i = 0;
                  // Construct the SQL query to fetch the desired orders for a specific reseller's users
                  $sql = "SELECT ur.*, u.user_id AS added_user_id
                     FROM usdt_request AS ur
                     INNER JOIN user AS u ON ur.user_id = u.user_id
                     WHERE  u.added_by = '$rid'";

                  $res = mysqli_query($conn, $sql);
                  while ($row = mysqli_fetch_array($res)) {
                    $i++;

                  ?>
                    <tr>
                      <td>
                        <?php echo $row['date_time']; ?>
                      </td>
                      <td>
                        <a href="#" class="user-id-linking" style="color:blue ;font-weight:600;" data-toggle="modal" data-target="#modal-lg-id<?php echo $row['user_id']; ?>">

                          <?php echo $row['user_id']; ?>
                        </a>
                      </td>
                      <td>
                        <button type="button" class="btn btn-link" style="color:blue;font-weight:600;" data-toggle="modal" data-target="#exampleModalCenter_<?php echo $row['user_id']; ?>">
                          <?php echo $row['amount']; ?>
                        </button>
                      </td>
                      <td>
                        <?php echo $row['tnx_id']; ?>
                      </td>
                      <td>

                        <form method="POST" action="status_usdt_code.php">

                          <input type="hidden" name="item_id" value="<?php echo $row['id']; ?>">
                          <?php if ($row['status'] == 1) { ?>
                            <input type="submit" name="Reject" value="Reject" class="btn btn-danger" style="font-weight: 600;font-size: 12px;height: 30px;">
                          <?php } else { ?>
                            <input type="submit" name="Complete" value="Complete" class="btn btn-success" style="font-weight: 600;font-size: 12px;height: 30px;">
                          <?php } ?>

                        </form>

                      </td>
                    </tr>

                  <?php
                  }
                  ?>

                </tbody>

              </table>
              <!-- modal -->
              <?php
              $sql = "SELECT * FROM user  ORDER BY date_time";
              $res = mysqli_query($conn, $sql);

              while ($row = mysqli_fetch_array($res)) {
              ?>
                <div class="modal fade" id="modal-lg-id<?php echo $row['user_id']; ?>" style="display: none;" aria-hidden="true">
                  <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                      <div class="modal-header" style="background-color: black;">

                        <h6 class="modal-title float-left">
                          <span style="font-weight:600; text-transform:uppercase">Added by&nbsp;: &nbsp;</span> <span style="color:white">
                            <?php echo $row['added_by']; ?>&nbsp;<i class="fa fa-chevron-right" aria-hidden="true" style="font-size:12px;"></i>&nbsp;
                            <?php echo $row['user_id']; ?>
                          </span>

                        </h6>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">×</span>
                        </button>
                      </div>
                      <div class="modal-body">
                        <div class="row">

                          <div class="col-12">
                            <span style="float:center;font-weight:600; text-transform:uppercase">Created On&nbsp;:
                              &nbsp;</span> <span style="color:green">
                              <?php echo $row['date_time']; ?>
                            </span>
                          </div>

                        </div>
                        <br>

                        <div class="row">

                          <div class="col-6">
                            <ul style="list-style-type: none">
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>Name: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['user_name']; ?>
                                </span></li>
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>City: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['city']; ?>
                                </span></li>
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>Password: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['password']; ?>
                                </span></li>
                            </ul>
                          </div>
                          <div class="col-6">
                            <ul style="list-style-type: none">
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>Email: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['user_email']; ?>
                                </span></li>
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>Country: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['country']; ?>
                                </span></li>
                              <li style="font-weight:600; text-transform:uppercase"> <i class="fa fa-chevron-right" aria-hidden="true" style="margin-right: 2%;font-size: 11px;"></i>Security Answer: <span style="color:blueviolet;text-transform: none;margin-left:1%;font-weight:400;">
                                  <?php echo $row['answer']; ?>
                                </span></li>
                            </ul>
                          </div>

                        </div>
                        <div class="modal-footer justify-content-between">
                          <button type="button" class="btn btn-dark" style="background-color: black;" data-dismiss="modal">Close</button>
                          <!-- <input type="submit" class="btn btn-primary" value="Submit"> -->
                        </div>

                      </div>

                    </div>

                  </div>

                </div>
              <?php } ?>
              <!-- modal end -->

              <!-- Modal -->
              <?php
              $sql = "SELECT * FROM usdt_request";
              $res = mysqli_query($conn, $sql);

              while ($row = mysqli_fetch_array($res)) {
              ?>
                <div class="modal fade" id="exampleModalCenter_<?php echo $row['user_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                  <div class="modal-dialog modal-dialog-centered" role="document">
                    <div class="modal-content">
                      <div class="modal-header" style="background-color: black;">
                        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                        </button>
                      </div>
                      <div class="modal-body">
                        <form action="txn_id_update.php" method="post">
                          <div class="form-group">
                            <label for="exampleFormControlInput1">User USDT Wallet Address</label>
                            <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                            <input type="text" class="form-control" value="<?php echo $row['usdt_wallet_address']; ?>" readonly>
                          </div>
                          <div class="form-group">
                            <label for="exampleFormControlInput1">Network</label>
                            <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                            <input type="text" class="form-control" value="TRC20" readonly>
                          </div>
                          <div class="form-group">
                            <label for="exampleFormControlInput1">Txn Id</label>
                            <input type="text" name="tnx_id" value="<?php echo $row['tnx_id']; ?>" class="form-control">
                          </div>
                          <div class="modal-footer">
                            <button type="button" style="background-color: black;" class="btn btn-dark" data-dismiss="modal">Close</button>
                            <input type="submit" style="background-color: black;" class="btn btn-dark" name="submit" value="Submit">
                          </div>
                        </form>
                      </div>

                    </div>
                  </div>
                </div>
              <?php } ?>
              <!-- modal end -->
            </div>
          </div>
          <!-- /.card-body -->

        </div>

        <!-- /.card -->
      </div>

      <!-- /.col -->
    </div>
    <!-- /.row -->

    <!-- /.container-fluid -->
  </section>
  <!-- /.content -->

</div>
<!-- for searching -->
<script>


</script>
<!-- searching end -->

<!-- pagination -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>

<script>
  // Add your SweetAlert2 code here
  <?php if (isset($_GET['error'])) { ?>
    Swal.fire({
      title: 'Error',
      text: '<?php echo $_GET['error']; ?>',
      icon: 'error',
      confirmButtonText: 'OK',
      confirmButtonClass: 'btn btn-success btn-lg',
    });
  <?php } ?>
  <?php if (isset($_GET['success'])) { ?>
    Swal.fire({
      title: 'Success',
      text: '<?php echo $_GET['success']; ?>',
      icon: 'success',
      confirmButtonText: 'OK',
      confirmButtonClass: 'btn btn-success btn-lg',
    });
  <?php } ?>
</script>
<?php
require("footer.php")
?>