<?php
$amt=$trans['amount'];
$mode=$_POST['mode'];
if($mode == "BWT") {
	$charge=0.01 * $amt;
}
else {
	$charge=0.005 * $amt;
}
$newbal=$curr_user['balance2'] - $amt;
if($newbal < $charge) {
	$error_msg="You do not have sufficient funds to pay the cost of transfer for $".number_format($amt);
}
else {
	mysqli_query($connectionString,"UPDATE users SET balance=balance-'$charge', balance2=balance2-'$charge' WHERE number='$accid' LIMIT 1");
	$ntid=rand(10000,99999);
	mysqli_query($connectionString,"INSERT INTO `history` (`id`, `tid`, `number`, `date`, `bname`, `bcountry`, `accnum`, `sort`, `amount`, `type`, `details`, `status`, `stat`) VALUES ('', '$ntid', '$accid', NOW(), '-', '-', '-', '-', '$charge', 'Direct Debit', 'COT Charges for transaction number $tid', 'Successful', '0')");
}
if($curr_user['tax_status'] != 1) {
	mysqli_query($connectionString,"UPDATE history SET stat='Progress_TAX' WHERE tid='$tid' LIMIT 1");
	redirect("?r=transfer&sid=".base64_encode($tid));
}
else {
	mysqli_query($connectionString,"UPDATE history SET stat='Progress_FSA' WHERE tid='$tid' LIMIT 1");
	redirect("?r=transfer&sid=".base64_encode($tid));
}

?>
