<?php if(!defined('FastCore')){exit('Opss!');}

# Заголовок
$opt['title'] = 'Referral system';

# Экономия места
$income = round($user['income'],4);
$refs = $user['refs'];
$url = ('https://'.$_SERVER['HTTP_HOST']);
$lp = ($url.'/img/promo/');


?>


<div class="modal-aff card-lg h-100 mb-2">



<div class="row">
<div class="col-xl-9 col-lg-8 col-md-12">
<div class="info-con-aff">
          <h4>Affiliate System</h4>

          <p>Earn <b> 10%</b> on every purchase of mining power in <b>TH/s</b> made by your referrals. With our generous affiliate program, every new person you bring into the community not only enjoys the benefits of cryptocurrency mining with us but also enriches it, ensuring you earn a share of the profits.</p>
       </div>
<form action="" method="post" onsubmit="submitfromexchange(this);return false">
<div class="input-group for-url-aff">
	<input type="text" onclick="this.select()" class="form-control form-control-lg" value="<?=$url.'/i/'.$uid; ?>" id="ref" onclick="copier();">

	<span class="input-group-text copy" onclick="copier();"> <i class="fa fa-copy pe-1"></i> Copy</span>
</div>

</form>

<style>
.copy {
  text-transform: uppercase;
  cursor: pointer;
	color: #fff;
	
}
.copy:hover {
	background-color: #fb5880;
	color: #fff;
}
</style>

<script>
function copier() {
    $("#ref").select();
    document.execCommand('copy');
	document.getElementById('ref').style.color = '#f35';
}
</script>

<a href="#demos" class="btn btn-lg mt-2 btn-danger notranslate" data-bs-toggle="collapse" data-bs-target="#demos">GIF <i class="fa fa-copy"></i></a>

</div>

<div class="col-xl-3 col-lg-4 col-md-12 text-center pe-3">

<div class="row">
<div class="col-lg-12 col-md-6 text-center">
<div class="row-aff-in color-1">
<div class="top-in-aff">
<div class="icon-aff-t">
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_122_87)">
<path d="M17.5383 0.0151367C11.2739 0.0151367 6.19474 5.09425 6.19474 11.3587C6.19474 17.6231 11.2739 22.7022 17.5383 22.7022C23.8027 22.7022 28.8818 17.6231 28.8818 11.3587C28.8818 5.09425 23.8027 0.0151367 17.5383 0.0151367ZM9.96115 15.1251H25.1154C23.7196 17.9167 20.8727 19.8663 17.5383 19.8663C14.2039 19.8663 11.3569 17.9167 9.96115 15.1251ZM10.9803 24.6519C6.75971 25.7596 3.45856 28.3961 1.94092 34.0457H33.1356C31.618 28.3961 28.3169 25.7596 24.0963 24.6519C22.1411 25.6987 19.9089 26.2914 17.5383 26.2914C15.1677 26.2914 12.9355 25.6987 10.9803 24.6519Z" fill="#334C8B"></path>
</g>
<defs>
<clipPath id="clip0_122_87">
<rect width="34.0306" height="34.0306" fill="white" transform="translate(0.522949 0.0151367)"></rect>
</clipPath>
</defs>
</svg>
</div>
<h4 class="color-b"><small>My affiliates</small></h4>
</div>
<h5 class="color-b"><b><?=$refs;?></b></h5>
</div>
</div>

<div class="col-lg-12 col-md-6 text-center">
<div class="row-aff-in color-2">
<div class="top-in-aff">
 <div class="icon-aff-t">
<svg width="27" height="28" viewBox="0 0 27 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.4365 3.89106L0 0L11.2813 28L27 9.11003L21.4365 3.89106ZM21.0916 5.60556L24.3706 8.67975L15.4019 10.2817L21.0916 5.60556ZM13.4544 9.96132L4.00114 2.22819L19.4514 5.0323L13.4544 9.96132ZM12.7806 11.329L11.2397 23.8984L2.92871 3.26881L12.7806 11.329ZM14.2073 11.9962L24.1384 10.2221L12.747 23.9117L14.2073 11.9962Z" fill="#FF5583"></path>
</svg>
 </div>
<h4 class="color-p"><small>Total Paid</small></h4>
</div>
<h5 class="color-p"><b><?=$income;?> {!VAL!}</b></h5>
</div>
</div>
</div>
</div>

</div>



</div>

<div id="demos" class="p-1 collapse">
<div class="statistics mb-2">
<img src="/img/promo/468.gif" alt="468" style="max-width: 99%;margin: 0 auto;">

<div class="p-2">
<h6 class="card-title">Banner link:</h6>
<div class="input-group m-2">
<span class="input-group-text">468x60 </span>
<input type="text" onclick="this.select()" class="form-control" value="<?=$lp;?>468.gif">
</div>

<div class="input-group m-2">
<span class="input-group-text">728x90 </span>
<input type="text" onclick="this.select()" class="form-control" value="<?=$lp;?>728.gif">
</div>
</div>
</div>
</div>



<div class="table-responsive">
<table class="stats2 table table-sm table-striped mb-0">  
                <thead>
                  <tr scope="row">
                    <th scope="col">User</th>
                    <th scope="col" class="text-center">Income</th>
                    <th scope="col" class="text-center">Site</th>
                    <th scope="col" class="text-end">Date</th>
                  </tr>
                </thead>
                <tbody>
<?PHP

if (isset($_POST["reflogin"])) {
	$searchRef = filter_var($_POST["reflogin"], FILTER_SANITIZE_STRING);
	$ref = $db->query("SELECT login, ref_to, refsite, reg FROM db_users WHERE rid = '$uid' AND login = '$searchRef'")->fetchAll();
} 
else {
    $ref = $db->query("SELECT ref_to, refsite, login, reg FROM db_users WHERE rid = '$uid' ORDER BY ref_to DESC LIMIT 200")->fetchAll();
}
	foreach($ref as $r){
?>
<tr>
	<td scope="row"><?=substr($r['login'],0,-20); ?><span class="text-danger">xxx</span></td>
	<td class="text-center"><?=sprintf("%.3f",$r['ref_to']); ?></td>
	<td class="text-center"><?=$r['refsite']; ?></td>
	<td class="text-end"><?=date("d M Y - H:i:s",$r['reg']); ?></td>
</tr>
<?PHP
	}
?>
                </tbody>
              </table>
            </div>
