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

$opt['title'] = 'Make a deposit';

# Способ платежа
//$py = $pg->segment[2] ?? NULL;

if ($user['ban'] == 1){
    exit('Your account has been blocked for violating the rules');
}
if(isset($_POST['dep'])) {

# Выбран способ оплаты
$py = "Tron";
$sumDep = filter_var($_POST['sum'], FILTER_SANITIZE_STRING);
if ($py) {

$selectPS = mb_strtoupper($py);
$systemPay = $db->query('SELECT * FROM db_paysystem WHERE name = ? LIMIT 1',$selectPS)->fetchArray();
$minDep = round($systemPay['mindep'],2);
$currencyPS = $systemPay['currency'];
$psTitle = $systemPay['title'];

# Заносим в БД
$db->query("INSERT INTO db_insert (uid, login, sum, sum_x, sys, `add`, role, type, status) VALUES ('$uid','$login','$minDep','$minDep','$currencyPS', '".time()."','1','1','0')");
$order_idd = $db->LastInsert();

$params = [
	"amount" => $minDep,
	"system" => $systemPay['name'],
	"currency" =>  $currencyPS,
	"order_id" => $order_idd,
	"comment" => "Insert by id-" .$order_idd,
];

$calculate = $systemPay['pairs'] * $minDep;

$test = false; // Режим тестирования

$paykassa = new PaykassaSCI($config->pkm_id, $config->pkm_pass,$test);


$res = $paykassa->createAddress(
	$params["system"],
	$params["currency"],
	$params["order_id"],
	$params["comment"]
);

if ($res['error']) {
	echo $res['message'];
	// ошибка когда что-то не так
} else {
	if (false === $test) {
		$invoice_id = $res['data']['invoice'];

		$address = $res["data"]["wallet"];
		$tag = $res["data"]["tag"];
		$tag_name = $res["data"]["tag_name"];
		$is_tag = $res["data"]["is_tag"];

		$system = $res["data"]["system"];
		$currency = $res["data"]["currency"];

		$display = sprintf("%s", $address);
		if ($is_tag) {
			$display = sprintf("address %s %s: %s", $address, mb_convert_case($tag_name, MB_CASE_TITLE), $tag);
		}

		if (null === $params["amount"]) {
			echo sprintf(
				'<b>Send a money to the %s (%s) address</b>
				<div class="input-group input-group-lg mb-2">
					<input type="text" class="form-control notranslate" placeholder="wallet" value="%s" name="wall" id="purse" onclick="copier();">
					<span class="input-group-text copy" onclick="copier();"><i class="fa fa-copy"></i></span>
				</div>
				',
				$system,
				$currency,
				htmlspecialchars($display,ENT_QUOTES, "UTF-8")
			);
			
		} else {
			echo '<div class="row">';
			echo sprintf(
				'<div class="col-3 p-2"></div>
				<div class="col-lg-6 p-1">
				<div class="card mt-1 mb-2">

				<div class="p-2 p-lg-3">

				<div class="header-top-dp">
							 <h4>Make deposit</h4>
						 </div>
						 
			<div class="row m-auto">	
				<div class="col-lg-9 text-center pb-2">
					<input type="text" class="form-control notranslate" placeholder="wallet" value="%s" name="wall" id="purse" onclick="copier();">
				</div>	
				<div class="col-lg-3 text-center pb-2">
				<span class="btn btn-danger text-light mx-auto copy" onclick="copier();">Copy</span>
				</div>	
</div>
<div class="txt-info-dp">
              <div class="txt-send-dp">
			  
                   <p>Send only <b>%s {!VAL!}</b>    <svg width="43" height="43" viewBox="0 0 43 43" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="21.5" cy="21.5" r="21.5" fill="url(#paint0_linear_84_22)"></circle>
<g filter="url(#filter0_d_84_22)">
<path d="M27.3337 15.2767L11.5769 12.4038L19.8692 33.0769L31.4231 19.13L27.3337 15.2767ZM27.0801 16.5425L29.4903 18.8123L22.898 19.995L27.0801 16.5425ZM21.4664 19.7585L14.5179 14.0489L25.8745 16.1193L21.4664 19.7585ZM20.9712 20.7682L19.8386 30.0486L13.7296 14.8172L20.9712 20.7682ZM22.0199 21.2609L29.3197 19.9511L20.9465 30.0584L22.0199 21.2609Z" fill="#ECE8E9"></path>
</g>
<defs>
<filter id="filter0_d_84_22" x="10.6769" y="12.4038" width="21.6462" height="23.5729" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="2"></feOffset>
<feGaussianBlur stdDeviation="0.45"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_84_22"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_84_22" result="shape"></feBlend>
</filter>
<linearGradient id="paint0_linear_84_22" x1="30.1827" y1="2.89423" x2="11.5769" y2="42.1731" gradientUnits="userSpaceOnUse">
<stop stop-color="#F84B73"></stop>
<stop offset="0.99321" stop-color="#AF3451"></stop>
</linearGradient>
</defs>
</svg>
     to this %s address</p>
              </div>

              <div class="txt-dp-min">
                 <p>
 Minimum Deposit <b>%s %s</b>Expected arrival &amp; unlock 3 Network Confirmations</p>
              </div>
         </div>
</div>
</div></div>',
				htmlspecialchars($display, ENT_QUOTES, "UTF-8"),
				$sumDep,
								$system,
				$params["amount"],
				$currency
			);
		}


		echo '</div>';
	} else {
		echo sprintf('Test link: <a target="_blank" href="%s">Open link</a>', $res["data"]["url"]);
	}
}
?>
<style>
.copy {
  text-transform: uppercase;
  cursor: pointer;
	
}
.copy:hover {
	color: #fff;
}
</style>
<script>
function copier() {
    $("#purse").select();
    document.execCommand('copy');
	document.getElementById('purse').style.color = '#ff5583';
}
</script>
<?php 
}
} else {
	if(isset($_POST['redep'])) {
// тут реинвестиции параметры


}

?>


<div class="row">
<div class="col-3 p-2"></div>
<div class="col-lg-6 p-1">
<div class="card mt-1 mb-2">

<div class="p-2 p-lg-3">

<div class="header-top-dp">
             <h4>Make deposit</h4>
         </div>

    <form action="" method="POST">
<div class="p-1 text-uppercase text-center">
<div class="col-lg-6 col-md-8 m-auto">
<div class="input-group input-group-lg mb-2">
	<input type="text" class="form-control" placeholder="Enter here" value="10" name="sum" id="calculatorInput" oninput="calculatorBuyHash(1,30,0.05)">
	<span class="input-group-text"> {!VAL!}</span>
</div>
</div>
<button class="btn btn-lg btn-danger text-uppercase" name="dep" type="submit">DEPOSIT</button>
<!-- <button class="btn btn-lg btn-info text-uppercase" name="redep" type="submit">REINVEST</button> -->

</div><hr>
<div class="p-1"><h5 style="color: #fff;"> Calculator </h5>

<p style="font-size: 20px;margin-top: 10px;color: #9093a3;">Hash power
<span class="float-end text-light notranslate"> 

                          <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 2C11.765 2.00009 11.5375 2.08295 11.3575 2.23403C11.1775 2.3851 11.0565 2.59475 11.0156 2.82617L8.03516 15.7324L8.03711 15.7344C8.01287 15.8208 8.00039 15.9102 8 16C8 16.2652 8.10536 16.5196 8.29289 16.7071C8.48043 16.8946 8.73478 17 9 17H14.5L13.0195 26.8008C13.0064 26.8664 12.9998 26.9331 13 27C13 27.2652 13.1054 27.5196 13.2929 27.7071C13.4804 27.8946 13.7348 28 14 28C14.1817 27.9997 14.3599 27.9499 14.5154 27.856C14.671 27.762 14.798 27.6275 14.8828 27.4668H14.8848L21.8066 14.5898L21.7969 14.5723C21.9152 14.408 22 14.2178 22 14C22 13.448 21.552 13 21 13H15.5L18.9121 3.41016C18.9701 3.28119 19 3.14139 19 3C19 2.73478 18.8946 2.48043 18.7071 2.29289C18.5196 2.10536 18.2652 2 18 2H12Z" fill="#F84B73"></path>
</svg>

                
<span id="calculatorAreaBuySpeed">1.00</span> TH/s</span>
</p>

<p style="font-size: 20px;margin-top: 10px;color: #9093a3;">Per hour 
<span class="float-end text-light notranslate"> 
<svg width="27" height="27" viewBox="0 0 27 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="13.5" cy="13.5" r="13.5" fill="url(#paint0_linear_98_75)"></circle>
<g filter="url(#filter0_d_98_75)">
<path d="M17.163 9.59246L7.26923 7.78857L12.476 20.7693L19.7308 12.012L17.163 9.59246ZM17.0038 10.3873L18.5172 11.8125L14.3778 12.5552L17.0038 10.3873ZM13.4789 12.4066L9.11591 8.82156L16.2468 10.1215L13.4789 12.4066ZM13.168 13.0407L12.4568 18.8679L8.62094 9.30399L13.168 13.0407ZM13.8265 13.35L18.41 12.5275L13.1525 18.874L13.8265 13.35Z" fill="#ECE8E9"></path>
</g>
<defs>
<filter id="filter0_d_98_75" x="6.36923" y="7.78857" width="14.2615" height="15.881" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="2"></feOffset>
<feGaussianBlur stdDeviation="0.45"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_98_75"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_98_75" result="shape"></feBlend>
</filter>
<linearGradient id="paint0_linear_98_75" x1="18.9519" y1="1.81731" x2="7.26923" y2="26.4808" gradientUnits="userSpaceOnUse">
<stop stop-color="#F84B73"></stop>
<stop offset="0.99321" stop-color="#AF3451"></stop>
</linearGradient>
</defs>
</svg>
<span id="calculatorAreaBuyHash">0.02</span> {!VAL!}</span>
</p>

<p style="font-size: 20px;margin-top: 10px;color: #9093a3;">Per day
<span class="float-end text-light notranslate"> 
<svg width="27" height="27" viewBox="0 0 27 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="13.5" cy="13.5" r="13.5" fill="url(#paint0_linear_98_75)"></circle>
<g filter="url(#filter0_d_98_75)">
<path d="M17.163 9.59246L7.26923 7.78857L12.476 20.7693L19.7308 12.012L17.163 9.59246ZM17.0038 10.3873L18.5172 11.8125L14.3778 12.5552L17.0038 10.3873ZM13.4789 12.4066L9.11591 8.82156L16.2468 10.1215L13.4789 12.4066ZM13.168 13.0407L12.4568 18.8679L8.62094 9.30399L13.168 13.0407ZM13.8265 13.35L18.41 12.5275L13.1525 18.874L13.8265 13.35Z" fill="#ECE8E9"></path>
</g>
<defs>
<filter id="filter0_d_98_75" x="6.36923" y="7.78857" width="14.2615" height="15.881" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="2"></feOffset>
<feGaussianBlur stdDeviation="0.45"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_98_75"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_98_75" result="shape"></feBlend>
</filter>
<linearGradient id="paint0_linear_98_75" x1="18.9519" y1="1.81731" x2="7.26923" y2="26.4808" gradientUnits="userSpaceOnUse">
<stop stop-color="#F84B73"></stop>
<stop offset="0.99321" stop-color="#AF3451"></stop>
</linearGradient>
</defs>
</svg>
<span id="calculatorAreaBuyHash2">0.50</span> {!VAL!}</span>
</p>

<p style="font-size: 20px;margin-top: 10px;color: #9093a3;">Per week
<span class="float-end text-light notranslate"> 
<svg width="27" height="27" viewBox="0 0 27 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="13.5" cy="13.5" r="13.5" fill="url(#paint0_linear_98_75)"></circle>
<g filter="url(#filter0_d_98_75)">
<path d="M17.163 9.59246L7.26923 7.78857L12.476 20.7693L19.7308 12.012L17.163 9.59246ZM17.0038 10.3873L18.5172 11.8125L14.3778 12.5552L17.0038 10.3873ZM13.4789 12.4066L9.11591 8.82156L16.2468 10.1215L13.4789 12.4066ZM13.168 13.0407L12.4568 18.8679L8.62094 9.30399L13.168 13.0407ZM13.8265 13.35L18.41 12.5275L13.1525 18.874L13.8265 13.35Z" fill="#ECE8E9"></path>
</g>
<defs>
<filter id="filter0_d_98_75" x="6.36923" y="7.78857" width="14.2615" height="15.881" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="2"></feOffset>
<feGaussianBlur stdDeviation="0.45"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_98_75"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_98_75" result="shape"></feBlend>
</filter>
<linearGradient id="paint0_linear_98_75" x1="18.9519" y1="1.81731" x2="7.26923" y2="26.4808" gradientUnits="userSpaceOnUse">
<stop stop-color="#F84B73"></stop>
<stop offset="0.99321" stop-color="#AF3451"></stop>
</linearGradient>
</defs>
</svg>
<span id="calculatorAreaBuyHash3">3.50</span> {!VAL!}</span>
</p>

<p style="font-size: 20px;margin-top: 10px;color: #9093a3;">Per month
<span class="float-end text-light notranslate"> 
<svg width="27" height="27" viewBox="0 0 27 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="13.5" cy="13.5" r="13.5" fill="url(#paint0_linear_98_75)"></circle>
<g filter="url(#filter0_d_98_75)">
<path d="M17.163 9.59246L7.26923 7.78857L12.476 20.7693L19.7308 12.012L17.163 9.59246ZM17.0038 10.3873L18.5172 11.8125L14.3778 12.5552L17.0038 10.3873ZM13.4789 12.4066L9.11591 8.82156L16.2468 10.1215L13.4789 12.4066ZM13.168 13.0407L12.4568 18.8679L8.62094 9.30399L13.168 13.0407ZM13.8265 13.35L18.41 12.5275L13.1525 18.874L13.8265 13.35Z" fill="#ECE8E9"></path>
</g>
<defs>
<filter id="filter0_d_98_75" x="6.36923" y="7.78857" width="14.2615" height="15.881" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="2"></feOffset>
<feGaussianBlur stdDeviation="0.45"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_98_75"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_98_75" result="shape"></feBlend>
</filter>
<linearGradient id="paint0_linear_98_75" x1="18.9519" y1="1.81731" x2="7.26923" y2="26.4808" gradientUnits="userSpaceOnUse">
<stop stop-color="#F84B73"></stop>
<stop offset="0.99321" stop-color="#AF3451"></stop>
</linearGradient>
</defs>
</svg>
<span id="calculatorAreaBuyHash4">15.00</span> {!VAL!}</span>
</p>

</div></form>

<!-- End Modal Portfolio area -->




<script type="text/javascript">
	function calculatorBuyHash(hashprice, period) {
		var inputValue = parseFloat(document.getElementById('calculatorInput').value);

		if (isNaN(inputValue) || inputValue <= 0) {
			document.getElementById("calculatorAreaBuyHash").style.display = "none";
			return;
		}

		let dailyRate = 0;

		// Determine the daily rate based on input value
		if (inputValue >= 100 && inputValue < 500) {
			dailyRate = 10; // 10%
		} else if (inputValue >= 500 && inputValue < 1000) {
			dailyRate = 20; // 20%
		} else if (inputValue >= 1000 && inputValue < 5000) {
			dailyRate = 30; // 30%
		} else if (inputValue >= 5000 && inputValue <= 10000) {
			dailyRate = 50; // 50%
		} else {
// 			alert("Please enter an amount between 100 and 10000.");
			return;
		}

		var hashAmount = parseFloat(inputValue / hashprice).toFixed(2);
		document.getElementById("calculatorAreaBuyHash").style.display = "";

		var dailyEarn = (inputValue * dailyRate / 100).toFixed(2);
		var hourEarn = (dailyEarn / 24).toFixed(2);
		var weekEarn = (dailyEarn * 7).toFixed(2);
		var totalEarn = (dailyEarn * period).toFixed(2);

		document.getElementById("calculatorAreaBuySpeed").innerHTML = parseFloat(hashAmount / 10).toFixed(2);
		document.getElementById("calculatorAreaBuyHash").innerHTML = hourEarn;
		document.getElementById("calculatorAreaBuyHash2").innerHTML = dailyEarn;
		document.getElementById("calculatorAreaBuyHash3").innerHTML = weekEarn;
		document.getElementById("calculatorAreaBuyHash4").innerHTML = totalEarn;
	}
</script>



<script type="text/javascript">

// 	function calculatorBuyHash(hashprice, period, dailyEarn) {
// 		var inputValue = parseFloat(document.getElementById('calculatorInput').value);
// 		if (isNaN(inputValue)) {
// 			document.getElementById("calculatorAreaBuyHash").style.display = "none";
// 			return;
// 		}
// 		var hashAmount = parseFloat(inputValue/hashprice).toFixed(2);
// 		document.getElementById("calculatorAreaBuyHash").style.display = "";
// 		var dailyEarnRate = (hashprice * hashAmount / 100).toFixed(2);
// 		var hourEarn = (dailyEarn * hashAmount / 24).toFixed(2);
// 		var weekEarn = parseFloat(dailyEarn*hashAmount*7).toFixed(2);
// 		var totalEarn = parseFloat(dailyEarn*hashAmount*period).toFixed(2);
// 		document.getElementById("calculatorAreaBuySpeed").innerHTML = parseFloat(hashAmount/10).toFixed(2);
// 		document.getElementById("calculatorAreaBuyHash").innerHTML = parseFloat(hourEarn).toFixed(2);
//     	document.getElementById("calculatorAreaBuyHash2").innerHTML = parseFloat(dailyEarn*hashAmount).toFixed(2);
// 		document.getElementById("calculatorAreaBuyHash3").innerHTML = parseFloat(weekEarn).toFixed(2);
// 		document.getElementById("calculatorAreaBuyHash4").innerHTML = parseFloat(totalEarn).toFixed(2);
// 	}
</script>




</div>

</div>
</div>
</div>


<?php 
} 
?>