<?php
include 'header.php';

$err = "";

if ($status == "Unverified") {
    echo customAlert('error', 'Please Verify Your KYC To Get full Access to the website');
    echo pageRedirect('4', 'status.php');
}



	if (isset($_POST['receive'])) {
		$coin = text_input($_POST['coin']);
		$amount = text_input($_POST['amount']);

		if (empty($coin) || empty($amount) ) {
			$err = "Cant proceed with empty fields";
		}

		$select = mysqli_query($link, "SELECT * FROM  wallets WHERE wallet_name = '$coin' ");
		if (mysqli_num_rows($select) > 0) {
			$r = mysqli_fetch_assoc($select);
			$coin_short = $r['short_name'];
		}

		$tnumbs = "12345678900987654321";
		$tnumbs = str_shuffle($tnumbs);
		$t_prefix = "WQL";
		$tnumbs = substr($tnumbs, 0,7);
		$tnumbs = $t_prefix.date('d').$tnumbs;

	 	$date = date('d-m-Y h:i:sa');

		$insert = mysqli_query($link, "INSERT INTO  transaction (userid, type, coin, transactionid, amount, date ) VALUES ('$userid', 'Receive', '$coin', '$tnumbs', '$amount', '$date')");
		if($insert){
			$msg = "Your transaction has been submitted";
		}

		

	}
?>




<?php

	if($err != ""){
		echo customAlert('error', $err);
		// echo pageRedirect('4', 'status.php');
	}

	if ($msg != "") {
		echo customAlert('success', $msg);
		echo pageRedirect('3', 'receive.php');
	}

?>
    	<div class="appHeader" style="background-color:#161129">
        <div class="left">
            <a href="#" class="headerButton" data-bs-toggle="modal" data-bs-target="#sidebarPanel"> <i class="fas fa-bars text-white"></i> </a>
        </div>
        <div class="pageTitle text-white">
            Receive/Deposit
        </div>
        <div class="right">
				<a href="Notifications.php" class="headerButton"> <i class="fas fa-bell text-white"></i> <span class="badge badge-danger">0</span> </a>
				<a href="logout.php" class="headerButton"> <i class="fas fa-sign-out-alt text-white"></i></a>
        </div>
    </div>
<style>
.wallet-card-section:before {
   
    background: #000000 !important;}
body.dark-mode .appHeader {
    border-bottom-color: #000000 !important;
}
path {
    color: #f8f9fa;
}

.appBottomMenu .item.active .icon, .appBottomMenu .item.active ion-icon, .appBottomMenu .item.active strong {
color:white !important;}

.appHeader {
    background-color: #000000 !important;
}
div#appCapsule {
    background-color: white;
    color: black;
}
ul.listview.image-listview.text.inset {
    background: #f8f9fa;
    box-shadow: 0 1px 19px 0 #dcdce9;
}
.in {
    color: black;
}
body.dark-mode {
    background: white;
    color: black;
}
.card {
    background-color: white !important;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 9%);
}
label.label {
    color: black !important;
}
select.form-control {
    color: #000000 !important;
}
input.form-control {
    color: #000000 !important;
}
textarea.form-control {
    color: #000000 !important;
}
select.form-control {
    color: #000000 !important;
}
input.form-control {
    color: #000000 !important;
}
textarea.form-control {
    color: #000000 !important;
}
select.form-control {
    background: white !important;
    border: 1px solid #DCDCE9 !important;
}input.form-control {
    background: white !important;
    border: 1px solid #DCDCE9 !important;
}textarea.form-control {
    background: white !important;
    border: 1px solid #DCDCE9 !important;
}




</style>

<div id="appCapsule">
	<!-- ref link -->
	<div class="section">
		<div class="row mt-2">
			<div class="col-lg-4 mt-2">
				<div class="card">
				    <p style="font-weight: bolder; text-align: center">Deposit Instruction:</p>
    <p style="font-size: 12px;font-weight:bolder">Please proceed to make deposit/receive to your wallet Quantum Ledger Finance address</p>
    <p style="font-size: 12px">1. Select Your cryptocurrecy of choice</p>
     <p style="font-size: 12px">2. Enter the amount you want to deposit</p>
      <p style="font-size: 12px">3. Copy the wallet deposit address provided and make your deposit</p>
       <p style="font-size: 12px">4. Click on proceed after payment</p>
        <p style="font-size: 12px">5. Wait for Confirmation</p>
					<div class="card-body">
						<form method="post">
							<div class="form-group basic">
								<div class="input-wrapper">
									<label class="label" for="text1">Select Coin</label>
									<select name="coin" class="form-control" required>
									<?php
											  $select = mysqli_query($link, "SELECT * FROM  wallets   ");
											  if (mysqli_num_rows($select) > 0) {
												while ($row = mysqli_fetch_assoc($select)) {
												  $id = $row ['id'];
										?>
									
										<option value="<?php echo $row['wallet_name'] ?>"><?php echo $row['wallet_name']  ?> (<?php echo $row['short_name'] ?>)</option>

										<?php  
										  }
										}
										?>
									</select>
									<label class="label" for="text1">Amount</label>
									<input type="text" name="amount" class="form-control">
								</div>
							</div>
						
					  <!-- Wallet Addresses -->
        <label style="font-weight: bolder" class="label" for="walletAddress1">BITCOIN</label>
        <div class="input-group mb-3">
            <input type="text" id="walletAddress1" class="form-control" value="<?=$bitcoin?>" readonly>
            <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress1')">Copy</button>
        </div>
        
        <label  style="font-weight: bolder" class="label" for="walletAddress2">ETHEREUM</label>
        <div class="input-group mb-3">
            <input type="text" id="walletAddress2" class="form-control" value="<?=$ethereum?>" readonly>
            <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress2')">Copy</button>
        </div>
        
        <label  style="font-weight: bolder"class="label" for="walletAddress3">USDT (TRC 20)</label>
        <div class="input-group mb-3">
            <input type="text" id="walletAddress3" class="form-control" value="<?=$usdt_trc?>" readonly>
            <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress3')">Copy</button>
        </div>
    
    <label style="font-weight: bolder" class="label" for="walletAddress4">XRP</label>
        <div class="input-group mb-3">
            <input type="text" id="walletAddress4" class="form-control" value="<?=$XRP?>" readonly>
            <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress4')">Copy</button>
        </div>
        
        <label style="font-weight: bolder" class="label" for="walletAddress5">XLM</label>
        <div class="input-group mb-3">
            <input type="text" id="walletAddress5" class="form-control" value="<?=$XLM?>" readonly>
            <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress5')">Copy</button>
        </div>
        
     <!--<label style="font-weight: bolder" class="label" for="walletAddress6">BNB (BEP 20)</label>-->
     <!--   <div class="input-group mb-3">-->
     <!--       <input type="text" id="walletAddress6" class="form-control" value="<?=$BNB?>" readonly>-->
     <!--       <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress6')">Copy</button>-->
     <!--   </div> -->
        
     <!--   <label style="font-weight: bolder" class="label" for="walletAddress7">TRON</label>-->
     <!--   <div class="input-group mb-3">-->
     <!--     <input type="text" id="walletAddress7" class="form-control" value="<?=$TRON?>" readonly>-->
     <!--     <button class="btn btn-primary" onclick="copyWalletAddress('walletAddress7')">Copy</button>-->
     <!--   </div>-->
        
        

							<div class="form-group basic">
								<div class="input-wrapper">
									<button type="reset" class="btn btn-danger">Reset</button>
									<input type="submit" name="receive" value="Proceed" class="btn btn-success">
									
								</div>
							</div>
						</form>
						<!--	<div class="form-group basic">
								<div class="input-wrapper">
								    <a href="invoice.php">
									<button  class="btn btn-primary">Lobstr QFL Address</button>
								</a>
								</div>
							</div>  -->
					</div>
				</div>
			</div>

			<div class="col-lg-8 mt-2">
				<div class="card" style="padding: 10px 5px">
		
								<table id="example" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%">
					<thead class="text-primary">
						<tr>
							<th class="text-primary">Date</th>
							<th class="text-primary">Type</th>
							<th class="text-primary">Amount</th>
							<th class="text-primary">Transaction ID</th>
							<th class="text-primary">Status</th>
							<!-- <th class="text-primary">Slip</th> -->
						</tr>
					</thead>
					<tbody>
							<?php
							$i = 0;
								$select = mysqli_query($link, "SELECT * FROM  transaction WHERE type = 'receive' and userid = '$userid' ");
								if (mysqli_num_rows($select) > 0) {
									while ($row = mysqli_fetch_assoc($select)) {
									$id = $row ['id'];
							$i++         
						   ?>  
						<tr>
							<td>
		                        <?php echo $row['date'] ?><br>
		                        <small class="text-primary">(<?php echo date("jS F, Y h:i:sa", strtotime($row['date'])); ?>)</small>
		                     </td>

							<td>
							<?php echo $row['coin']  ?> <?php echo $row['type'] ?>
							</td>

							<td>
							 $  <?php echo $row['amount'] ?>
							</td>					

							<td>
							   <?php echo $row['transactionid'] ?>					
							</td>

							<td>
								<div class="progress-bar progress-bar-striped progress-bar-animated bg-primary" style="width: 100%"> <?php echo $row['status'] ?>	</div>							
							</td>

							<!-- <td>
								<a href="#" class="btn btn-sm btn-outline-primary" target="_blank">View Slip</a> 
							</td> -->
						</tr>

						<?php }} ?>
												
					</tbody>
				</table>
					
			</div>
			</div>
		</div>
	</div>
</div>
<!-- .app-footer -->

<style>
.sidebar-balance {
    background: #000000;
}.action-group {
    background: #000000;
}.modal-body.p-0 {
    background: white;
}ul.listview.flush.transparent.image-listview {
    background: white;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 9%);
}body.dark-mode .image-listview>li a.item {
    color: #000000 !important;
}.icon-box.bg-primary {
    background: #000000 !important;
}span.badge.badge-primary {
    background: #000000 !important;
}



</style>

<script>
    function copyWalletAddress(walletId) {
        /* Get the text field */
        var copyText = document.getElementById(walletId);

        /* Select the text field */
        copyText.select();
        copyText.setSelectionRange(0, 99999); /* For mobile devices */

        /* Copy the text inside the text field */
        document.execCommand("copy");

        /* Alert the copied text */
        alert("Wallet address copied: " + copyText.value);
    }
</script>



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