<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>


<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>

<?php
$type_wallet = $_GET['type_wallet'];
$withdraw = $_GET['withdraw'];
$type_wallet = "gold_wallet";
      
$sql_wallet = "SELECT * FROM wallet 
WHERE ref_code='$ref_code' LIMIT 1";
$result_wallet = $mysqli->query($sql_wallet);
if ($result_wallet ->num_rows > 0)
{
	$row_wallet = $result_wallet ->fetch_assoc();
    $e_wallet = $row_wallet['cash_wallet'];
    $product_wallet = $row_wallet['product_wallet'];
}

if ( $type_wallet == "e_wallet")
{
    $wallet = $e_wallet ;
    $walletname = "e-Wallet";
    $type_of_transaction = "CW";
}
else  
if ( $type_wallet == "gold_wallet")
{
    $wallet = $product_wallet;
    $walletname = "Activation Wallet";
    $type_of_transaction = "PW";
}

$sql_user = "SELECT * 
FROM user 
WHERE ref_code='$ref_code'
And status='1'";
$result_user = $mysqli->query($sql_user);
if ($result_user ->num_rows > 0)
{
	$row_user = $result_user ->fetch_assoc();
	$name = $row_user['name'];
    $last_name = $row_user['last_name'];
    $phone_number = $row_user['phone_number'];
    $address = $row_user['address'];
    $address_2 = $row_user['address_2'];
    $state = $row_user['state'];
    $area = $row_user['area'];
    $postcode = $row_user['postcode'];
    $country = $row_user['country'];
    $ic_front = $row_user['ic_front'];
    $ic_back = $row_user['ic_back'];

    $sql_curr_rate = "SELECT *
			    FROM currency_rate_setting
			    Where status='1'
			    order by id Asc";
    $result_curr_rate = $mysqli->query($sql_curr_rate);
	if ($result_curr_rate ->num_rows > 0)
	{
		$row_curr_rate = $result_curr_rate ->fetch_assoc();
		$deposit_rm = $row_curr_rate['deposit_rm'];
        $withdrawal_rm = $row_curr_rate['withdrawal_rm'];
        $withdraw_fees_usd = $row_curr_rate['withdraw_fees_usd'];
        $withdraw_fees_usdt_percent = $row_curr_rate['withdraw_fees_usdt_percent'];
}
	}
?>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">

<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
    
<!-- Start Page Content -->
<!-- ============================================================== -->

<?php

$ref_code = $_GET['ref_code'];
if ( $ref_code == '')
{
    $ref_code=$_SESSION['ref_code'];
}

$q = "SELECT *
FROM user
WHERE ref_code='$ref_code'";
$result = $mysqli->query($q);
if ($result->num_rows > 0)
{
    while($record = $result -> fetch_assoc())
    {    
               
    $id = $record['id'] ;
    $sponsor_code = $record['sponsor_code'] ;
    $ref_code = $record['ref_code'] ;
    $name = $record['name'];
    $email = $record['email'];
    $password = $record['password'];
    $phone_number = $record['phone_number'];
    $paid = $record['paid'];
    $address = $record['address'];
    $bank_type = $record['bank_type'];
    $acc_no = $record['acc_no'];
    $acc_holder = $record['acc_holder'];

    $sql_my_wallet = "SELECT * FROM wallet
    WHERE ref_code='$ref_code' LIMIT 1";
    $result_my_wallet = $mysqli-> query($sql_my_wallet);
	if ($result_my_wallet -> num_rows > 0)
	{
		$row_my_wallet = $result_my_wallet ->fetch_assoc();
		$product_wallet = number_format($row_my_wallet['product_wallet'],2);	
	}

    $sql_reg_price = "SELECT *
				      FROM registration_price_setting
				      Where status='1'
				      order by id Asc";
    $result_reg_price = $mysqli->query($sql_reg_price);
	if ($result_reg_price ->num_rows > 0)
	{
		$row_reg_price = $result_reg_price  ->fetch_assoc();
		$full_total_price = $row_reg_price['price'];
	}  
?> 

<div class="row">
<div class="col-lg-12">
    <div class="card">
        <div class="card-body">
            <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data" onsubmit="return confirm('Do you want to proceed?');" onsubmit="return postForm()">
                <div class="form-body">

                    <h3 class="card-title">Activate My Account Using Activation Wallet (Balance: $<?php echo $product_wallet; ?>)</h3> 
                    <hr>
                    <div class="row p-t-20">

                         <!--div class="col-md-12">
                            <div class="form-group">
                                <label class="control-label">Activate Using</label>
                                <br>
                                <select class="form-control" name="activation_way" id="activation_way" onchange="myCalculation()" required>
                                    <option value="">Please Select Way Of Activation</option>
                                    <option value="FPX">FPX Or Credit Card</option>
                                    <option value="activation_wallet">Using My Activation Wallet (A-Wallet Balance: $<?php echo $product_wallet; ?>)</option>  
                                </select>
                            </div>
                        </div-->
                    </div>
                    <input type="hidden" class="form-control"  name="activation_way" value="activation_wallet">
                    <input type="hidden" class="form-control"  name="from_page" value="activate_account.php">
                    <input type="hidden" class="form-control"  name="ref_code" value="<?php echo $ref_code; ?>">
                    <input type="hidden" class="form-control"  name="activation_charge" value="Not_Free">
                </div>
                <div class="form-actions">               
                    <button name="activate_new_user" class="btn btn-success"><i class="fa fa-check"></i> Click To Pay $<?php echo $full_total_price; ?> and Get Activated </button>      
                </div>
            </form>
        </div>
    </div>                     
</div>
</div>
<?php
}
}
else
{
echo mysql_error();
}
?>				
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

<script type="text/javascript">
function myCalculation()
{
  deposit_way = document.getElementById("deposit_way").value;
  amount = 10;
  deposit_fees_usdt_percent = document.getElementById("deposit_fees_usdt_percent").value;
  deposit_fees = Number(amount) * (Number(deposit_fees_usdt_percent)/100);
  total_deposit_need_to_transfer =  Number(amount) +  Number(deposit_fees)

  console.log(deposit_fees);
  console.log(deposit_fees_usdt_percent);
  //console.log(total_deposit_need_to_transfer);

  document.getElementById("deposit_fees").value = deposit_fees.toFixed(2);
  document.getElementById("total_deposit_need_to_transfer").value = total_deposit_need_to_transfer.toFixed(2);


  if ( deposit_way == "FPX")
  {
    $("#Upload_Receipt_div").hide();
    $("#Payment_Reference_Div").hide();
	$("#TRX_REF_div").hide();
    $("#withdraw_fees_div").hide();
    $("#total_deposit_need_to_transfer_div").hide();
  }
  else
  if ( deposit_way == "Upload_Receipt")
  {
    $("#Upload_Receipt_div").show();
    $("#Payment_Reference_Div").show();
    $("#TRX_REF_div").hide();
    $("#withdraw_fees_div").hide();
    $("#total_deposit_need_to_transfer_div").hide();

	document.getElementById("receipt_upload").required = true;
    document.getElementById("payment_reference").required = true;
  }
  else
  if ( deposit_way == "USDT")
  {
    $("#TRX_REF_div").show();
    $("#withdraw_fees_div").show();
    $("#total_deposit_need_to_transfer_div").show();
    $("#Upload_Receipt_div").hide();
    $("#Payment_Reference_Div").hide();

	document.getElementById("trx_ref").required = true;	
  }
}   
</script>


<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

    

</body>

</html>