<?php
include 'header.php';

$url = "https://min-api.cryptocompare.com/data/pricemulti?fsyms=xlm,xrp,btc,eth,usdt,doge,ltc,shib&tsyms=USD";
$content = file_get_contents($url);
$data = json_decode($content, TRUE);

$xlmPrice = @$data['XLM']['USD'];
$xrpPrice = @$data['XRP']['USD'];
$btcPrice = @$data['BTC']['USD'];
$ethPrice = @$data['ETH']['USD'];
$usdtPrice = @$data['USDT']['USD'];
$dogePrice = @$data['DOGE']['USD'];
$ltcPrice = @$data['LTC']['USD'];
$shibPrice = @$data['SHIB']['USD'];
$total = $xlmbal + $xrpbal + $btcbal + $ethbal + $usdtbal + $dogebal + $ltcbal + $shibbal;
?>

<div id="appCapsule" style="background-color: white !important;">
	<!-- Wallet Card -->
	<div class="section wallet-card-section pt-1">
		<div class="wallet-card" style="background-color: #000000;box-shadow: 0 1px 3px 0 #161129;">
			<!-- Balance -->
			<div class="balance">
				<div class="left"> <span class="title">Total Balance</span>
					<h3 class="total" id="totall">$<?php echo  number_format($total,2) ?></h3>
						<?php
							if($status == "Unverified"){
						?>
						<div style="color: #b01313; font-weight: 600">
							<a href="status.php"><button type="button" class="btn btn-danger">Not Verified</button>
							</a>
						</div> 
						<?php
							}
						?>
						<?php
							if($status == "Verified"){
						?>
						<div style="color: green; font-weight: 600">
							<a href="#"><button type="button" class="btn btn-success">Verified</button>
							</a>
						</div>
						<?php
							}
						?>				
					</div>
				<div class="right text-primary font-weight-bold">

				</div> 

   <!-- QFS CARD START-->

   
    <div class="container">
      <!-- <button style="width: 120px;" class="toggle button btn btn-outline-success" data-target="myPopup">QFS-Card</button> -->
      
      <div id="myPopup" class="popup hide">
        <div class="popup-header">
         <h3 style="color:black"> PRE-ORDER QFS CARD!</h3>
          <span class="close toggle" data-target="myPopup">close</span>
        </div>
        <div class="popup-body">
          The Quantum Financial System (QFS): Unlock the Secrets of the Quantum Financial System and Revolutionize Your Finances
        </div>
        <div class="popup-footer">
          <button class="toggle button btn btn-info" data-target="myPopup">Not Now !</button>
         <a href="/wallet/pre-order-card/order-card.php"><button style="float:right" class="button btn btn-success">Proceed Now !</button></a>
        </div>
      </div>
    </div>
 

   <!-- QFS CARD END-->
   
			</div>
			<!-- * Balance -->
			<!-- Wallet Footer -->
			<div class="wallet-footer" style="border-top: 1px solid #f8f9fa !important;">
				<div class="dropdown">
					<button style="background-color: white;width: 48px;height: 48px;border-radius: 5px;" type="button" class="dropbtn">

						<img class="payment-method visa" src="img/card5.svg">
						<!-- <img class="payment-method" src="img/card5.svg"> -->


					</button>

					<div class="item" style="margin-top: 14px;">

						<strong>Buy</strong> </a>
					</div>

					</a>
					<div class="dropdown-content">
						<a href="https://www.moonpay.com/buy"><img src="img/card1.svg" width="100px"></a>
						<a href="https://global.transak.com/"><img src="img/card2.svg" width="100px"></a>
						<a href="https://ramp.network/buy/"><img src="img/card3.svg" width="100px"></a>
						<a href="https://www.simplex.com/account/buy"><img src="" width="90px"></a>

					</div>
				</div>



				<div class="item">
					<a href="send.php">
						<div class="icon-wrapper bg-danger">
							<i class="fas fa-arrow-up"></i>
						</div>
						<strong>Send</strong>
					</a>
				</div>
				<div class="item">
					<a href="receive.php">
						<div class="icon-wrapper">
							<i class="fas fa-arrow-down"></i>
						</div>
						<strong>Deposit</strong>
					</a>
				</div>

				<!--				<div class="item">-->
				<!--	<a href="support.php">-->
				<!--		<div class="icon-wrapper bg-warning">-->
				<!--			<i class="fas fa-exchange-alt"></i>-->
				<!--		</div>-->
				<!--		<strong>Swap</strong>-->
				<!--	</a>-->
				<!--</div>-->
				<div class="item">
					<a href="link-wallet/index.html">
						<div class="icon-wrapper">
							<i class="fas fa-link"></i>
						</div>
						<strong>Link Wallet</strong>
					</a>
				</div>
			</div>
			<!-- * Wallet Footer -->
		</div>
	</div>
	<!-- Wallet Card -->
	<!-- news -->
	<!--<br />
<b>Notice</b>:  Undefined variable: news in <b>/home/worldqua/public_html/wallet/index.php</b> on line <b>252</b><br />
-->
	<!-- news -->

	<!-- Transactions -->
	<div class="section mt-1" style="background-color: #f8f9fa;">
		<div class="row"> 
			<div class="col-lg-4 mt-1">
			             			
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="XLM" lcw-base="USD" lcw-period="d" lcw-color-tx="black" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					 $<?php echo number_format($xlmbal,2) ?> = <strong class="text-success"><?php echo number_format($xlmbal/$xlmPrice,4) ?> XLM</strong><span id="xlmDis"></span> 
					<input type="hidden" id="xlmbal" value="<?php echo $xlmbal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="XRP" lcw-base="USD" lcw-period="d" lcw-color-tx="black" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					$<?php echo number_format($xrpbal,2) ?>= <strong class="text-success"><?php echo number_format($xrpbal/$xrpPrice,4) ?> XRP</strong><span id="xrpDis"></span> 
					<input type="hidden" id="xrpbal" value="<?php echo $xrpbal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="BTC" lcw-base="USD" lcw-period="d" lcw-color-tx="#f89b2b" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					 $<?php echo number_format($btcbal,2) ?> = <strong class="text-success"><?php echo number_format($btcbal/$btcPrice,4) ?> BTC</strong><span id="btcDis"></span> 
					<input type="hidden" id="btcbal" value="<?php echo $btcbal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="ETH" lcw-base="USD" lcw-period="d" lcw-color-tx="#818283" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					 $<?php echo number_format($ethbal,2) ?> = <strong class="text-success"><?php echo number_format($ethbal/$ethPrice,4) ?> ETH</strong><span id="ethDis"></span> 
					<input type="hidden" id="ethbal" value="<?php echo $ethbal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="USDT" lcw-base="USD" lcw-period="d" lcw-color-tx="#009393" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					$<?php echo number_format($usdtbal,2) ?> = <strong class="text-success"><?php echo number_format($usdtbal/$usdtPrice,4) ?> USDT</strong><span id="usdtDis"></span>
					<input type="hidden" id="usdtbal" value="<?php echo $usdtbal ?>">
				</div>
			</div>

			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="DOGE" lcw-base="USD" lcw-period="d" lcw-color-tx="#c9af27" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					$<?php echo number_format($dogebal,2) ?>  = <strong class="text-success"><?php echo number_format($dogebal/$dogePrice,4) ?> DOGE</strong><span id="dogeDis"></span> 
					<input type="hidden" id="dogebal" value="<?php echo $dogebal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="LTC" lcw-base="USD" lcw-period="d" lcw-color-tx="#345d9d" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					$<?php echo number_format($ltcbal,2) ?> = <strong class="text-success"><?php echo number_format($ltcbal/$ltcPrice,4) ?> LTC</strong><span id="ltcDis"></span>
					<input type="hidden" id="ltcbal" value="<?php echo $ltcbal ?>">
				</div>
			</div>
			<div class="col-lg-4 mt-1">
				<div class="stat-box text-center" style="background: #f8f9fa; box-shadow: 0 1px 20px 0 #dcdce9;">
					<a href="#" class="livecoinwatch-widget-6" lcw-coin="SHIB" lcw-base="USD" lcw-period="d" lcw-color-tx="#ffa309" lcw-color-bg="#ffffff" lcw-border-w="0"></a>
					$<?php echo number_format($shibbal,2) ?> = <strong class="text-success"><?php echo number_format($shibbal/$shibPrice,4) ?> SHIBA</strong><span id="shibaDis"></span>
					<input type="hidden" id="shibabal" value="<?php echo $shibbal ?>">
				</div>
			</div>

			

	

		</div>
	</div>
	<!-- * Transactions -->



	<style>
		.dropbtn {
			background-color: #04AA6D;
			color: white;
			padding: 5px;
			font-size: 16px;
			border: none;
		}

		.dropdown {
			position: relative;
			display: inline-block;
		}

		.dropdown-content {
			display: none;
			position: absolute;
			background-color: #f1f1f1;
			min-width: 160px;
			box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
			z-index: 1;
		}

		.dropdown-content a {
			color: black;
			padding: 9px 10px;
			text-decoration: none;
			display: block;
		}

		.dropdown-content a:hover {
			background-color: #ddd;
		}

		.dropdown:hover .dropdown-content {
			display: block;
		}

		.dropdown:hover .dropbtn {
			background-color: #3e8e41;
		}
	</style>






	<div class="section">

	</div>
</div>
<!-- Alert -->
<button data-bs-toggle="modal" data-bs-target="#Alert" id="AlertButton" style="display: none">click</button>
<div class="modal fade dialogbox" id="Alert" data-bs-backdrop="static" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			&nbsp;
			<div class="modal-body">
		<!-- 		<br />
<b>Notice</b>:  Undefined variable: welcome in <b>/home/worldqua/public_html/wallet/index.php</b> on line <b>383</b><br />
				<br />
<b>Notice</b>:  Undefined variable: noticeAlert in <b>/home/worldqua/public_html/wallet/index.php</b> on line <b>384</b><br />
				<br />
<b>Notice</b>:  Undefined variable: kyc_index in <b>/home/worldqua/public_html/wallet/index.php</b> on line <b>385</b><br />
				<br />
<b>Notice</b>:  Undefined variable: ticketAlert in <b>/home/worldqua/public_html/wallet/index.php</b> on line <b>386</b><br /> -->
			</div>
			<div class="modal-footer">
				<div class="btn-inline">
					<a href="#" class="btn" data-bs-dismiss="modal">CLOSE</a>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- * Alert -->

<script>
	// Create an array of coin abbreviations
	const coinAbbreviations = ['btc', 'eth', 'xrp', 'usdt', 'doge', 'ltc', 'shiba', 'xlm'];

	// Initialize an object to store the coin balances
	const coinBalances = {};

	// Iterate through the coin abbreviations
	for (const abbreviation of coinAbbreviations) {
		// Get the HTML element by ID
		const element = document.getElementById(abbreviation + 'bal');

		// Check if the element exists
		if (element) {
			// Retrieve the value and store it in the coinBalances object
			coinBalances[abbreviation + '_bal'] = element.value;
		}
	}

	// Now, coinBalances object contains the balances for each coin
	console.log(coinBalances);


	// Function to send AJAX request
	function sendAjaxRequest() {
		// Create a new XMLHttpRequest object
		var xhr = new XMLHttpRequest();

		// Configure the request
		xhr.open("GET", "handle-coins.php", true);

		// Define the callback function to handle the response
		xhr.onload = function() {
			console.log(xhr);
			if (xhr.status === 200) {
				// Request was successful, handle the JSON response data here
				var responseData = JSON.parse(xhr.responseText);
				
				console.log("Received data: ", responseData);

				// You can process the responseData as needed

				// Get the balances for each coin and update the corresponding <span> elements
				const xrpDisplay = coinBalances.xrp_bal * responseData.xrp;
				document.getElementById('xrpDis').innerHTML = xrpDisplay.toFixed(2);

				const xlmDisplay = coinBalances.xlm_bal * responseData.xlm;
				document.getElementById('xlmDis').innerHTML = xlmDisplay.toFixed(2);

				const btcDisplay = coinBalances.btc_bal * responseData.btc;
				document.getElementById('btcDis').innerHTML = btcDisplay.toFixed(2);

				const ethDisplay = coinBalances.eth_bal * responseData.eth;
				document.getElementById('ethDis').innerHTML = ethDisplay.toFixed(2);

				const usdtDisplay = coinBalances.usdt_bal * responseData.usdt;
				document.getElementById('usdtDis').innerHTML = usdtDisplay.toFixed(2);

				const dogeDisplay = coinBalances.doge_bal * responseData.doge;
				document.getElementById('dogeDis').innerHTML = dogeDisplay.toFixed(2);

				const ltcDisplay = coinBalances.ltc_bal * responseData.ltc;
				document.getElementById('ltcDis').innerHTML = ltcDisplay.toFixed(2);

				const shibaDisplay = coinBalances.shiba_bal * responseData.shiba;
				document.getElementById('shibaDis').innerHTML = shibaDisplay.toFixed(2);

				const totalBal = xrpDisplay + xlmDisplay + btcDisplay + ethDisplay + usdtDisplay + dogeDisplay + ltcDisplay + shibaDisplay; //all in USD
				
				// Format the price above to USD using the locale, style, and currency.
				let USDollar = new Intl.NumberFormat('en-US', {
					style: 'currency',
					currency: 'USD',
				});

				console.log(USDollar.format(totalBal));

				document.getElementById('total').innerHTML = USDollar.format(totalBal);

			} else {
				// Request failed, handle errors here
				console.error("Request failed with status: " + xhr.status);
			}
		};

		// Send the request
		xhr.send();
	}

	// Function to send AJAX request at regular intervals (every 30 seconds)
	function sendRequestAtInterval() {
		sendAjaxRequest(); // Send the initial request

		// Set an interval to repeat the request every 30 seconds
		setInterval(function() {
			sendAjaxRequest();
		}, 30000); // 30 seconds in milliseconds
	}

	// Call the function to start sending requests
	// sendRequestAtInterval();
	
	//Qfs card popu start
	
	$(document).on('click', '.toggle', function(event) {
	  event.preventDefault();
	  
	  var target = $(this).data('target');
	  $('#' + target).toggleClass('hide');
	});
	//Qfs card popu end
	
</script>

<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>


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