
<?php
    date_default_timezone_set("Asia/Kuala_Lumpur");
	$today = date('Y-m-d');
   
    $sql_new_announcement =
    "select Count(id) As num 
    FROM announcement
    Where status = '1'
    And created_date = '$today' ";    
    $result_new_announcement = $mysqli->query($sql_new_announcement);
    $row_new_announcement = $result_new_announcement->fetch_assoc();
    $new_announcement = $row_new_announcement['num'];		
    
    $sql_data = "select COUNT(id) As num 
    from user 
    Where sponsor_code ='$ref_code'
    And status='1'";
    $result_data = $mysqli->query($sql_data);
    $row_data = $result_data->fetch_assoc();
    $total_downline = $row_data['num'];		
    
    $data_total_package = 
    "SELECT SUM(order_full_total) As num 
    FROM woocommerce_order_info
    WHERE new_ref_code='$ref_code'
    AND status = '1'";    
    $result_total_package = $mysqli->query($data_total_package);
	if ($result_total_package ->num_rows > 0)
	{
		$row_total_package = $result_total_package ->fetch_assoc();
		$full_total_package = number_format($row_total_package['num'],2);
	}

    $data_total_package_paid = 
    "SELECT SUM(amount) As num 
    FROM package_payment
    WHERE ref_code='$ref_code'
    AND status = '1'";    
    $result_total_package_paid = $mysqli->query($data_total_package_paid);
	if ($result_total_package_paid ->num_rows > 0)
	{
		$row_total_package_paid = $result_total_package_paid ->fetch_assoc();
		$full_total_package_paid = number_format($row_total_package_paid['num'],2);
	}


    $data_total_commission = 
    "SELECT SUM(in_transactions) As num 
    from transactions
    WHERE user_ref_code='$ref_code'
    AND type_of_transaction In ('In')  
    AND in_transactions > '0'
    AND status = '1'";    
    $result_total_commission = $mysqli->query($data_total_commission);
	if ($result_total_commission ->num_rows > 0)
	{
		$row_total_commission = $result_total_commission ->fetch_assoc();
		$full_total_commission = number_format($row_total_commission['num'],2);
	}

    $sql_wallet = "SELECT * 
    FROM wallet 
    WHERE ref_code='$ref_code' LIMIT 1";
    $result_wallet = $mysqli->query($sql_wallet);
    $row_wallet = $result_wallet->fetch_assoc();
    $cash_wallet =  number_format($row_wallet['cash_wallet'],2); 
    $product_wallet =  number_format($row_wallet['product_wallet'],2);
    $pins_wallet =  number_format($row_wallet['pins_wallet'],2); 
    
    $type_of_transaction = "CW";
    $sql_total_withdraw = 
    "select SUM(out_transactions) As num 
    FROM transactions  
    Where user_ref_code = '$ref_code'
    And type_of_transaction = '$type_of_transaction'
    And withdraw_status != ' '
    And status = '1'";    
    $result_total_withdraw = $mysqli->query($sql_total_withdraw);
    $row_total_withdraw = $result_total_withdraw->fetch_assoc();
    $full_total_withdraw = number_format($row_total_withdraw['num'],2); 
?>

<?php 
date_default_timezone_set("Asia/Kuala_Lumpur");
$today = date('Y-m-d');

$sql = "SELECT * FROM user
WHERE ref_code='$ref_code'
And status='1'";
$result = $mysqli->query($sql);
if ($result->num_rows > 0)
{
    $row = $result->fetch_assoc();		
	$sponsor_code = $row['sponsor_code'];
	$ref_code = $row['ref_code'];
    $nick_name = $row['nick_name'];
	$name = $row['name'];
    $email= $row['email'];
    $last_name = $row['last_name'];
	$level = $row['level'];
    $package_type = $row['package_type'];
    $created_date = $row['created_date'];
    $created_date_display = date('d-m-Y', strtotime($row['created_date']));
}
?>

<div class="row">
    <div class="col-lg-12">
        <div class="card ">
            <img class="card-img" height="550" src="../Assets/images/banner.jpg" alt="Card image">
            <div class="card-img-overlay  social-profile-first">
                <div style="background-color: rgba(212,175,55,0.65); display: inline-block; margin-top: 100px; padding: 25px 35px; border-radius: 6px;">
                    <img src="../Assets/images/personal.png" class="img-circle" width="100">
                    <h4 class="card-title text-white"><?php echo $name; ?> <?php echo $last_name; ?> </h4>
                    <h5 class="text-white"><b>Username: <?php echo $nick_name; ?></b></h5>               
                    <h5 class="text-white"><b>Registration Date: <?php echo $created_date_display; ?></b></h5>
                </div>
            </div>          
        </div>
    </div>
</div>

<div class="row">  
    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">MY PACKAGE</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-graph"></i> USD <?php echo $full_total_package; ?> </h3>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">MY PACKAGE PAID</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-graph"></i> USD <?php echo $full_total_package_paid; ?> </h3>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">MY COMMISSION</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-wallet"></i> USD <?php echo $full_total_commission; ?></h3>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">MY WITHDRAW</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-wallet"></i> USD <?php echo $full_total_withdraw; ?></h3>
                </div>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">MY DOWNLINE</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-user"></i> <?php echo $total_downline; ?></h3>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">E-WALLET</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-wallet"></i> USD <?php echo $cash_wallet; ?></h3>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div style="background-color: rgba(212,175,55,0.65)" class="card text-white">
            <div class="card-body">
                <h5 class="card-title">NEW ANNOUNCEMENT</h5>
                <div class="col-12  m-t-30">
                    <h3 class="text-white"><i class="icon-volume-2"></i> <?php echo $new_announcement; ?></h3>
                </div>
            </div>
        </div>
    </div>
    <br>
</div>

<script>
function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999)
  document.execCommand("copy");
  alert("Copied the text: " + copyText.value);
}
</script>

