

 <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <title>Demo</title>
      
      <!-- Favicon -->
      <link rel="shortcut icon" href="logo.png" />
      
      <!-- Library / Plugin Css Build -->
      <link rel="stylesheet" href="assets/css/core/libs.min.css" />
      
      <!-- Aos Animation Css -->
      <link rel="stylesheet" href="assets/vendor/aos/dist/aos.css" />
      
      <!-- Hope Ui Design System Css -->
      <link rel="stylesheet" href="assets/css/hope-ui.min.css?v=2.0.0" />
      
      <!-- Custom Css -->
      <link rel="stylesheet" href="assets/css/custom.min.css?v=2.0.0" />
      
      <!-- Dark Css -->
      <link rel="stylesheet" href="assets/css/dark.min.css"/>
      
      <!-- Customizer Css -->
      <link rel="stylesheet" href="assets/css/customizer.min.css" />
      
      <!-- RTL Css -->
      <link rel="stylesheet" href="assets/css/rtl.min.css"/>
      
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">



  <!-- Bootstrap 5 -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Select2 -->
  <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet">
  <!-- Font Awesome (optional) -->
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" rel="stylesheet">
    

<link rel="icon" type="image/png" href="https://test.traderssolution.com/crmvideonew/logob.png?v=2">

    
<?php
if (isset($_POST['transactionbtn'])) {
    session_start(); // Ensure session is started
    if (!isset($_SESSION['clogin'])) {
        echo "<script>alert('Please log in to continue.'); window.location.href='login.php';</script>";
        exit();
    }
    
    
    $transaction = $_POST['transaction'];
    
    if($transaction == "Deposit"){
        echo "<script>window.location.href='deposit_history';</script>";
    }
    
        if($transaction == "Withdraw"){
        echo "<script>window.location.href='withdraw_history';</script>";
    }
    
    
    
    
    
}

?>


<!-- Transfer Fund-->


<div class="modal fade" id="openAccountModaltransfer" tabindex="-1" aria-labelledby="openAccountModaltransferLabel" aria-hidden="true" data-bs-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="background: radial-gradient(circle, #ffb300, #b8860b); color: white;">
                <h5 class="modal-title" id="openAccountModaltransferLabel" style="color:white">Transfer Funds</h5>
                <button type="button"  data-bs-dismiss="modal" aria-label="Close" style="color:white;background-color:transparent;border:none;font-size:26px"><span>&times;</span></button>
            </div>
            <div class="modal-body">
                 <form action="otpcode"  method="post" enctype="multipart/form-data" onsubmit="disableButtontransfer()">
              <!-- Trading Account -->
              <div class="form-group">
  <label class="form-label" for="pwd">Trading Account</label>
  <select class="form-control" id="trade_idtransfer" name="trade_id" onchange="fetchBalancetransfer()">
    <option value="">Select Account</option>
    <?php
    include 'config.php';
    $email = $_SESSION['clogin'];
    $sql = "SELECT * FROM liveaccount WHERE email = '$email'";
    $query = $dbh->prepare($sql);
    $query->execute();
    $results = $query->fetchAll(PDO::FETCH_OBJ);

    if ($query->rowCount() > 0) {
        foreach ($results as $result) {
            ?>
            <option value="<?php echo htmlentities($result->trade_id); ?>">
                <?php echo htmlentities($result->trade_id); ?> (<?php echo htmlentities($result->account_name); ?>)
            </option>
            <?php
        }
    }
    ?>
  </select>
</div>

<div class="form-group">
  <label class="form-label" for="email">Available Balance (USD)</label>
  <input type="text" class="form-control" id="avlbalancetransfer" name="wallet_balance" value="" style="background-color:#e6e6e6" name="" readonly>
   <input type="hidden" id="avlbalancetransfer" name="wallet_balance1"  class="form-control fill">
  <input type="hidden" name="withdraw_type" value="Internal Transfer" class="form-control fill">    
</div>




<div class="form-group">
  <label class="form-label" for="tradeInput">Enter Trade ID</label>
  <input type="text" class="form-control" id="tradeInput" name="accountfor" placeholder="Enter Trade ID" required>
  <div id="tradeAlert" style="color: red; display: none;">Trade ID does not exist!</div>
</div>



<script>
  function fetchBalancetransfer() {
    var trade_idtransfer = document.getElementById("trade_idtransfer").value;
    if (trade_idtransfer) {
      var xhr = new XMLHttpRequest();
      xhr.open("POST", "fetch_balance_transfer.php", true);
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
          document.getElementById("avlbalancetransfer").value = xhr.responseText;
        }
      };
      xhr.send("trade_idtransfer=" + trade_idtransfer);
    } else {
      document.getElementById("avlbalancetransfer").value = "";
    }
  }
</script>

                        



   <div class="form-group">
  <label class="form-label" for="email">Withdraw Amount USD</label>
  <input type="number" class="form-control" name="withdraw_amount" id="withdrawAmounttransfer" required oninput="checkWithdrawLimit()">
                              <input name="email" type="hidden" required class="form-control fill" value="<?php echo $_SESSION['clogin'];?>">

  <small id="withdrawErrortransfer" style="color: red; display: none;">Withdrawal amount cannot exceed available balance.</small>
</div>


  <script>
  function checkWithdrawLimit() {
    var withdrawAmount = document.getElementById("withdrawAmounttransfer").value;
    var availableBalance = parseFloat(document.getElementById("avlbalancetransfer").value || 0); // Handle empty balance case

    if (withdrawAmount > availableBalance) {
      document.getElementById("withdrawErrortransfer").style.display = "block";
      document.getElementById("withdrawAmounttransfer").value = availableBalance; // Set max value to available balance
    } else {
      document.getElementById("withdrawErrortransfer").style.display = "none";
    }
  }
</script>



              <!-- Submit Button -->
            <div class="d-flex justify-content-between">
  <button type="submit"  id="submitBtn" style="background: radial-gradient(circle, #ffb300, #b8860b); width:100%" class="btn btn-primary" disabled>Submit</button>
</div>
            </form>
            </div>
        </div>
    </div>
</div>

<script>
 function disableButtontransfer() {
    var button = document.getElementById("submitBtn");
    if (button) {
    setTimeout(function() {
      button.disabled = true;
    }, 1);  // delay just enough to let the form submit
  }
  }


  document.addEventListener("DOMContentLoaded", function () {
    const tradeInput = document.getElementById("tradeInput");
    const submitBtn = document.getElementById("submitBtn");
    const tradeAlert = document.getElementById("tradeAlert");

    tradeInput.addEventListener("input", function () {
      const enteredTradeId = tradeInput.value.trim();

      if (enteredTradeId === "") {
        submitBtn.setAttribute("disabled", "true");
        tradeAlert.style.display = "none";
        return;
      }

      // AJAX request to check if Trade ID exists in the database
      fetch("check_trade_id.php?trade_id=" + encodeURIComponent(enteredTradeId))
        .then(response => response.json())
        .then(data => {
          if (data.exists) {
            submitBtn.removeAttribute("disabled");
            tradeAlert.style.display = "none"; // Hide alert if Trade ID exists
          } else {
            submitBtn.setAttribute("disabled", "true");
            tradeAlert.style.display = "block"; // Show alert if Trade ID does not exist
          }
        })
        .catch(error => console.error("Error:", error));
    });
  });
</script>

<!-- Transfer Fund-->







<!-- Transaction History-->




<div class="modal fade" id="openAccountModaltransaction" tabindex="-1" aria-labelledby="openAccountModaltransactionLabel" aria-hidden="true" data-bs-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="background: radial-gradient(circle, #ffb300, #b8860b); color: white;">
                <h5 class="modal-title" id="openAccountModaltransactionLabel" style="color:white">Transaction History</h5>
                <button type="button"  data-bs-dismiss="modal" aria-label="Close" style="color:white;background-color:transparent;border:none;font-size:26px"><span>&times;</span></button>
            </div>
            <div class="modal-body">
                 <form action="" method="post" enctype="multipart/form-data">
              <!-- Trading Account -->


<div class="form-group">
  <label class="form-label" for="email">Transaction Type</label>
  
  <select class="form-control" name="transaction" required>
      <option value="" selected disabled>Select transaction type</option>
      <option value="Deposit">Deposit</option>
      <option value="Withdraw">Withdraw</option>
  </select>
</div>



        





              <!-- Submit Button -->
              <div class="d-flex justify-content-between">
                <button type="submit" name="transactionbtn" style="background: radial-gradient(circle, #ffb300, #b8860b);width:100%" class="btn btn-primary">Submit</button>
              </div>
            </form>
            </div>
        </div>
    </div>
</div>





<!-- Transaction History-->


<script>
    // JavaScript to populate the modal dynamically
    document.addEventListener('DOMContentLoaded', () => {
        const modal = document.getElementById('openAccountModalbankwithdraw');
        const accountTypeInput = document.getElementById('accountType');
        const accountTypeGroup = document.getElementById('accountGroup');

        document.querySelectorAll('.open-modal-btn').forEach(button => {
            button.addEventListener('click', function () {
                const accountType = this.getAttribute('data-account-type');
                const accountGroup = this.getAttribute('data-account-group');
                accountTypeInput.value = accountType; // Autofill Account Type
                accountTypeGroup.value = accountGroup; // Autofill Account Type
            });
        });
    });
</script>


<!-- Transfer Fund- END -->



<!-- tRADE History-->




<div class="modal fade" id="openAccountModaltrade" tabindex="-1" aria-labelledby="openAccountModaltradeLabel" aria-hidden="true" data-bs-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="background: radial-gradient(circle, #ffb300, #b8860b); color: white;">
                <h5 class="modal-title" id="openAccountModaltradeLabel" style="color:white">Select Trading Account to Unsubscribe</h5>
                <button type="button"  data-bs-dismiss="modal" aria-label="Close" style="color:white;background-color:transparent;border:none;font-size:26px"><span>&times;</span></button>
            </div>
            <div class="modal-body">
                 <form action="unsubscribe_copy_trade" method="post" enctype="multipart/form-data">
              <!-- Trading Account -->


<div class="form-group">
  <label class="form-label" for="email">Select Trading Account </label>
  
<select class="form-control" id="leverageSelect" name="tradeid2" required>
                  <option value="">Select Account</option>
                  <?php
                  include 'config.php';
                  $email = $_SESSION['clogin'];
                  $sql = "SELECT * FROM copyaccounts WHERE email = '$email'";
                  $query = $dbh->prepare($sql);
                  $query->execute();
                  $results = $query->fetchAll(PDO::FETCH_OBJ);
                  if ($query->rowCount() > 0) {
                    foreach ($results as $result) {
                  ?>
                    <option value="<?php echo htmlentities($result->slavetrade); ?>">
                      <?php echo htmlentities($result->slavetrade); ?> (<?php echo htmlentities($result->strategyname); ?>)
                    </option>
                    
                  <?php }
                  } ?>
                </select>
</div>



              <!-- Submit Button -->
              <div class="d-flex justify-content-between">
                <button type="submit" name="" style="background: radial-gradient(circle, #ffb300, #b8860b);width:100%" class="btn btn-primary">Unsubscribe Now</button>
              </div>
            </form>
            </div>
        </div>
    </div>
</div>





<!-- tRADE History-->

