<?php
if($p_status!=="2" && $p_status!=="3" && $status=="Activate"){

$u6_user_id = $user_id;
//
$sql25="SELECT * from j_users WHERE 
j_deleted < 1 AND j_id='".$u6_user_id."'
"; //  
$result25 = runSQL($sql25);
$data25 = mysqli_fetch_array($result25);
//$j_verify = $data25['j_verify'];
$u6_id = $data25['j_id'];
$u6_bal = $data25['j_wallet'];
$wallet = $data25['j_wallet'];
$wallet_ghs = $data25['j_wallet_ghs'];
$wallet_usd = $data25['j_wallet_usd'];

$u6_email = $data25['j_email'];
$u6_phone = $data25['j_phone'];
$u6_firstname = $data25['j_firstname'];
$u6_lastname = $data25['j_lastname'];
$u6_name = "$u6_firstname $u6_lastname"; $u6_name = trim($u6_name);
if($u6_id > 0){
	$u6_r_bonus = $u6_amount; 
	$amount = $u6_amount;
	//
	//
	$timex = time();
	$ip = getIPAddress();
	
	$wallet_type = $currency;
	/*
	if($wallet_type=="NGN"){ $wallet = $wallet;   $wallet_db = "j_wallet"; }
	if($wallet_type=="GHS"){ $wallet = $wallet_ghs;  $wallet_db = "j_wallet_ghs"; }
	if($wallet_type=="USD"){ $wallet = $wallet_usd;    $wallet_db = "j_wallet_usd"; }
	if($wallet_type!=="NGN" && $wallet_type!=="GHS" && $wallet_type!=="USD"){ $wallet = 0; }
	*/
	
	$wallet = $wallet;   $wallet_db = "j_wallet";

	//die("done $currency $wallet");
	//die("$bonus");
	
	
	$bal = TWO_DEC($wallet+$u6_r_bonus);

	$sql = "UPDATE j_pays SET
	j_paid='1', j_disburse='1', j_status='3',j_bal='".$bal."'
	WHERE j_id='".$deposit_id."'";
	$result = runSQL($sql);
	if(!$result){
		die("Error. Code 1003.");
	}
	
	
	$sql = "UPDATE j_users SET
	j_wallet = '".$bal."'
	WHERE j_id='".$user_id."'
	";
	$result = runSQL($sql);
	if(!$result){
		die("Error. Code 1003.");
	}
	
	
	/*
	$sql = "UPDATE j_users SET
	$wallet_db ='".$bal."'
	WHERE j_id='".$user_id."'";
	$result = runSQL($sql);
	if(!$result){
		die("Error. Code 1003.");
	}
	*/
	
	
	//give 10% direct referral bonus.
	
	//require_once("mlm/refer_direct.php");
	//require_once("mlm/refer_indirect.php");
	
	
	
	$u_email = $u6_email;
	$u_subject ="Deposit Status";
	$u_subject_m ="Deposit Status";
	$u_message ="<p>Dear $u6_name;</p> 
	<p>Your deposit of (<b>".num_format($u6_r_bonus)." $wallet_type</b>) has been approved &amp; your wallet has been credited.
	<br/><br/>
	Payment Ref: <b>$r_ref</b>
	<br/><br/>
	Thank you for choosing <b>$company</b>.
	</p>";
	
	$u_message_sm ="Your deposit of (<b>".num_format($u6_r_bonus)." $wallet_type</b>) has been approved &amp; your wallet has been credited. Payment Ref: <b>$r_ref</b>";
	
	//send notify
	//send_notify("",$u6_id,$u_subject_m,$u_message);
	send_notify2("",$u6_id,$u_subject,$u_message,$u_message_sm,"notification","deposit_success","");
	
	require("../j_incs/mail.php");
	
	
	
//send sms
$s_sender = $company;
$s_phone = $u6_phone;
$s_message ="Money In Alert!; 
Fund Wallet: $currency_in_use ".num_format($u6_r_bonus)."
Av. Bal: $currency_in_use ".num_format($bal)."
$company_website";
//send_sms($s_sender,$s_phone,$s_message,$schedule);


	//give referral bonus
	echo $u_message;
	
}
}
?>