<?php
	require_once ('inserts.php');
	$max_amt_bal="100000000000";
		if(
		isset($_POST['gateway_code']) &&
		// isset($_POST['gateway_network']) &&
		isset($_POST['amount'])
			){
				$gateway = mysqli_real_escape_string($conn,$_POST['gateway_code']);
				$amount = $_SESSION['pay_amount_usd'] = mysqli_real_escape_string($conn,$_POST['amount']);
				// alert($amount);
				if(!empty($gateway) && !empty($amount)){
				// alert(" $gateway $amount");
				
			$pay_curreny = 	 array("bitcoin"=>"btc","ethereum"=>"eth", "tether"=>"usdt", "tether1"=>"usdt","tether2"=>"usdt", "tether3"=>"usdt", "bnb"=>"bnb",'binance_coin'=>"bnb" );
			
			$gateway_network = 	 array("bitcoin"=>null,"ethereum"=>null, "tether1"=>"bep2", "tether2"=>"erc20", "tether3"=>"trc20", "bnb"=>"bep20",'binance_coin'=>"bep2" );
			$pay_wallet = 	 array("bitcoin"=>$settings['btc'],"ethereum"=>$settings['eth'], "tether1"=>$settings['usdt_erc20'], "tether2"=>$settings['usdt_bep2'], "tether3"=>$settings['usdt_trc20'], "bnb"=>$settings['bnb'],'binance_coin'=>$settings['bnb2'], );
				
				if($amount < $max_amt_bal){
			// alert($gateway);
				$_SESSION['pay_gate'] = $gateway;
				$_SESSION['pay_network'] = $gateway_network[$gateway];
				$_SESSION['pay_curreny'] = $pay_curreny[$gateway];
				
				$_SESSION['pay_amount_usd']=$_SESSION['pay_amount_usd'];
				
				$_SESSION['pay_wallet']	=$pay_wallet[$gateway];
				
				$_SESSION['time_left'] = date('M d, Y H:i:s',time()+(3*60*60));

				$_SESSION['trans_id']	= strtoupper('TRX'.substr(md5(rand(1,99999999)),rand(1,15),10));
	
 $new_email = $mail;
 $new_amount = $amount;
 $new_fee = 0;
 $new_trans_id = $_SESSION['trans_id'];
 $new_status = 'pending';
 $new_method = $pay_curreny[$gateway];
 $new_type = 'deposit';
 $new_description = 'Deposit With '.strtoupper($pay_curreny[$gateway]);
 // $created_at ;
 // $updated_at;			
 $details =$_SESSION['pay_wallet'];
			if($stmt_trans->execute()){
			    
$gateway = strtoupper($_SESSION['pay_curreny']);
$details =$_SESSION['pay_wallet'];
$trans_id = $_SESSION['trans_id'];
	    require_once('dep_mail.php');

				$stmt_trans->close();
				// $conn->close();
								
								header('location:../deposit/payment.php');
			}	
			
		}else{
			$notice_msg="Entered amount above  maximum balance";
			note_msg($notice_msg,'../deposit',2);
		}
			}else{
				$notice_msg="All fields are required";
			note_msg($notice_msg,'../deposit',2);
		}
			}else{
				$notice_msg="All fields are required";
			note_msg($notice_msg,'../deposit',2);
		}
			
		
	
	
?>